diff options
| -rw-r--r-- | .github/workflows/ci.yml | 39 | ||||
| -rw-r--r-- | Cargo.toml | 28 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | src/platform.rs | 12 |
4 files changed, 68 insertions, 13 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cdd644..6c2a77d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,14 +30,41 @@ jobs: - run: cargo test --features=rayon # no_std tests. - run: cargo test --no-default-features - # Test the intrinsics implementations. + + # A matrix of different test settings: + # - debug vs release + # - assembly vs Rust+C intrinsics vs pure Rust intrinsics + # - different levels of SIMD support + # + # Full SIMD support. + - run: cargo test --features= - run: cargo test --features=prefer_intrinsics - # Test the pure Rust build. - run: cargo test --features=pure - # Test release mode. This does more iteratations in test_fuzz_hasher. - - run: cargo test --release - - run: cargo test --release --features=prefer_intrinsics - - run: cargo test --release --features=pure + - run: cargo test --features= --release + - run: cargo test --features=prefer_intrinsics --release + - run: cargo test --features=pure --release + # No AVX-512. + - run: cargo test --features=no_avx512 + - run: cargo test --features=no_avx512,prefer_intrinsics + - run: cargo test --features=no_avx512,pure + - run: cargo test --features=no_avx512 --release + - run: cargo test --features=no_avx512,prefer_intrinsics --release + - run: cargo test --features=no_avx512,pure --release + # No AVX2. + - run: cargo test --features=no_avx512,no_avx2 + - run: cargo test --features=no_avx512,no_avx2,prefer_intrinsics + - run: cargo test --features=no_avx512,no_avx2,pure + - run: cargo test --features=no_avx512,no_avx2 --release + - run: cargo test --features=no_avx512,no_avx2,prefer_intrinsics --release + - run: cargo test --features=no_avx512,no_avx2,pure --release + # No SSE4.1 + - run: cargo test --features=no_avx512,no_avx2,no_sse41 + - run: cargo test --features=no_avx512,no_avx2,no_sse41,prefer_intrinsics + - run: cargo test --features=no_avx512,no_avx2,no_sse41,pure + - run: cargo test --features=no_avx512,no_avx2,no_sse41 --release + - run: cargo test --features=no_avx512,no_avx2,no_sse41,prefer_intrinsics --release + - run: cargo test --features=no_avx512,no_avx2,no_sse41,pure --release + # Test benchmarks. RUSTC_BOOTSTRAP=1 lets this run on non-nightly toolchains. - run: cargo test --benches env: @@ -24,12 +24,6 @@ default = ["std"] # is free make its own decision about build dependencies. pure = [] -# As described above, on x86_64 this crate use assembly implementations by -# default. Enabling the "prefer_intrinsics" feature makes this crate use -# intrinsics implementations on both 32-bit and 64-bit x86. This is mainly for -# testing, and calling crates should not need it. -prefer_intrinsics = [] - # The NEON implementation does not participate in dynamic feature detection, # which is currently x86-only. If "neon" is on, NEON support is assumed. Note # that AArch64 always supports NEON, but support on ARMv7 varies. The NEON @@ -48,6 +42,28 @@ std = ["digest/std"] # perform multi-threaded hashing. However, even if this feature is enabled, all # other APIs remain single-threaded. +# ---------- Features below this line are for internal testing only. ---------- + +# As described above, on x86_64 this crate use assembly implementations by +# default. Enabling the "prefer_intrinsics" feature makes this crate use +# intrinsics implementations on both 32-bit and 64-bit x86. +prefer_intrinsics = [] + +# Disable individual instruction sets. CI testing uses these flags to simulate +# different levels of hardware SIMD support. Note that code for the +# corresponding instruction set is still compiled; only detection is disabled. +# +# As noted above, these flags are *for testing only* and are not stable. It's +# possible that some users might find that their particular use case performs +# better if e.g. AVX-512 is disabled, because of issues like CPU downlocking. +# If that comes up, and if disabling the instruction set here at the feature +# level turns out to be the right approach, then we can design a stable +# feature. Until then, we reserve the right to break these features in a patch +# release. +no_sse41 = [] +no_avx2 = [] +no_avx512 = [] + [package.metadata.docs.rs] # Document blake3::join::RayonJoin on docs.rs. features = ["rayon"] @@ -1,4 +1,4 @@ -# <a href="#"><img src="media/BLAKE3.svg" alt="BLAKE3" height=50></a> [](https://github.com/BLAKE3-team/BLAKE3/actions) +# <a href="https://github.com/BLAKE3-team/BLAKE3/actions"><img align="right" alt="CI status" src="https://github.com/BLAKE3-team/BLAKE3/workflows/tests/badge.svg"></a> <a href="#"><img src="media/BLAKE3.svg" alt="BLAKE3" height=50></a> BLAKE3 is a cryptographic hash function that is: diff --git a/src/platform.rs b/src/platform.rs index b1b9dad..0cc8d49 100644 --- a/src/platform.rs +++ b/src/platform.rs @@ -289,6 +289,10 @@ impl Platform { #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] #[inline(always)] pub fn avx512_detected() -> bool { + // A testing-only short-circuit. + if cfg!(feature = "no_avx512") { + return false; + } // Static check, e.g. for building with target-cpu=native. #[cfg(all(target_feature = "avx512f", target_feature = "avx512vl"))] { @@ -307,6 +311,10 @@ pub fn avx512_detected() -> bool { #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] #[inline(always)] pub fn avx2_detected() -> bool { + // A testing-only short-circuit. + if cfg!(feature = "no_avx2") { + return false; + } // Static check, e.g. for building with target-cpu=native. #[cfg(target_feature = "avx2")] { @@ -325,6 +333,10 @@ pub fn avx2_detected() -> bool { #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] #[inline(always)] pub fn sse41_detected() -> bool { + // A testing-only short-circuit. + if cfg!(feature = "no_sse41") { + return false; + } // Static check, e.g. for building with target-cpu=native. #[cfg(target_feature = "sse4.1")] { |
