Skip to content

Commit 747b98a

Browse files
author
Wei Dai
committed
Merge pull request #375 from fboemer/fboemer/hexl-v1.2.0
Update to HEXL version 1.2.1
1 parent e966ba1 commit 747b98a

File tree

8 files changed

+30
-31
lines changed

8 files changed

+30
-31
lines changed

CMakeLists.txt

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ endif()
8484
# Required files and directories
8585
include(GNUInstallDirs)
8686

87+
# Runtime path setup
88+
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
89+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
90+
8791
# Source Tree
8892
set(SEAL_INCLUDES_DIR ${CMAKE_CURRENT_LIST_DIR}/native/src)
8993
set(SEAL_THIRDPARTY_DIR ${CMAKE_CURRENT_LIST_DIR}/thirdparty)
@@ -219,9 +223,9 @@ if(SEAL_USE_INTEL_HEXL)
219223
message(STATUS "Intel HEXL: download ...")
220224
seal_fetch_thirdparty_content(ExternalIntelHEXL)
221225
else()
222-
find_package(HEXL 1.1.0)
226+
find_package(HEXL 1.2.1)
223227
if (NOT TARGET HEXL::hexl)
224-
FATAL_ERROR("Intel HEXL: not found")
228+
message(FATAL_ERROR "Intel HEXL: not found")
225229
endif()
226230
endif()
227231
endif()
@@ -412,15 +416,13 @@ if(NOT BUILD_SHARED_LIBS)
412416
if(SEAL_USE_INTEL_HEXL)
413417
if(SEAL_BUILD_DEPS)
414418
add_dependencies(seal HEXL::hexl)
415-
target_include_directories(seal PUBLIC $<BUILD_INTERFACE:${hexl_SOURCE_DIR}/hexl/include>)
419+
target_include_directories(seal PUBLIC
420+
$<BUILD_INTERFACE:$<TARGET_PROPERTY:HEXL::hexl,INTERFACE_INCLUDE_DIRECTORIES>>)
416421
seal_combine_archives(seal HEXL::hexl)
422+
target_compile_options(seal PUBLIC $<TARGET_PROPERTY:HEXL::hexl,INTERFACE_COMPILE_OPTIONS>)
423+
target_link_options(seal PUBLIC $<TARGET_PROPERTY:HEXL::hexl,INTERFACE_LINK_OPTIONS>)
417424
else()
418-
target_link_libraries(seal PRIVATE HEXL::hexl)
419-
get_target_property(
420-
HEXL_INCLUDE_DIR
421-
HEXL::hexl
422-
INTERFACE_INCLUDE_DIRECTORIES)
423-
target_include_directories(seal PUBLIC ${HEXL_INCLUDE_DIR})
425+
target_link_libraries(seal PUBLIC HEXL::hexl)
424426
endif()
425427
endif()
426428

@@ -461,12 +463,12 @@ else()
461463
endif()
462464

