Skip to content

Commit e50b2f6

Browse files
silver-ymzAmanieu
authored andcommitted
check sub-leaf to detect avx512bf16
Signed-off-by: Mingzhuo Yin <[email protected]>
1 parent 55af6a2 commit e50b2f6

File tree

1 file changed

+7
-7
lines changed
  • crates/std_detect/src/detect/os

1 file changed

+7
-7
lines changed

crates/std_detect/src/detect/os/x86.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ pub(crate) fn detect_features() -> cache::Initializer {
6767
..
6868
} = unsafe { __cpuid(0x0000_0001_u32) };
6969

70-
// EAX = 7, ECX = 0: Queries "Extended Features";
70+
// EAX = 7: Queries "Extended Features";
7171
// Contains information about bmi,bmi2, and avx2 support.
7272
let (
73-
extended_features_eax,
7473
extended_features_ebx,
7574
extended_features_ecx,
7675
extended_features_edx,
76+
extended_features_eax_leaf_1,
7777
) = if max_basic_leaf >= 7 {
78-
let CpuidResult {
79-
eax, ebx, ecx, edx, ..
80-
} = unsafe { __cpuid(0x0000_0007_u32) };
81-
(eax, ebx, ecx, edx)
78+
let CpuidResult { ebx, ecx, edx, .. } = unsafe { __cpuid(0x0000_0007_u32) };
79+
let CpuidResult { eax: eax_1, .. } =
80+
unsafe { __cpuid_count(0x0000_0007_u32, 0x0000_0001_u32) };
81+
(ebx, ecx, edx, eax_1)
8282
} else {
8383
(0, 0, 0, 0) // CPUID does not support "Extended Features"
8484
};
@@ -206,7 +206,6 @@ pub(crate) fn detect_features() -> cache::Initializer {
206206
// For AVX-512 the OS also needs to support saving/restoring
207207
// the extended state, only then we enable AVX-512 support:
208208
if os_avx512_support {
209-
enable(extended_features_eax, 5, Feature::avx512bf16);
210209
enable(extended_features_ebx, 16, Feature::avx512f);
211210
enable(extended_features_ebx, 17, Feature::avx512dq);
212211
enable(extended_features_ebx, 21, Feature::avx512ifma);
@@ -225,6 +224,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
225224
enable(extended_features_ecx, 14, Feature::avx512vpopcntdq);
226225
enable(extended_features_edx, 8, Feature::avx512vp2intersect);
227226
enable(extended_features_edx, 23, Feature::avx512fp16);
227+
enable(extended_features_eax_leaf_1, 5, Feature::avx512bf16);
228228
}
229229
}
230230
}

0 commit comments

Comments
 (0)