diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/cpuinfo_x86.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/cpuinfo_x86.c index 85415639f..15e846a88 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/cpuinfo_x86.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/cpuinfo_x86.c @@ -202,11 +202,13 @@ static bool HasYmmOsXSave(uint32_t xcr0_eax) // Checks that operating system saves and restores zmm registers during context // switches. +#if !defined(CPU_FEATURES_OS_DARWIN) static bool HasZmmOsXSave(uint32_t xcr0_eax) { return HasMask(xcr0_eax, MASK_XMM | MASK_YMM | MASK_MASKREG | MASK_ZMM0_15 | MASK_ZMM16_31); } +#endif // Checks that operating system saves and restores AMX/TMUL state during context // switches. @@ -1185,6 +1187,20 @@ static void ParseLeaf4(const int max_cpuid_leaf, CacheInfo* info) } } +#if defined(CPU_FEATURES_OS_DARWIN) +#if defined(CPU_FEATURES_MOCK_CPUID_X86) +extern bool GetDarwinSysCtlByName(const char*); +#else // CPU_FEATURES_MOCK_CPUID_X86 +static bool GetDarwinSysCtlByName(const char* name) +{ + int enabled; + size_t enabled_len = sizeof(enabled); + const int failure = sysctlbyname(name, &enabled, &enabled_len, NULL, 0); + return failure ? false : enabled; +} +#endif +#endif // CPU_FEATURES_OS_DARWIN + // Internal structure to hold the OS support for vector operations. // Avoid to recompute them since each call to cpuid is ~100 cycles. typedef struct @@ -1213,7 +1229,11 @@ static OsSupport CheckOsSupport(const uint32_t max_cpuid_leaf) const uint32_t xcr0_eax = GetXCR0Eax(); os_support.have_sse_via_cpuid = HasXmmOsXSave(xcr0_eax); os_support.have_avx = HasYmmOsXSave(xcr0_eax); +#if defined(CPU_FEATURES_OS_DARWIN) + os_support.have_avx512 = GetDarwinSysCtlByName("hw.optional.avx512f"); +#else os_support.have_avx512 = HasZmmOsXSave(xcr0_eax); +#endif // CPU_FEATURES_OS_DARWIN os_support.have_amx = HasTmmOsXSave(xcr0_eax); } else @@ -1236,20 +1256,6 @@ static bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature) #endif #endif // CPU_FEATURES_OS_WINDOWS -#if defined(CPU_FEATURES_OS_DARWIN) -#if defined(CPU_FEATURES_MOCK_CPUID_X86) -extern bool GetDarwinSysCtlByName(const char*); -#else // CPU_FEATURES_MOCK_CPUID_X86 -static bool GetDarwinSysCtlByName(const char* name) -{ - int enabled; - size_t enabled_len = sizeof(enabled); - const int failure = sysctlbyname(name, &enabled, &enabled_len, NULL, 0); - return failure ? false : enabled; -} -#endif -#endif // CPU_FEATURES_OS_DARWIN - static void DetectSseViaOs(X86Features* features) { #if defined(CPU_FEATURES_OS_WINDOWS)