From 012e4ce580a9024040bab39dcdaef396ac3fa681 Mon Sep 17 00:00:00 2001 From: Mingzhuo Yin Date: Sun, 3 Mar 2024 09:54:10 +0800 Subject: [PATCH] check sub-leaf to detect avx512bf16 Signed-off-by: Mingzhuo Yin --- .../stdarch/crates/std_detect/src/detect/os/x86.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library/stdarch/crates/std_detect/src/detect/os/x86.rs b/library/stdarch/crates/std_detect/src/detect/os/x86.rs index 971e56c1403f..3e55baa7d8c2 100644 --- a/library/stdarch/crates/std_detect/src/detect/os/x86.rs +++ b/library/stdarch/crates/std_detect/src/detect/os/x86.rs @@ -67,18 +67,18 @@ pub(crate) fn detect_features() -> cache::Initializer { .. } = unsafe { __cpuid(0x0000_0001_u32) }; - // EAX = 7, ECX = 0: Queries "Extended Features"; + // EAX = 7: Queries "Extended Features"; // Contains information about bmi,bmi2, and avx2 support. let ( - extended_features_eax, extended_features_ebx, extended_features_ecx, extended_features_edx, + extended_features_eax_leaf_1, ) = if max_basic_leaf >= 7 { - let CpuidResult { - eax, ebx, ecx, edx, .. - } = unsafe { __cpuid(0x0000_0007_u32) }; - (eax, ebx, ecx, edx) + let CpuidResult { ebx, ecx, edx, .. } = unsafe { __cpuid(0x0000_0007_u32) }; + let CpuidResult { eax: eax_1, .. } = + unsafe { __cpuid_count(0x0000_0007_u32, 0x0000_0001_u32) }; + (ebx, ecx, edx, eax_1) } else { (0, 0, 0, 0) // CPUID does not support "Extended Features" }; @@ -206,7 +206,6 @@ pub(crate) fn detect_features() -> cache::Initializer { // For AVX-512 the OS also needs to support saving/restoring // the extended state, only then we enable AVX-512 support: if os_avx512_support { - enable(extended_features_eax, 5, Feature::avx512bf16); enable(extended_features_ebx, 16, Feature::avx512f); enable(extended_features_ebx, 17, Feature::avx512dq); enable(extended_features_ebx, 21, Feature::avx512ifma); @@ -225,6 +224,7 @@ pub(crate) fn detect_features() -> cache::Initializer { enable(extended_features_ecx, 14, Feature::avx512vpopcntdq); enable(extended_features_edx, 8, Feature::avx512vp2intersect); enable(extended_features_edx, 23, Feature::avx512fp16); + enable(extended_features_eax_leaf_1, 5, Feature::avx512bf16); } } }