Skip to content

Conversation

@aminya
Copy link
Contributor

@aminya aminya commented Sep 7, 2024

MSVC doesn't have -march=native option 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.

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__)
Copy link
Owner

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.

Copy link
Owner

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"
Copy link
Owner

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?

Copy link
Owner

@lemire lemire left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants