MeVisLab Toolbox Reference
macCPUInfo.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 MAC_CPUINFO_H
14 #define MAC_CPUINFO_H
15 
17 
18 #if defined(__APPLE__)
19 
21 #include <macSysCtl.h>
22 #include <stdint.h>
23 #include <string>
24 
25 namespace macos {
26 
29  {
30  public:
31 
33  enum CPUType {
34  CPUTypeUnknown = -1,
40  CPUTypeARM_64
41  };
42 
44  static CPUType getCPUType();
45 
47  static bool is64BitCapable() {
48  return SysCtl::boolByName("hw.cpu64bit_capable");
49  }
50 
52  static bool isMMXPresent() {
53  return SysCtl::boolByName("hw.optional.mmx");
54  }
55 
57  static bool isSSEPresent() {
58  return SysCtl::boolByName("hw.optional.sse");
59  }
60 
62  static bool isSSE2Present() {
63  return SysCtl::boolByName("hw.optional.sse2");
64  }
65 
67  static bool isSSE3Present() {
68  return SysCtl::boolByName("hw.optional.sse3");
69  }
70 
72  static bool isSSSE3Present() {
73  return SysCtl::boolByName("hw.optional.supplementalsse3");
74  }
75 
77  static bool isSSE4_1Present() {
78  return SysCtl::boolByName("hw.optional.sse4_1");
79  }
80 
82  static bool isSSE4_2Present() {
83  return SysCtl::boolByName("hw.optional.sse4_2");
84  }
85 
87  static bool isAVX1Present() {
88  return SysCtl::boolByName("hw.optional.avx1_0");
89  }
90 
92  static bool isAVX2Present() {
93  return SysCtl::boolByName("hw.optional.avx2_0");
94  }
95 
97  static bool isAESPresent() {
98  return SysCtl::boolByName("hw.optional.aes");
99  }
100 
102  static uint64_t getCPUFrequency() {
103  return SysCtl::uint64ByName("hw.cpufrequency");
104  }
105 
107  static uint64_t getL1CacheSize() {
108  // hw.l1dcachesize ?
109  return SysCtl::uint64ByName("hw.l1icachesize");
110  }
111 
113  static uint64_t getL2CacheSize() {
114  return SysCtl::uint64ByName("hw.l2cachesize");
115  }
116 
118  static uint64_t getL3CacheSize() {
119  return SysCtl::uint64ByName("hw.l3cachesize");
120  }
121 
123  static unsigned int getVirtualCoresCount() {
124  uint32_t packCount = SysCtl::uint32ByName("hw.packages");
125  return (packCount == 0) ? 1 : SysCtl::uint32ByName("hw.ncpu") / packCount;
126  }
127 
130  static std::string getCPUVendor() {
131  return SysCtl::stringByName("machdep.cpu.vendor");
132  }
133 
136  static std::string getCPUBrandString() {
137  return SysCtl::stringByName("machdep.cpu.brand_string");
138  }
139 
140  };
141 
142 }
143 
144 #endif // __APPLE__
145 #endif // __macCPUInfo_H
CPU information.
Definition: macCPUInfo.h:29
static bool isSSE4_2Present()
Check if Streaming SIMD Extensions 4.2 are present.
Definition: macCPUInfo.h:82
static uint64_t getCPUFrequency()
Get CPU frequency in hertz.
Definition: macCPUInfo.h:102
static bool isAVX1Present()
Check if AVX1 instructions are present and enabled in the OS.
Definition: macCPUInfo.h:87
static std::string getCPUVendor()
Return CPU vendor string e.g.
Definition: macCPUInfo.h:130
CPUType
CPU types.
Definition: macCPUInfo.h:33
@ CPUTypeX86_64
64-bit X86
Definition: macCPUInfo.h:38
@ CPUTypePPC64
64-bit PPC
Definition: macCPUInfo.h:36
@ CPUTypeARM
32-bit ARM
Definition: macCPUInfo.h:39
@ CPUTypeI386
I386.
Definition: macCPUInfo.h:37
@ CPUTypePPC
PPC.
Definition: macCPUInfo.h:35
static std::string getCPUBrandString()
Return CPU brand string e.g.
Definition: macCPUInfo.h:136
static bool isSSE2Present()
Check if Streaming SIMD Extensions 2 are present.
Definition: macCPUInfo.h:62
static uint64_t getL1CacheSize()
Get first level cache size in bytes.
Definition: macCPUInfo.h:107
static bool isAVX2Present()
Check if AVX2 instructions are present and enabled in the OS.
Definition: macCPUInfo.h:92
static bool isSSSE3Present()
Check if Supplemental Streaming SIMD Extensions 3 are present.
Definition: macCPUInfo.h:72
static uint64_t getL3CacheSize()
Get third level cache size in bytes.
Definition: macCPUInfo.h:118
static bool is64BitCapable()
Check if 64 bit support is present.
Definition: macCPUInfo.h:47
static bool isSSEPresent()
Check if Streaming SIMD Extensions are present.
Definition: macCPUInfo.h:57
static bool isMMXPresent()
Check if MMX vector instructions are present.
Definition: macCPUInfo.h:52
static bool isAESPresent()
Check if AES Extensions are present.
Definition: macCPUInfo.h:97
static unsigned int getVirtualCoresCount()
Return number of virtual cpus per processor package.
Definition: macCPUInfo.h:123
static bool isSSE3Present()
Check if Streaming SIMD Extensions 3 are present.
Definition: macCPUInfo.h:67
static bool isSSE4_1Present()
Check if Streaming SIMD Extensions 4.1 are present.
Definition: macCPUInfo.h:77
static CPUType getCPUType()
Return CPU type.
static uint64_t getL2CacheSize()
Get second level cache size in bytes.
Definition: macCPUInfo.h:113
static std::string stringByName(const char *option)
static uint64_t uint64ByName(const char *option)
static uint32_t uint32ByName(const char *option)
static bool boolByName(const char *option)
#define OSXSUPPORT_PUBLIC_API
Symbol visibility macros.
AppleScript support.