pub fn should_run(module: &str) -> bool {
match module {
#[cfg(all(target_arch = "x86_64", feature = "avx2"))]
"avx2" => crate::util::has_avx2(),
#[cfg(all(target_arch = "x86_64", feature = "avx512"))]
"avx512" => crate::util::has_avx512_skylake(),
_ => true,
}
}
macro_rules! verify_asm {
(ret $module:ident, $func:ident($($args:expr),* $(,)?)) => {{
#[allow(unused_unsafe)]
if stringify!($module) != "rust" {
let rust_result = super::rust::$func($($args),*);
let simd_result = unsafe { super::$module::$func($($args),*) };
assert_eq!(rust_result, simd_result,
"Mismatch between Rust and {} in {}",
stringify!($module),
stringify!($func)
);
simd_result
} else {
super::$module::$func($($args),*)
}
}};
($module:ident, $func:ident($dest:expr, $($args:expr),* $(,)?)) => {{
#[allow(unused_unsafe)]
if stringify!($module) != "rust" {
let mut rust_dest = $dest.clone();
super::rust::$func(
&mut rust_dest,
$($args),*
);
unsafe {
super::$module::$func(
$dest,
$($args),*
);
}
assert_eq!(rust_dest, *$dest,
"Mismatch between Rust and {} in {}",
stringify!($module),
stringify!($func)
);
} else {
unsafe {
super::$module::$func(
$dest,
$($args),*
);
}
}
}};
}