Skip to content

Commit

Permalink
optimized compiler flags, spreader is now fast as GCC-13 with other c…
Browse files Browse the repository at this point in the history
…ompilers
  • Loading branch information
DiamonDinoia committed Jun 29, 2024
1 parent a448697 commit 405fbc1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,27 @@ project(finufft VERSION 2.2.0 LANGUAGES C CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)


set(GNU_LIKE_FRONTENDS AppleClang Clang GNU)
if (CMAKE_CXX_COMPILER_ID IN_LIST GNU_LIKE_FRONTENDS)
# Set custom compiler flags for gcc-compatible compilers
set(FINUFFT_CXX_FLAGS_RELEASE -O3 -funroll-loops -ffp-contract=fast)
set(FINUFFT_CXX_FLAGS_RELEASE -O3
-funroll-loops
-ffp-contract=fast
-fexcess-precision=fast
-fno-math-errno
-fno-signed-zeros
-fno-trapping-math
-fassociative-math
-freciprocal-math
# These flags make the spreader 20% faster in 2D and up to 100% faster in 3D with no loss of accuracy.
# Why no -fast-math or -funsafe-math-optimizations ?
# It breaks the code, and influences other software that depend on finufft bu changing the rounding mode.
# GCC-13 recently fixed this issue:
# https://github.com/llvm/llvm-project/issues/57589
# https://gcc.gnu.org/gcc-13/changes.html
# https://trofi.github.io/posts/302-Ofast-and-ffast-math-non-local-effects.html
)
set(FINUFFT_CXX_FLAGS_RELWITHDEBINFO -g ${FINUFFT_CXX_FLAGS_RELEASE})
endif ()

Expand Down

0 comments on commit 405fbc1

Please sign in to comment.