@@ -1164,6 +1164,19 @@ static void ParseLeaf4(const int max_cpuid_leaf, CacheInfo* info) {
1164
1164
}
1165
1165
}
1166
1166
1167
+ #if defined(CPU_FEATURES_OS_DARWIN )
1168
+ #if defined(CPU_FEATURES_MOCK_CPUID_X86 )
1169
+ extern bool GetDarwinSysCtlByName (const char * );
1170
+ #else // CPU_FEATURES_MOCK_CPUID_X86
1171
+ static bool GetDarwinSysCtlByName (const char * name ) {
1172
+ int enabled ;
1173
+ size_t enabled_len = sizeof (enabled );
1174
+ const int failure = sysctlbyname (name , & enabled , & enabled_len , NULL , 0 );
1175
+ return failure ? false : enabled ;
1176
+ }
1177
+ #endif
1178
+ #endif // CPU_FEATURES_OS_DARWIN
1179
+
1167
1180
// Internal structure to hold the OS support for vector operations.
1168
1181
// Avoid to recompute them since each call to cpuid is ~100 cycles.
1169
1182
typedef struct {
@@ -1189,7 +1202,11 @@ static OsSupport CheckOsSupport(const uint32_t max_cpuid_leaf) {
1189
1202
const uint32_t xcr0_eax = GetXCR0Eax ();
1190
1203
os_support .have_sse_via_cpuid = HasXmmOsXSave (xcr0_eax );
1191
1204
os_support .have_avx = HasYmmOsXSave (xcr0_eax );
1205
+ #if defined(CPU_FEATURES_OS_DARWIN )
1206
+ os_support .have_avx512 = GetDarwinSysCtlByName ("hw.optional.avx512f" );
1207
+ #else
1192
1208
os_support .have_avx512 = HasZmmOsXSave (xcr0_eax );
1209
+ #endif // CPU_FEATURES_OS_DARWIN
1193
1210
os_support .have_amx = HasTmmOsXSave (xcr0_eax );
1194
1211
} else {
1195
1212
// Atom based or older cpus need to ask the OS for sse support.
@@ -1209,19 +1226,6 @@ static bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature) {
1209
1226
#endif
1210
1227
#endif // CPU_FEATURES_OS_WINDOWS
1211
1228
1212
- #if defined(CPU_FEATURES_OS_DARWIN )
1213
- #if defined(CPU_FEATURES_MOCK_CPUID_X86 )
1214
- extern bool GetDarwinSysCtlByName (const char * );
1215
- #else // CPU_FEATURES_MOCK_CPUID_X86
1216
- static bool GetDarwinSysCtlByName (const char * name ) {
1217
- int enabled ;
1218
- size_t enabled_len = sizeof (enabled );
1219
- const int failure = sysctlbyname (name , & enabled , & enabled_len , NULL , 0 );
1220
- return failure ? false : enabled ;
1221
- }
1222
- #endif
1223
- #endif // CPU_FEATURES_OS_DARWIN
1224
-
1225
1229
static void DetectSseViaOs (X86Features * features ) {
1226
1230
#if defined(CPU_FEATURES_OS_WINDOWS )
1227
1231
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent
0 commit comments