Skip to content

Commit 1ebcabf

Browse files
gnzlbgalexcrichton
authored andcommitted
Upgrade to cupid 0.0.5 and cleanup duplicated code in x86 run-time (rust-lang#203)
* [ci] upgrade to cupid 0.0.5 * [runtime x86] cleanup duplicated code
1 parent 03ba741 commit 1ebcabf

File tree

4 files changed

+26
-32
lines changed

4 files changed

+26
-32
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ opt-level = 3
2828

2929
[dev-dependencies]
3030
stdsimd-test = { version = "0.*", path = "stdsimd-test" }
31-
cupid = "0.4.0"
31+
cupid = "0.5.0"
3232

3333
[features]
3434
std = []

src/nvptx/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
//! These intrinsics form the foundation of the CUDA
44
//! programming model.
55
//!
6-
//! The reference is the [CUDA C Programming Guide][cuda_c]. Relevant is also the [LLVM NVPTX Backend documentation][llvm_docs].
6+
//! The reference is the [CUDA C Programming Guide][cuda_c]. Relevant is also
7+
//! the [LLVM NVPTX Backend documentation][llvm_docs].
78
//!
89
//! [cuda_c]:
910
//! http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html

src/runtime/x86.rs

+9-16
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,6 @@ macro_rules! __unstable_detect_feature {
140140
$crate::vendor::__unstable_detect_feature(
141141
$crate::vendor::__Feature::xsaveopt{})
142142
};
143-
("xsave") => {
144-
$crate::vendor::__unstable_detect_feature(
145-
$crate::vendor::__Feature::xsave{})
146-
};
147-
("xsaveopt") => {
148-
$crate::vendor::__unstable_detect_feature(
149-
$crate::vendor::__Feature::xsaveopt{})
150-
};
151143
("xsaves") => {
152144
$crate::vendor::__unstable_detect_feature(
153145
$crate::vendor::__Feature::xsaves{})
@@ -265,9 +257,9 @@ pub fn detect_features() -> usize {
265257
// leaf value for subsequent calls of `cpuinfo` in range [0,
266258
// 0x8000_0000]. - The vendor ID is stored in 12 u8 ascii chars,
267259
// returned in EBX, EDX, and ECX (in that order):
268-
let (max_leaf, vendor_id) = unsafe {
260+
let (max_basic_leaf, vendor_id) = unsafe {
269261
let CpuidResult {
270-
eax: max_leaf,
262+
eax: max_basic_leaf,
271263
ebx,
272264
ecx,
273265
edx,
@@ -278,10 +270,10 @@ pub fn detect_features() -> usize {
278270
mem::transmute(ecx),
279271
];
280272
let vendor_id: [u8; 12] = mem::transmute(vendor_id);
281-
(max_leaf, vendor_id)
273+
(max_basic_leaf, vendor_id)
282274
};
283275

284-
if max_leaf < 1 {
276+
if max_basic_leaf < 1 {
285277
// Earlier Intel 486, CPUID not implemented
286278
return value;
287279
}
@@ -296,7 +288,8 @@ pub fn detect_features() -> usize {
296288

297289
// EAX = 7, ECX = 0: Queries "Extended Features";
298290
// Contains information about bmi,bmi2, and avx2 support.
299-
let (extended_features_ebx, extended_features_ecx) = if max_leaf >= 7 {
291+
let (extended_features_ebx, extended_features_ecx) = if max_basic_leaf >= 7
292+
{
300293
let CpuidResult { ebx, ecx, .. } = unsafe { __cpuid(0x0000_0007_u32) };
301294
(ebx, ecx)
302295
} else {
@@ -307,13 +300,13 @@ pub fn detect_features() -> usize {
307300
// - EAX returns the max leaf value for extended information, that is,
308301
// `cpuid` calls in range [0x8000_0000; u32::MAX]:
309302
let CpuidResult {
310-
eax: extended_max_leaf,
303+
eax: extended_max_basic_leaf,
311304
..
312305
} = unsafe { __cpuid(0x8000_0000_u32) };
313306

314307
// EAX = 0x8000_0001, ECX=0: Queries "Extended Processor Info and Feature
315308
// Bits"
316-
let extended_proc_info_ecx = if extended_max_leaf >= 1 {
309+
let extended_proc_info_ecx = if extended_max_basic_leaf >= 1 {
317310
let CpuidResult { ecx, .. } = unsafe { __cpuid(0x8000_0001_u32) };
318311
ecx
319312
} else {
@@ -393,7 +386,7 @@ pub fn detect_features() -> usize {
393386

394387
// Processor Extended State Enumeration Sub-leaf (EAX = 0DH, ECX =
395388
// 1)
396-
if max_leaf >= 0xd {
389+
if max_basic_leaf >= 0xd {
397390
let CpuidResult {
398391
eax: proc_extended_state1_eax,
399392
..

tests/cpu-detection.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ fn works() {
2020
assert_eq!(cfg_feature_enabled!("sse4.2"), information.sse4_2());
2121
assert_eq!(cfg_feature_enabled!("avx"), information.avx());
2222
assert_eq!(cfg_feature_enabled!("avx2"), information.avx2());
23-
// assert_eq!(cfg_feature_enabled!("avx512f"), information.avx512f());
24-
// assert_eq!(cfg_feature_enabled!("avx512cd"), information.avx512cd());
25-
// assert_eq!(cfg_feature_enabled!("avx512er"), information.avx512er());
26-
// assert_eq!(cfg_feature_enabled!("avx512pf"), information.avx512pf());
27-
// assert_eq!(cfg_feature_enabled!("avx512bw"), information.avx512bw());
28-
// assert_eq!(cfg_feature_enabled!("avx512dq"), information.avx512dq());
29-
// assert_eq!(cfg_feature_enabled!("avx512vl"), information.avx512vl());
30-
// assert_eq!(cfg_feature_enabled!("avx512ifma"),
31-
// information.avx512_ifma());
32-
// assert_eq!(cfg_feature_enabled!("avx512vbmi"),
33-
// information.avx512_vbmi());
34-
// assert_eq!(cfg_feature_enabled!("avx512vpopcntdq"),
35-
// information.avx512_vpopcntdq());
23+
assert_eq!(cfg_feature_enabled!("avx512f"), information.avx512f());
24+
assert_eq!(cfg_feature_enabled!("avx512cd"), information.avx512cd());
25+
assert_eq!(cfg_feature_enabled!("avx512er"), information.avx512er());
26+
assert_eq!(cfg_feature_enabled!("avx512pf"), information.avx512pf());
27+
assert_eq!(cfg_feature_enabled!("avx512bw"), information.avx512bw());
28+
assert_eq!(cfg_feature_enabled!("avx512dq"), information.avx512dq());
29+
assert_eq!(cfg_feature_enabled!("avx512vl"), information.avx512vl());
30+
assert_eq!(cfg_feature_enabled!("avx512ifma"), information.avx512_ifma());
31+
assert_eq!(cfg_feature_enabled!("avx512vbmi"), information.avx512_vbmi());
32+
assert_eq!(
33+
cfg_feature_enabled!("avx512vpopcntdq"),
34+
information.avx512_vpopcntdq()
35+
);
3636
assert_eq!(cfg_feature_enabled!("fma"), information.fma());
3737
assert_eq!(cfg_feature_enabled!("bmi"), information.bmi1());
3838
assert_eq!(cfg_feature_enabled!("bmi2"), information.bmi2());
3939
assert_eq!(cfg_feature_enabled!("popcnt"), information.popcnt());
40-
// assert_eq!(cfg_feature_enabled!("sse4a"), information.sse4a());
40+
assert_eq!(cfg_feature_enabled!("sse4a"), information.sse4a());
4141
assert_eq!(cfg_feature_enabled!("abm"), information.lzcnt());
4242
assert_eq!(cfg_feature_enabled!("tbm"), information.tbm());
4343
assert_eq!(cfg_feature_enabled!("lzcnt"), information.lzcnt());

0 commit comments

Comments
 (0)