]> git.proxmox.com Git - rustc.git/blame - src/stdsimd/crates/stdsimd/tests/cpu-detection.rs
New upstream version 1.31.0~beta.4+dfsg1
[rustc.git] / src / stdsimd / crates / stdsimd / tests / cpu-detection.rs
CommitLineData
83c7162d
XL
1#![feature(stdsimd)]
2#![cfg_attr(stdsimd_strict, deny(warnings))]
8faf50e0
XL
3#![cfg_attr(
4 feature = "cargo-clippy",
5 allow(option_unwrap_used, use_debug, print_stdout)
6)]
0531ce1d 7
0bf4aa26
XL
8#[cfg(any(
9 target_arch = "arm",
10 target_arch = "aarch64",
11 target_arch = "x86",
12 target_arch = "x86_64",
13 target_arch = "powerpc",
14 target_arch = "powerpc64"
15))]
0531ce1d
XL
16#[macro_use]
17extern crate stdsimd;
18
19#[test]
0bf4aa26
XL
20#[cfg(all(
21 target_arch = "arm",
22 any(target_os = "linux", target_os = "android")
23))]
0531ce1d
XL
24fn arm_linux() {
25 println!("neon: {}", is_arm_feature_detected!("neon"));
26 println!("pmull: {}", is_arm_feature_detected!("pmull"));
27}
28
29#[test]
0bf4aa26
XL
30#[cfg(all(
31 target_arch = "aarch64",
32 any(target_os = "linux", target_os = "android")
33))]
0531ce1d
XL
34fn aarch64_linux() {
35 println!("fp: {}", is_aarch64_feature_detected!("fp"));
36 println!("fp16: {}", is_aarch64_feature_detected!("fp16"));
37 println!("neon: {}", is_aarch64_feature_detected!("neon"));
8faf50e0 38 println!("asimd: {}", is_aarch64_feature_detected!("asimd"));
0531ce1d
XL
39 println!("sve: {}", is_aarch64_feature_detected!("sve"));
40 println!("crc: {}", is_aarch64_feature_detected!("crc"));
8faf50e0 41 println!("crypto: {}", is_aarch64_feature_detected!("crypto"));
0531ce1d
XL
42 println!("lse: {}", is_aarch64_feature_detected!("lse"));
43 println!("rdm: {}", is_aarch64_feature_detected!("rdm"));
44 println!("rcpc: {}", is_aarch64_feature_detected!("rcpc"));
8faf50e0
XL
45 println!("dotprod: {}", is_aarch64_feature_detected!("dotprod"));
46}
47
48#[test]
49#[cfg(all(target_arch = "powerpc", target_os = "linux"))]
50fn powerpc_linux() {
51 println!("altivec: {}", is_powerpc_feature_detected!("altivec"));
52 println!("vsx: {}", is_powerpc_feature_detected!("vsx"));
53 println!("power8: {}", is_powerpc_feature_detected!("power8"));
0531ce1d
XL
54}
55
56#[test]
57#[cfg(all(target_arch = "powerpc64", target_os = "linux"))]
58fn powerpc64_linux() {
8faf50e0 59 println!("altivec: {}", is_powerpc64_feature_detected!("altivec"));
0531ce1d 60 println!("vsx: {}", is_powerpc64_feature_detected!("vsx"));
8faf50e0 61 println!("power8: {}", is_powerpc64_feature_detected!("power8"));
0531ce1d
XL
62}
63
64#[test]
65#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
66fn x86_all() {
8faf50e0
XL
67 println!("aes: {:?}", is_x86_feature_detected!("aes"));
68 println!("pcmulqdq: {:?}", is_x86_feature_detected!("pclmulqdq"));
69 println!("rdrand: {:?}", is_x86_feature_detected!("rdrand"));
70 println!("rdseed: {:?}", is_x86_feature_detected!("rdseed"));
71 println!("tsc: {:?}", is_x86_feature_detected!("tsc"));
72 println!("mmx: {:?}", is_x86_feature_detected!("mmx"));
0531ce1d
XL
73 println!("sse: {:?}", is_x86_feature_detected!("sse"));
74 println!("sse2: {:?}", is_x86_feature_detected!("sse2"));
75 println!("sse3: {:?}", is_x86_feature_detected!("sse3"));
76 println!("ssse3: {:?}", is_x86_feature_detected!("ssse3"));
8faf50e0
XL
77 println!("sse4.1: {:?}", is_x86_feature_detected!("sse4.1"));
78 println!("sse4.2: {:?}", is_x86_feature_detected!("sse4.2"));
0531ce1d 79 println!("sse4a: {:?}", is_x86_feature_detected!("sse4a"));
83c7162d 80 println!("sha: {:?}", is_x86_feature_detected!("sha"));
0531ce1d
XL
81 println!("avx: {:?}", is_x86_feature_detected!("avx"));
82 println!("avx2: {:?}", is_x86_feature_detected!("avx2"));
8faf50e0
XL
83 println!("avx512f {:?}", is_x86_feature_detected!("avx512f"));
84 println!("avx512cd {:?}", is_x86_feature_detected!("avx512cd"));
85 println!("avx512er {:?}", is_x86_feature_detected!("avx512er"));
86 println!("avx512pf {:?}", is_x86_feature_detected!("avx512pf"));
87 println!("avx512bw {:?}", is_x86_feature_detected!("avx512bw"));
88 println!("avx512dq {:?}", is_x86_feature_detected!("avx512dq"));
89 println!("avx512vl {:?}", is_x86_feature_detected!("avx512vl"));
90 println!("avx512_ifma {:?}", is_x86_feature_detected!("avx512ifma"));
91 println!("avx512_vbmi {:?}", is_x86_feature_detected!("avx512vbmi"));
0531ce1d
XL
92 println!(
93 "avx512_vpopcntdq {:?}",
94 is_x86_feature_detected!("avx512vpopcntdq")
95 );
96 println!("fma: {:?}", is_x86_feature_detected!("fma"));
8faf50e0 97 println!("bmi1: {:?}", is_x86_feature_detected!("bmi1"));
0531ce1d 98 println!("bmi2: {:?}", is_x86_feature_detected!("bmi2"));
8faf50e0 99 println!("abm: {:?}", is_x86_feature_detected!("abm"));
0531ce1d 100 println!("lzcnt: {:?}", is_x86_feature_detected!("lzcnt"));
8faf50e0
XL
101 println!("tbm: {:?}", is_x86_feature_detected!("tbm"));
102 println!("popcnt: {:?}", is_x86_feature_detected!("popcnt"));
0531ce1d
XL
103 println!("fxsr: {:?}", is_x86_feature_detected!("fxsr"));
104 println!("xsave: {:?}", is_x86_feature_detected!("xsave"));
8faf50e0
XL
105 println!("xsaveopt: {:?}", is_x86_feature_detected!("xsaveopt"));
106 println!("xsaves: {:?}", is_x86_feature_detected!("xsaves"));
107 println!("xsavec: {:?}", is_x86_feature_detected!("xsavec"));
0531ce1d 108}