aboutsummaryrefslogtreecommitdiff
path: root/src/platform.rs
AgeCommit message (Collapse)Author
2025-04-24Check x86 features even in `no_std`Nazar Mokrynskyi
2025-03-16Make some function safeIvan Boldyrev
Certain functions' unsafety comes from v128 loads and store. If argument types guarantee that these loads and stores are safe, function is declared safe, and internal unsafe blocks are commented.
2025-03-16Fix platform constantsIvan Boldyrev
2025-03-16Fix commentIvan Boldyrev
2025-03-16Wasm32 SIMD implementationIvan Boldyrev
This code is based on rust_sse2.rs of the same distribution, and is subject to further improvements. Some comments are left intact even if their applicability is questioned. SIMD implementation is gated by `wasm32-simd` feature, portable version is used otherwise. Performance measurements with a primitive benchmark with ~16Kb of data: | M1 native | 11,610 ns | | M1 WASM SIMD | 13,355 ns | | M1 WASM | 22,037 ns | | x64 native | 6,713 ns | | x64 WASM SIMD | 11,985 ns | | x64 WASM | 25,978 ns | wasmtime v12.0.1 was used on both platforms. Closes #187.
2024-08-18make xof_many fall back to compress_xof instead of portable codeJack O'Connor
2024-08-18debug_assert that xof_many is always called with whole blocksJack O'Connor
2024-08-18test that xof_many doesn't write more blocks than requestedJack O'Connor
2024-08-15mark blake3_xof_many_avx512 Unix-only in Rust and CJack O'Connor
2024-08-15integrate xof_many with the Rust implementation and with Rust and C testsJack O'Connor
2024-03-09Support running inside miriRyo Onodera
2023-10-02allow(unreachable_code) in all the *_detected functionsJack O'Connor
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'.
2021-10-07Implement better target detection for NEONrsdy
2021-05-18upgrade to arrayvec 0.7.0Jack O'Connor
This version uses const generics, which bumps our minimum supported compiler version to 1.51.
2020-08-31add the dynamic check for SSE2 supportJack O'Connor
It will be very rare that this actually executes, but we should include it for completeness.
2020-08-31fix a build break on x86 targets without guaranteed SSE2 supportJack O'Connor
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-24Fix unreachable expression compiler warningMatthew Krupcale
SSE2 target_feature appears to always be present for x86_64.
2020-08-24Start SSE2 implementation based on SSE4.1 versionMatthew Krupcale
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-04-10unbreak neon benchmarksJack O'Connor
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-01automatically fall back to the pure Rust buildJack O'Connor
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-03-29add testing-only flags to disable individual instruction setsJack O'Connor
This lets CI test a wider range of possible SIMD support settings.
2020-03-29refactor the Cargo feature setJack O'Connor
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-02-12integrate assembly implementations into the blake3 crateJack O'Connor
2020-02-10avoid compiling avx512_detected() when the "c_avx512" feature is disabledJack O'Connor
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.
2019-12-12rename "offset" to "counter" and always increment it by 1Jack O'Connor
This is simpler than sometimes incrementing by CHUNK_LEN and other times incrementing by BLOCK_LEN.
2019-12-12make the "c_avx512" feature a no-op on non-x86Jack O'Connor
This lets us enable it by default in b3sum.
2019-12-11switch to representing CVs as words for the compression functionJack O'Connor
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 (https://github.com/veorq/BLAKE3-c/commit/12a37be8b50922a358c016ba07f46816a3da4a31), 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-08silence an unreachable code warning when "c_neon" is in useJack O'Connor
2019-12-08add Rust FFI wrappers for AVX-512 and NEONJack O'Connor
2019-12-07add the OffsetDeltas type aliasJack O'Connor
I'm about to add C integration for AVX-512 and NEON, and this matches better what the C code is doing.
2019-12-06get rid of the bitflags dependencyJack O'Connor
2019-12-04add hash/keyed_hash/derive_key and tests against reference_impl.rsJack O'Connor
2019-12-04add recursive subtree hashingJack O'Connor
2019-12-03implementation notesJack O'Connor
2019-12-03add struct ChunkStateJack O'Connor
2019-12-03switch from words to bytes in representing chaining valuesJack O'Connor
2019-12-03add no_std supportJack O'Connor
2019-12-03add platform.rsJack O'Connor