MeVisLab Toolbox 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. More...
 
bool hasMMX () const
 Returns true if MMX is supported. More...
 
bool hasSSE () const
 Returns true if SSE is supported. More...
 
bool hasSSE2 () const
 Returns true if SSE2 is supported. More...
 
bool hasSSE3 () const
 Returns true if SSE3 is supported. More...
 
bool hasSSSE3 () const
 Returns true if SSSE3 is supported. More...
 
bool hasSSE4_1 () const
 Returns true if SSE4.1 is supported. More...
 
bool hasSSE4_2 () const
 Returns true if SSE4.2 is supported. More...
 
bool hasSSE4a () const
 Returns true if SSE4a is supported. More...
 
bool hasSSE5 () const
 Returns true if SSE5 is supported. More...
 
bool hasAVX () const
 Returns true if AVX is supported. More...
 
bool has3DNow () const
 Returns true if 3DNow! is supported. More...
 
bool has3DNowP () const
 Returns true if 3DNow+ is supported. More...
 
void getCacheSizes (unsigned int &csize_l1, unsigned int &csize_l2) const
 Returns L1 and L2 cache sizes. More...
 
const std::string & getVendorID () const
 Returns the CPU's vendor identifier ('AuthenticAMD' for example). More...
 
const std::string & getModelID () const
 Returns the CPU's model identifier if supported. More...
 
void getCPUCount (unsigned int &numPhysicalProcessors, unsigned int &numCores, unsigned int &numVirtualProcessors)
 Returns the machine's CPU configuration; that means the number of actual CPUs, the number of cores, and the total number of processors. More...
 
unsigned int getNumPhysicalProcessors () const
 Returns the total number of actual CPUs. More...
 
unsigned int getNumCores () const
 Returns the total number of cores. More...
 
unsigned int getNumVirtualProcessors () const
 Returns the total number of virtual processors. More...
 
unsigned int getCPUFrequency () const
 Returns the CPU frequency in megahertz. More...
 
void printInfo (std::ostream &ostr)
 Formated output of system information to stdout. More...
 

Static Public Member Functions

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

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). More...
 

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 resources. There are different layers that influence the performance if used for multithreading. The lowest level is Hyper-Threading (two or more threads running on one core). Those threads share a lot more resources than threads running on different cores. Again those share resources (cache for example) that threads on different CPUs share. This hierarchy can give information on the quality of parallelization. A lot of valuable information can be found on this page: https://www.sandpile.org/x86/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 42 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 machine's 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 megahertz.

◆ 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 THREAD-SAFE!)

◆ getModelID()

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

Returns the CPU's model identifier if supported.

Definition at line 126 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 ('AuthenticAMD' for example).

Definition at line 122 of file mlCPUInfo.h.

◆ has3DNow()

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

Returns true if 3DNow! is supported.

Definition at line 108 of file mlCPUInfo.h.

◆ has3DNowP()

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

Returns true if 3DNow+ is supported.

Definition at line 112 of file mlCPUInfo.h.

◆ hasAVX()

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

Returns true if AVX is supported.

Definition at line 104 of file mlCPUInfo.h.

◆ hasMMX()

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

Returns true if MMX is supported.

Definition at line 68 of file mlCPUInfo.h.

◆ hasSSE()

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

Returns true if SSE is supported.

Definition at line 72 of file mlCPUInfo.h.

◆ hasSSE2()

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

Returns true if SSE2 is supported.

Definition at line 76 of file mlCPUInfo.h.

◆ hasSSE3()

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

Returns true if SSE3 is supported.

Definition at line 80 of file mlCPUInfo.h.

◆ hasSSE4_1()

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

Returns true if SSE4.1 is supported.

Definition at line 88 of file mlCPUInfo.h.

◆ hasSSE4_2()

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

Returns true if SSE4.2 is supported.

Definition at line 92 of file mlCPUInfo.h.

◆ hasSSE4a()

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

Returns true if SSE4a is supported.

Definition at line 96 of file mlCPUInfo.h.

◆ hasSSE5()

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

Returns true if SSE5 is supported.

Definition at line 100 of file mlCPUInfo.h.

◆ hasSSSE3()

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

Returns true if SSSE3 is supported.

Definition at line 84 of file mlCPUInfo.h.

◆ isPentium()

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

Returns true if this is a Pentium based system.

Definition at line 64 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: