mirror of
https://github.com/google/cpu_features.git
synced 2025-04-27 15:12:30 +02:00
Fix list_cpu_features.exe does not detect SSE42 on Xeon X5650 (Windows) (#220)
This commit is contained in:
parent
2f5a7bf80a
commit
f1801f0ca1
@ -246,7 +246,7 @@ typedef struct {
|
||||
// These two functions have to be implemented by the OS, that is the file
|
||||
// including this file.
|
||||
static void OverrideOsPreserves(OsPreserves* os_preserves);
|
||||
static void DetectFeaturesFromOs(X86Features* features);
|
||||
static void DetectFeaturesFromOs(X86Info* info, X86Features* features);
|
||||
|
||||
// Reference https://en.wikipedia.org/wiki/CPUID.
|
||||
static void ParseCpuId(const Leaves* leaves, X86Info* info,
|
||||
@ -371,7 +371,7 @@ static void ParseCpuId(const Leaves* leaves, X86Info* info,
|
||||
} else {
|
||||
// When XCR0 is not available (Atom based or older cpus) we need to defer to
|
||||
// the OS via custom code.
|
||||
DetectFeaturesFromOs(features);
|
||||
DetectFeaturesFromOs(info, features);
|
||||
// Now that we have queried the OS for SSE support, we report this back to
|
||||
// os_preserves. This is needed in case of AMD CPU's to enable testing of
|
||||
// sse4a (See ParseExtraAMDCpuId below).
|
||||
|
@ -28,7 +28,8 @@ static void OverrideOsPreserves(OsPreserves* os_preserves) {
|
||||
#include "internal/stack_line_reader.h"
|
||||
#include "internal/string_view.h"
|
||||
|
||||
static void DetectFeaturesFromOs(X86Features* features) {
|
||||
static void DetectFeaturesFromOs(X86Info* info, X86Features* features) {
|
||||
(void)info;
|
||||
// Handling FreeBSD platform through parsing /var/run/dmesg.boot.
|
||||
const int fd = CpuFeatures_OpenFile("/var/run/dmesg.boot");
|
||||
if (fd >= 0) {
|
||||
|
@ -27,7 +27,8 @@ static void OverrideOsPreserves(OsPreserves* os_preserves) {
|
||||
#include "internal/filesystem.h"
|
||||
#include "internal/stack_line_reader.h"
|
||||
#include "internal/string_view.h"
|
||||
static void DetectFeaturesFromOs(X86Features* features) {
|
||||
static void DetectFeaturesFromOs(X86Info* info, X86Features* features) {
|
||||
(void)info;
|
||||
// Handling Linux platform through /proc/cpuinfo.
|
||||
const int fd = CpuFeatures_OpenFile("/proc/cpuinfo");
|
||||
if (fd >= 0) {
|
||||
|
@ -42,7 +42,8 @@ static void OverrideOsPreserves(OsPreserves* os_preserves) {
|
||||
os_preserves->avx512_registers = GetDarwinSysCtlByName("hw.optional.avx512f");
|
||||
}
|
||||
|
||||
static void DetectFeaturesFromOs(X86Features* features) {
|
||||
static void DetectFeaturesFromOs(X86Info* info, X86Features* features) {
|
||||
(void)info;
|
||||
// Handling Darwin platform through sysctlbyname.
|
||||
features->sse = GetDarwinSysCtlByName("hw.optional.sse");
|
||||
features->sse2 = GetDarwinSysCtlByName("hw.optional.sse2");
|
||||
|
@ -34,7 +34,7 @@ static bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static void DetectFeaturesFromOs(X86Features* features) {
|
||||
static void DetectFeaturesFromOs(X86Info* info, X86Features* features) {
|
||||
// Handling Windows platform through IsProcessorFeaturePresent.
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent
|
||||
features->sse =
|
||||
@ -43,6 +43,15 @@ static void DetectFeaturesFromOs(X86Features* features) {
|
||||
GetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE);
|
||||
features->sse3 =
|
||||
GetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE);
|
||||
|
||||
// https://github.com/google/cpu_features/issues/200
|
||||
#if (_WIN32_WINNT >= 0x0601) // Win7+
|
||||
if (GetX86Microarchitecture(info) == INTEL_WSM) {
|
||||
features->ssse3 = true;
|
||||
features->sse4_1 = true;
|
||||
features->sse4_2 = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // CPU_FEATURES_OS_WINDOWS
|
||||
|
@ -1117,6 +1117,32 @@ TEST_F(CpuidX86Test, INTEL_KNIGHTS_LANDING) {
|
||||
X86Microarchitecture::INTEL_KNIGHTS_L);
|
||||
}
|
||||
|
||||
// https://github.com/google/cpu_features/issues/200
|
||||
// http://users.atw.hu/instlatx64/GenuineIntel/GenuineIntel00206F2_Eagleton_CPUID.txt
|
||||
#if defined(CPU_FEATURES_OS_WINDOWS)
|
||||
TEST_F(CpuidX86Test, WIN_INTEL_WESTMERE_EX) {
|
||||
cpu().SetLeaves({
|
||||
{{0x00000000, 0}, Leaf{0x0000000B, 0x756E6547, 0x6C65746E, 0x49656E69}},
|
||||
{{0x00000001, 0}, Leaf{0x000206F2, 0x00400800, 0x02BEE3FF, 0xBFEBFBFF}},
|
||||
});
|
||||
const auto info = GetX86Info();
|
||||
|
||||
EXPECT_EQ(info.family, 0x06);
|
||||
EXPECT_EQ(info.model, 0x2F);
|
||||
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_WSM);
|
||||
|
||||
#if (_WIN32_WINNT < 0x0601) // before Win7
|
||||
EXPECT_FALSE(info.features.ssse3);
|
||||
EXPECT_FALSE(info.features.sse4_1);
|
||||
EXPECT_FALSE(info.features.sse4_2);
|
||||
#else
|
||||
EXPECT_TRUE(info.features.ssse3);
|
||||
EXPECT_TRUE(info.features.sse4_1);
|
||||
EXPECT_TRUE(info.features.sse4_2);
|
||||
#endif
|
||||
}
|
||||
#endif // CPU_FEATURES_OS_WINDOWS
|
||||
|
||||
// TODO(user): test what happens when xsave/osxsave are not present.
|
||||
// TODO(user): test what happens when xmm/ymm/zmm os support are not
|
||||
// present.
|
||||
|
Loading…
x
Reference in New Issue
Block a user