diff --git a/host-configs/LLNL/lassen-clang@upstream.cmake b/host-configs/LLNL/lassen-clang@upstream.cmake index d76474db..1aa38e94 100644 --- a/host-configs/LLNL/lassen-clang@upstream.cmake +++ b/host-configs/LLNL/lassen-clang@upstream.cmake @@ -2,7 +2,7 @@ set(CONFIG_NAME "lassen-clang@upstream" CACHE PATH "") # Set up the tpls set(GEOSX_TPL_ROOT_DIR /usr/gapps/GEOSX/thirdPartyLibs CACHE PATH "") -set(GEOSX_TPL_DIR ${GEOSX_TPL_ROOT_DIR}/2020-08-05/install-${CONFIG_NAME}-release CACHE PATH "") +set(GEOSX_TPL_DIR ${GEOSX_TPL_ROOT_DIR}/2020-09-18/install-${CONFIG_NAME}-release CACHE PATH "") set(ENABLE_UMPIRE ON CACHE BOOL "") set(ENABLE_CHAI ON CACHE BOOL "") diff --git a/host-configs/LLNL/lassen-gcc@8.3.1.cmake b/host-configs/LLNL/lassen-gcc@8.3.1.cmake index e7b695e4..b20086a7 100644 --- a/host-configs/LLNL/lassen-gcc@8.3.1.cmake +++ b/host-configs/LLNL/lassen-gcc@8.3.1.cmake @@ -3,7 +3,7 @@ set(CONFIG_NAME "lassen-gcc@8.3.1" CACHE PATH "") # Set up the tpls # These were probably built with clang (no guarantee that they would work) set(GEOSX_TPL_ROOT_DIR /usr/gapps/GEOSX/thirdPartyLibs CACHE PATH "") -set(GEOSX_TPL_DIR ${GEOSX_TPL_ROOT_DIR}/2020-08-05/install-${CONFIG_NAME}-release CACHE PATH "") +set(GEOSX_TPL_DIR ${GEOSX_TPL_ROOT_DIR}/2020-09-18/install-${CONFIG_NAME}-release CACHE PATH "") set(ENABLE_UMPIRE ON CACHE BOOL "") set(ENABLE_CHAI ON CACHE BOOL "") diff --git a/host-configs/LLNL/quartz-base.cmake b/host-configs/LLNL/quartz-base.cmake index 4b3498aa..834c7ee9 100644 --- a/host-configs/LLNL/quartz-base.cmake +++ b/host-configs/LLNL/quartz-base.cmake @@ -23,7 +23,7 @@ set(MPIEXEC /usr/bin/srun CACHE PATH "") set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "") set(GEOSX_TPL_ROOT_DIR /usr/gapps/GEOSX/thirdPartyLibs CACHE PATH "") -set(GEOSX_TPL_DIR ${GEOSX_TPL_ROOT_DIR}/2020-08-05/install-${CONFIG_NAME}-release CACHE PATH "") +set(GEOSX_TPL_DIR ${GEOSX_TPL_ROOT_DIR}/2020-09-18/install-${CONFIG_NAME}-release CACHE PATH "") set(ENABLE_UMPIRE ON CACHE BOOL "") set(ENABLE_CHAI ON CACHE BOOL "") diff --git a/src/system.cpp b/src/system.cpp index 7accf235..6d41ca3c 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -506,6 +506,11 @@ void resetSignalHandling() } } +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +int getDefaultFloatingPointExceptions() +{ + return ( FE_DIVBYZERO | FE_OVERFLOW | FE_INVALID ); +} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int enableFloatingPointExceptions( int const exceptions ) @@ -515,14 +520,13 @@ int enableFloatingPointExceptions( int const exceptions ) // http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c static fenv_t fenv; int const newExcepts = exceptions & FE_ALL_EXCEPT; - // previous masks - int oldExcepts; if( fegetenv( &fenv )) { return -1; } - oldExcepts = fenv.__control & FE_ALL_EXCEPT; + // all previous masks + int const oldExcepts = fenv.__control & FE_ALL_EXCEPT; // unmask fenv.__control &= ~newExcepts; @@ -544,14 +548,13 @@ int disableFloatingPointExceptions( int const exceptions ) // http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c static fenv_t fenv; int const newExcepts = exceptions & FE_ALL_EXCEPT; - // all previous masks - int oldExcepts; if( fegetenv( &fenv )) { return -1; } - oldExcepts = fenv.__control & FE_ALL_EXCEPT; + // all previous masks + int const oldExcepts = ~( fenv.__control & FE_ALL_EXCEPT ); // mask fenv.__control |= newExcepts; @@ -575,13 +578,9 @@ void setFPE() _MM_SET_DENORMALS_ZERO_MODE( _MM_DENORMALS_ZERO_ON ); #endif #if defined(__x86_64__) - enableFloatingPointExceptions( FE_DIVBYZERO | FE_OVERFLOW | FE_INVALID ); + enableFloatingPointExceptions( getDefaultFloatingPointExceptions() ); #endif } -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -int getAllExceptionsMask() -{ return FE_ALL_EXCEPT; } - } // namespace system } // namespace LvArray diff --git a/src/system.hpp b/src/system.hpp index 80227024..2940432e 100644 --- a/src/system.hpp +++ b/src/system.hpp @@ -82,19 +82,25 @@ void setSignalHandling( void (* handler)( int ) ); */ void resetSignalHandling(); +/** + * @brief Get the default set of exceptions to check. + * @return The default set of exceptions. + */ +int getDefaultFloatingPointExceptions(); + /** * @brief A wrapper around @c feenableexcept that work on OSX. * @param exceptions The set of floating point exceptions to enable. * @return The old exception mask or -1 if there was an error. */ -int enableFloatingPointExceptions( int const exceptions ); +int enableFloatingPointExceptions( int const exceptions = getDefaultFloatingPointExceptions() ); /** * @brief A wrapper around @c fedisableexcept that work on OSX. * @param exceptions The set of floating point exceptions to disable. * @return The old exception mask or -1 if there was an error. */ -int disableFloatingPointExceptions( int const exceptions ); +int disableFloatingPointExceptions( int const exceptions = getDefaultFloatingPointExceptions() ); /** * @brief Sets the floating point environment. @@ -114,7 +120,7 @@ class FloatingPointExceptionGuard * @brief Disable the floating point exceptions given by @p exceptions. * @param exceptions The floating point exceptions to disable. */ - FloatingPointExceptionGuard( int const exceptions ): + FloatingPointExceptionGuard( int const exceptions = getDefaultFloatingPointExceptions() ): m_previousExceptions( disableFloatingPointExceptions( exceptions ) ) {} diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index cd61ef00..06838185 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -87,6 +87,11 @@ blt_add_executable( NAME testFloatingPointExceptions OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY} DEPENDS_ON gtest lvarray ${lvarray_dependencies} ) +# Need to avoid optimization to catch invalid operations +if( APPLE AND ${CMAKE_CXX_COMPILER} MATCHES "clang" ) + set_source_files_properties( testFloatingPointExceptionsHelpers.cpp PROPERTIES COMPILE_FLAGS "-O0" ) +endif() + target_include_directories( testFloatingPointExceptions PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../src ) blt_add_test( NAME testFloatingPointExceptions