From 09d4f8ec9ccf9c415a97dc835c379f475c5db7ee Mon Sep 17 00:00:00 2001 From: Yuriy O'Donnell <36282596+yuriy-odonnell-epic@users.noreply.github.com> Date: Mon, 25 Jul 2022 23:54:59 +0200 Subject: [PATCH] [blake3] Add assembly implementations (#25921) * [blake3] Extend build script to support assembly implementations * [blake3] Add AVX512 assembly implementation --- ports/blake3/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++------ ports/blake3/vcpkg.json | 1 + versions/b-/blake3.json | 5 +++++ versions/baseline.json | 2 +- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/ports/blake3/CMakeLists.txt b/ports/blake3/CMakeLists.txt index cc5f37e1fc..1ef6c3893f 100644 --- a/ports/blake3/CMakeLists.txt +++ b/ports/blake3/CMakeLists.txt @@ -10,22 +10,46 @@ target_sources(blake3 PRIVATE c/blake3_portable.c ) -# This is a bit too exotic to be worth supporting right now -target_compile_definitions(blake3 PRIVATE BLAKE3_NO_AVX512=1) - -if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + target_compile_definitions(blake3 PRIVATE BLAKE3_NO_AVX512=1) target_sources(blake3 PRIVATE c/blake3_avx2.c c/blake3_sse2.c c/blake3_sse41.c ) - if (NOT MSVC) + if(NOT MSVC) set_source_files_properties(c/blake3_avx2.c COMPILE_FLAGS -mavx2) set_source_files_properties(c/blake3_sse2.c COMPILE_FLAGS -msse2) set_source_files_properties(c/blake3_sse41.c COMPILE_FLAGS -msse4.1) endif() +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + if(WIN32 AND MSVC) + enable_language(ASM_MASM) + target_sources(blake3 PRIVATE + c/blake3_avx2_x86-64_windows_msvc.asm + c/blake3_sse2_x86-64_windows_msvc.asm + c/blake3_sse41_x86-64_windows_msvc.asm + c/blake3_avx512_x86-64_windows_msvc.asm + ) + elseif(WIN32 AND NOT MSVC) + enable_language(ASM) + target_sources(blake3 PRIVATE + c/blake3_avx2_x86-64_windows_gnu.S + c/blake3_sse2_x86-64_windows_gnu.S + c/blake3_sse41_x86-64_windows_gnu.S + c/blake3_avx512_x86-64_windows_gnu.S + ) + else() + enable_language(ASM) + target_sources(blake3 PRIVATE + c/blake3_avx2_x86-64_unix.S + c/blake3_sse2_x86-64_unix.S + c/blake3_sse41_x86-64_unix.S + c/blake3_avx512_x86-64_unix.S + ) + endif() else() - target_compile_definitions(blake3 PRIVATE BLAKE3_NO_SSE2=1 BLAKE3_NO_SSE41=1 BLAKE3_NO_AVX2=1) + target_compile_definitions(blake3 PRIVATE BLAKE3_NO_SSE2=1 BLAKE3_NO_SSE41=1 BLAKE3_NO_AVX2=1 BLAKE3_NO_AVX512=1) endif() if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") diff --git a/ports/blake3/vcpkg.json b/ports/blake3/vcpkg.json index 44c8020227..1c2d1b03ce 100644 --- a/ports/blake3/vcpkg.json +++ b/ports/blake3/vcpkg.json @@ -1,6 +1,7 @@ { "name": "blake3", "version": "1.3.1", + "port-version": 1, "description": "BLAKE3 cryptographic hash function.", "homepage": "https://github.com/BLAKE3-team/BLAKE3", "license": "CC0-1.0 OR Apache-2.0", diff --git a/versions/b-/blake3.json b/versions/b-/blake3.json index 1a9effce0a..71f6cb45e6 100644 --- a/versions/b-/blake3.json +++ b/versions/b-/blake3.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "78cffdc59cdb9f1c75dffa671578203d0a79fa42", + "version": "1.3.1", + "port-version": 1 + }, { "git-tree": "62a5201ca424389c823b9b4be3d588e1cbb88a58", "version": "1.3.1", diff --git a/versions/baseline.json b/versions/baseline.json index d4628e1a42..2e39787bd5 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -502,7 +502,7 @@ }, "blake3": { "baseline": "1.3.1", - "port-version": 0 + "port-version": 1 }, "blas": { "baseline": "1",