Add runtime feature detection for F16C
This commit is contained in:
@@ -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::*},
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user