From 8ed121cfe6d8d423200a1a6fdd428d0d94d45886 Mon Sep 17 00:00:00 2001 From: Max Luebke Date: Tue, 5 Apr 2022 20:17:50 +0200 Subject: [PATCH 1/4] Define new build type 'GenericOpt' --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fe7fb6..bc7e476 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,5 +10,13 @@ find_package(OpenMP) option(USE_OPENMP "Compile with OpenMP support" ON) +set(CMAKE_CXX_FLAGS_GENERICOPT "-O3 -march=native" CACHE STRING + "Flags used by the C++ compiler during opt builds." + FORCE) + +set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel GenericOpt." + FORCE) + add_subdirectory(app) add_subdirectory(src) From f0d680ea55e01c1e310bd48c24868a87fa69d606 Mon Sep 17 00:00:00 2001 From: Max Luebke Date: Tue, 5 Apr 2022 20:47:09 +0200 Subject: [PATCH 2/4] Added `ffast-math` to Options --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc7e476..cb7a12b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ find_package(OpenMP) option(USE_OPENMP "Compile with OpenMP support" ON) -set(CMAKE_CXX_FLAGS_GENERICOPT "-O3 -march=native" CACHE STRING +set(CMAKE_CXX_FLAGS_GENERICOPT "-O3 -march=native -ffast-math" CACHE STRING "Flags used by the C++ compiler during opt builds." FORCE) From 007bade8898334c21fbdeaf82ece0b81b6947a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Wed, 6 Apr 2022 09:49:31 +0200 Subject: [PATCH 3/4] Revert "Added `ffast-math` to Options" This reverts commit f0d680ea55e01c1e310bd48c24868a87fa69d606 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb7a12b..bc7e476 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ find_package(OpenMP) option(USE_OPENMP "Compile with OpenMP support" ON) -set(CMAKE_CXX_FLAGS_GENERICOPT "-O3 -march=native -ffast-math" CACHE STRING +set(CMAKE_CXX_FLAGS_GENERICOPT "-O3 -march=native" CACHE STRING "Flags used by the C++ compiler during opt builds." FORCE) From 90b4d1b6af524463553eb580def01e755de61fa6 Mon Sep 17 00:00:00 2001 From: Max Luebke Date: Wed, 6 Apr 2022 10:08:45 +0200 Subject: [PATCH 4/4] Define option to toggle '-ffast-math' --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb7a12b..c7a8a8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,5 +18,15 @@ set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel GenericOpt." FORCE) +option(USE_UNSAFE_MATH_OPT + "Use compiler options to break IEEE compliances by + oenabling reordering of instructions when adding/multiplying of floating + points." + OFF) + +if(USE_UNSAFE_MATH_OPT) + add_compile_options(-ffast-math) +endif() + add_subdirectory(app) add_subdirectory(src)