Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/embree/common/sys/sysinfo.h
9912 views
1
// Copyright 2009-2021 Intel Corporation
2
// SPDX-License-Identifier: Apache-2.0
3
4
#pragma once
5
6
#define CACHELINE_SIZE 64
7
8
#if !defined(PAGE_SIZE)
9
#define PAGE_SIZE 4096
10
#endif
11
12
#define PAGE_SIZE_2M (2*1024*1024)
13
#define PAGE_SIZE_4K (4*1024)
14
15
#include "platform.h"
16
17
/* define isa namespace and ISA bitvector */
18
#if defined (__AVX512VL__)
19
# define isa avx512
20
# define ISA AVX512
21
# define ISA_STR "AVX512"
22
#elif defined (__AVX2__)
23
# define isa avx2
24
# define ISA AVX2
25
# define ISA_STR "AVX2"
26
#elif defined(__AVXI__)
27
# define isa avxi
28
# define ISA AVXI
29
# define ISA_STR "AVXI"
30
#elif defined(__AVX__)
31
# define isa avx
32
# define ISA AVX
33
# define ISA_STR "AVX"
34
#elif defined (__SSE4_2__)
35
# define isa sse42
36
# define ISA SSE42
37
# define ISA_STR "SSE4.2"
38
//#elif defined (__SSE4_1__) // we demote this to SSE2, MacOSX code compiles with SSE41 by default with XCode 11
39
//# define isa sse41
40
//# define ISA SSE41
41
//# define ISA_STR "SSE4.1"
42
//#elif defined(__SSSE3__) // we demote this to SSE2, MacOSX code compiles with SSSE3 by default with ICC
43
//# define isa ssse3
44
//# define ISA SSSE3
45
//# define ISA_STR "SSSE3"
46
//#elif defined(__SSE3__) // we demote this to SSE2, MacOSX code compiles with SSE3 by default with clang
47
//# define isa sse3
48
//# define ISA SSE3
49
//# define ISA_STR "SSE3"
50
#elif defined(__SSE2__) || defined(__SSE3__) || defined(__SSSE3__)
51
# define isa sse2
52
# define ISA SSE2
53
# define ISA_STR "SSE2"
54
#elif defined(__SSE__)
55
# define isa sse
56
# define ISA SSE
57
# define ISA_STR "SSE"
58
#elif defined(__ARM_NEON)
59
// NOTE(LTE): Use sse2 for `isa` for the compatibility at the moment.
60
#define isa sse2
61
#define ISA NEON
62
#define ISA_STR "NEON"
63
#else
64
#error Unknown ISA
65
#endif
66
67
namespace embree
68
{
69
enum class CPU
70
{
71
XEON_ICE_LAKE,
72
CORE_ICE_LAKE,
73
CORE_TIGER_LAKE,
74
CORE_COMET_LAKE,
75
CORE_CANNON_LAKE,
76
CORE_KABY_LAKE,
77
XEON_SKY_LAKE,
78
CORE_SKY_LAKE,
79
XEON_PHI_KNIGHTS_MILL,
80
XEON_PHI_KNIGHTS_LANDING,
81
XEON_BROADWELL,
82
CORE_BROADWELL,
83
XEON_HASWELL,
84
CORE_HASWELL,
85
XEON_IVY_BRIDGE,
86
CORE_IVY_BRIDGE,
87
SANDY_BRIDGE,
88
NEHALEM,
89
CORE2,
90
CORE1,
91
ARM,
92
UNKNOWN,
93
};
94
95
/*! get the full path to the running executable */
96
std::string getExecutableFileName();
97
98
/*! return platform name */
99
std::string getPlatformName();
100
101
/*! get the full name of the compiler */
102
std::string getCompilerName();
103
104
/*! return the name of the CPU */
105
std::string getCPUVendor();
106
107
/*! get microprocessor model */
108
CPU getCPUModel();
109
110
/*! converts CPU model into string */
111
std::string stringOfCPUModel(CPU model);
112
113
/*! CPU features */
114
static const int CPU_FEATURE_SSE = 1 << 0;
115
static const int CPU_FEATURE_SSE2 = 1 << 1;
116
static const int CPU_FEATURE_SSE3 = 1 << 2;
117
static const int CPU_FEATURE_SSSE3 = 1 << 3;
118
static const int CPU_FEATURE_SSE41 = 1 << 4;
119
static const int CPU_FEATURE_SSE42 = 1 << 5;
120
static const int CPU_FEATURE_POPCNT = 1 << 6;
121
static const int CPU_FEATURE_AVX = 1 << 7;
122
static const int CPU_FEATURE_F16C = 1 << 8;
123
static const int CPU_FEATURE_RDRAND = 1 << 9;
124
static const int CPU_FEATURE_AVX2 = 1 << 10;
125
static const int CPU_FEATURE_FMA3 = 1 << 11;
126
static const int CPU_FEATURE_LZCNT = 1 << 12;
127
static const int CPU_FEATURE_BMI1 = 1 << 13;
128
static const int CPU_FEATURE_BMI2 = 1 << 14;
129
static const int CPU_FEATURE_AVX512F = 1 << 16;
130
static const int CPU_FEATURE_AVX512DQ = 1 << 17;
131
static const int CPU_FEATURE_AVX512PF = 1 << 18;
132
static const int CPU_FEATURE_AVX512ER = 1 << 19;
133
static const int CPU_FEATURE_AVX512CD = 1 << 20;
134
static const int CPU_FEATURE_AVX512BW = 1 << 21;
135
static const int CPU_FEATURE_AVX512VL = 1 << 22;
136
static const int CPU_FEATURE_AVX512IFMA = 1 << 23;
137
static const int CPU_FEATURE_AVX512VBMI = 1 << 24;
138
static const int CPU_FEATURE_XMM_ENABLED = 1 << 25;
139
static const int CPU_FEATURE_YMM_ENABLED = 1 << 26;
140
static const int CPU_FEATURE_ZMM_ENABLED = 1 << 27;
141
static const int CPU_FEATURE_NEON = 1 << 28;
142
static const int CPU_FEATURE_NEON_2X = 1 << 29;
143
144
/*! get CPU features */
145
int getCPUFeatures();
146
147
/*! convert CPU features into a string */
148
std::string stringOfCPUFeatures(int features);
149
150
/*! creates a string of all supported targets that are supported */
151
std::string supportedTargetList (int isa);
152
153
/*! ISAs */
154
static const int SSE = CPU_FEATURE_SSE | CPU_FEATURE_XMM_ENABLED;
155
static const int SSE2 = SSE | CPU_FEATURE_SSE2;
156
static const int SSE3 = SSE2 | CPU_FEATURE_SSE3;
157
static const int SSSE3 = SSE3 | CPU_FEATURE_SSSE3;
158
static const int SSE41 = SSSE3 | CPU_FEATURE_SSE41;
159
static const int SSE42 = SSE41 | CPU_FEATURE_SSE42 | CPU_FEATURE_POPCNT;
160
static const int AVX = SSE42 | CPU_FEATURE_AVX | CPU_FEATURE_YMM_ENABLED;
161
static const int AVXI = AVX | CPU_FEATURE_F16C;
162
static const int AVX2 = AVXI | CPU_FEATURE_AVX2 | CPU_FEATURE_FMA3 | CPU_FEATURE_BMI1 | CPU_FEATURE_BMI2 | CPU_FEATURE_LZCNT;
163
static const int AVX512 = AVX2 | CPU_FEATURE_AVX512F | CPU_FEATURE_AVX512DQ | CPU_FEATURE_AVX512CD | CPU_FEATURE_AVX512BW | CPU_FEATURE_AVX512VL | CPU_FEATURE_ZMM_ENABLED;
164
static const int NEON = CPU_FEATURE_NEON | CPU_FEATURE_SSE | CPU_FEATURE_SSE2;
165
static const int NEON_2X = CPU_FEATURE_NEON_2X | AVX2;
166
167
/*! converts ISA bitvector into a string */
168
std::string stringOfISA(int features);
169
170
/*! return the number of logical threads of the system */
171
unsigned int getNumberOfLogicalThreads();
172
173
/*! returns the size of the terminal window in characters */
174
int getTerminalWidth();
175
176
/*! returns performance counter in seconds */
177
double getSeconds();
178
179
/*! sleeps the specified number of seconds */
180
void sleepSeconds(double t);
181
182
/*! returns virtual address space occupied by process */
183
size_t getVirtualMemoryBytes();
184
185
/*! returns resident memory required by process */
186
size_t getResidentMemoryBytes();
187
}
188
189