mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 04:00:34 +00:00
parent
08aea9aa5b
commit
dcb5daf9a8
@ -202,11 +202,13 @@ static bool HasYmmOsXSave(uint32_t xcr0_eax)
|
|||||||
|
|
||||||
// Checks that operating system saves and restores zmm registers during context
|
// Checks that operating system saves and restores zmm registers during context
|
||||||
// switches.
|
// switches.
|
||||||
|
#if !defined(CPU_FEATURES_OS_DARWIN)
|
||||||
static bool HasZmmOsXSave(uint32_t xcr0_eax)
|
static bool HasZmmOsXSave(uint32_t xcr0_eax)
|
||||||
{
|
{
|
||||||
return HasMask(xcr0_eax, MASK_XMM | MASK_YMM | MASK_MASKREG | MASK_ZMM0_15 |
|
return HasMask(xcr0_eax, MASK_XMM | MASK_YMM | MASK_MASKREG | MASK_ZMM0_15 |
|
||||||
MASK_ZMM16_31);
|
MASK_ZMM16_31);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Checks that operating system saves and restores AMX/TMUL state during context
|
// Checks that operating system saves and restores AMX/TMUL state during context
|
||||||
// switches.
|
// 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.
|
// Internal structure to hold the OS support for vector operations.
|
||||||
// Avoid to recompute them since each call to cpuid is ~100 cycles.
|
// Avoid to recompute them since each call to cpuid is ~100 cycles.
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -1213,7 +1229,11 @@ static OsSupport CheckOsSupport(const uint32_t max_cpuid_leaf)
|
|||||||
const uint32_t xcr0_eax = GetXCR0Eax();
|
const uint32_t xcr0_eax = GetXCR0Eax();
|
||||||
os_support.have_sse_via_cpuid = HasXmmOsXSave(xcr0_eax);
|
os_support.have_sse_via_cpuid = HasXmmOsXSave(xcr0_eax);
|
||||||
os_support.have_avx = HasYmmOsXSave(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);
|
os_support.have_avx512 = HasZmmOsXSave(xcr0_eax);
|
||||||
|
#endif // CPU_FEATURES_OS_DARWIN
|
||||||
os_support.have_amx = HasTmmOsXSave(xcr0_eax);
|
os_support.have_amx = HasTmmOsXSave(xcr0_eax);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1236,20 +1256,6 @@ static bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature)
|
|||||||
#endif
|
#endif
|
||||||
#endif // CPU_FEATURES_OS_WINDOWS
|
#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)
|
static void DetectSseViaOs(X86Features* features)
|
||||||
{
|
{
|
||||||
#if defined(CPU_FEATURES_OS_WINDOWS)
|
#if defined(CPU_FEATURES_OS_WINDOWS)
|
||||||
|
Loading…
Reference in New Issue
Block a user