Skip to content

Commit 654ce02

Browse files
lu-zeroalexcrichton
authored andcommitted
Add Icelake avx512 features (#838)
* Add Icelake avx512 features As documented in https://software.intel.com/sites/default/files/managed/c5/15//architecture-instruction-set-extensions-programming-reference.pdf * Sort the avx512 feature checks by bit * Unbreak macos Force nightly.
1 parent 8cba9ab commit 654ce02

File tree

6 files changed

+80
-1
lines changed

6 files changed

+80
-1
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,12 @@ jobs:
173173
run: |
174174
curl https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
175175
echo "##[add-path]$HOME/.cargo/bin"
176+
rustup update nightly --no-self-update
177+
rustup default nightly
176178
if: matrix.os == 'macos-latest'
177-
- run: rustup target add ${{ matrix.target }}
179+
- run: |
180+
rustup default nightly
181+
rustup target add ${{ matrix.target }}
178182
if: "!endsWith(matrix.target, 'emulated')"
179183
- run: cargo generate-lockfile
180184

crates/core_arch/tests/cpu-detection.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ fn x86_all() {
3030
"avx512_vpopcntdq {:?}",
3131
is_x86_feature_detected!("avx512vpopcntdq")
3232
);
33+
println!("avx512vbmi2 {:?}", is_x86_feature_detected!("avx512vbmi2"));
34+
println!("avx512gfni {:?}", is_x86_feature_detected!("avx512gfni"));
35+
println!("avx512vaes {:?}", is_x86_feature_detected!("avx512vaes"));
36+
println!(
37+
"avx512vpclmulqdq {:?}",
38+
is_x86_feature_detected!("avx512vpclmulqdq")
39+
);
40+
println!("avx512vnni {:?}", is_x86_feature_detected!("avx512vnni"));
41+
println!(
42+
"avx512bitalg {:?}",
43+
is_x86_feature_detected!("avx512bitalg")
44+
);
45+
println!("avx512bf16 {:?}", is_x86_feature_detected!("avx512bf16"));
46+
println!(
47+
"avx512vp2intersect {:?}",
48+
is_x86_feature_detected!("avx512vp2intersect")
49+
);
3350
println!("f16c: {:?}", is_x86_feature_detected!("f16c"));
3451
println!("fma: {:?}", is_x86_feature_detected!("fma"));
3552
println!("abm: {:?}", is_x86_feature_detected!("abm"));

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,22 @@ features! {
135135
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vpopcntdq: "avx512vpopcntdq";
136136
/// AVX-512 VPOPCNTDQ (Vector Population Count Doubleword and
137137
/// Quadword)
138+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vbmi2: "avx512vbmi2";
139+
/// AVX-512 VBMI2 (Additional byte, word, dword and qword capabilities)
140+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512gfni: "avx512gfni";
141+
/// AVX-512 GFNI (Galois Field New Instruction)
142+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vaes: "avx512vaes";
143+
/// AVX-512 VAES (Vector AES instruction)
144+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vpclmulqdq: "avx512vpclmulqdq";
145+
/// AVX-512 VPCLMULQDQ (Vector PCLMULQDQ instructions)
146+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vnni: "avx512vnni";
147+
/// AVX-512 VNNI (Vector Neural Network Instructions)
148+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512bitalg: "avx512bitalg";
149+
/// AVX-512 BITALG (Support for VPOPCNT[B,W] and VPSHUFBITQMB)
150+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512bf16: "avx512bf16";
151+
/// AVX-512 BF16 (BFLOAT16 instructions)
152+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vp2intersect: "avx512vp2intersect";
153+
/// AVX-512 P2INTERSECT
138154
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] f16c: "f16c";
139155
/// F16C (Conversions between IEEE-754 `binary16` and `binary32` formats)
140156
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] fma: "fma";

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ pub(crate) fn detect_features() -> cache::Initializer {
209209
enable(extended_features_ebx, 30, Feature::avx512bw);
210210
enable(extended_features_ebx, 31, Feature::avx512vl);
211211
enable(extended_features_ecx, 1, Feature::avx512vbmi);
212+
enable(extended_features_ecx, 5, Feature::avx512bf16);
213+
enable(extended_features_ecx, 6, Feature::avx512vbmi2);
214+
enable(extended_features_ecx, 8, Feature::avx512gfni);
215+
enable(extended_features_ecx, 8, Feature::avx512vp2intersect);
216+
enable(extended_features_ecx, 9, Feature::avx512vaes);
217+
enable(extended_features_ecx, 10, Feature::avx512vpclmulqdq);
218+
enable(extended_features_ecx, 11, Feature::avx512vnni);
219+
enable(extended_features_ecx, 12, Feature::avx512bitalg);
212220
enable(extended_features_ecx, 14, Feature::avx512vpopcntdq);
213221
}
214222
}

crates/std_detect/tests/cpu-detection.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,23 @@ fn x86_all() {
9494
"avx512vpopcntdq: {:?}",
9595
is_x86_feature_detected!("avx512vpopcntdq")
9696
);
97+
println!("avx512vbmi2 {:?}", is_x86_feature_detected!("avx512vbmi2"));
98+
println!("avx512gfni {:?}", is_x86_feature_detected!("avx512gfni"));
99+
println!("avx512vaes {:?}", is_x86_feature_detected!("avx512vaes"));
100+
println!(
101+
"avx512vpclmulqdq {:?}",
102+
is_x86_feature_detected!("avx512vpclmulqdq")
103+
);
104+
println!("avx512vnni {:?}", is_x86_feature_detected!("avx512vnni"));
105+
println!(
106+
"avx512bitalg {:?}",
107+
is_x86_feature_detected!("avx512bitalg")
108+
);
109+
println!("avx512bf16 {:?}", is_x86_feature_detected!("avx512bf16"));
110+
println!(
111+
"avx512vp2intersect {:?}",
112+
is_x86_feature_detected!("avx512vp2intersect")
113+
);
97114
println!("f16c: {:?}", is_x86_feature_detected!("f16c"));
98115
println!("fma: {:?}", is_x86_feature_detected!("fma"));
99116
println!("bmi1: {:?}", is_x86_feature_detected!("bmi1"));

crates/std_detect/tests/x86-specific.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ fn dump() {
3535
"avx512_vpopcntdq {:?}",
3636
is_x86_feature_detected!("avx512vpopcntdq")
3737
);
38+
println!("avx512vbmi2 {:?}", is_x86_feature_detected!("avx512vbmi2"));
39+
println!("avx512gfni {:?}", is_x86_feature_detected!("avx512gfni"));
40+
println!("avx512vaes {:?}", is_x86_feature_detected!("avx512vaes"));
41+
println!(
42+
"avx512vpclmulqdq {:?}",
43+
is_x86_feature_detected!("avx512vpclmulqdq")
44+
);
45+
println!("avx512vnni {:?}", is_x86_feature_detected!("avx512vnni"));
46+
println!(
47+
"avx512bitalg {:?}",
48+
is_x86_feature_detected!("avx512bitalg")
49+
);
50+
println!("avx512bf16 {:?}", is_x86_feature_detected!("avx512bf16"));
51+
println!(
52+
"avx512vp2intersect {:?}",
53+
is_x86_feature_detected!("avx512vp2intersect")
54+
);
3855
println!("fma: {:?}", is_x86_feature_detected!("fma"));
3956
println!("abm: {:?}", is_x86_feature_detected!("abm"));
4057
println!("bmi: {:?}", is_x86_feature_detected!("bmi1"));

0 commit comments

Comments
 (0)