Plasma Engine  2.0
Loading...
Searching...
No Matches
SystemInformation.h
1#pragma once
2
7{
8#if PL_ENABLED(PL_PLATFORM_ARCH_X86)
9 // Vendor
10 bool Vendor_AMD = false;
11 bool Vendor_Intel = false;
12
13 // OS Features
14 bool OS_x64 = false;
15 bool OS_AVX = false;
16 bool OS_AVX512 = false;
17
18 // Misc.
19 bool HW_MMX = false;
20 bool HW_x64 = false;
21 bool HW_ABM = false;
22 bool HW_RDRAND = false;
23 bool HW_RDSEED = false;
24 bool HW_BMI1 = false;
25 bool HW_BMI2 = false;
26 bool HW_ADX = false;
27 bool HW_MPX = false;
28 bool HW_PREFETCHW = false;
29 bool HW_PREFETCHWT1 = false;
30 bool HW_RDPID = false;
31
32 // SIMD: 128-bit
33 bool HW_SSE = false;
34 bool HW_SSE2 = false;
35 bool HW_SSE3 = false;
36 bool HW_SSSE3 = false;
37 bool HW_SSE41 = false;
38 bool HW_SSE42 = false;
39 bool HW_SSE4a = false;
40 bool HW_AES = false;
41 bool HW_SHA = false;
42
43 // SIMD: 256-bit
44 bool HW_AVX = false;
45 bool HW_XOP = false;
46 bool HW_FMA3 = false;
47 bool HW_FMA4 = false;
48 bool HW_AVX2 = false;
49
50 // SIMD: 512-bit
51 bool HW_AVX512_F = false;
52 bool HW_AVX512_CD = false;
53
54 // Knights Landing
55 bool HW_AVX512_PF = false;
56 bool HW_AVX512_ER = false;
57
58 // Skylake Purley
59 bool HW_AVX512_VL = false;
60 bool HW_AVX512_BW = false;
61 bool HW_AVX512_DQ = false;
62
63 // Cannon Lake
64 bool HW_AVX512_IFMA = false;
65 bool HW_AVX512_VBMI = false;
66
67 // Knights Mill
68 bool HW_AVX512_VPOPCNTDQ = false;
69 bool HW_AVX512_4FMAPS = false;
70 bool HW_AVX512_4VNNIW = false;
71
72 // Cascade Lake
73 bool HW_AVX512_VNNI = false;
74
75 // Cooper Lake
76 bool HW_AVX512_BF16 = false;
77
78 // Ice Lake
79 bool HW_AVX512_VBMI2 = false;
80 bool HW_GFNI = false;
81 bool HW_VAES = false;
82 bool HW_AVX512_VPCLMUL = false;
83 bool HW_AVX512_BITALG = false;
84
85 bool IsAvx1Available() const { return OS_AVX && HW_AVX; }
86 bool IsAvx2Available() const { return OS_AVX && HW_AVX2; }
87#endif
88
89 void Detect();
90};
91
96class PL_FOUNDATION_DLL plSystemInformation
97{
98public:
100 plUInt64 GetInstalledMainMemory() const { return m_uiInstalledMainMemory; }
101
103 plUInt64 GetAvailableMainMemory() const;
104
106 plUInt32 GetMemoryPageSize() const { return m_uiMemoryPageSize; }
107
109 plUInt32 GetCPUCoreCount() const { return m_uiCPUCoreCount; }
110
112 float GetCPUUtilization() const;
113
115 bool Is64BitOS() const { return m_bB64BitOS; }
116
117 const char* GetPlatformName() const { return m_szPlatformName; }
118
119 const char* GetHostName() const { return m_sHostName; }
120
121 const char* GetBuildConfiguration() const { return m_szBuildConfiguration; }
122
124 const plCpuFeatures& GetCpuFeatures() const { return m_CpuFeatures; }
125
126public:
128 static bool IsDebuggerAttached();
129
131 static const plSystemInformation& Get()
132 {
133 if (!s_SystemInformation.m_bIsInitialized)
134 Initialize();
135
136 return s_SystemInformation;
137 }
138
139private:
140 plUInt64 m_uiInstalledMainMemory;
141 plUInt32 m_uiMemoryPageSize;
142 plUInt32 m_uiCPUCoreCount;
143 const char* m_szPlatformName = nullptr;
144 const char* m_szBuildConfiguration = nullptr;
145 char m_sHostName[256];
146 bool m_bB64BitOS;
147 bool m_bIsInitialized;
148 plCpuFeatures m_CpuFeatures;
149
150 static void Initialize();
151
152 static plSystemInformation s_SystemInformation;
153};
The system configuration class encapsulates information about the system the application is running o...
Definition SystemInformation.h:97
plUInt64 GetInstalledMainMemory() const
Returns the installed physical memory in bytes.
Definition SystemInformation.h:100
static const plSystemInformation & Get()
Allows access to the current system configuration.
Definition SystemInformation.h:131
plUInt32 GetCPUCoreCount() const
Returns the CPU core count of the system.
Definition SystemInformation.h:109
bool Is64BitOS() const
Returns true if the process is currently running on a 64-bit OS.
Definition SystemInformation.h:115
const plCpuFeatures & GetCpuFeatures() const
Returns a struct that contains detailed information about the available CPU features (SIMD support).
Definition SystemInformation.h:124
plUInt32 GetMemoryPageSize() const
Returns the size of a memory page in bytes.
Definition SystemInformation.h:106
Flags that tell you which SIMD features are available on this processor / OS.
Definition SystemInformation.h:7
void Detect()
CPU feature detection code copied from https://github.com/Mysticial/FeatureDetector.
Definition SystemInformation.cpp:168