#[cfg(not(any(
doc,
debug_assertions,
target_feature = "avx2",
target_feature = "neon",
feature = "scalar"
)))]
compile_error!("
The tool you are trying to build uses AVX2 (on x64) or NEON (on aarch64) SIMD instructions for performance.
Unfortunately, AVX2 is not enabled by default on x64.
To get the expected performance, compile/install using e.g.:
RUSTFLAGS=\"-C target-cpu=native\" cargo ...
Alternatively, silence this error by activating the `scalar` feature (eg `cargo install -F scalar ...`).
See the readme at https://github.com/ragnargrootkoerkamp/ensure_simd for details."
);
pub fn ensure_simd() {
#[cfg(target_feature = "avx2")]
{
if !is_x86_feature_detected!("avx2") {
eprintln!(
"
This binary was compiled with AVX2 instructions enabled, but your CPU does not support this.
Please run on a CPU that supports AVX2, or build from source with the `-F scalar` feature enabled.
See the readme at https://github.com/ragnargrootkoerkamp/ensure_simd for details.
"
);
std::process::exit(1);
}
}
}