ML Reference
ml::CPUInfo Class Reference

Singleton class that provides hardware specific information. More...

#include <mlCPUInfo.h>

Public Member Functions

bool isPentium () const
 Returns true if this is a pentium based system.
 
bool hasMMX () const
 Returns true if MMX is supported.
 
bool hasSSE () const
 Returns true if SSE is supported.
 
bool hasSSE2 () const
 Returns true if SSE2 is supported.
 
bool hasSSE3 () const
 Returns true if SSE3 is supported.
 
bool hasSSSE3 () const
 Returns true if SSSE3 is supported.
 
bool hasSSE4_1 () const
 Returns true if SSE4.1 is supported.
 
bool hasSSE4_2 () const
 Returns true if SSE4.2 is supported.
 
bool hasSSE4a () const
 Returns true if SSE4a is supported.
 
bool hasSSE5 () const
 Returns true if SSE5 is supported.
 
bool hasAVX () const
 Returns true if AVX is supported.
 
bool has3DNow () const
 Returns true if 3DNow! is supported.
 
bool has3DNowP () const
 Returns true if 3DNow+ is supported.
 
void getCacheSizes (unsigned int &csize_l1, unsigned int &csize_l2) const
 Returns L1 and L2 cache sizes.
 
const std::string & getVendorID () const
 Returns the CPU's vendor identifier (something like "AuthenticAMD" for example).
 
const std::string & getModelID () const
 Returns the CPU's model identifier if supported.
 
void getCPUCount (unsigned int &numPhysicalProcessors, unsigned int &numCores, unsigned int &numVirtualProcessors)
 Returns the machines CPU configuration, that means the number of actual CPUs, the number of cores and the total number of processors.
 
unsigned int getNumPhysicalProcessors () const
 Returns the total number of actual CPUs.
 
unsigned int getNumCores () const
 Returns the total number of cores.
 
unsigned int getNumVirtualProcessors () const
 Returns the total number of virtual processors.
 
unsigned int getCPUFrequency () const
 Returns the cpu frequency in mega hertz.
 
void printInfo (std::ostream &ostr)
 Formated output of system information to stdout.
 

Static Public Member Functions

static CPUInfogetInstance ()
 Returns the single existing object of this class.
 

Protected Member Functions

 CPUInfo ()
 This constructor must not be called from anywhere else but the getInstance() method (which does call this function if the static pointer to the valid object is not set yet).
 

Detailed Description

Singleton class that provides hardware specific information.

