From ebdea727fdc596a3686b52eec0d03891d7a8f9ea Mon Sep 17 00:00:00 2001 From: Mikko Juola Date: Sat, 18 Mar 2023 00:48:44 -0700 Subject: [PATCH] Don't let the crate be built without avx2, avx, etc. or it'll be very slow. --- .cargo/config | 2 ++ src/main.rs | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 .cargo/config diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000..b6febfe --- /dev/null +++ b/.cargo/config @@ -0,0 +1,2 @@ +[build] +rustflags = ["-C", "target-feature=+avx2,+avx,+sse,+fma"] diff --git a/src/main.rs b/src/main.rs index 1fe1682..c612460 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,12 @@ +#[cfg(not(target_feature = "avx2"))] +compile_error!("This library assumes availability of AVX and must be compiled with -C target-feature=+sse2,+avx,+fma,+avx2"); +#[cfg(not(target_feature = "sse2"))] +compile_error!("This library assumes availability of AVX and must be compiled with -C target-feature=+sse2,+avx,+fma,+avx2"); +#[cfg(not(target_feature = "fma"))] +compile_error!("This library assumes availability of AVX and must be compiled with -C target-feature=+sse2,+avx,+fma,+avx2"); +#[cfg(not(target_feature = "avx"))] +compile_error!("This library assumes availability of AVX and must be compiled with -C target-feature=+sse2,+avx,+fma,+avx2"); + pub fn main() -> Result<(), Box> { rllama::rllama_main::main() }