]> git.proxmox.com Git - rustc.git/blob - src/stdsimd/crates/stdsimd/tests/cpu-detection.rs
New upstream version 1.27.1+dfsg1
[rustc.git] / src / stdsimd / crates / stdsimd / tests / cpu-detection.rs
1 #![feature(stdsimd)]
2 #![cfg_attr(stdsimd_strict, deny(warnings))]
3 #![cfg_attr(feature = "cargo-clippy",
4 allow(option_unwrap_used, use_debug, print_stdout))]
5
6 #[cfg(any(target_arch = "arm", target_arch = "aarch64",
7 target_arch = "x86", target_arch = "x86_64",
8 target_arch = "powerpc64"))]
9 #[macro_use]
10 extern crate stdsimd;
11
12 #[test]
13 #[cfg(all(target_arch = "arm", target_os = "linux"))]
14 fn arm_linux() {
15 println!("neon: {}", is_arm_feature_detected!("neon"));
16 println!("pmull: {}", is_arm_feature_detected!("pmull"));
17 }
18
19 #[test]
20 #[cfg(all(target_arch = "aarch64", target_os = "linux"))]
21 fn aarch64_linux() {
22 println!("fp: {}", is_aarch64_feature_detected!("fp"));
23 println!("fp16: {}", is_aarch64_feature_detected!("fp16"));
24 println!("neon: {}", is_aarch64_feature_detected!("neon"));
25 println!(
26 "asimd: {}",
27 is_aarch64_feature_detected!("asimd")
28 );
29 println!("sve: {}", is_aarch64_feature_detected!("sve"));
30 println!("crc: {}", is_aarch64_feature_detected!("crc"));
31 println!(
32 "crypto: {}",
33 is_aarch64_feature_detected!("crypto")
34 );
35 println!("lse: {}", is_aarch64_feature_detected!("lse"));
36 println!("rdm: {}", is_aarch64_feature_detected!("rdm"));
37 println!("rcpc: {}", is_aarch64_feature_detected!("rcpc"));
38 println!(
39 "dotprod: {}",
40 is_aarch64_feature_detected!("dotprod")
41 );
42 }
43
44 #[test]
45 #[cfg(all(target_arch = "powerpc64", target_os = "linux"))]
46 fn powerpc64_linux() {
47 println!(
48 "altivec: {}",
49 is_powerpc64_feature_detected!("altivec")
50 );
51 println!("vsx: {}", is_powerpc64_feature_detected!("vsx"));
52 println!(
53 "power8: {}",
54 is_powerpc64_feature_detected!("power8")
55 );
56 }
57
58 #[test]
59 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
60 fn x86_all() {
61 println!("sse: {:?}", is_x86_feature_detected!("sse"));
62 println!("sse2: {:?}", is_x86_feature_detected!("sse2"));
63 println!("sse3: {:?}", is_x86_feature_detected!("sse3"));
64 println!("ssse3: {:?}", is_x86_feature_detected!("ssse3"));
65 println!(
66 "sse4.1: {:?}",
67 is_x86_feature_detected!("sse4.1")
68 );
69 println!(
70 "sse4.2: {:?}",
71 is_x86_feature_detected!("sse4.2")
72 );
73 println!("sse4a: {:?}", is_x86_feature_detected!("sse4a"));
74 println!("sha: {:?}", is_x86_feature_detected!("sha"));
75 println!("avx: {:?}", is_x86_feature_detected!("avx"));
76 println!("avx2: {:?}", is_x86_feature_detected!("avx2"));
77 println!(
78 "avx512f {:?}",
79 is_x86_feature_detected!("avx512f")
80 );
81 println!(
82 "avx512cd {:?}",
83 is_x86_feature_detected!("avx512cd")
84 );
85 println!(
86 "avx512er {:?}",
87 is_x86_feature_detected!("avx512er")
88 );
89 println!(
90 "avx512pf {:?}",
91 is_x86_feature_detected!("avx512pf")
92 );
93 println!(
94 "avx512bw {:?}",
95 is_x86_feature_detected!("avx512bw")
96 );
97 println!(
98 "avx512dq {:?}",
99 is_x86_feature_detected!("avx512dq")
100 );
101 println!(
102 "avx512vl {:?}",
103 is_x86_feature_detected!("avx512vl")
104 );
105 println!(
106 "avx512_ifma {:?}",
107 is_x86_feature_detected!("avx512ifma")
108 );
109 println!(
110 "avx512_vbmi {:?}",
111 is_x86_feature_detected!("avx512vbmi")
112 );
113 println!(
114 "avx512_vpopcntdq {:?}",
115 is_x86_feature_detected!("avx512vpopcntdq")
116 );
117 println!("fma: {:?}", is_x86_feature_detected!("fma"));
118 println!("abm: {:?}", is_x86_feature_detected!("abm"));
119 println!("bmi: {:?}", is_x86_feature_detected!("bmi1"));
120 println!("bmi2: {:?}", is_x86_feature_detected!("bmi2"));
121 println!("tbm: {:?}", is_x86_feature_detected!("tbm"));
122 println!(
123 "popcnt: {:?}",
124 is_x86_feature_detected!("popcnt")
125 );
126 println!("lzcnt: {:?}", is_x86_feature_detected!("lzcnt"));
127 println!("fxsr: {:?}", is_x86_feature_detected!("fxsr"));
128 println!("xsave: {:?}", is_x86_feature_detected!("xsave"));
129 println!(
130 "xsaveopt: {:?}",
131 is_x86_feature_detected!("xsaveopt")
132 );
133 println!(
134 "xsaves: {:?}",
135 is_x86_feature_detected!("xsaves")
136 );
137 println!(
138 "xsavec: {:?}",
139 is_x86_feature_detected!("xsavec")
140 );
141 }