Skip to content
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

Option for SIMD compilation #29

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ option(PYTHON_BINDING_USER_INSTALL "Install the Python bindings in user space" O
option(PYTHON_BINDING_FORCE_PYTHON3 "Use pip3/python3 instead of pip/python" OFF)
option(DISABLE_TESTS "Disable unit tests." OFF)
option(BENCHMARKS "Generate benchmark." OFF)
option(ENABLE_SIMD "Build with all SIMD instructions on the current local machine" OFF)

SET(Eigen_REQUIRED "eigen3 >= 3.2.0")
SEARCH_FOR_EIGEN()
Expand Down
16 changes: 16 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ set(HEADERS SpaceVecAlg/MotionVec.h
# !!! Don't link against it !!!
add_library(SpaceVecAlg ${SOURCES} ${HEADERS})

if(ENABLE_SIMD)
if(MSVC)
target_compile_options(SpaceVecAlg PUBLIC /arch:SSE2 /arch:AVX /arch:AVX2)
elseif(CMAKE_COMPILER_IS_GNUCXX)
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpfullversion -dumpversion OUTPUT_VARIABLE GCC_VERSION)
set(CXX_COMPILER_VERSION ${GCC_VERSION})
target_compile_options(SpaceVecAlg PUBLIC -march=native)
if(GCC_VERSION VERSION_GREATER 7.0)
target_compile_options(SpaceVecAlg PUBLIC -faligned-new)
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
target_compile_options(SpaceVecAlg PUBLIC -march=native -faligned-new)
endif()
endif()

if(DEFINED Eigen_INCLUDE_DIR)
target_include_directories(SpaceVecAlg SYSTEM INTERFACE "${Eigen_INCLUDE_DIR}")
else()
Expand Down