From b93ee30ab53b7b73f79ddf21626777219efa4664 Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Wed, 24 Apr 2024 13:29:26 -0400 Subject: [PATCH] Enable non-finite values with Intel compiler The Intel compiler by default turns on an optimization that assumes that all floating point values are finite. This breaks any ligitimate uses of non-finite values including checking values with functions like `isnan` and `isinf`. Turn off this feature for the intel compiler. --- CMake/VTKmCompilerFlags.cmake | 13 +++++++++++++ docs/changelog/intel-finites.md | 6 ++++++ 2 files changed, 19 insertions(+) create mode 100644 docs/changelog/intel-finites.md diff --git a/CMake/VTKmCompilerFlags.cmake b/CMake/VTKmCompilerFlags.cmake index 2a7f4841f..b9be52053 100644 --- a/CMake/VTKmCompilerFlags.cmake +++ b/CMake/VTKmCompilerFlags.cmake @@ -90,6 +90,19 @@ set_target_properties( EXPORT_NAME developer_flags ) +# Intel OneAPI compilers >= 2021.2.0 turn on "fast math" at any non-zero +# optimization level. Suppress this non-standard behavior using the +# `-fp-model=precise` flag. +set(intel_oneapi_compiler_version_min "2021.2.0") +set(is_lang "$") +set(is_intelllvm "$") +set(is_intelllvm_fastmath_assuming_version "$,${intel_oneapi_compiler_version_min}>") +set(intel_oneapi_compiler_detections + "$") +target_compile_options(vtkm_developer_flags + INTERFACE + "$>") + # Additional warnings just for Clang 3.5+, and AppleClang 7+ # about failures to vectorize. if (VTKM_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.4) diff --git a/docs/changelog/intel-finites.md b/docs/changelog/intel-finites.md new file mode 100644 index 000000000..0b2128839 --- /dev/null +++ b/docs/changelog/intel-finites.md @@ -0,0 +1,6 @@ +# Enable non-finite values with Intel compiler + +The Intel compiler by default turns on an optimization that assumes that +all floating point values are finite. This breaks any ligitimate uses of +non-finite values including checking values with functions like `isnan` +and `isinf`. Turn off this feature for the intel compiler.