| 1 |
#![allow(dead_code)] |
| 2 |
#![allow(unreachable_code)] |
| 3 |
|
| 4 |
pub struct CpuFeatures; |
| 5 |
|
| 6 |
impl CpuFeatures { |
| 7 |
pub const NONE: usize = 0; |
| 8 |
pub const AVX2: usize = 1; |
| 9 |
} |
| 10 |
|
| 11 |
#[inline(always)] |
| 12 |
pub fn is_enabled_sse() -> bool { |
| 13 |
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))] |
| 14 |
#[cfg(feature = "std")] |
| 15 |
return std::is_x86_feature_detected!("sse"); |
| 16 |
|
| 17 |
false |
| 18 |
} |
| 19 |
|
| 20 |
#[inline(always)] |
| 21 |
pub fn is_enabled_sse42() -> bool { |
| 22 |
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))] |
| 23 |
#[cfg(feature = "std")] |
| 24 |
return std::is_x86_feature_detected!("sse4.2"); |
| 25 |
|
| 26 |
false |
| 27 |
} |
| 28 |
|
| 29 |
#[inline(always)] |
| 30 |
pub fn is_enabled_avx2() -> bool { |
| 31 |
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))] |
| 32 |
#[cfg(feature = "std")] |
| 33 |
return std::is_x86_feature_detected!("avx2"); |
| 34 |
|
| 35 |
false |
| 36 |
} |
| 37 |
|
| 38 |
#[inline(always)] |
| 39 |
pub fn is_enabled_avx512() -> bool { |
| 40 |
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))] |
| 41 |
#[cfg(feature = "std")] |
| 42 |
return std::is_x86_feature_detected!("avx512f"); |
| 43 |
|
| 44 |
false |
| 45 |
} |
| 46 |
|
| 47 |
#[inline(always)] |
| 48 |
pub fn is_enabled_pclmulqdq() -> bool { |
| 49 |
#[cfg(target_arch = "x86_64")] |
| 50 |
#[cfg(feature = "std")] |
| 51 |
return std::is_x86_feature_detected!("pclmulqdq") |
| 52 |
&& std::is_x86_feature_detected!("sse2") |
| 53 |
&& std::is_x86_feature_detected!("sse4.1"); |
| 54 |
|
| 55 |
false |
| 56 |
} |
| 57 |
|
| 58 |
#[inline(always)] |
| 59 |
pub fn is_enabled_neon() -> bool { |
| 60 |
#[cfg(target_arch = "aarch64")] |
| 61 |
#[cfg(feature = "std")] |
| 62 |
return std::arch::is_aarch64_feature_detected!("neon"); |
| 63 |
|
| 64 |
false |
| 65 |
} |
| 66 |
|
| 67 |
#[inline(always)] |
| 68 |
pub fn is_enabled_crc() -> bool { |
| 69 |
#[cfg(target_arch = "aarch64")] |
| 70 |
#[cfg(feature = "std")] |
| 71 |
return std::arch::is_aarch64_feature_detected!("crc"); |
| 72 |
|
| 73 |
false |
| 74 |
} |
| 75 |
|
| 76 |
#[inline(always)] |
| 77 |
pub fn is_enabled_simd128() -> bool { |
| 78 |
#[cfg(target_arch = "wasm32")] |
| 79 |
return cfg!(target_feature = "simd128"); |
| 80 |
|
| 81 |
false |
| 82 |
} |