463465
if(SEAL_USE_INTEL_HEXL)
464-
get_target_property(
465-
HEXL_INCLUDE_DIR
466-
HEXL::hexl
467-
INTERFACE_INCLUDE_DIRECTORIES)
468-
target_include_directories(seal_shared PUBLIC ${HEXL_INCLUDE_DIR})
469-
target_link_libraries(seal_shared PRIVATE HEXL::hexl)
466+
target_link_libraries(seal_shared PUBLIC HEXL::hexl)
467+
# Install shared HEXL library to installation directory
468+
install(DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
469+
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_LIBRARY_PREFIX}
470+
FILES_MATCHING PATTERN "*hexl*"
471+
)
470472
endif()
471473
endif()
472474

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ The optional dependencies and their tested versions (other versions may work as
116116

117117
| Optional dependency | Tested version | Use |
118118
| ------------------------------------------------------ | -------------- | ------------------------------------------------ |
119-
| [Intel HEXL](https://github.com/intel/hexl) | 1.1.0 | Acceleration of low-level kernels |
119+
| [Intel HEXL](https://github.com/intel/hexl) | 1.2.1 | Acceleration of low-level kernels |
120120
| [Microsoft GSL](https://github.com/microsoft/GSL) | 3.1.0 | API extensions |
121121
| [ZLIB](https://github.com/madler/zlib) | 1.2.11 | Compressed serialization |
122122
| [Zstandard](https://github.com/facebook/zstd) | 1.4.5 | Compressed serialization (much faster than ZLIB) |

cmake/ExternalIntelHEXL.cmake

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,19 @@ FetchContent_Declare(
55
hexl
66
PREFIX hexl
77
GIT_REPOSITORY https://github.com/intel/hexl
8-
GIT_TAG 2dc1db # v1.1.0
8+
GIT_TAG df6c26f # 1.2.1
99
)
1010
FetchContent_GetProperties(hexl)
1111

1212
if(NOT hexl_POPULATED)
1313
FetchContent_Populate(hexl)
14-
set(HEXL_DEBUG OFF) # Set to ON/OFF to toggle debugging
15-
1614
set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING "" FORCE)
1715
set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING "" FORCE)
1816
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "" FORCE)
19-
set(HEXL_DEBUG ${HEXL_DEBUG} CACHE BOOL "" FORCE)
2017
set(HEXL_BENCHMARK OFF CACHE BOOL "" FORCE)
21-
set(HEXL_EXPORT OFF CACHE BOOL "" FORCE)
2218
set(HEXL_COVERAGE OFF CACHE BOOL "" FORCE)
2319
set(HEXL_TESTING OFF CACHE BOOL "" FORCE)
24-
set(HEXL_SHARED_LIB OFF CACHE BOOL "" FORCE)
20+
set(HEXL_SHARED_LIB ${BUILD_SHARED_LIBS} CACHE BOOL "" FORCE)
2521
set(EXCLUDE_FROM_ALL TRUE)
2622

2723
mark_as_advanced(BUILD_HEXL)

native/src/seal/evaluator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ namespace seal
522522
// x = (x[0] * y[0], x[0] * y[1] + x[1] * y[0], x[1] * y[1])
523523
// with appropriate modular reduction
524524
SEAL_ITERATE(coeff_modulus, coeff_modulus_size, [&](auto I) {
525-
SEAL_ITERATE(iter(size_t(0)), num_tiles, [&](auto J) {
525+
SEAL_ITERATE(iter(size_t(0)), num_tiles, [&](SEAL_MAYBE_UNUSED auto J) {
526526
// Compute third output polynomial, overwriting input
527527
// x[2] = x[1] * y[1]
528528
dyadic_product_coeffmod(

native/src/seal/serialization.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ namespace seal
223223

224224
streamoff Serialization::Save(
225225
function<void(ostream &)> save_members, streamoff raw_size, ostream &stream, compr_mode_type compr_mode,
226-
bool clear_buffers)
226+
SEAL_MAYBE_UNUSED bool clear_buffers)
227227
{
228228
if (!save_members)
229229
{
@@ -339,7 +339,7 @@ namespace seal
339339
}
340340

341341
streamoff Serialization::Load(
342-
function<void(istream &, SEALVersion)> load_members, istream &stream, bool clear_buffers)
342+
function<void(istream &, SEALVersion)> load_members, istream &stream, SEAL_MAYBE_UNUSED bool clear_buffers)
343343
{
344344
if (!load_members)
345345
{

native/src/seal/util/intel_seal_ext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace intel
1616
{
1717
namespace seal_ext
1818
{
19-
hexl::NTT get_ntt(size_t N, uint64_t modulus, uint64_t root)
19+
intel::hexl::NTT &get_ntt(size_t N, uint64_t modulus, uint64_t root)
2020
{
2121
static unordered_map<pair<uint64_t, uint64_t>, hexl::NTT, HashPair> ntt_cache_;
2222

native/src/seal/util/intel_seal_ext.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ namespace intel
3535
return cache_.back().get();
3636
}
3737

38-
void deallocate_impl(void *p, std::size_t n)
38+
void deallocate_impl(void *p, SEAL_MAYBE_UNUSED std::size_t n)
3939
{
40-
(void)n;
4140
auto it = std::remove_if(
4241
cache_.begin(), cache_.end(),
4342
[p](const seal::util::Pointer<seal::seal_byte> &seal_pointer) { return p == seal_pointer.get(); });
@@ -97,9 +96,8 @@ namespace intel
9796
}
9897
}
9998

100-
void deallocate_impl(void *p, std::size_t n)
99+
void deallocate_impl(void *p, SEAL_MAYBE_UNUSED std::size_t n)
101100
{
102-
(void)n;
103101
{
104102
// to prevent inline optimization with deadlock
105103
auto accessor = policy_.locker();
@@ -151,7 +149,7 @@ namespace intel
151149
@param[in] modulus The modulus
152150
@param[in] root The root of unity
153151
*/
154-
hexl::NTT get_ntt(std::size_t N, std::uint64_t modulus, std::uint64_t root);
152+
intel::hexl::NTT &get_ntt(size_t N, uint64_t modulus, uint64_t root);
155153

156154
/**
157155
Computes the forward negacyclic NTT from the given parameters.

native/tests/seal/util/rns.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,8 @@ namespace sealtest
875875
}
876876

877877
// The size of Bsk is 2. Both values here are multiples of 35 (i.e., q).
878+
// Skip tests exceeding input bound when using HEXL in DEBUG mode
879+
#if !defined(SEAL_DEBUG) || !defined(SEAL_USE_INTEL_HEXL)
878880
in[0] = 35;
879881
in[1] = 70;
880882
in[2] = 35;
@@ -896,6 +898,7 @@ namespace sealtest
896898
rns_tool->decrypt_scale_and_round(in_iter, out_iter, pool);
897899
ASSERT_EQ(2ULL, out[0]);
898900
ASSERT_EQ(0ULL, out[1]);
901+
#endif
899902
}
900903

901904
TEST(RNSToolTest, DivideAndRoundQLastInplace)

0 commit comments

Comments
 (0)