MeVisLab Toolbox 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
23
24//=============================================================================
42//=============================================================================
44{
45public:
46 // --------------------------------------------------------------------------
50 // --------------------------------------------------------------------------
52
53protected:
54 // --------------------------------------------------------------------------
58 // --------------------------------------------------------------------------
60
61public:
62 // --------------------------------------------------------------------------
64 // --------------------------------------------------------------------------
65 bool isPentium() const { return _isPentium; };
66 // --------------------------------------------------------------------------
68 // --------------------------------------------------------------------------
69 bool hasMMX() const { return _hasMMX; };
70 // --------------------------------------------------------------------------
72 // --------------------------------------------------------------------------
73 bool hasSSE() const { return _hasSSE; };
74 // --------------------------------------------------------------------------
76 // --------------------------------------------------------------------------
77 bool hasSSE2() const { return _hasSSE2; };
78 // --------------------------------------------------------------------------
80 // --------------------------------------------------------------------------
81 bool hasSSE3() const { return _hasSSE3; };
82 // --------------------------------------------------------------------------
84 // --------------------------------------------------------------------------
85 bool hasSSSE3() const { return _hasSSSE3; };
86 // --------------------------------------------------------------------------
88 // --------------------------------------------------------------------------
89 bool hasSSE4_1() const { return _hasSSE4_1; };
90 // --------------------------------------------------------------------------
92 // --------------------------------------------------------------------------
93 bool hasSSE4_2() const { return _hasSSE4_2; };
94 // --------------------------------------------------------------------------
96 // --------------------------------------------------------------------------
97 bool hasSSE4a() const { return _hasSSE4a; };
98 // --------------------------------------------------------------------------
100 // --------------------------------------------------------------------------
101 bool hasSSE5() const { return _hasSSE5; };
102 // --------------------------------------------------------------------------
104 // --------------------------------------------------------------------------
105 bool hasAVX() const { return _hasAVX; };
106 // --------------------------------------------------------------------------
108 // --------------------------------------------------------------------------
109 bool has3DNow() const { return _has3DNow; };
110 // --------------------------------------------------------------------------
112 // --------------------------------------------------------------------------
113 bool has3DNowP() const { return _has3DNowP; };
114 // --------------------------------------------------------------------------
116 // --------------------------------------------------------------------------
117 void getCacheSizes(unsigned int &csize_l1,
118 unsigned int &csize_l2) const;
119 // --------------------------------------------------------------------------
122 // --------------------------------------------------------------------------
123 const std::string &getVendorID() const { return _vendorID; };
124 // --------------------------------------------------------------------------
126 // --------------------------------------------------------------------------
127 const std::string &getModelID() const { return _modelID; };
128 // --------------------------------------------------------------------------
134 // --------------------------------------------------------------------------
136 unsigned int &numCores,
137 unsigned int &numVirtualProcessors);
138
139 // --------------------------------------------------------------------------
141 // --------------------------------------------------------------------------
142 unsigned int getNumPhysicalProcessors() const;
143 // --------------------------------------------------------------------------
145 // --------------------------------------------------------------------------
146 unsigned int getNumCores() const;
147 // --------------------------------------------------------------------------
149 // --------------------------------------------------------------------------
150 unsigned int getNumVirtualProcessors() const;
151
152 // --------------------------------------------------------------------------
154 // --------------------------------------------------------------------------
155 unsigned int getCPUFrequency() const;
156
157 // --------------------------------------------------------------------------
159 // --------------------------------------------------------------------------
160 void printInfo(std::ostream &ostr);
161
162private:
164 std::string _vendorID;
166 std::string _modelID;
168 bool _isPentium;
170 bool _hasMMX;
172 bool _hasSSE;
174 bool _hasSSE2;
176 bool _hasSSE3;
178 bool _hasSSSE3;
180 bool _hasSSE4_1;
182 bool _hasSSE4_2;
184 bool _hasSSE4a;
186 bool _hasSSE5;
188 bool _hasAVX;
190 bool _has3DNow;
192 bool _has3DNowP;
194 unsigned int _cpuFrequency;
196 unsigned int _csize_l1;
198 unsigned int _csize_l2;
200 unsigned int _numVirtualProcessors;
202 unsigned int _numCores;
204 unsigned int _numPhysicalProcessors;
205};
206
208#endif
Singleton class that provides hardware specific information.
Definition mlCPUInfo.h:44
static CPUInfo & getInstance()
Returns the single existing object of this class.
bool hasSSE2() const
Returns true if SSE2 is supported.
Definition mlCPUInfo.h:77
unsigned int getNumCores() const
Returns the total number of cores.
const std::string & getVendorID() const
Returns the CPU's vendor identifier (something like "AuthenticAMD" for example).
Definition mlCPUInfo.h:123
void printInfo(std::ostream &ostr)
Formated output of system information to stdout.
bool has3DNow() const
Returns true if 3DNow! is supported.
Definition mlCPUInfo.h:109
bool hasSSE() const
Returns true if SSE is supported.
Definition mlCPUInfo.h:73
bool hasMMX() const
Returns true if MMX is supported.
Definition mlCPUInfo.h:69
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:65
bool hasSSE3() const
Returns true if SSE3 is supported.
Definition mlCPUInfo.h:81
bool has3DNowP() const
Returns true if 3DNow+ is supported.
Definition mlCPUInfo.h:113
bool hasSSE4a() const
Returns true if SSE4a is supported.
Definition mlCPUInfo.h:97
bool hasSSE5() const
Returns true if SSE5 is supported.
Definition mlCPUInfo.h:101
unsigned int getNumPhysicalProcessors() const
Returns the total number of actual CPUs.
bool hasSSSE3() const
Returns true if SSSE3 is supported.
Definition mlCPUInfo.h:85
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...
const std::string & getModelID() const
Returns the CPU's model identifier if supported.
Definition mlCPUInfo.h:127
bool hasSSE4_2() const
Returns true if SSE4.2 is supported.
Definition mlCPUInfo.h:93
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:89
bool hasAVX() const
Returns true if AVX is supported.
Definition mlCPUInfo.h:105
unsigned int getCPUFrequency() const
Returns the cpu frequency in mega hertz.
unsigned int getNumVirtualProcessors() const
Returns the total number of virtual processors.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
#define ML_UTILS_EXPORT
Defines platform dependent DLL export macro for mlUtils.
Definition mlUtilities.h:20