1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-05-06 00:26:08 +02:00
Commit Graph

28 Commits

Author SHA1 Message Date
Ryo Onodera e6e7f27336 Support running inside miri 2024-03-09 16:56:59 -08:00
Jack O'Connor 3d921ae703 allow(unreachable_code) in all the *_detected functions
Previously we only disabled these warnings for SSE2, which is assumed
enabled on x86-64, but it looks like new nightly compilers are also
assuming SSE4.1 on macOS. Disabling these warnings across all the
detection functions accounts for that, and it also gets rid of some
warnings that you'd see if you used RUSTFLAGS='-C target-cpu=native'.
2023-10-02 08:36:29 -07:00
rsdy 0a0bb7126e Implement better target detection for NEON 2021-10-07 12:41:53 +01:00
Jack O'Connor 037de38bfe upgrade to arrayvec 0.7.0
This version uses const generics, which bumps our minimum supported
compiler version to 1.51.
2021-05-18 12:28:29 -04:00
Jack O'Connor 3c1db55529 add the dynamic check for SSE2 support
It will be very rare that this actually executes, but we should include
it for completeness.
2020-08-31 18:25:38 -04:00
Jack O'Connor a79fec7e39 fix a build break on x86 targets without guaranteed SSE2 support
This is quite hard to trigger, because SSE2 has been guaranteed for a
long time. But you could trigger it this way:

    rustup target add i686-unknown-linux-musl
    RUSTFLAGS="-C target-cpu=i386" cargo build --target i686-unknown-linux-musl

Note a relevant gotcha though: The `cross` tool will not forward
environment variables like RUSTFLAGS to the container by default, so if
you're testing with `cross` you'll need to use the `rustc` command to
explicitly pass the flag, as I've done here in ci.yml. (Or you could
create a `Cross.toml` file, but I don't want to commit one of those if I
can avoid it.)
2020-08-31 18:25:38 -04:00
Matthew Krupcale c32660099a Fix unreachable expression compiler warning
SSE2 target_feature appears to always be present for x86_64.
2020-08-24 21:09:56 -04:00
Matthew Krupcale d91f20dd29 Start SSE2 implementation based on SSE4.1 version
Wire up basic functions and features for SSE2 support using the SSE4.1 version
as a basis without implementing the SSE2 instructions yet.

 * Cargo.toml: add no_sse2 feature
 * benches/bench.rs: wire SSE2 benchmarks
 * build.rs: add SSE2 rust intrinsics and assembly builds
 * c/Makefile.testing: add SSE2 C and assembly targets
 * c/README.md: add SSE2 to C build instructions
 * c/blake3_c_rust_bindings/build.rs: add SSE2 C rust binding builds
 * c/blake3_c_rust_bindings/src/lib.rs: add SSE2 C rust bindings
 * c/blake3_dispatch.c: add SSE2 C dispatch
 * c/blake3_impl.h: add SSE2 C function prototypes
 * c/blake3_sse2.c: add SSE2 C intrinsic file starting with SSE4.1 version
 * c/blake3_sse2_x86-64_{unix.S,windows_gnu.S,windows_msvc.asm}: add SSE2
   assembly files starting with SSE4.1 version
 * src/ffi_sse2.rs: add rust implementation using SSE2 C rust bindings
 * src/lib.rs: add SSE2 rust intrinsics and SSE2 C rust binding rust SSE2 module
   configurations
 * src/platform.rs: add SSE2 rust platform detection and dispatch
 * src/rust_sse2.rs: add SSE2 rust intrinsic file starting with SSE4.1 version
 * tools/instruction_set_support/src/main.rs: add SSE2 feature detection
