Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::CpuInfo Class Reference

#include <cpu-info.h>

Collaboration diagram for impala::CpuInfo:

Public Types

enum  CacheLevel { L1_CACHE = 0, L2_CACHE = 1, L3_CACHE = 2 }
 Cache enums for L1 (data), L2 and L3. More...
 

Static Public Member Functions

static void Init ()
 Initialize CpuInfo. More...
 
static void VerifyCpuRequirements ()
 
static int64_t hardware_flags ()
 Returns all the flags for this cpu. More...
 
static bool IsSupported (long flag)
 Returns whether of not the cpu supports this flag. More...
 
static void EnableFeature (long flag, bool enable)
 
static long CacheSize (CacheLevel level)
 Returns the size of the cache in KB at this cache level. More...
 
static int64_t cycles_per_ms ()
 Returns the number of cpu cycles per millisecond. More...
 
static int num_cores ()
 Returns the number of cores (including hyper-threaded) on this machine. More...
 
static std::string model_name ()
 Returns the model name of the cpu (e.g. Intel i7-2600) More...
 
static std::string DebugString ()
 

Static Public Attributes

static const int64_t SSSE3 = (1 << 1)
 
static const int64_t SSE4_1 = (1 << 2)
 
static const int64_t SSE4_2 = (1 << 3)
 
static const int64_t POPCNT = (1 << 4)
 

Static Private Attributes

static bool initialized_ = false
 
static int64_t hardware_flags_ = 0
 
static int64_t original_hardware_flags_
 
static long cache_sizes_ [L3_CACHE+1]
 
static int64_t cycles_per_ms_
 
static int num_cores_ = 1
 
static std::string model_name_ = "unknown"
 

Detailed Description

CpuInfo is an interface to query for cpu information at runtime. The caller can ask for the sizes of the caches and what hardware features are supported. On Linux, this information is pulled from a couple of sys files (/proc/cpuinfo and /sys/devices)

Definition at line 30 of file cpu-info.h.

Member Enumeration Documentation

Cache enums for L1 (data), L2 and L3.

Enumerator
L1_CACHE 
L2_CACHE 
L3_CACHE 

Definition at line 38 of file cpu-info.h.

Member Function Documentation

static long impala::CpuInfo::CacheSize ( CacheLevel  level)
inlinestatic

Returns the size of the cache in KB at this cache level.

Definition at line 68 of file cpu-info.h.

References cache_sizes_, and initialized_.

Referenced by DebugString().

static int64_t impala::CpuInfo::cycles_per_ms ( )
inlinestatic

Returns the number of cpu cycles per millisecond.

Definition at line 74 of file cpu-info.h.

References cycles_per_ms_, and initialized_.

Referenced by impala::Benchmark::Measure().

void impala::CpuInfo::EnableFeature ( long  flag,
bool  enable 
)
static

Toggle a hardware feature on and off. It is not valid to turn on a feature that the underlying hardware cannot support. This is useful for testing.

Definition at line 144 of file cpu-info.cc.

References impala::flag, hardware_flags_, initialized_, and original_hardware_flags_.

static int64_t impala::CpuInfo::hardware_flags ( )
inlinestatic

Returns all the flags for this cpu.

Definition at line 52 of file cpu-info.h.

References hardware_flags_, and initialized_.

void impala::CpuInfo::Init ( )
static
static std::string impala::CpuInfo::model_name ( )
inlinestatic

Returns the model name of the cpu (e.g. Intel i7-2600)

Definition at line 86 of file cpu-info.h.

References initialized_, and model_name_.

Referenced by impala::Benchmark::GetMachineInfo().

static int impala::CpuInfo::num_cores ( )
inlinestatic

Returns the number of cores (including hyper-threaded) on this machine.

Definition at line 80 of file cpu-info.h.

References initialized_, and num_cores_.

Referenced by Init(), and impala::ThreadResourceMgr::ThreadResourceMgr().

void impala::CpuInfo::VerifyCpuRequirements ( )
static

Determine if the CPU meets the minimum CPU requirements and if not, issue an error and terminate.

Definition at line 137 of file cpu-info.cc.

References IsSupported(), and SSSE3.

Member Data Documentation

long impala::CpuInfo::cache_sizes_
staticprivate

Definition at line 97 of file cpu-info.h.

Referenced by CacheSize(), and Init().

int64_t impala::CpuInfo::cycles_per_ms_
staticprivate

Definition at line 98 of file cpu-info.h.

Referenced by cycles_per_ms(), and Init().

int64_t impala::CpuInfo::hardware_flags_ = 0
staticprivate

Definition at line 95 of file cpu-info.h.

Referenced by EnableFeature(), hardware_flags(), Init(), and IsSupported().

bool impala::CpuInfo::initialized_ = false
staticprivate
string impala::CpuInfo::model_name_ = "unknown"
staticprivate

Definition at line 100 of file cpu-info.h.

Referenced by DebugString(), Init(), and model_name().

int impala::CpuInfo::num_cores_ = 1
staticprivate

Definition at line 99 of file cpu-info.h.

Referenced by DebugString(), Init(), and num_cores().

int64_t impala::CpuInfo::original_hardware_flags_
staticprivate

Definition at line 96 of file cpu-info.h.

Referenced by EnableFeature(), and Init().

const int64_t impala::CpuInfo::POPCNT = (1 << 4)
static

Definition at line 35 of file cpu-info.h.

Referenced by impala::BitUtil::Popcount().

const int64_t impala::CpuInfo::SSE4_1 = (1 << 2)
static

Definition at line 33 of file cpu-info.h.

const int64_t impala::CpuInfo::SSSE3 = (1 << 1)
static

Definition at line 32 of file cpu-info.h.

Referenced by VerifyCpuRequirements().


The documentation for this class was generated from the following files: