use super::detect::{SIMD_MATH, TEST_ISA_OVERRIDE, decode_isa_override};
use super::instruction_set::InstructionSet;
use std::sync::atomic::Ordering;
#[derive(Clone, Copy)]
pub struct SimdMathConfig {
pub instruction_set: InstructionSet,
pub name: &'static str,
pub is_avx512: bool,
}
impl SimdMathConfig {
pub fn current() -> Self {
let raw = TEST_ISA_OVERRIDE.load(Ordering::Relaxed);
if let Some(isa) = decode_isa_override(raw) {
Self {
instruction_set: isa,
name: match isa {
InstructionSet::Avx2 => "AVX2 (overridden)",
InstructionSet::Avx512 => "AVX-512 (overridden)",
InstructionSet::Avx512VnniBf16 => "AVX-512 VNNI+BF16 (overridden)",
},
is_avx512: matches!(isa, InstructionSet::Avx512 | InstructionSet::Avx512VnniBf16),
}
} else {
*SIMD_MATH
}
}
pub fn get() -> Self {
Self::current()
}
}