Skip to content

Commit

Permalink
refactor optimization flags
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber committed Oct 6, 2021
1 parent 9e63caa commit 94946cf
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 94 deletions.
19 changes: 4 additions & 15 deletions examples/alpaka/nbody/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,8 @@ alpaka_add_executable(${PROJECT_NAME} nbody.cpp ../../common/Stopwatch.hpp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
target_link_libraries(${PROJECT_NAME} PRIVATE llama::llama alpaka::alpaka Vc::Vc)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(${PROJECT_NAME} PRIVATE
#-fno-math-errno # sqrt prevents vectorization otherwise
-march=native
-ffast-math
)
elseif(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE
/arch:AVX2
/fp:fast
)
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /arch:AVX2 /fp:fast)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -march=native -ffast-math)
endif()
13 changes: 3 additions & 10 deletions examples/alpaka/pic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
target_link_libraries(${PROJECT_NAME} PRIVATE llama::llama fmt::fmt alpaka::alpaka OpenMP::OpenMP_CXX)

if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE
/arch:AVX2
/fp:fast
)
elseif()
target_compile_options(${PROJECT_NAME} PRIVATE
#-fno-math-errno # sqrt prevents vectorization otherwise
-march=native
-ffast-math
)
target_compile_options(${PROJECT_NAME} PRIVATE /arch:AVX2 /fp:fast)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -march=native -ffast-math)
endif()
16 changes: 3 additions & 13 deletions examples/heatequation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,8 @@ if (Vc_FOUND)
target_link_libraries(${PROJECT_NAME} PRIVATE Vc::Vc)
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(${PROJECT_NAME} PRIVATE
-march=native
-ffast-math
)
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /arch:AVX2 /fp:fast)
elseif(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE
/arch:AVX2
/fp:fast
)
target_compile_options(${PROJECT_NAME} PRIVATE -march=native -ffast-math)
endif()
19 changes: 4 additions & 15 deletions examples/nbody/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,8 @@ if (Vc_FOUND)
target_link_libraries(${PROJECT_NAME} PRIVATE Vc::Vc)
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(${PROJECT_NAME} PRIVATE
#-fno-math-errno # sqrt prevents vectorization otherwise
-march=native
-ffast-math
)
elseif(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE
/arch:AVX2
/fp:fast
)
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /arch:AVX2 /fp:fast)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -march=native -ffast-math)
endif()
18 changes: 3 additions & 15 deletions examples/nbody_benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,8 @@ add_executable(${PROJECT_NAME} nbody.cpp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
target_link_libraries(${PROJECT_NAME} PRIVATE llama::llama fmt::fmt)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(${PROJECT_NAME} PRIVATE
#-fno-math-errno # sqrt prevents vectorization otherwise
-march=native
-ffast-math
)
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /arch:AVX2 /fp:fast /bigobj)
elseif(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE
/arch:AVX2
/fp:fast
/bigobj
)
target_compile_options(${PROJECT_NAME} PRIVATE -march=native -ffast-math)
endif()
6 changes: 6 additions & 0 deletions examples/raycast/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ add_executable(${PROJECT_NAME} raycast.cpp)
target_include_directories(${PROJECT_NAME} PRIVATE ../../thirdparty/stb/include)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
target_link_libraries(${PROJECT_NAME} PRIVATE tinyobjloader::tinyobjloader llama::llama)

if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /arch:AVX2 /fp:fast)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -march=native -ffast-math)
endif()
18 changes: 4 additions & 14 deletions examples/vectoradd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,8 @@ add_executable(${PROJECT_NAME} vectoradd.cpp ../common/Stopwatch.hpp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
target_link_libraries(${PROJECT_NAME} PRIVATE llama::llama)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(${PROJECT_NAME} PRIVATE
-march=native
-ffast-math
)
elseif(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE
/arch:AVX2
/fp:fast
)
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /arch:AVX2 /fp:fast)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -march=native -ffast-math)
endif()
16 changes: 4 additions & 12 deletions examples/viewcopy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,8 @@ add_executable(${PROJECT_NAME} viewcopy.cpp ../common/Stopwatch.hpp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
target_link_libraries(${PROJECT_NAME} PRIVATE llama::llama OpenMP::OpenMP_CXX)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(${PROJECT_NAME} PRIVATE
-march=native
)
elseif(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE
/arch:AVX2
)
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /arch:AVX2)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -march=native)
endif()

0 comments on commit 94946cf

Please sign in to comment.