From c7557013d0934e60ee78e94277974c4064dbfac0 Mon Sep 17 00:00:00 2001 From: Florent Michel <56166507+FlorentCLMichel@users.noreply.github.com> Date: Tue, 9 Aug 2022 21:40:50 +0100 Subject: [PATCH 01/12] Added OpenFHE to the list of libraries using Hexl (#128) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 05998cdb..5113f6f0 100644 --- a/README.md +++ b/README.md @@ -268,6 +268,7 @@ Intel HE Acceleration Library is single-threaded and thread-safe. Intel HE Acceleration Library has been integrated to the following homomorphic encryption libraries: +- [OpenFHE](https://github.com/openfheorg/openfhe-development) - [PALISADE](https://gitlab.com/palisade/palisade-release) - [Microsoft SEAL](https://github.com/microsoft/SEAL) - [HElib](https://github.com/homenc/HElib) From d9ba54785e1d9f4e8d2f70b460bd9dea03509c55 Mon Sep 17 00:00:00 2001 From: Jose Rojas Chaves Date: Tue, 13 Sep 2022 09:28:41 -0600 Subject: [PATCH 02/12] Complies to Clang-Format +11 (#129) Include the directory when naming header files --- test/CMakeLists.txt | 3 +++ test/experimental/fft-like/test-fft-like-avx512.cpp | 2 +- test/experimental/fft-like/test-fft-like-native.cpp | 2 +- test/experimental/fft-like/test-fft-like.cpp | 2 +- test/experimental/misc/test-lr-mat-vec-mult.cpp | 2 +- test/experimental/seal/test-dyadic-multiply.cpp | 2 +- test/experimental/seal/test-key-switch.cpp | 2 +- test/{ => include/test}/test-ntt-util.hpp | 0 test/{ => include/test}/test-util-avx512.hpp | 2 +- test/{ => include/test}/test-util.hpp | 0 test/test-aligned-vector.cpp | 2 +- test/test-avx512-util.cpp | 2 +- test/test-eltwise-add-mod-avx512.cpp | 2 +- test/test-eltwise-add-mod.cpp | 2 +- test/test-eltwise-cmp-add-avx512.cpp | 2 +- test/test-eltwise-cmp-add.cpp | 2 +- test/test-eltwise-cmp-sub-mod-avx512.cpp | 2 +- test/test-eltwise-cmp-sub-mod.cpp | 2 +- test/test-eltwise-fma-mod-avx512.cpp | 2 +- test/test-eltwise-fma-mod.cpp | 2 +- test/test-eltwise-mult-mod-avx512.cpp | 2 +- test/test-eltwise-mult-mod.cpp | 2 +- test/test-eltwise-reduce-mod-avx512.cpp | 2 +- test/test-eltwise-reduce-mod.cpp | 2 +- test/test-eltwise-sub-mod-avx512.cpp | 2 +- test/test-eltwise-sub-mod.cpp | 2 +- test/test-ntt-avx512.cpp | 4 ++-- test/test-ntt.cpp | 4 ++-- test/test-util-internal.cpp | 2 +- 29 files changed, 31 insertions(+), 28 deletions(-) rename test/{ => include/test}/test-ntt-util.hpp (100%) rename test/{ => include/test}/test-util-avx512.hpp (97%) rename test/{ => include/test}/test-util.hpp (100%) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 510d90e6..8628ea94 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -54,8 +54,11 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_definitions(unit-test PRIVATE -D_CRT_SECURE_NO_WARNINGS) endif() +set(HEXL_TEST_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) + target_include_directories(unit-test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + ${HEXL_TEST_INC_DIR} ${HEXL_SRC_ROOT_DIR} # Private headers ) diff --git a/test/experimental/fft-like/test-fft-like-avx512.cpp b/test/experimental/fft-like/test-fft-like-avx512.cpp index eba8e22e..9ad9d260 100644 --- a/test/experimental/fft-like/test-fft-like-avx512.cpp +++ b/test/experimental/fft-like/test-fft-like-avx512.cpp @@ -9,7 +9,7 @@ #include "hexl/experimental/fft-like/fft-like.hpp" #include "hexl/logging/logging.hpp" #include "hexl/util/defines.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" #include "util/cpu-features.hpp" #include "util/util-internal.hpp" diff --git a/test/experimental/fft-like/test-fft-like-native.cpp b/test/experimental/fft-like/test-fft-like-native.cpp index 8d27eb3e..3aec1eb2 100644 --- a/test/experimental/fft-like/test-fft-like-native.cpp +++ b/test/experimental/fft-like/test-fft-like-native.cpp @@ -9,7 +9,7 @@ #include "hexl/experimental/fft-like/fft-like.hpp" #include "hexl/logging/logging.hpp" #include "hexl/util/defines.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" #include "util/cpu-features.hpp" #include "util/util-internal.hpp" diff --git a/test/experimental/fft-like/test-fft-like.cpp b/test/experimental/fft-like/test-fft-like.cpp index 0ce0fd29..cf596056 100644 --- a/test/experimental/fft-like/test-fft-like.cpp +++ b/test/experimental/fft-like/test-fft-like.cpp @@ -7,7 +7,7 @@ #include "hexl/logging/logging.hpp" #include "hexl/util/defines.hpp" #include "ntt/ntt-internal.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" #include "util/cpu-features.hpp" namespace intel { diff --git a/test/experimental/misc/test-lr-mat-vec-mult.cpp b/test/experimental/misc/test-lr-mat-vec-mult.cpp index 41fee102..d11557f8 100644 --- a/test/experimental/misc/test-lr-mat-vec-mult.cpp +++ b/test/experimental/misc/test-lr-mat-vec-mult.cpp @@ -8,7 +8,7 @@ #include "hexl/experimental/misc/lr-mat-vec-mult.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" namespace intel { namespace hexl { diff --git a/test/experimental/seal/test-dyadic-multiply.cpp b/test/experimental/seal/test-dyadic-multiply.cpp index 385bbf90..5f4ca52a 100644 --- a/test/experimental/seal/test-dyadic-multiply.cpp +++ b/test/experimental/seal/test-dyadic-multiply.cpp @@ -8,7 +8,7 @@ #include "hexl/experimental/seal/dyadic-multiply.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" namespace intel { namespace hexl { diff --git a/test/experimental/seal/test-key-switch.cpp b/test/experimental/seal/test-key-switch.cpp index 26f68a91..3c04acc7 100644 --- a/test/experimental/seal/test-key-switch.cpp +++ b/test/experimental/seal/test-key-switch.cpp @@ -8,7 +8,7 @@ #include "hexl/experimental/seal/key-switch.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" namespace intel { namespace hexl { diff --git a/test/test-ntt-util.hpp b/test/include/test/test-ntt-util.hpp similarity index 100% rename from test/test-ntt-util.hpp rename to test/include/test/test-ntt-util.hpp diff --git a/test/test-util-avx512.hpp b/test/include/test/test-util-avx512.hpp similarity index 97% rename from test/test-util-avx512.hpp rename to test/include/test/test-util-avx512.hpp index 9136d979..3e7d0bf9 100644 --- a/test/test-util-avx512.hpp +++ b/test/include/test/test-util-avx512.hpp @@ -8,7 +8,7 @@ #include "hexl/logging/logging.hpp" #include "hexl/util/check.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" #include "util/avx512-util.hpp" namespace intel { diff --git a/test/test-util.hpp b/test/include/test/test-util.hpp similarity index 100% rename from test/test-util.hpp rename to test/include/test/test-util.hpp diff --git a/test/test-aligned-vector.cpp b/test/test-aligned-vector.cpp index b58a8cde..6bad9806 100644 --- a/test/test-aligned-vector.cpp +++ b/test/test-aligned-vector.cpp @@ -6,7 +6,7 @@ #include "hexl/util/aligned-allocator.hpp" #include "hexl/util/defines.hpp" #include "hexl/util/types.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" namespace intel { namespace hexl { diff --git a/test/test-avx512-util.cpp b/test/test-avx512-util.cpp index b3001c18..b60e7aea 100644 --- a/test/test-avx512-util.cpp +++ b/test/test-avx512-util.cpp @@ -7,7 +7,7 @@ #include #include "gtest/gtest.h" -#include "test-util-avx512.hpp" +#include "test/test-util-avx512.hpp" #include "util/avx512-util.hpp" #include "util/cpu-features.hpp" #include "util/util-internal.hpp" diff --git a/test/test-eltwise-add-mod-avx512.cpp b/test/test-eltwise-add-mod-avx512.cpp index c2af1835..10ee4146 100644 --- a/test/test-eltwise-add-mod-avx512.cpp +++ b/test/test-eltwise-add-mod-avx512.cpp @@ -10,7 +10,7 @@ #include "hexl/eltwise/eltwise-add-mod.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util-avx512.hpp" +#include "test/test-util-avx512.hpp" #include "util/cpu-features.hpp" #include "util/util-internal.hpp" diff --git a/test/test-eltwise-add-mod.cpp b/test/test-eltwise-add-mod.cpp index bb39aa1c..c4680e14 100644 --- a/test/test-eltwise-add-mod.cpp +++ b/test/test-eltwise-add-mod.cpp @@ -9,7 +9,7 @@ #include "hexl/eltwise/eltwise-add-mod.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" namespace intel { namespace hexl { diff --git a/test/test-eltwise-cmp-add-avx512.cpp b/test/test-eltwise-cmp-add-avx512.cpp index eb919a71..9e73a974 100644 --- a/test/test-eltwise-cmp-add-avx512.cpp +++ b/test/test-eltwise-cmp-add-avx512.cpp @@ -10,7 +10,7 @@ #include "hexl/eltwise/eltwise-cmp-add.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util-avx512.hpp" +#include "test/test-util-avx512.hpp" #include "util/cpu-features.hpp" #include "util/util-internal.hpp" diff --git a/test/test-eltwise-cmp-add.cpp b/test/test-eltwise-cmp-add.cpp index 9a6cb064..b373a087 100644 --- a/test/test-eltwise-cmp-add.cpp +++ b/test/test-eltwise-cmp-add.cpp @@ -9,7 +9,7 @@ #include "hexl/eltwise/eltwise-cmp-add.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" namespace intel { namespace hexl { diff --git a/test/test-eltwise-cmp-sub-mod-avx512.cpp b/test/test-eltwise-cmp-sub-mod-avx512.cpp index 3df02c24..a55f9c48 100644 --- a/test/test-eltwise-cmp-sub-mod-avx512.cpp +++ b/test/test-eltwise-cmp-sub-mod-avx512.cpp @@ -10,7 +10,7 @@ #include "hexl/eltwise/eltwise-cmp-sub-mod.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util-avx512.hpp" +#include "test/test-util-avx512.hpp" #include "util/cpu-features.hpp" #include "util/util-internal.hpp" diff --git a/test/test-eltwise-cmp-sub-mod.cpp b/test/test-eltwise-cmp-sub-mod.cpp index f276fb86..0d2915cf 100644 --- a/test/test-eltwise-cmp-sub-mod.cpp +++ b/test/test-eltwise-cmp-sub-mod.cpp @@ -9,7 +9,7 @@ #include "hexl/eltwise/eltwise-cmp-sub-mod.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" namespace intel { namespace hexl { diff --git a/test/test-eltwise-fma-mod-avx512.cpp b/test/test-eltwise-fma-mod-avx512.cpp index 34bc2bcc..5004c3ea 100644 --- a/test/test-eltwise-fma-mod-avx512.cpp +++ b/test/test-eltwise-fma-mod-avx512.cpp @@ -10,7 +10,7 @@ #include "hexl/eltwise/eltwise-fma-mod.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util-avx512.hpp" +#include "test/test-util-avx512.hpp" #include "util/cpu-features.hpp" #include "util/util-internal.hpp" diff --git a/test/test-eltwise-fma-mod.cpp b/test/test-eltwise-fma-mod.cpp index 8c150795..9dfdae3b 100644 --- a/test/test-eltwise-fma-mod.cpp +++ b/test/test-eltwise-fma-mod.cpp @@ -9,7 +9,7 @@ #include "hexl/eltwise/eltwise-fma-mod.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" #include "util/cpu-features.hpp" namespace intel { diff --git a/test/test-eltwise-mult-mod-avx512.cpp b/test/test-eltwise-mult-mod-avx512.cpp index 39ec04f5..6bce28eb 100644 --- a/test/test-eltwise-mult-mod-avx512.cpp +++ b/test/test-eltwise-mult-mod-avx512.cpp @@ -11,7 +11,7 @@ #include "hexl/eltwise/eltwise-mult-mod.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util-avx512.hpp" +#include "test/test-util-avx512.hpp" #include "util/cpu-features.hpp" #include "util/util-internal.hpp" diff --git a/test/test-eltwise-mult-mod.cpp b/test/test-eltwise-mult-mod.cpp index 55d4ea8a..973f8fb7 100644 --- a/test/test-eltwise-mult-mod.cpp +++ b/test/test-eltwise-mult-mod.cpp @@ -10,7 +10,7 @@ #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" #include "ntt/ntt-internal.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" namespace intel { namespace hexl { diff --git a/test/test-eltwise-reduce-mod-avx512.cpp b/test/test-eltwise-reduce-mod-avx512.cpp index cb9ca10e..c2bb18c7 100644 --- a/test/test-eltwise-reduce-mod-avx512.cpp +++ b/test/test-eltwise-reduce-mod-avx512.cpp @@ -10,7 +10,7 @@ #include "hexl/eltwise/eltwise-reduce-mod.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util-avx512.hpp" +#include "test/test-util-avx512.hpp" #include "util/cpu-features.hpp" #include "util/util-internal.hpp" diff --git a/test/test-eltwise-reduce-mod.cpp b/test/test-eltwise-reduce-mod.cpp index e1e4e51d..d6b85a63 100644 --- a/test/test-eltwise-reduce-mod.cpp +++ b/test/test-eltwise-reduce-mod.cpp @@ -9,7 +9,7 @@ #include "hexl/eltwise/eltwise-reduce-mod.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" #include "util/util-internal.hpp" namespace intel { diff --git a/test/test-eltwise-sub-mod-avx512.cpp b/test/test-eltwise-sub-mod-avx512.cpp index 78596393..af2398fc 100644 --- a/test/test-eltwise-sub-mod-avx512.cpp +++ b/test/test-eltwise-sub-mod-avx512.cpp @@ -10,7 +10,7 @@ #include "hexl/eltwise/eltwise-sub-mod.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util-avx512.hpp" +#include "test/test-util-avx512.hpp" #include "util/cpu-features.hpp" #include "util/util-internal.hpp" diff --git a/test/test-eltwise-sub-mod.cpp b/test/test-eltwise-sub-mod.cpp index 7d508efe..95af549a 100644 --- a/test/test-eltwise-sub-mod.cpp +++ b/test/test-eltwise-sub-mod.cpp @@ -9,7 +9,7 @@ #include "hexl/eltwise/eltwise-sub-mod.hpp" #include "hexl/logging/logging.hpp" #include "hexl/number-theory/number-theory.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" namespace intel { namespace hexl { diff --git a/test/test-ntt-avx512.cpp b/test/test-ntt-avx512.cpp index d44e8824..c3c5d924 100644 --- a/test/test-ntt-avx512.cpp +++ b/test/test-ntt-avx512.cpp @@ -12,8 +12,8 @@ #include "ntt/inv-ntt-avx512.hpp" #include "ntt/ntt-avx512-util.hpp" #include "ntt/ntt-internal.hpp" -#include "test-ntt-util.hpp" -#include "test-util.hpp" +#include "test/test-ntt-util.hpp" +#include "test/test-util.hpp" #include "util/cpu-features.hpp" namespace intel { diff --git a/test/test-ntt.cpp b/test/test-ntt.cpp index 6fd163c1..a931d480 100644 --- a/test/test-ntt.cpp +++ b/test/test-ntt.cpp @@ -11,8 +11,8 @@ #include "hexl/number-theory/number-theory.hpp" #include "hexl/util/defines.hpp" #include "ntt/ntt-internal.hpp" -#include "test-ntt-util.hpp" -#include "test-util.hpp" +#include "test/test-ntt-util.hpp" +#include "test/test-util.hpp" #include "util/cpu-features.hpp" namespace intel { diff --git a/test/test-util-internal.cpp b/test/test-util-internal.cpp index 8aa132e1..1b222d45 100644 --- a/test/test-util-internal.cpp +++ b/test/test-util-internal.cpp @@ -7,7 +7,7 @@ #include "hexl/util/aligned-allocator.hpp" #include "ntt/ntt-internal.hpp" -#include "test-util.hpp" +#include "test/test-util.hpp" namespace intel { namespace hexl { From 311fe72c0ae6d5a6b5d3dcc52936bb0d9fc9f2bd Mon Sep 17 00:00:00 2001 From: Jose Rojas Chaves Date: Thu, 13 Oct 2022 16:57:52 -0600 Subject: [PATCH 03/12] Fixing issue #131 - EltwiseFMAMod Failing on 52 bits modulus (#136) --- hexl/eltwise/eltwise-fma-mod.cpp | 2 +- test/test-eltwise-fma-mod-avx512.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hexl/eltwise/eltwise-fma-mod.cpp b/hexl/eltwise/eltwise-fma-mod.cpp index 6b883543..03478fc0 100644 --- a/hexl/eltwise/eltwise-fma-mod.cpp +++ b/hexl/eltwise/eltwise-fma-mod.cpp @@ -40,7 +40,7 @@ void EltwiseFMAMod(uint64_t* result, const uint64_t* arg1, uint64_t arg2, << (input_mod_factor * modulus)); #ifdef HEXL_HAS_AVX512IFMA - if (has_avx512ifma && input_mod_factor * modulus < (1ULL << 52)) { + if (has_avx512ifma && input_mod_factor * modulus < (1ULL << 51)) { HEXL_VLOG(3, "Calling 52-bit EltwiseFMAModAVX512"); switch (input_mod_factor) { diff --git a/test/test-eltwise-fma-mod-avx512.cpp b/test/test-eltwise-fma-mod-avx512.cpp index 5004c3ea..c88d0ad8 100644 --- a/test/test-eltwise-fma-mod-avx512.cpp +++ b/test/test-eltwise-fma-mod-avx512.cpp @@ -221,7 +221,7 @@ TEST(EltwiseFMAMod, AVX512IFMA) { constexpr uint64_t input_mod_factor = 8; - for (size_t bits = 48; bits <= 51; ++bits) { + for (size_t bits = 48; bits <= 52; ++bits) { uint64_t modulus = GeneratePrimes(1, bits, true, length)[0]; for (size_t trial = 0; trial < 1000; ++trial) { auto arg1 = GenerateInsecureUniformIntRandomValues( @@ -238,7 +238,7 @@ TEST(EltwiseFMAMod, AVX512IFMA) { EltwiseFMAMod(arg1.data(), arg1.data(), arg2, arg3_data, arg1.size(), modulus, input_mod_factor); - if (has_avx512ifma) { + if (has_avx512ifma && input_mod_factor * modulus < (1ULL << 51)) { EltwiseFMAModAVX512<52, input_mod_factor>( arg1a.data(), arg1a.data(), arg2, arg3_data, arg1.size(), modulus); ASSERT_EQ(arg1, arg1a); From 2d196fdd71f24511bd7e0e23dc07d37c888f53e7 Mon Sep 17 00:00:00 2001 From: Gelila Seifu Date: Mon, 5 Dec 2022 11:39:01 -0600 Subject: [PATCH 04/12] optimize keyswitching (#137) * optimize keyswitching * added comments --- .../experimental/seal/key-switch-internal.cpp | 25 ++++----- hexl/include/hexl/experimental/seal/locks.hpp | 35 ++++++++++++ .../hexl/experimental/seal/ntt-cache.hpp | 56 +++++++++++++++++++ 3 files changed, 102 insertions(+), 14 deletions(-) create mode 100644 hexl/include/hexl/experimental/seal/locks.hpp create mode 100644 hexl/include/hexl/experimental/seal/ntt-cache.hpp diff --git a/hexl/experimental/seal/key-switch-internal.cpp b/hexl/experimental/seal/key-switch-internal.cpp index 04477979..15edb9a8 100644 --- a/hexl/experimental/seal/key-switch-internal.cpp +++ b/hexl/experimental/seal/key-switch-internal.cpp @@ -11,8 +11,8 @@ #include "hexl/eltwise/eltwise-fma-mod.hpp" #include "hexl/eltwise/eltwise-mult-mod.hpp" #include "hexl/eltwise/eltwise-reduce-mod.hpp" +#include "hexl/experimental/seal/ntt-cache.hpp" #include "hexl/logging/logging.hpp" -#include "hexl/ntt/ntt.hpp" #include "hexl/number-theory/number-theory.hpp" #include "hexl/util/aligned-allocator.hpp" #include "hexl/util/check.hpp" @@ -36,22 +36,20 @@ void KeySwitch(uint64_t* result, const uint64_t* t_target_iter_ptr, uint64_t n, uint64_t coeff_count = n; // Create a copy of target_iter - std::vector t_target(coeff_count * decomp_modulus_size, 0); - for (size_t i = 0; i < coeff_count * decomp_modulus_size; ++i) { - t_target[i] = t_target_iter_ptr[i]; - } - - uint64_t* t_target_ptr = &t_target[0]; + std::vector t_target( + t_target_iter_ptr, + t_target_iter_ptr + (coeff_count * decomp_modulus_size)); + uint64_t* t_target_ptr = t_target.data(); // Simplified implementation, where we assume no modular reduction is required // for intermediate additions std::vector t_ntt(coeff_count, 0); - uint64_t* t_ntt_ptr = &t_ntt[0]; + uint64_t* t_ntt_ptr = t_ntt.data(); // In CKKS t_target is in NTT form; switch // back to normal form for (size_t j = 0; j < decomp_modulus_size; ++j) { - NTT(n, moduli[j]) + GetNTT(n, moduli[j]) .ComputeInverse(&t_target_ptr[j * coeff_count], &t_target_ptr[j * coeff_count], 2, 1); } @@ -87,8 +85,7 @@ void KeySwitch(uint64_t* result, const uint64_t* t_target_iter_ptr, uint64_t n, } // NTT conversion lazy outputs in [0, 4q) - NTT(n, moduli[key_index]).ComputeForward(t_ntt_ptr, t_ntt_ptr, 4, 4); - + GetNTT(n, moduli[key_index]).ComputeForward(t_ntt_ptr, t_ntt_ptr, 4, 4); t_operand = t_ntt_ptr; } @@ -141,7 +138,8 @@ void KeySwitch(uint64_t* result, const uint64_t* t_target_iter_ptr, uint64_t n, &t_poly_prod[key_component * coeff_count * rns_modulus_size]; uint64_t* t_last = &t_poly_prod_it[decomp_modulus_size * coeff_count]; - NTT(n, moduli[key_modulus_size - 1]).ComputeInverse(t_last, t_last, 2, 2); + GetNTT(n, moduli[key_modulus_size - 1]) + .ComputeInverse(t_last, t_last, 2, 2); uint64_t qk = moduli[key_modulus_size - 1]; uint64_t qk_half = qk >> 1; @@ -178,8 +176,7 @@ void KeySwitch(uint64_t* result, const uint64_t* t_target_iter_ptr, uint64_t n, } uint64_t qi_lazy = qi << 1; // some multiples of qi - - NTT(n, moduli[i]).ComputeForward(t_ntt_ptr, t_ntt_ptr, 4, 4); + GetNTT(n, moduli[i]).ComputeForward(t_ntt_ptr, t_ntt_ptr, 4, 4); // Since SEAL uses at most 60bit moduli, 8*qi < 2^63. qi_lazy = qi << 2; diff --git a/hexl/include/hexl/experimental/seal/locks.hpp b/hexl/include/hexl/experimental/seal/locks.hpp new file mode 100644 index 00000000..4595f4e5 --- /dev/null +++ b/hexl/include/hexl/experimental/seal/locks.hpp @@ -0,0 +1,35 @@ +// Copyright (C) 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include + +namespace intel { +namespace hexl { + +using Lock = std::shared_mutex; +using WriteLock = std::unique_lock; +using ReadLock = std::shared_lock; + +class RWLock { + public: + RWLock() = default; + inline ReadLock AcquireRead() { return ReadLock(rw_mutex); } + inline WriteLock AcquireWrite() { return WriteLock(rw_mutex); } + inline ReadLock TryAcquireRead() noexcept { + return ReadLock(rw_mutex, std::try_to_lock); + } + inline WriteLock TryAcquireWrite() noexcept { + return WriteLock(rw_mutex, std::try_to_lock); + } + + private: + RWLock(const RWLock& copy) = delete; + RWLock& operator=(const RWLock& assign) = delete; + Lock rw_mutex{}; +}; + +} // namespace hexl +} // namespace intel diff --git a/hexl/include/hexl/experimental/seal/ntt-cache.hpp b/hexl/include/hexl/experimental/seal/ntt-cache.hpp new file mode 100644 index 00000000..8f6c1046 --- /dev/null +++ b/hexl/include/hexl/experimental/seal/ntt-cache.hpp @@ -0,0 +1,56 @@ +// Copyright (C) 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "hexl/experimental/seal/locks.hpp" +#include "ntt/ntt-internal.hpp" + +namespace intel { +namespace hexl { + +struct HashPair { + template + std::size_t operator()(const std::pair& p) const { + auto hash1 = std::hash{}(p.first); + auto hash2 = std::hash{}(p.second); + return hash_combine(hash1, hash2); + } + + // Golden Ratio Hashing with seeds + static std::size_t hash_combine(std::size_t lhs, std::size_t rhs) { + lhs ^= rhs + 0x9e3779b9 + (lhs << 6) + (lhs >> 2); + return lhs; + } +}; + +NTT& GetNTT(size_t N, uint64_t modulus) { + static std::unordered_map, NTT, HashPair> + ntt_cache; + static RWLock ntt_cache_locker; + + std::pair key{N, modulus}; + + // Enable shared access to NTT already present + { + ReadLock reader_lock(ntt_cache_locker.AcquireRead()); + auto ntt_it = ntt_cache.find(key); + if (ntt_it != ntt_cache.end()) { + return ntt_it->second; + } + } + + // Deal with NTT not yet present + WriteLock write_lock(ntt_cache_locker.AcquireWrite()); + + // Check ntt_cache for value (may be added by another thread) + auto ntt_it = ntt_cache.find(key); + if (ntt_it == ntt_cache.end()) { + NTT ntt(N, modulus); + ntt_it = ntt_cache.emplace(std::move(key), std::move(ntt)).first; + } + return ntt_it->second; +} + +} // namespace hexl +} // namespace intel From 8463983c8e5691ea39abeae89be7d8d93b9a1e71 Mon Sep 17 00:00:00 2001 From: Flavio Bergamaschi Date: Tue, 2 Jul 2024 10:28:34 -0400 Subject: [PATCH 05/12] Update Build and Test CI Workflow (#149) * Remove support for Ubuntu 18.04 builds * Removing unavailable platforms from build and test workflow * Set workflow for Ubuntu 22.04 * Adjust GCC and CLANG versions for Ubuntu 22.04 * Adjusting build environment for HEXL experimental build on Ubuntu 20.04 The HEXL experimental build workflow is only available on Ubuntu 20.04. This is an experimental and unsupported build. --- .github/workflows/github-ci.yml | 122 +++++--------------------------- 1 file changed, 18 insertions(+), 104 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index eafcfce3..46534d2c 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -30,8 +30,8 @@ env: -DHEXL_HINT_DIR=${GITHUB_WORKSPACE}/lib/cmake/hexl-${HEXL_VER} COVERAGE_COMPILER_FLAGS: > -DCMAKE_BUILD_TYPE=Debug - -DCMAKE_CXX_COMPILER=g++-9 - -DCMAKE_C_COMPILER=gcc-9 + -DCMAKE_CXX_COMPILER=g++-11 + -DCMAKE_C_COMPILER=gcc-11 -DHEXL_BENCHMARK=ON -DHEXL_TESTING=ON -DHEXL_COVERAGE=ON @@ -42,7 +42,7 @@ env: jobs: format: name: Format - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 # Required for pre-commit @@ -60,8 +60,11 @@ jobs: shell: bash strategy: matrix: + # removed platforms not available on github hosted servers. + # sel-fhosted ice-lake servers not enabled by sysadmin # os: [ice-lake, [self-hosted, ubuntu-18.04], macos-latest, ubuntu-20.04] - os: [ice-lake, macos-latest, ubuntu-20.04] + # os: [macos-latest, ubuntu-20.04] + os: [macos-latest, ubuntu-22.04] build_type: [Release, Debug] shared_lib: [ON, OFF] include: @@ -83,8 +86,8 @@ jobs: run: | set -x if [ "$RUNNER_OS" == "Linux" ]; then - export CC=clang-10 - export CXX=clang++-10 + export CC=clang-14 + export CXX=clang++-14 fi # Print information useful for debugging @@ -177,101 +180,6 @@ jobs: # TODO: add pkgconfig and vcpkg examples - - - ubuntu-1804-build: - name: '${{ matrix.os }} ${{ matrix.build_type }} shared=${{ matrix.shared_lib }}' - runs-on: '${{ matrix.os }}' - defaults: - run: - shell: bash - strategy: - matrix: - os: [ubuntu-18.04] - build_type: [Release, Debug] - shared_lib: [ON, OFF] - include: - # Run benchmarks quickly in Debug mode - - build_type: Debug - benchmark_min_time: "--benchmark_min_time=0.001" - - build_type: Release - benchmark_min_time: "" - exclude: # Skip debug on Mac. TODO: add Debug mode - - os: macos-latest - build_type: Debug - steps: - - uses: actions/checkout@v2 - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v1.10 - with: - cmake-version: '3.13.x' - - name: Default build - run: | - set -x - if [ "$RUNNER_OS" == "Linux" ]; then - export CC=gcc - export CXX=g++ - fi - - # Print information useful for debugging - gcc --version - g++ --version - whoami - echo $HOME - echo $GITHUB_WORKSPACE - echo "Testing from branch:" - echo $GITHUB_REFH - cmake --version - pwd - - # Build library - cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DHEXL_SHARED_LIB=${{ matrix.shared_lib }} \ - -DCMAKE_INSTALL_PREFIX=./ - cmake --build build -j - cmake --build build --target install - cmake --build build --target unittest - # Instead of calling cmake --build build --target bench, - # we run the executable directly to pass command-line arguments - ./build/benchmark/bench_hexl \ - --benchmark_out="${GITHUB_WORKFLOW}_${GITHUB_SHA}" \ - --benchmark_out_format=csv ${{ matrix.benchmark_min_time }} - - # Build and run examples - cd $GITHUB_WORKSPACE/example/cmake - cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - ${{ env.HEXL_HINT_DIR }} - cmake --build build - build/example - - # Build example using pkgconfig - cd $GITHUB_WORKSPACE/example/pkgconfig - # Set PKG_CONFIG_PATH to locate hexl.pc - export PKG_CONFIG_PATH=$GITHUB_WORKSPACE/lib/pkgconfig - cmake -S . -B build - cmake --build build - build/example - - # Build example using vcpkg - # TODO: fix vcpkg example CI - # vcpkg install hexl --overlay-ports=$GITHUB_WORKSPACE/port/hexl/ --head - # cd $GITHUB_WORKSPACE/example/vcpkg - # vcpkg_toolchain=$(locate vcpkg.cmake) - # echo $vcpkg_toolchain - # cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$vcpkg_toolchain - # cmake --build build - # build/example - # set +x - - - name: Archive benchmark results - uses: actions/upload-artifact@v2 - with: - name: bench_hexl_${{github.sha}}.csv - path: ${{ github.workspace }}/${{ github.workflow }}_${{ github.sha }} - retention-days: 90 # Maximum for free version - - - experimental-build: name: 'experimental: ${{ matrix.os }} ${{ matrix.build_type }} shared=${{ matrix.shared_lib }}' runs-on: '${{ matrix.os }}' @@ -280,7 +188,13 @@ jobs: shell: bash strategy: matrix: - os: [ice-lake] + # This is an unsupported experimental build - use at your own risk + # + # Ice-lake platform not available on github + # self-hosted platforms disabled by Intel github sys admin + # building on default ubuntu-20.04 platform + # os: [ice-lake] + os: [ubuntu-20.04] build_type: [Release] shared_lib: [ON] steps: @@ -289,8 +203,8 @@ jobs: run: | set -x if [ "$RUNNER_OS" == "Linux" ]; then - export CC=clang-10 - export CXX=clang++-10 + export CC=clang-11 + export CXX=clang++-11 fi # Print information useful for debugging From 4be3996b4989861b64de4accae0f4384dc97518a Mon Sep 17 00:00:00 2001 From: Flavio Bergamaschi Date: Thu, 18 Jul 2024 15:20:57 +0100 Subject: [PATCH 06/12] Add SECURITY.md for OSSF Scorecard compliance (#150) * Add SECURITY.md for OSSF Scorecard compliance Co-authored-by: Robert Dower robert.dower@intel.com --- SECURITY.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..e17a0972 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,8 @@ +# Security Policy +Intel is committed to rapidly addressing security vulnerabilities affecting +our customers and providing clear guidance on the solution, impact, severity +and mitigation. + +## Reporting a Vulnerability +Please report any security vulnerabilities in this project utilizing the +guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). From f018f0f0fcd5d599f0c41ca0eeb1ccfa371caede Mon Sep 17 00:00:00 2001 From: Michael Beale Date: Thu, 18 Jul 2024 13:09:05 -0700 Subject: [PATCH 07/12] Added workflow permissions to meet OpenSSF Scorecard requirements (#151) Added workflow permissions to meet OpenSSF Scorecard requirements. Update github-ci.yml --- .github/workflows/github-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 46534d2c..91ba1dbf 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 name: Build and Test +permissions: read-all on: # By default this will run when the activity type is "opened", "synchronize", # or "reopened". @@ -55,6 +56,8 @@ jobs: nix-build: name: '${{ matrix.os }} ${{ matrix.build_type }} shared=${{ matrix.shared_lib }}' runs-on: '${{ matrix.os }}' + permissions: + contents: write # required for actions/upload-artifacts@v2 defaults: run: shell: bash From 18250dbb8ecfa62a5d203cffb88b9abe07e26a27 Mon Sep 17 00:00:00 2001 From: Flavio Bergamaschi Date: Fri, 19 Jul 2024 11:08:32 +0100 Subject: [PATCH 08/12] Add Build&Test CI Badge (#152) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5113f6f0..f2b1db0b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build and Test](https://github.com/intel/hexl/actions/workflows/github-ci.yml/badge.svg?branch=main)](https://github.com/intel/hexl/actions/workflows/github-ci.yml) +[![Build and Test](https://github.com/intel/hexl/actions/workflows/github-ci.yml/badge.svg)](https://github.com/intel/hexl/actions/workflows/github-ci.yml) # Intel Homomorphic Encryption (HE) Acceleration Library Intel:registered: HE Acceleration Library is an open-source library which From 5c1e40dcc57709fb57dbfb93e19a6dcc1c1908cf Mon Sep 17 00:00:00 2001 From: Jose Rojas Chaves Date: Mon, 12 May 2025 14:12:13 -0600 Subject: [PATCH 09/12] Fix deprecated version for actions and remove unsupported platforms - Updates actions/upload-artifact from v2 to v4 - Updates actions/checkout from v2 to v3 - Updates pre-commit/action to v3.0.1 - Removed Mac-OS and Ubuntu20.04 --- .github/workflows/github-ci.yml | 66 +++------------------------------ 1 file changed, 5 insertions(+), 61 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 91ba1dbf..5f9b4c59 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -45,11 +45,11 @@ jobs: name: Format runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 # Required for pre-commit - run: pip3 install cpplint==1.5.5 # NOTE: This is deprecated in favor of pre-commit.ci - - uses: pre-commit/action@v2.0.2 + - uses: pre-commit/action@v3.0.1 with: extra_args: --all-files @@ -64,10 +64,7 @@ jobs: strategy: matrix: # removed platforms not available on github hosted servers. - # sel-fhosted ice-lake servers not enabled by sysadmin - # os: [ice-lake, [self-hosted, ubuntu-18.04], macos-latest, ubuntu-20.04] - # os: [macos-latest, ubuntu-20.04] - os: [macos-latest, ubuntu-22.04] + os: [ubuntu-22.04] build_type: [Release, Debug] shared_lib: [ON, OFF] include: @@ -76,9 +73,6 @@ jobs: benchmark_min_time: "--benchmark_min_time=0.001" - build_type: Release benchmark_min_time: "" - exclude: # Skip debug on Mac. TODO: add Debug mode - - os: macos-latest - build_type: Debug steps: - uses: actions/checkout@v2 - name: Setup cmake @@ -142,9 +136,9 @@ jobs: # set +x - name: Archive benchmark results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: bench_hexl_${{github.sha}}.csv + name: bench_hexl_${{github.sha}}_${{github.run_id}}_${{github.job}}_${{matrix.os}}_${{matrix.build_type}}_Shared_${{matrix.shared_lib}} path: ${{ github.workspace }}/${{ github.workflow }}_${{ github.sha }} retention-days: 90 # Maximum for free version @@ -182,53 +176,3 @@ jobs: build/${{ matrix.build_type}}/example.exe # TODO: add pkgconfig and vcpkg examples - - experimental-build: - name: 'experimental: ${{ matrix.os }} ${{ matrix.build_type }} shared=${{ matrix.shared_lib }}' - runs-on: '${{ matrix.os }}' - defaults: - run: - shell: bash - strategy: - matrix: - # This is an unsupported experimental build - use at your own risk - # - # Ice-lake platform not available on github - # self-hosted platforms disabled by Intel github sys admin - # building on default ubuntu-20.04 platform - # os: [ice-lake] - os: [ubuntu-20.04] - build_type: [Release] - shared_lib: [ON] - steps: - - uses: actions/checkout@v2 - - name: Default build - run: | - set -x - if [ "$RUNNER_OS" == "Linux" ]; then - export CC=clang-11 - export CXX=clang++-11 - fi - - # Print information useful for debugging - whoami - echo $HOME - echo $GITHUB_WORKSPACE - echo "Testing from branch:" - echo $GITHUB_REFH - cmake --version - pwd - - # Build library - cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DHEXL_SHARED_LIB=${{ matrix.shared_lib }} \ - -DCMAKE_INSTALL_PREFIX=./ \ - -DHEXL_EXPERIMENTAL=ON - cmake --build build -j - cmake --build build --target install - cmake --build build --target unittest - # Instead of calling cmake --build build --target bench, - # we run the executable directly to pass command-line arguments - ./build/benchmark/bench_hexl \ - --benchmark_out="${GITHUB_WORKFLOW}_${GITHUB_SHA}" \ - --benchmark_out_format=csv From 23ea8570ebb67e0f4529074a00b5b3c2096117b6 Mon Sep 17 00:00:00 2001 From: Jose Rojas Chaves Date: Tue, 13 May 2025 11:04:36 -0600 Subject: [PATCH 10/12] Fix issue #146 - Check Bounds for avx512 reduction mod_2 (#153) * Fix issue #146 - Check Bounds for avx512 reduction mod_2 --- hexl/eltwise/eltwise-reduce-mod-avx512.hpp | 4 +- hexl/eltwise/eltwise-reduce-mod.cpp | 2 +- test/test-eltwise-reduce-mod-avx512.cpp | 46 ++++++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/hexl/eltwise/eltwise-reduce-mod-avx512.hpp b/hexl/eltwise/eltwise-reduce-mod-avx512.hpp index 5374c9c8..87ad2c6d 100644 --- a/hexl/eltwise/eltwise-reduce-mod-avx512.hpp +++ b/hexl/eltwise/eltwise-reduce-mod-avx512.hpp @@ -81,8 +81,8 @@ void EltwiseReduceModAVX512(uint64_t* result, const uint64_t* operand, __m512i v_op = _mm512_loadu_si512(v_operand); v_op = _mm512_hexl_barrett_reduce64( v_op, v_modulus, v_bf, v_bf_52, prod_right_shift, v_neg_mod); - HEXL_CHECK_BOUNDS(ExtractValues(v_op).data(), 8, modulus, - "v_op exceeds bound " << modulus); + HEXL_CHECK_BOUNDS(ExtractValues(v_op).data(), 8, twice_mod, + "v_op exceeds bound " << twice_mod); _mm512_storeu_si512(v_result, v_op); ++v_operand; ++v_result; diff --git a/hexl/eltwise/eltwise-reduce-mod.cpp b/hexl/eltwise/eltwise-reduce-mod.cpp index accfe938..e7b9dd06 100644 --- a/hexl/eltwise/eltwise-reduce-mod.cpp +++ b/hexl/eltwise/eltwise-reduce-mod.cpp @@ -35,7 +35,7 @@ void EltwiseReduceModNative(uint64_t* result, const uint64_t* operand, if (input_mod_factor == modulus) { if (output_mod_factor == 2) { for (size_t i = 0; i < n; ++i) { - if (operand[i] >= modulus) { + if (operand[i] >= twice_modulus) { result[i] = BarrettReduce64<2>(operand[i], modulus, barrett_factor); } else { result[i] = operand[i]; diff --git a/test/test-eltwise-reduce-mod-avx512.cpp b/test/test-eltwise-reduce-mod-avx512.cpp index c2bb18c7..c64f0ea2 100644 --- a/test/test-eltwise-reduce-mod-avx512.cpp +++ b/test/test-eltwise-reduce-mod-avx512.cpp @@ -35,6 +35,29 @@ TEST(EltwiseReduceMod, avx512_64_mod_1) { CheckEqual(result, exp_out); } +TEST(EltwiseReduceMod, avx512_64_mod_2) { + if (!has_avx512dq) { + GTEST_SKIP(); + } + + std::vector op{18399319504785536384ULL, 17772833711639413686ULL, + 12597119745262224203ULL, 1504294004559805751ULL, + 11357185129558358846ULL, 15524763729212309524ULL, + 15578066193709346988ULL, 9262080163435001663ULL}; + + std::vector exp_out{1282985348605, 701667589612, 1154521301334, + 519986957540, 1153052298859, 914113932554, + 1255706689604, 1229762981307}; + std::vector result{0, 0, 0, 0, 0, 0, 0, 0}; + + uint64_t modulus = 1099511590913; + const uint64_t input_mod_factor = modulus; + const uint64_t output_mod_factor = 2; + EltwiseReduceModAVX512<64>(result.data(), op.data(), op.size(), modulus, + input_mod_factor, output_mod_factor); + CheckEqual(result, exp_out); +} + TEST(EltwiseReduceModMontInOut, avx512_64_mod_1) { if (!has_avx512dq) { GTEST_SKIP(); @@ -83,6 +106,29 @@ TEST(EltwiseReduceMod, avx512_52_mod_1) { CheckEqual(result, exp_out); } +TEST(EltwiseReduceMod, avx512_52_mod_2) { + if (!has_avx512ifma) { + GTEST_SKIP(); + } + + std::vector op{18399319504785536384ULL, 17772833711639413686ULL, + 12597119745262224203ULL, 1504294004559805751ULL, + 11357185129558358846ULL, 15524763729212309524ULL, + 15578066193709346988ULL, 9262080163435001663ULL}; + + std::vector exp_out{183473757692, 701667589612, 1154521301334, + 519986957540, 1153052298859, 914113932554, + 1255706689604, 130251390394}; + std::vector result{0, 0, 0, 0, 0, 0, 0, 0}; + + uint64_t modulus = 1099511590913; + const uint64_t input_mod_factor = modulus; + const uint64_t output_mod_factor = 2; + EltwiseReduceModAVX512<52>(result.data(), op.data(), op.size(), modulus, + input_mod_factor, output_mod_factor); + CheckEqual(result, exp_out); +} + TEST(EltwiseReduceMod, avx512_52_Big_mod_1) { if (!has_avx512ifma) { GTEST_SKIP(); From 65d9d54a9794b7de4f501fd15ab2bb11fa5e93e8 Mon Sep 17 00:00:00 2001 From: Jose Rojas Chaves Date: Thu, 15 May 2025 10:59:53 -0600 Subject: [PATCH 11/12] Fix for destructor error (#159) Co-authored-by: @fboemer --- CMakeLists.txt | 9 +++++++++ hexl/include/hexl/ntt/ntt.hpp | 2 +- hexl/ntt/ntt-internal.cpp | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0da96f7..61892c37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,15 @@ if (NOT HEXL_FPGA_COMPATIBILITY) set(HEXL_FPGA_COMPATIBILITY "0" CACHE INTERNAL "Set FPGA compatibility mask" FORCE) endif() +# Get the current working branch +execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +message(STATUS "HEXL BRANCH: ${GIT_BRANCH}") message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}") diff --git a/hexl/include/hexl/ntt/ntt.hpp b/hexl/include/hexl/ntt/ntt.hpp index 93ccba72..6346d266 100644 --- a/hexl/include/hexl/ntt/ntt.hpp +++ b/hexl/include/hexl/ntt/ntt.hpp @@ -40,7 +40,7 @@ class NTT { NTT() = default; /// @brief Destructs the NTT object - ~NTT() = default; + ~NTT(); /// @brief Initializes an NTT object with degree \p degree and modulus \p q. /// @param[in] degree also known as N. Size of the NTT transform. Must be a diff --git a/hexl/ntt/ntt-internal.cpp b/hexl/ntt/ntt-internal.cpp index 9ace8741..5c86b01c 100644 --- a/hexl/ntt/ntt-internal.cpp +++ b/hexl/ntt/ntt-internal.cpp @@ -51,6 +51,8 @@ NTT::NTT(uint64_t degree, uint64_t q, uint64_t root_of_unity, NTT::NTT(uint64_t degree, uint64_t q, std::shared_ptr alloc_ptr) : NTT(degree, q, MinimalPrimitiveRoot(2 * degree, q), alloc_ptr) {} +NTT::~NTT() = default; + void NTT::ComputeRootOfUnityPowers() { AlignedVector64 root_of_unity_powers(m_degree, 0, m_aligned_alloc); AlignedVector64 inv_root_of_unity_powers(m_degree, 0, From 75a60b8cc908fb4c166315dd8b55b2e1ee7faea7 Mon Sep 17 00:00:00 2001 From: Flavio Bergamaschi Date: Thu, 29 May 2025 14:46:16 -0400 Subject: [PATCH 12/12] Prep and testing for 1.2.6 (#160) * Update github-ci.yml * Update CHANGES.md * Update CMakeLists.txt * Update README.md * Update CMakeLists.txt * Update vcpkg.json * Update portfile.cmake * Update CODEOWNERS * Update CHANGES.md Co-authored-by: Jose Rojas Chaves --- .github/workflows/github-ci.yml | 2 +- CHANGES.md | 11 ++++++++++- CMakeLists.txt | 2 +- CODEOWNERS | 2 +- example/README.md | 4 ++-- example/cmake/CMakeLists.txt | 2 +- example/vcpkg/vcpkg.json | 4 ++-- port/hexl/portfile.cmake | 2 +- port/hexl/vcpkg.json | 2 +- 9 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 5f9b4c59..f0656f13 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -25,7 +25,7 @@ on: # Define env vars # ################### env: - HEXL_VER: 1.2.5 + HEXL_VER: 1.2.6 HEXL_DIR: ${GITHUB_WORKSPACE}/lib/cmake/hexl-${HEXL_VER} HEXL_HINT_DIR: > -DHEXL_HINT_DIR=${GITHUB_WORKSPACE}/lib/cmake/hexl-${HEXL_VER} diff --git a/CHANGES.md b/CHANGES.md index 356c13a3..72cb3c43 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,16 @@ # Changes -## Version 1.2.5 +## Version 1.2.6 +- Update documentation to make a reference to OpenFHE +- Complies with Clang-Format +11 +- Fixes EltwiseFMAMod Failing on 52 bits modulus (https://github.com/IntelLabs/hexl/pull/136) +- Fixes Check Bounds for avx512 reduction mod_2 (https://github.com/IntelLabs/hexl/pull/153) +- Fixes Destructor error (https://github.com/IntelLabs/hexl/pull/159) +- Updates to CI/CD +- Add SECURITY.md for OSSF Scorecard compliance +- Added workflow permissions to meet OpenSSF Scorecard requirements +## Version 1.2.5 - Adds experimental FFT-like (https://github.com/intel/hexl/pull/104) - Adds big moduli tests for IFMA (https://github.com/intel/hexl/pull/123) - Fixes HEXL's example build (https://github.com/intel/hexl/pull/114) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61892c37..2d35adba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ # target_link_options and cmake -S . -B build require cmake 3.13 cmake_minimum_required(VERSION 3.13) -project(HEXL VERSION 1.2.5 LANGUAGES C CXX) +project(HEXL VERSION 1.2.6 LANGUAGES C CXX) include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) diff --git a/CODEOWNERS b/CODEOWNERS index bc9ecb02..6ff542b1 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -2,4 +2,4 @@ # SPDX-License-Identifier: Apache-2.0 # Default codeowner for all files -* @intel/hexl-maintain +* @IntelLabs/hexl-maintain diff --git a/example/README.md b/example/README.md index 9b877299..a55dff2d 100644 --- a/example/README.md +++ b/example/README.md @@ -29,14 +29,14 @@ Once you have installed Intel HE Acceleration Library. Then, in your external application, add the following lines to your `CMakeLists.txt`: ```bash -find_package(HEXL 1.2.5 +find_package(HEXL 1.2.6 HINTS ${HEXL_HINT_DIR} REQUIRED) target_link_libraries( HEXL::hexl) ``` If Intel HE Acceleration Library is installed globally, `HEXL_HINT_DIR` is not needed. Otherwise, `HEXL_HINT_DIR` should be the directory containing -`HEXLConfig.cmake`, e.g. `${CMAKE_INSTALL_PREFIX}/lib/cmake/hexl-1.2.5/` +`HEXLConfig.cmake`, e.g. `${CMAKE_INSTALL_PREFIX}/lib/cmake/hexl-1.2.6/` ## Method 2 (pkgconfig) diff --git a/example/cmake/CMakeLists.txt b/example/cmake/CMakeLists.txt index ec7bf652..6701c13b 100644 --- a/example/cmake/CMakeLists.txt +++ b/example/cmake/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.13) set(CMAKE_CXX_STANDARD 17) # Example using source -find_package(HEXL 1.2.5 +find_package(HEXL 1.2.6 HINTS ${HEXL_HINT_DIR} REQUIRED) if (NOT TARGET HEXL::hexl) diff --git a/example/vcpkg/vcpkg.json b/example/vcpkg/vcpkg.json index 83c91261..e6423f66 100644 --- a/example/vcpkg/vcpkg.json +++ b/example/vcpkg/vcpkg.json @@ -4,11 +4,11 @@ "dependencies": [ { "name": "hexl", - "version>=": "1.2.5" + "version>=": "1.2.6" } ], "builtin-baseline": "7baf7bc9f3390bab2f47e2bcbd35b065663bc80d", "overrides": [ - { "name": "hexl", "version": "1.2.1", "port-version": 0} + { "name": "hexl", "version": "1.2.6", "port-version": 0} ] } diff --git a/port/hexl/portfile.cmake b/port/hexl/portfile.cmake index 6c68c546..90270a4c 100644 --- a/port/hexl/portfile.cmake +++ b/port/hexl/portfile.cmake @@ -26,7 +26,7 @@ vcpkg_cmake_configure( ) vcpkg_cmake_install() -vcpkg_cmake_config_fixup(PACKAGE_NAME "HEXL" CONFIG_PATH "lib/cmake/hexl-1.2.5") +vcpkg_cmake_config_fixup(PACKAGE_NAME "HEXL" CONFIG_PATH "lib/cmake/hexl-1.2.6") vcpkg_fixup_pkgconfig() diff --git a/port/hexl/vcpkg.json b/port/hexl/vcpkg.json index fccd8518..cea42f10 100644 --- a/port/hexl/vcpkg.json +++ b/port/hexl/vcpkg.json @@ -1,6 +1,6 @@ { "name": "hexl", - "version": "1.2.5", + "version": "1.2.6", "description": "IntelĀ® HEXL is an open-source library which provides efficient implementations of integer arithmetic on Galois fields.", "homepage": "https://github.com/intel/hexl", "supports": "x64 & !(windows & !static)",