Skip to content

Commit 7a4e6b7

Browse files
committed
added -ffast math compiler option
1 parent 152cda2 commit 7a4e6b7

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ option(SAF_USE_INTEL_IPP "Use Intel IPP for the FFT, resampler, etc.
1515
option(SAF_USE_FFTW "Use FFTW3 for the FFT." OFF)
1616
option(SAF_ENABLE_SIMD "Enable the use of SSE3, AVX2, AVX512" OFF)
1717
option(SAF_ENABLE_NETCDF "Enable netcdf for the sofa reader module" OFF)
18+
option(SAF_USE_FAST_MATH_FLAG "Enable -ffast-math compiler flag" ON)
1819
if (NOT SAF_PERFORMANCE_LIB)
1920
set(SAF_PERFORMANCE_LIB "SAF_USE_INTEL_MKL_LP64" CACHE STRING "Performance library for SAF to use.")
2021
endif()

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ The available SAF-related CMake options (and their default values) are:
9898
-DSAF_BUILD_TESTS=1 # build unit testing program
9999
-DSAF_USE_INTEL_IPP=0 # link and use Intel IPP for the FFT, resampler, etc.
100100
-DSAF_ENABLE_SIMD=0 # enable/disable SSE, AVX, and/or AVX-512 support
101+
-DSAF_USE_FAST_MATH_FLAG=1 # enable the -ffast-math compiler flag on clang/gcc
101102
```
102103

103104
If using e.g. **SAF_USE_INTEL_MKL_LP64** as the performance library, note that the default header and library search paths may be overridden [according to your setup](docs/PERFORMANCE_LIBRARY_INSTRUCTIONS.md) with:

framework/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,15 @@ endif()
357357

358358

359359
############################################################################
360+
# Extra compiler flags
360361
if(UNIX)
361362
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra)
362363
endif()
364+
if(SAF_USE_FAST_MATH_FLAG)
365+
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU"))
366+
add_compile_options(-ffast-math)
367+
endif()
368+
endif()
363369

364370

365371
############################################################################

0 commit comments

Comments
 (0)