2020-08-24 00:54:46 -04:00
Jack O'Connor 86c3174d5b unbreak neon benchmarks
A helper function was incorrectly restricted to x86-only. CI doesn't
currently cover this, because benchmarks are nightly-only, and it's kind
of inconvenient to set RUSTC_BOOTSTRAP=1 through `cross` (which normally
doesn't propagate env vars). But maybe we should start...
2020-04-10 11:24:39 -04:00
Jack O'Connor b8cdcb1f84 automatically fall back to the pure Rust build
There are two scenarios where compiling AVX-512 C or assembly code might
not work:

1. There might not be a C compiler installed at all. Most commonly this
   is either in cross-compiling situations, or with the Windows GNU
   target.
2. The installed C compiler might not support e.g. -mavx512f, because
   it's too old.

In both of these cases, print a relevant warning, and then automatically
fall back to using the pure Rust intrinsics build.

Note that this only affects x86 targets. Other targets always use pure
Rust, unless the "neon" feature is enabled.
2020-04-01 19:13:15 -04:00
Jack O'Connor 152740578e add testing-only flags to disable individual instruction sets
This lets CI test a wider range of possible SIMD support settings.
2020-03-29 23:12:47 -04:00
Jack O'Connor e06a0f255a refactor the Cargo feature set
The biggest change here is that assembly implementations are enabled by
default.

Added features:
- "pure" (Pure Rust, with no C or assembly implementations.)

Removed features:
- "c" (Now basically the default.)

Renamed features;
- "c_prefer_intrinsics" -> "prefer_intrinsics"
- "c_neon" -> "neon"

Unchanged:
- "rayon"
- "std" (Still the only feature on by default.)
2020-03-29 18:02:03 -04:00
Jack O'Connor efbfa0463c integrate assembly implementations into the blake3 crate 2020-02-12 10:23:17 -05:00
Jack O'Connor af2e791602 avoid compiling avx512_detected() when the "c_avx512" feature is disabled
https://github.com/rust-lang/rust/issues/68905 is currently causing
nightly builds to fail, unless `--no-default-features` is used. This
change means that the default build will succeed, and the failure will
only happen when the "c_avx512" is enabled. The `b3sum` crate will still
fail to build on nightly, because it enables that feature, but most
callers should start succeeding on nightly.
2020-02-10 15:25:23 -05:00
Jack O'Connor b5f1e925f7 rename "offset" to "counter" and always increment it by 1
This is simpler than sometimes incrementing by CHUNK_LEN and other times
incrementing by BLOCK_LEN.
2019-12-12 21:41:30 -05:00
Jack O'Connor 9bf1020213 make the "c_avx512" feature a no-op on non-x86
This lets us enable it by default in b3sum.
2019-12-12 15:13:04 -05:00
Jack O'Connor 52ea6487f8 switch to representing CVs as words for the compression function
The portable implementation was getting slowed down by converting back
and forth between words and bytes.

I made the corresponding change on the C side first
(12a37be8b5),
and as part of this commit I'm re-vendoring the C code. I'm also
exposing a small FFI interface to C so that blake3_neon.c can link
against portable.rs rather than blake3_portable.c, see c_neon.rs.
2019-12-11 18:05:26 -05:00
Jack O'Connor ee0014776f silence an unreachable code warning when "c_neon" is in use 2019-12-08 21:58:32 -05:00
Jack O'Connor c7fff32392 add Rust FFI wrappers for AVX-512 and NEON 2019-12-08 21:56:10 -05:00
Jack O'Connor c7a1f6e919 add the OffsetDeltas type alias
I'm about to add C integration for AVX-512 and NEON, and this matches
better what the C code is doing.
2019-12-07 21:55:13 -05:00
Jack O'Connor 912ae19bce get rid of the bitflags dependency 2019-12-06 15:32:20 -05:00
Jack O'Connor 5458066da9 add hash/keyed_hash/derive_key and tests against reference_impl.rs 2019-12-04 18:17:24 -05:00
Jack O'Connor a274a9b0fa add recursive subtree hashing 2019-12-04 16:53:31 -05:00
Jack O'Connor 7736b254ce implementation notes 2019-12-03 16:23:19 -05:00
Jack O'Connor ccdff5db59 add struct ChunkState 2019-12-03 15:50:51 -05:00
Jack O'Connor 07890f36f6 switch from words to bytes in representing chaining values 2019-12-03 15:23:07 -05:00
Jack O'Connor daad5a55b6 add no_std support 2019-12-03 13:44:30 -05:00
Jack O'Connor c01b725bc7 add platform.rs 2019-12-03 13:30:04 -05:00