[PATCH] D121510: [Support] Introduce the BLAKE3 hashing function implementation
Argyrios Kyrtzidis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 11 21:20:45 PST 2022
akyrtzi created this revision.
Herald added a reviewer: deadalnix.
Herald added subscribers: dexonsmith, hiraditya, krytarowski, mgorny.
Herald added a project: All.
akyrtzi requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.
The C implementation originates from https://github.com/BLAKE3-team/BLAKE3/tree/1.3.1/c
License is at https://github.com/BLAKE3-team/BLAKE3/blob/1.3.1/LICENSE
This patch adds:
- `llvm/include/llvm-c/blake3.h`: The BLAKE3 C API with certain changes (details below)
- `llvm/include/llvm/Support/BLAKE3.h`: C++ wrapper of the C API
- `llvm/lib/Support/BLAKE3`: Directory containing the BLAKE3 C implementation files, including the `LICENSE` file
- `llvm/unittests/Support/BLAKE3Test.cpp`: unit tests for the BLAKE3 C++ wrapper
Changes from original BLAKE3 sources:
- `README.md`: added a note about where the sources originated from
- `blake.h`:
- Changes to avoid conflicts if a client also links with its own BLAKE3 version:
- Renamed the header macro guard with `LLVM_C_` prefix
- Renamed the C symbols to add the `llvm_` prefix
- Added a top header comment that references the CC0 license
- `blake3_impl.h`: Added `#define`s to remove some of `llvm_` prefixes for the rest of the internal implementation.
- Implementation files:
- Used `llvm_` prefix for the C public API functions
- Used `LLVM_LIBRARY_VISIBILITY` for internal implementation functions
- Added `.private_extern`/`.hidden` in assembly files to reduce visibility of the internal implementation functions
And here's some timings comparing BLAKE3 with LLVM's SHA1/SHA256/MD5.
The table shows the speed-up multiplier of BLAKE3 for hashing 100 MBs:
| Processor | SHA1 | SHA256 | MD5 |
| :------------: | :----: | :------: | :----: |
| Intel Xeon W | 6.5x | 17x | 5.9x |
| M1Pro | 2.1x | 4.7x | 2.8x |
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121510
Files:
llvm/include/llvm-c/blake3.h
llvm/include/llvm/Support/BLAKE3.h
llvm/lib/Support/BLAKE3/.clang-format
llvm/lib/Support/BLAKE3/CMakeLists.txt
llvm/lib/Support/BLAKE3/LICENSE
llvm/lib/Support/BLAKE3/README.md
llvm/lib/Support/BLAKE3/blake3.c
llvm/lib/Support/BLAKE3/blake3_avx2.c
llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S
llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_windows_gnu.S
llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_windows_msvc.asm
llvm/lib/Support/BLAKE3/blake3_avx512.c
llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S
llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_windows_gnu.S
llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_windows_msvc.asm
llvm/lib/Support/BLAKE3/blake3_dispatch.c
llvm/lib/Support/BLAKE3/blake3_impl.h
llvm/lib/Support/BLAKE3/blake3_neon.c
llvm/lib/Support/BLAKE3/blake3_portable.c
llvm/lib/Support/BLAKE3/blake3_sse2.c
llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S
llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_windows_gnu.S
llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_windows_msvc.asm
llvm/lib/Support/BLAKE3/blake3_sse41.c
llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S
llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_windows_gnu.S
llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_windows_msvc.asm
llvm/lib/Support/CMakeLists.txt
llvm/unittests/Support/BLAKE3Test.cpp
llvm/unittests/Support/CMakeLists.txt
More information about the llvm-commits
mailing list