Skip to content

Commit

Permalink
added -ffast math compiler option
Browse files Browse the repository at this point in the history
  • Loading branch information
leomccormack committed Apr 2, 2022
1 parent 152cda2 commit 7a4e6b7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ option(SAF_USE_INTEL_IPP "Use Intel IPP for the FFT, resampler, etc.
option(SAF_USE_FFTW "Use FFTW3 for the FFT." OFF)
option(SAF_ENABLE_SIMD "Enable the use of SSE3, AVX2, AVX512" OFF)
option(SAF_ENABLE_NETCDF "Enable netcdf for the sofa reader module" OFF)
option(SAF_USE_FAST_MATH_FLAG "Enable -ffast-math compiler flag" ON)
if (NOT SAF_PERFORMANCE_LIB)
set(SAF_PERFORMANCE_LIB "SAF_USE_INTEL_MKL_LP64" CACHE STRING "Performance library for SAF to use.")
endif()
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ The available SAF-related CMake options (and their default values) are:
-DSAF_BUILD_TESTS=1 # build unit testing program
-DSAF_USE_INTEL_IPP=0 # link and use Intel IPP for the FFT, resampler, etc.
-DSAF_ENABLE_SIMD=0 # enable/disable SSE, AVX, and/or AVX-512 support
-DSAF_USE_FAST_MATH_FLAG=1 # enable the -ffast-math compiler flag on clang/gcc
```

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:
Expand Down
6 changes: 6 additions & 0 deletions framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,15 @@ endif()


############################################################################
# Extra compiler flags
if(UNIX)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra)
endif()
if(SAF_USE_FAST_MATH_FLAG)
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU"))
add_compile_options(-ffast-math)
endif()
endif()


############################################################################
Expand Down

0 comments on commit 7a4e6b7

Please sign in to comment.