#[cfg(target_arch = "aarch64")]
use std::arch::is_aarch64_feature_detected;
pub const NEON_F32_LANES: usize = 4;
pub const NEON_F64_LANES: usize = 2;
#[allow(dead_code)]
pub const NEON_ALIGNMENT: usize = 16;
#[allow(dead_code)]
pub const NEON_F64_LANES_UNROLL: usize = NEON_F64_LANES * 4;
pub struct NeonEnhancedOps;
pub struct NeonFeatureDetector;
impl NeonFeatureDetector {
pub fn detect_neon_features() -> NeonFeatures {
#[allow(unused_mut)] let mut features = NeonFeatures::default();
#[cfg(target_arch = "aarch64")]
{
features.neon = true;
if is_aarch64_feature_detected!("asimd") {
features.asimd = true;
}
if is_aarch64_feature_detected!("fp") {
features.fp = true;
}
}
features
}
pub fn optimal_block_size() -> usize {
32
}
}
#[derive(Debug, Default, Clone)]
pub struct NeonFeatures {
pub neon: bool, pub asimd: bool, pub fp: bool, }
impl NeonFeatures {
pub fn has_full_support(&self) -> bool {
self.neon && self.asimd && self.fp
}
pub fn recommended_operations(&self) -> Vec<&'static str> {
let mut ops = Vec::new();
if self.neon {
ops.push("Basic vectorization");
ops.push("Integer operations");
}
if self.asimd {
ops.push("Advanced SIMD operations");
ops.push("Crypto operations");
}
if self.fp {
ops.push("Floating point operations");
ops.push("Vector math");
}
ops
}
}