Skip to content

Commit 405fbc1

Browse files
committed
optimized compiler flags, spreader is now fast as GCC-13 with other compilers
1 parent a448697 commit 405fbc1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

CMakeLists.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,27 @@ project(finufft VERSION 2.2.0 LANGUAGES C CXX)
44

55
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
66

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

0 commit comments

Comments
 (0)