To get a pointer to a valid object of this type use the getInstance() method. The getCPUCount method is required to get an overview of the machines CPU ressources. There are different layers which influence the performance if used for multithreading. The lowest level would be Hyper-Threading (two or more threads running on one core. Those share a lot more ressources than threads running on different cores. Again those share ressources (cache for example) that threads on different CPUs would share. This hierarchy can give information on the quality of parallelization. Information about the IA-32 platform can be read via the cpuid command. A lot of valuable information can be found on this page: http://www.sandpile.org/ia32/cpuid.htm or in the "IntelĀ® Processor Identification and the CPUID Instruction". I tried to find an optimal way for providing information but not having to struggle too much with Intel's way to mystify data. Therefore there is primary use of the extended registers that provide lots of information in a more sane fashion.

Definition at line 43 of file mlCPUInfo.h.

Constructor & Destructor Documentation

◆ CPUInfo()

ml::CPUInfo::CPUInfo ( )
protected

This constructor must not be called from anywhere else but the getInstance() method (which does call this function if the static pointer to the valid object is not set yet).

Member Function Documentation

◆ getCacheSizes()

void ml::CPUInfo::getCacheSizes ( unsigned int & csize_l1,
unsigned int & csize_l2 ) const

Returns L1 and L2 cache sizes.

◆ getCPUCount()

void ml::CPUInfo::getCPUCount ( unsigned int & numPhysicalProcessors,
unsigned int & numCores,
unsigned int & numVirtualProcessors )

Returns the machines CPU configuration, that means the number of actual CPUs, the number of cores and the total number of processors.

Parameters
numPhysicalProcessorsThe total number of actual CPUs.
numCoresThe total number of cores.
numVirtualProcessorsThe total number of virtual processors.

◆ getCPUFrequency()

unsigned int ml::CPUInfo::getCPUFrequency ( ) const

Returns the cpu frequency in mega hertz.

◆ getInstance()

static CPUInfo & ml::CPUInfo::getInstance ( )
static

Returns the single existing object of this class.

The concept of this class is based on the Singleton design pattern which ensures there is only one object of this class. (NOT THREADSAFE!)

◆ getModelID()

const std::string & ml::CPUInfo::getModelID ( ) const
inline

Returns the CPU's model identifier if supported.

Definition at line 127 of file mlCPUInfo.h.

◆ getNumCores()

unsigned int ml::CPUInfo::getNumCores ( ) const

Returns the total number of cores.

◆ getNumPhysicalProcessors()

unsigned int ml::CPUInfo::getNumPhysicalProcessors ( ) const

Returns the total number of actual CPUs.

◆ getNumVirtualProcessors()

unsigned int ml::CPUInfo::getNumVirtualProcessors ( ) const

Returns the total number of virtual processors.

◆ getVendorID()

const std::string & ml::CPUInfo::getVendorID ( ) const
inline

Returns the CPU's vendor identifier (something like "AuthenticAMD" for example).

Definition at line 123 of file mlCPUInfo.h.

◆ has3DNow()

bool ml::CPUInfo::has3DNow ( ) const
inline

Returns true if 3DNow! is supported.

Definition at line 109 of file mlCPUInfo.h.

◆ has3DNowP()

bool ml::CPUInfo::has3DNowP ( ) const
inline

Returns true if 3DNow+ is supported.

Definition at line 113 of file mlCPUInfo.h.

◆ hasAVX()

bool ml::CPUInfo::hasAVX ( ) const
inline

Returns true if AVX is supported.

Definition at line 105 of file mlCPUInfo.h.

◆ hasMMX()

bool ml::CPUInfo::hasMMX ( ) const
inline

Returns true if MMX is supported.

Definition at line 69 of file mlCPUInfo.h.

◆ hasSSE()

bool ml::CPUInfo::hasSSE ( ) const
inline

Returns true if SSE is supported.

Definition at line 73 of file mlCPUInfo.h.

◆ hasSSE2()

bool ml::CPUInfo::hasSSE2 ( ) const
inline

Returns true if SSE2 is supported.

Definition at line 77 of file mlCPUInfo.h.

◆ hasSSE3()

bool ml::CPUInfo::hasSSE3 ( ) const
inline

Returns true if SSE3 is supported.

Definition at line 81 of file mlCPUInfo.h.

◆ hasSSE4_1()

bool ml::CPUInfo::hasSSE4_1 ( ) const
inline

Returns true if SSE4.1 is supported.

Definition at line 89 of file mlCPUInfo.h.

◆ hasSSE4_2()

bool ml::CPUInfo::hasSSE4_2 ( ) const
inline

Returns true if SSE4.2 is supported.

Definition at line 93 of file mlCPUInfo.h.

◆ hasSSE4a()

bool ml::CPUInfo::hasSSE4a ( ) const
inline

Returns true if SSE4a is supported.

Definition at line 97 of file mlCPUInfo.h.

◆ hasSSE5()

bool ml::CPUInfo::hasSSE5 ( ) const
inline

Returns true if SSE5 is supported.

Definition at line 101 of file mlCPUInfo.h.

◆ hasSSSE3()

bool ml::CPUInfo::hasSSSE3 ( ) const
inline

Returns true if SSSE3 is supported.

Definition at line 85 of file mlCPUInfo.h.

◆ isPentium()

bool ml::CPUInfo::isPentium ( ) const
inline

Returns true if this is a pentium based system.

Definition at line 65 of file mlCPUInfo.h.

◆ printInfo()

void ml::CPUInfo::printInfo ( std::ostream & ostr)

Formated output of system information to stdout.


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