ML Reference
mlCPUInfo.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_CPUINFO_H
14 #define ML_CPUINFO_H
15 
17 
18 #include "mlUtilsSystem.h"
19 
20 #include <string>
21 
22 ML_UTILS_START_NAMESPACE
23 
24 //=============================================================================
41 //=============================================================================
43 {
44 public:
45  // --------------------------------------------------------------------------
49  // --------------------------------------------------------------------------
50  static CPUInfo &getInstance();
51 
52 protected:
53  // --------------------------------------------------------------------------
57  // --------------------------------------------------------------------------
59 
60 public:
61  // --------------------------------------------------------------------------
63  // --------------------------------------------------------------------------
64  bool isPentium() const { return _isPentium; };
65  // --------------------------------------------------------------------------
67  // --------------------------------------------------------------------------
68  bool hasMMX() const { return _hasMMX; };
69  // --------------------------------------------------------------------------
71  // --------------------------------------------------------------------------
72  bool hasSSE() const { return _hasSSE; };
73  // --------------------------------------------------------------------------
75  // --------------------------------------------------------------------------
76  bool hasSSE2() const { return _hasSSE2; };
77  // --------------------------------------------------------------------------
79  // --------------------------------------------------------------------------
80  bool hasSSE3() const { return _hasSSE3; };
81  // --------------------------------------------------------------------------
83  // --------------------------------------------------------------------------
84  bool hasSSSE3() const { return _hasSSSE3; };
85  // --------------------------------------------------------------------------
87  // --------------------------------------------------------------------------
88  bool hasSSE4_1() const { return _hasSSE4_1; };
89  // --------------------------------------------------------------------------
91  // --------------------------------------------------------------------------
92  bool hasSSE4_2() const { return _hasSSE4_2; };
93  // --------------------------------------------------------------------------
95  // --------------------------------------------------------------------------
96  bool hasSSE4a() const { return _hasSSE4a; };
97  // --------------------------------------------------------------------------
99  // --------------------------------------------------------------------------
100  bool hasSSE5() const { return _hasSSE5; };
101  // --------------------------------------------------------------------------
103  // --------------------------------------------------------------------------
104  bool hasAVX() const { return _hasAVX; };
105  // --------------------------------------------------------------------------
107  // --------------------------------------------------------------------------
108  bool has3DNow() const { return _has3DNow; };
109  // --------------------------------------------------------------------------
111  // --------------------------------------------------------------------------
112  bool has3DNowP() const { return _has3DNowP; };
113  // --------------------------------------------------------------------------
115  // --------------------------------------------------------------------------
116  void getCacheSizes(unsigned int &csize_l1,
117  unsigned int &csize_l2) const;
118  // --------------------------------------------------------------------------
121  // --------------------------------------------------------------------------
122  const std::string &getVendorID() const { return _vendorID; };
123  // --------------------------------------------------------------------------
125  // --------------------------------------------------------------------------
126  const std::string &getModelID() const { return _modelID; };
127  // --------------------------------------------------------------------------
133  // --------------------------------------------------------------------------
134  void getCPUCount(unsigned int &numPhysicalProcessors,
135  unsigned int &numCores,
136  unsigned int &numVirtualProcessors);
137 
138  // --------------------------------------------------------------------------
140  // --------------------------------------------------------------------------
141  unsigned int getNumPhysicalProcessors() const;
142  // --------------------------------------------------------------------------
144  // --------------------------------------------------------------------------
145  unsigned int getNumCores() const;
146  // --------------------------------------------------------------------------
148  // --------------------------------------------------------------------------
149  unsigned int getNumVirtualProcessors() const;
150 
151  // --------------------------------------------------------------------------
153  // --------------------------------------------------------------------------
154  unsigned int getCPUFrequency() const;
155 
156  // --------------------------------------------------------------------------
158  // --------------------------------------------------------------------------
159  void printInfo(std::ostream &ostr);
160 
161 private:
163  std::string _vendorID;
165  std::string _modelID;
167  bool _isPentium;
169  bool _hasMMX;
171  bool _hasSSE;
173  bool _hasSSE2;
175  bool _hasSSE3;
177  bool _hasSSSE3;
179  bool _hasSSE4_1;
181  bool _hasSSE4_2;
183  bool _hasSSE4a;
185  bool _hasSSE5;
187  bool _hasAVX;
189  bool _has3DNow;
191  bool _has3DNowP;
193  unsigned int _cpuFrequency;
195  unsigned int _csize_l1;
197  unsigned int _csize_l2;
199  unsigned int _numVirtualProcessors;
201  unsigned int _numCores;
203  unsigned int _numPhysicalProcessors;
204 };
205 
206 ML_UTILS_END_NAMESPACE
207 #endif
Singleton class that provides hardware-specific information.
Definition: mlCPUInfo.h:43
static CPUInfo & getInstance()
Returns the single existing object of this class.
bool hasSSE2() const
Returns true if SSE2 is supported.
Definition: mlCPUInfo.h:76
unsigned int getNumCores() const
Returns the total number of cores.
void printInfo(std::ostream &ostr)
Formated output of system information to stdout.
bool has3DNow() const
Returns true if 3DNow! is supported.
Definition: mlCPUInfo.h:108
bool hasSSE() const
Returns true if SSE is supported.
Definition: mlCPUInfo.h:72
bool hasMMX() const
Returns true if MMX is supported.
Definition: mlCPUInfo.h:68
const std::string & getVendorID() const
Returns the CPU's vendor identifier ('AuthenticAMD' for example).
Definition: mlCPUInfo.h:122
void getCacheSizes(unsigned int &csize_l1, unsigned int &csize_l2) const
Returns L1 and L2 cache sizes.
bool isPentium() const
Returns true if this is a Pentium based system.
Definition: mlCPUInfo.h:64
bool hasSSE3() const
Returns true if SSE3 is supported.
Definition: mlCPUInfo.h:80
bool has3DNowP() const
Returns true if 3DNow+ is supported.
Definition: mlCPUInfo.h:112
bool hasSSE4a() const
Returns true if SSE4a is supported.
Definition: mlCPUInfo.h:96
bool hasSSE5() const
Returns true if SSE5 is supported.
Definition: mlCPUInfo.h:100
const std::string & getModelID() const
Returns the CPU's model identifier if supported.
Definition: mlCPUInfo.h:126
unsigned int getNumPhysicalProcessors() const
Returns the total number of actual CPUs.
bool hasSSSE3() const
Returns true if SSSE3 is supported.
Definition: mlCPUInfo.h:84
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,...
bool hasSSE4_2() const
Returns true if SSE4.2 is supported.
Definition: mlCPUInfo.h:92
CPUInfo()
This constructor must not be called from anywhere else but the getInstance() method (which does call ...
bool hasSSE4_1() const
Returns true if SSE4.1 is supported.
Definition: mlCPUInfo.h:88
bool hasAVX() const
Returns true if AVX is supported.
Definition: mlCPUInfo.h:104
unsigned int getCPUFrequency() const
Returns the CPU frequency in megahertz.
unsigned int getNumVirtualProcessors() const
Returns the total number of virtual processors.
#define ML_UTILS_EXPORT
Definition: mlUtilities.h:18