diff options
| author | gnzlbg <gonzalobg88@gmail.com> | 2019-04-23 10:10:41 +0200 |
|---|---|---|
| committer | gnzlbg <gnzlbg@users.noreply.github.com> | 2019-05-09 13:42:20 +0200 |
| commit | d31cc0b09e14f33e888f1bb83bd88c6147ba6fcc (patch) | |
| tree | c370b1c64a5102f71e1fab09dfe9bee6d4f7e52b /library/stdarch/crates | |
| parent | 0da68477f9cad075d45c537b93b7e0c83838e605 (diff) | |
| download | rust-d31cc0b09e14f33e888f1bb83bd88c6147ba6fcc.tar.gz rust-d31cc0b09e14f33e888f1bb83bd88c6147ba6fcc.zip | |
Add runtime feature detection for F16C
Diffstat (limited to 'library/stdarch/crates')
5 files changed, 14 insertions, 3 deletions
diff --git a/library/stdarch/crates/core_arch/src/x86/f16c.rs b/library/stdarch/crates/core_arch/src/x86/f16c.rs index 496e3a70671..597d86b2d04 100644 --- a/library/stdarch/crates/core_arch/src/x86/f16c.rs +++ b/library/stdarch/crates/core_arch/src/x86/f16c.rs @@ -1,5 +1,6 @@ -//! F16C intrinsics: -//! https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=fp16&expand=1769 +//! [F16C intrinsics]. +//! +//! [F16C intrinsics]: https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=fp16&expand=1769 use crate::{ core_arch::{simd::*, x86::*}, diff --git a/library/stdarch/crates/core_arch/tests/cpu-detection.rs b/library/stdarch/crates/core_arch/tests/cpu-detection.rs index 9a7c999a18b..321f24e9fc2 100644 --- a/library/stdarch/crates/core_arch/tests/cpu-detection.rs +++ b/library/stdarch/crates/core_arch/tests/cpu-detection.rs @@ -31,6 +31,7 @@ fn x86_all() { "avx512_vpopcntdq {:?}", is_x86_feature_detected!("avx512vpopcntdq") ); + println!("f16c: {:?}", is_x86_feature_detected!("f16c")); println!("fma: {:?}", is_x86_feature_detected!("fma")); println!("abm: {:?}", is_x86_feature_detected!("abm")); println!("bmi: {:?}", is_x86_feature_detected!("bmi1")); diff --git a/library/stdarch/crates/std_detect/src/detect/arch/x86.rs b/library/stdarch/crates/std_detect/src/detect/arch/x86.rs index 45f2d5bfc87..da14ce5cf0f 100644 --- a/library/stdarch/crates/std_detect/src/detect/arch/x86.rs +++ b/library/stdarch/crates/std_detect/src/detect/arch/x86.rs @@ -62,6 +62,7 @@ /// * `"avx512ifma"` /// * `"avx512vbmi"` /// * `"avx512vpopcntdq"` +/// * `"f16c"` /// * `"fma"` /// * `"bmi1"` /// * `"bmi2"` @@ -179,6 +180,10 @@ macro_rules! is_x86_feature_detected { cfg!(target_feature = "avx512vpopcntdq") || $crate::detect::check_for( $crate::detect::Feature::avx512_vpopcntdq) }; + ("f16c") => { + cfg!(target_feature = "avx512f") || $crate::detect::check_for( + $crate::detect::Feature::f16c) + }; ("fma") => { cfg!(target_feature = "fma") || $crate::detect::check_for( $crate::detect::Feature::fma) @@ -309,6 +314,8 @@ pub enum Feature { /// AVX-512 VPOPCNTDQ (Vector Population Count Doubleword and /// Quadword) avx512_vpopcntdq, + /// F16C (Conversions between IEEE-754 `binary16` and `binary32` formats) + f16c, /// FMA (Fused Multiply Add) fma, /// BMI1 (Bit Manipulation Instructions 1) diff --git a/library/stdarch/crates/std_detect/src/detect/os/x86.rs b/library/stdarch/crates/std_detect/src/detect/os/x86.rs index ab0622106c8..e543d301c79 100644 --- a/library/stdarch/crates/std_detect/src/detect/os/x86.rs +++ b/library/stdarch/crates/std_detect/src/detect/os/x86.rs @@ -113,13 +113,14 @@ fn detect_features() -> cache::Initializer { }; enable(proc_info_ecx, 0, Feature::sse3); + enable(proc_info_ecx, 1, Feature::pclmulqdq); enable(proc_info_ecx, 9, Feature::ssse3); enable(proc_info_ecx, 13, Feature::cmpxchg16b); enable(proc_info_ecx, 19, Feature::sse4_1); enable(proc_info_ecx, 20, Feature::sse4_2); enable(proc_info_ecx, 23, Feature::popcnt); enable(proc_info_ecx, 25, Feature::aes); - enable(proc_info_ecx, 1, Feature::pclmulqdq); + enable(proc_info_ecx, 29, Feature::f16c); enable(proc_info_ecx, 30, Feature::rdrand); enable(extended_features_ebx, 18, Feature::rdseed); enable(extended_features_ebx, 19, Feature::adx); diff --git a/library/stdarch/crates/std_detect/tests/cpu-detection.rs b/library/stdarch/crates/std_detect/tests/cpu-detection.rs index b2b8abb0102..0aae39e2947 100644 --- a/library/stdarch/crates/std_detect/tests/cpu-detection.rs +++ b/library/stdarch/crates/std_detect/tests/cpu-detection.rs @@ -87,6 +87,7 @@ fn x86_all() { "avx512_vpopcntdq {:?}", is_x86_feature_detected!("avx512vpopcntdq") ); + println!("f16c: {:?}", is_x86_feature_detected!("f16c")); println!("fma: {:?}", is_x86_feature_detected!("fma")); println!("bmi1: {:?}", is_x86_feature_detected!("bmi1")); println!("bmi2: {:?}", is_x86_feature_detected!("bmi2")); |
