Skip to content

Commit 25fd8a9

Browse files
authored
Fboemer/windows avx512 (#23)
* Fix Windows compilation
1 parent f4c7dcc commit 25fd8a9

File tree

6 files changed

+48
-14
lines changed

6 files changed

+48
-14
lines changed

README.md

+32-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Intel:registered: HEXL is an open-source library which provides efficient implem
99
- [Dependencies](#dependencies)
1010
- [Compile-time options](#compile-time-options)
1111
- [Compiling Intel HEXL](#compiling-intel-hexl)
12+
- [Linux and Mac](#linux-and-mac)
13+
- [Windows](#windows)
1214
- [Testing Intel HEXL](#testing-intel-hexl)
1315
- [Benchmarking Intel HEXL](#benchmarking-intel-hexl)
1416
- [Using Intel HEXL](#using-intel-hexl)
@@ -18,7 +20,7 @@ Intel:registered: HEXL is an open-source library which provides efficient implem
1820
- [Documentation](#documentation)
1921
- [Contributing](#contributing)
2022
- [Repository layout](#repository-layout)
21-
- [Citing Intel HEXL](#citing-intel-hexl)
23+
- [Citing Intel HEXL](#citing-intel-hexl)
2224
- [Version 1.2](#version-12)
2325
- [Version 1.1](#version-11)
2426
- [Version 1.0](#version-10)
@@ -74,9 +76,11 @@ For convenience, they are listed below:
7476
| HEXL_TREAT_WARNING_AS_ERROR | ON / OFF (default OFF) | Set to ON to treat all warnings as error |
7577

7678
### Compiling Intel HEXL
77-
The instructions to build Intel HEXL are common between Linux, MacOS, and Windows.
79+
To compile Intel HEXL from source code, first clone the repository and change directories to the where the source has been cloned.
80+
#### Linux and Mac
81+
The instructions to build Intel HEXL are common to Linux and MacOS.
7882

79-
To compile Intel HEXL from source code, first clone the repository into your current directory. Then, to configure the build, call
83+
Then, to configure the build, call
8084
```bash
8185
cmake -S . -B build
8286
```
@@ -99,6 +103,30 @@ To use a non-standard installation directory, configure the build with
99103
```bash
100104
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/path/to/install
101105
```
106+
before proceeding with the build and installation directions above.
107+
108+
#### Windows
109+
To compile Intel HEXL on Windows using Visual Studio in Release mode, configure the build via
110+
```bash
111+
cmake -S . -B build -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release
112+
```
113+
adding the desired compile-time options with a `-D` flag (see [Compile-time options](#compile-time-options)).
114+
115+
To specify the desired build configuration, pass either `--config Debug` or `--config Release` to the build step and install steps. For instance, to build Intel HEXL in Release mode, call
116+
```bash
117+
cmake --build build --config Release
118+
```
119+
This will build the Intel HEXL library in the `build/hexl/lib/` or `build/hexl/Release/lib` directory.
120+
121+
To install Intel HEXL to the installation directory, run
122+
```bash
123+
cmake --build build --target install --config Release
124+
```
125+
To use a non-standard installation directory, configure the build with
126+
```bash
127+
cmake -S . -B build -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install
128+
```
129+
before proceeding with the build and installation directions above.
102130

103131
## Testing Intel HEXL
104132
To run a set of unit tests via Googletest, configure and build Intel HEXL with `-DHEXL_TESTING=ON` (see [Compile-time options](#compile-time-options)).
@@ -119,7 +147,7 @@ The benchmark executable itself is located at `build/benchmark/bench_hexl`
119147
The `example` folder has an example of using Intel HEXL in a third-party project.
120148

121149
## Debugging
122-
For optimal performance, Intel HEXL does not perform input validation. In many cases the time required for the validation would be longer than the execution of the function itself. To debug Intel HEXL, configure and build Intel HEXL with `-DCMAKE_BUILD_TYPE=Debug` (see [Compile-time options](#compile-time-options)). This will generate a debug version of the library, e.g. `libhexl.a`, that can be used to debug the execution.
150+
For optimal performance, Intel HEXL does not perform input validation. In many cases the time required for the validation would be longer than the execution of the function itself. To debug Intel HEXL, configure and build Intel HEXL with `-DCMAKE_BUILD_TYPE=Debug` (see [Compile-time options](#compile-time-options)). This will generate a debug version of the library, e.g. `libhexl_debug.a`, that can be used to debug the execution. In Debug mode, Intel HEXL will also link against [Address Sanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer).
123151

124152
**Note**, enabling `CMAKE_BUILD_TYPE=Debug` will result in a significant runtime overhead.
125153
## Threading

benchmark/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@ endif()
2727
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
2828
target_compile_options(bench_hexl PRIVATE -Wall -Wextra -march=native -O3)
2929
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
30-
target_compile_options(bench_hexl PRIVATE /Wall /W4 /Zc:preprocessor)
30+
target_compile_options(bench_hexl PRIVATE /Wall /W4 /Zc:preprocessor
31+
/wd4127 # warning C4127: conditional expression is constant; C++11 doesn't support constexpr
32+
)
3133
endif()

hexl/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
7878
# so we disable it here
7979
target_compile_options(hexl PRIVATE /Wall /W4 /Zc:preprocessor /Ob0
8080
/wd4127 # warning C4127: conditional expression is constant; C++11 doesn't support constexpr
81-
)
81+
)
8282
target_compile_definitions(hexl PRIVATE -D_CRT_SECURE_NO_WARNINGS)
8383
endif()
8484

hexl/ntt/fwd-ntt-avx512.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ void ForwardTransformToBitReverseAVX512(
372372
} else {
373373
// Perform depth-first NTT via recursive call
374374
size_t t = (n >> 1);
375-
size_t W_idx = (1 << recursion_depth) + recursion_half;
375+
size_t W_idx = (1ULL << recursion_depth) + recursion_half;
376376
const uint64_t* W_op = &root_of_unity_powers[W_idx];
377377
const uint64_t* W_precon = &precon_root_of_unity_powers[W_idx];
378378

hexl/ntt/inv-ntt-avx512.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ template void InverseTransformFromBitReverseAVX512<NTT::s_ifma_shift_bits>(
2323
uint64_t* operand, uint64_t degree, uint64_t modulus,
2424
const uint64_t* inv_root_of_unity_powers,
2525
const uint64_t* precon_inv_root_of_unity_powers, uint64_t input_mod_factor,
26-
uint64_t output_mod_factor, uint64_t recursion_depth = 0,
27-
uint64_t recursion_half = 0);
26+
uint64_t output_mod_factor, uint64_t recursion_depth,
27+
uint64_t recursion_half);
2828
#endif
2929

3030
#ifdef HEXL_HAS_AVX512DQ
3131
template void InverseTransformFromBitReverseAVX512<32>(
3232
uint64_t* operand, uint64_t degree, uint64_t modulus,
3333
const uint64_t* inv_root_of_unity_powers,
3434
const uint64_t* precon_inv_root_of_unity_powers, uint64_t input_mod_factor,
35-
uint64_t output_mod_factor, uint64_t recursion_depth = 0,
36-
uint64_t recursion_half = 0);
35+
uint64_t output_mod_factor, uint64_t recursion_depth,
36+
uint64_t recursion_half);
3737

3838
template void InverseTransformFromBitReverseAVX512<NTT::s_default_shift_bits>(
3939
uint64_t* operand, uint64_t degree, uint64_t modulus,
4040
const uint64_t* inv_root_of_unity_powers,
4141
const uint64_t* precon_inv_root_of_unity_powers, uint64_t input_mod_factor,
42-
uint64_t output_mod_factor, uint64_t recursion_depth = 0,
43-
uint64_t recursion_half = 0);
42+
uint64_t output_mod_factor, uint64_t recursion_depth,
43+
uint64_t recursion_half);
4444
#endif
4545

4646
#ifdef HEXL_HAS_AVX512DQ

test/CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
3838
target_link_libraries(unit-test PRIVATE gflags)
3939
endif()
4040
# Disable inline, due to incorect optimization in ExtractValues, causing failing tests in Windows AVX512 in Release mode with HEXL_DEBUG=OFF
41-
target_compile_options(unit-test PRIVATE /Wall /W4 /Zc:preprocessor /Ob0)
41+
target_compile_options(unit-test PRIVATE /Wall /W4 /Zc:preprocessor /Ob0
42+
/wd4127 # warning C4127: conditional expression is constant; C++11 doesn't support constexpr
43+
/wd4389 # warning C4389: signed/unsigned mismatch from gtest
44+
)
45+
target_compile_definitions(unit-test PRIVATE -D_CRT_SECURE_NO_WARNINGS)
4246
endif()
4347

4448
target_include_directories(unit-test PRIVATE

0 commit comments

Comments
 (0)