[all-commits] [llvm/llvm-project] 9aa701: [Support] Introduce the BLAKE3 hashing function im...

Argyrios Kyrtzidis via All-commits all-commits at lists.llvm.org
Thu Mar 24 10:26:54 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9aa701984d399e752167cd1966708042804b15de
      https://github.com/llvm/llvm-project/commit/9aa701984d399e752167cd1966708042804b15de
  Author: Argyrios Kyrtzidis <kyrtzidis at apple.com>
  Date:   2022-03-24 (Thu, 24 Mar 2022)

  Changed paths:
    A llvm/include/llvm-c/blake3.h
    A llvm/include/llvm/Support/BLAKE3.h
    A llvm/lib/Support/BLAKE3/.clang-format
    A llvm/lib/Support/BLAKE3/CMakeLists.txt
    A llvm/lib/Support/BLAKE3/LICENSE
    A llvm/lib/Support/BLAKE3/README.md
    A llvm/lib/Support/BLAKE3/blake3.c
    A llvm/lib/Support/BLAKE3/blake3.h
    A llvm/lib/Support/BLAKE3/blake3_avx2.c
    A llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S
    A llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_windows_gnu.S
    A llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_windows_msvc.asm
    A llvm/lib/Support/BLAKE3/blake3_avx512.c
    A llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S
    A llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_windows_gnu.S
    A llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_windows_msvc.asm
    A llvm/lib/Support/BLAKE3/blake3_dispatch.c
    A llvm/lib/Support/BLAKE3/blake3_impl.h
    A llvm/lib/Support/BLAKE3/blake3_neon.c
    A llvm/lib/Support/BLAKE3/blake3_portable.c
    A llvm/lib/Support/BLAKE3/blake3_sse2.c
    A llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S
    A llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_windows_gnu.S
    A llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_windows_msvc.asm
    A llvm/lib/Support/BLAKE3/blake3_sse41.c
    A llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S
    A llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_windows_gnu.S
    A llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_windows_msvc.asm
    M llvm/lib/Support/CMakeLists.txt
    A llvm/unittests/Support/BLAKE3Test.cpp
    M llvm/unittests/Support/CMakeLists.txt

  Log Message:
  -----------
  [Support] Introduce the BLAKE3 hashing function implementation

BLAKE3 is a cryptographic hash function that is secure and very performant.
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
* `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

This initial patch contains the pristine BLAKE3 sources, a follow-up patch will introduce
LLVM-specific prefixes to avoid conflicts if a client also links with its own BLAKE3 version.

And here's some timings comparing BLAKE3 with LLVM's SHA1/SHA256/MD5.
Timings include `AVX512`, `AVX2`, `neon`, and the generic/portable implementations.
The table shows the speed-up multiplier of BLAKE3 for hashing 100 MBs:

|        Processor        | SHA1  | SHA256 |  MD5 |
|-------------------------|-------|--------|------|
| Intel Xeon W (AVX512)   | 10.4x |   27x  | 9.4x |
| Intel Xeon W (AVX2)     | 6.5x  |   17x  | 5.9x |
| Intel Xeon W (portable) | 1.3x  |  3.3x  | 1.1x |
|      M1Pro (neon)       | 2.1x  |  4.7x  | 2.8x |
|      M1Pro (portable)   | 1.1x  |  2.4x  | 1.5x |

Differential Revision: https://reviews.llvm.org/D121510


  Commit: 7f05aa2d4c36d6d53f97ac3e0db30ec600abbc62
      https://github.com/llvm/llvm-project/commit/7f05aa2d4c36d6d53f97ac3e0db30ec600abbc62
  Author: Argyrios Kyrtzidis <kyrtzidis at apple.com>
  Date:   2022-03-24 (Thu, 24 Mar 2022)

  Changed paths:
    M llvm/include/llvm-c/blake3.h
    M llvm/include/llvm/Support/BLAKE3.h
    M llvm/lib/Support/BLAKE3/README.md
    M llvm/lib/Support/BLAKE3/blake3.c
    R llvm/lib/Support/BLAKE3/blake3.h
    M llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S
    M llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_windows_gnu.S
    M llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S
    M llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_windows_gnu.S
    M llvm/lib/Support/BLAKE3/blake3_dispatch.c
    M llvm/lib/Support/BLAKE3/blake3_impl.h
    M llvm/lib/Support/BLAKE3/blake3_neon.c
    M llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S
    M llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_windows_gnu.S
    M llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S
    M llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_windows_gnu.S

  Log Message:
  -----------
  [Support/BLAKE3] LLVM-specific changes over the original BLAKE3 C implementation

Changes from original BLAKE3 sources:

* `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 and points to the `LICENSE` file in the repo.
* `blake3_impl.h`: Added `#define`s to remove some of `llvm_` prefixes for the rest of the internal implementation.
* Implementation files:
    * Added a top header comment for `blake.c`
    * 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
* `README.md`:
    * added a note about where the sources originated from
    * Used the C++ BLAKE3 class and `llvm_` prefixed C API in place of examples and API documentation.
    * Removed instructions about how to build the files.


Compare: https://github.com/llvm/llvm-project/compare/8722c12c1261...7f05aa2d4c36


More information about the All-commits mailing list