-
Notifications
You must be signed in to change notification settings - Fork 15
fix: assume AVX2 support on MSVC #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC") | ||
| message(STATUS "Assuming AVX2, SSE4.2, SSE4.1 support on MSVC") | ||
| target_compile_options(despacer PRIVATE /arch:AVX2) | ||
| target_compile_definitions(despacer PRIVATE __SSE4_1__ __SSE4_2__ __AVX2__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the Microsoft documentation:
The __AVX__ preprocessor symbol is defined when the /arch:AVX, /arch:AVX2 or /arch:AVX512 compiler option is specified. The __AVX2__ preprocessor symbol is defined when the /arch:AVX2 or /arch:AVX512 compiler option is specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather that the macros starting with _ not be manually set. Let the compiler do it.
|
|
||
| preBuildCommands "cmake -S ./ -B ./build && cmake --build ./build --config Release" | ||
| preBuildCommands "cmake -S ./ -B ./build -DBENCHMARKS=OFF -DUNIT_TESTS=OFF && cmake --build ./build --config Release" platform="posix" | ||
| preBuildCommands "cmake -G \"Ninja Multi-Config\" -S ./ -B ./build -DBENCHMARKS=OFF -DUNIT_TESTS=OFF && cmake --build ./build --config Release" platform="windows" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we assuming that Ninja is available and used?
lemire
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is fine to enable AVX2 under Visual Studio when under x64, but I do not think we should be setting manually the feature macros (__AVX2__). It is likely buying us technical debt.
MSVC doesn't have
-march=nativeoption so all the definitions are ignored resulting in no SIMD being used. This assumes that AVX2 is supported, which is a good compromise until runtime checking is implemented.