diff --git a/CHOLMOD/CMakeLists.txt b/CHOLMOD/CMakeLists.txt index c1c6aa2e50..0919d281a2 100644 --- a/CHOLMOD/CMakeLists.txt +++ b/CHOLMOD/CMakeLists.txt @@ -95,7 +95,7 @@ else ( ) set ( OpenMP_C_FOUND OFF ) endif ( ) -if ( OpenMP_C_FOUND ) +if ( CHOLMOD_USE_OPENMP AND OpenMP_C_FOUND ) set ( CHOLMOD_HAS_OPENMP ON ) else ( ) set ( CHOLMOD_HAS_OPENMP OFF ) diff --git a/GraphBLAS/CMakeLists.txt b/GraphBLAS/CMakeLists.txt index ad4d7c1cf4..0889cb19b6 100644 --- a/GraphBLAS/CMakeLists.txt +++ b/GraphBLAS/CMakeLists.txt @@ -109,7 +109,7 @@ else ( ) set ( OpenMP_C_FOUND OFF ) endif ( ) -if ( OpenMP_C_FOUND ) +if ( GRAPHBLAS_USE_OPENMP AND OpenMP_C_FOUND ) set ( GRAPHBLAS_HAS_OPENMP ON ) else ( ) set ( GRAPHBLAS_HAS_OPENMP OFF ) diff --git a/LAGraph/CMakeLists.txt b/LAGraph/CMakeLists.txt index fc212d4932..c62160797c 100644 --- a/LAGraph/CMakeLists.txt +++ b/LAGraph/CMakeLists.txt @@ -181,7 +181,7 @@ else ( ) endif ( ) endif ( ) -if ( OpenMP_C_FOUND ) +if ( LAGRAPH_USE_OPENMP AND OpenMP_C_FOUND ) set ( LAGRAPH_HAS_OPENMP ON ) else ( ) set ( LAGRAPH_HAS_OPENMP OFF ) diff --git a/LAGraph/experimental/CMakeLists.txt b/LAGraph/experimental/CMakeLists.txt index 6038808bfc..2caaa1c6d9 100644 --- a/LAGraph/experimental/CMakeLists.txt +++ b/LAGraph/experimental/CMakeLists.txt @@ -85,7 +85,7 @@ endif ( ) # add OpenMP #------------------------------------------------------------------------------- -if ( OpenMP_C_FOUND ) +if ( LAGRAPH_HAS_OPENMP ) if ( BUILD_SHARED_LIBS ) target_link_libraries ( LAGraphX PRIVATE OpenMP::OpenMP_C ) endif ( ) diff --git a/LAGraph/experimental/test/CMakeLists.txt b/LAGraph/experimental/test/CMakeLists.txt index 51f99f0987..3f72d74b9e 100644 --- a/LAGraph/experimental/test/CMakeLists.txt +++ b/LAGraph/experimental/test/CMakeLists.txt @@ -74,7 +74,7 @@ endif ( ) # add OpenMP #------------------------------------------------------------------------------- -if ( OpenMP_C_FOUND ) +if ( LAGRAPH_HAS_OPENMP ) if ( BUILD_SHARED_LIBS ) target_link_libraries ( lagraphxtest PRIVATE OpenMP::OpenMP_C ) endif ( ) diff --git a/LAGraph/src/CMakeLists.txt b/LAGraph/src/CMakeLists.txt index cb7b19aa4f..09177c73ee 100644 --- a/LAGraph/src/CMakeLists.txt +++ b/LAGraph/src/CMakeLists.txt @@ -90,7 +90,7 @@ endif ( ) # add OpenMP #------------------------------------------------------------------------------- -if ( OpenMP_C_FOUND ) +if ( LAGRAPH_HAS_OPENMP ) if ( BUILD_SHARED_LIBS ) target_link_libraries ( LAGraph PRIVATE OpenMP::OpenMP_C ) endif ( ) diff --git a/LAGraph/src/test/CMakeLists.txt b/LAGraph/src/test/CMakeLists.txt index 025b1b35ab..37e56418ae 100644 --- a/LAGraph/src/test/CMakeLists.txt +++ b/LAGraph/src/test/CMakeLists.txt @@ -76,7 +76,7 @@ endif ( ) # add OpenMP #------------------------------------------------------------------------------- -if ( OpenMP_C_FOUND ) +if ( LAGRAPH_HAS_OPENMP ) if ( BUILD_SHARED_LIBS ) target_link_libraries ( lagraphtest PRIVATE OpenMP::OpenMP_C ) endif ( ) diff --git a/README.md b/README.md index c4f9e6955d..d094551ef8 100644 --- a/README.md +++ b/README.md @@ -987,9 +987,9 @@ build type). The static libraries will not be built (since * `SUITESPARSE_USE_OPENMP`: - If `ON`, OpenMP is used if it is available. Default: `OFF`. + If `ON`, OpenMP is used by default if it is available. Default: `ON`. - GraphBLAS, LAGraph, and ParU will vastly slower if OpenMP is not used. + GraphBLAS, LAGraph, and ParU will be vastly slower if OpenMP is not used. CHOLMOD will be somewhat slower without OpenMP (as long as it still has a parallel BLAS/LAPACK). Three packages (UMFPACK, CHOLMOD, and SPQR) rely heavily on parallel BLAS/LAPACK libraries and those libraries may use OpenMP diff --git a/SuiteSparse_config/CMakeLists.txt b/SuiteSparse_config/CMakeLists.txt index 95c9cbceac..8c7933a824 100644 --- a/SuiteSparse_config/CMakeLists.txt +++ b/SuiteSparse_config/CMakeLists.txt @@ -71,7 +71,7 @@ endif ( ) #------------------------------------------------------------------------------- option ( SUITESPARSE_CONFIG_USE_OPENMP "ON: Use OpenMP in SuiteSparse_config if available. OFF: Do not use OpenMP. (Default: SUITESPARSE_USE_OPENMP)" ${SUITESPARSE_USE_OPENMP} ) -if ( SUITESPARSE_CONFIG_USE_OPENMP OR SUITESPARSE_USE_OPENMP ) +if ( SUITESPARSE_CONFIG_USE_OPENMP ) if ( CMAKE_VERSION VERSION_LESS 3.24 ) find_package ( OpenMP COMPONENTS C ) else ( ) @@ -82,20 +82,14 @@ else ( ) set ( OpenMP_C_FOUND OFF ) endif ( ) -if ( OpenMP_C_FOUND ) - set ( SUITESPARSE_HAS_OPENMP ON ) +if ( SUITESPARSE_CONFIG_USE_OPENMP AND OpenMP_C_FOUND ) set ( SUITESPARSE_CONFIG_HAS_OPENMP ON ) else ( ) - set ( SUITESPARSE_HAS_OPENMP OFF ) set ( SUITESPARSE_CONFIG_HAS_OPENMP OFF ) endif ( ) -message ( STATUS "SuiteSparse has OpenMP: ${SUITESPARSE_HAS_OPENMP}" ) message ( STATUS "SuiteSparse_config has OpenMP: ${SUITESPARSE_CONFIG_HAS_OPENMP}" ) # check for strict usage -if ( SUITESPARSE_USE_STRICT AND SUITESPARSE_USE_OPENMP AND NOT SUITESPARSE_HAS_OPENMP ) - message ( FATAL_ERROR "OpenMP required for SuiteSparse but not found" ) -endif ( ) if ( SUITESPARSE_USE_STRICT AND SUITESPARSE_CONFIG_USE_OPENMP AND NOT SUITESPARSE_CONFIG_HAS_OPENMP ) message ( FATAL_ERROR "OpenMP required for SuiteSparse_config but not found" ) endif ( ) @@ -212,7 +206,7 @@ if ( NOT NO_LIBM ) endif ( ) # OpenMP: -if ( SUITESPARSE_CONFIG_USE_OPENMP ) +if ( SUITESPARSE_CONFIG_HAS_OPENMP ) message ( STATUS "OpenMP C libraries: ${OpenMP_C_LIBRARIES} ") message ( STATUS "OpenMP C include: ${OpenMP_C_INCLUDE_DIRS} ") message ( STATUS "OpenMP C flags: ${OpenMP_C_FLAGS} ") diff --git a/SuiteSparse_config/Config/README.md.in b/SuiteSparse_config/Config/README.md.in index 152f3f3e44..7051d0554e 100644 --- a/SuiteSparse_config/Config/README.md.in +++ b/SuiteSparse_config/Config/README.md.in @@ -987,9 +987,9 @@ build type). The static libraries will not be built (since * `SUITESPARSE_USE_OPENMP`: - If `ON`, OpenMP is used if it is available. Default: `OFF`. + If `ON`, OpenMP is used by default if it is available. Default: `ON`. - GraphBLAS, LAGraph, and ParU will vastly slower if OpenMP is not used. + GraphBLAS, LAGraph, and ParU will be vastly slower if OpenMP is not used. CHOLMOD will be somewhat slower without OpenMP (as long as it still has a parallel BLAS/LAPACK). Three packages (UMFPACK, CHOLMOD, and SPQR) rely heavily on parallel BLAS/LAPACK libraries and those libraries may use OpenMP diff --git a/SuiteSparse_config/Config/SuiteSparse_configConfig.cmake.in b/SuiteSparse_config/Config/SuiteSparse_configConfig.cmake.in index 3a40b9d52a..1831e466ab 100644 --- a/SuiteSparse_config/Config/SuiteSparse_configConfig.cmake.in +++ b/SuiteSparse_config/Config/SuiteSparse_configConfig.cmake.in @@ -40,7 +40,7 @@ include ( CMakeFindDependencyMacro ) set ( _dependencies_found ON ) # Look for OpenMP -if ( @SUITESPARSE_HAS_OPENMP@ AND NOT OpenMP_C_FOUND ) +if ( @SUITESPARSE_CONFIG_HAS_OPENMP@ AND NOT OpenMP_C_FOUND ) find_dependency ( OpenMP COMPONENTS C ) if ( NOT OpenMP_C_FOUND ) set ( _dependencies_found OFF ) @@ -56,7 +56,7 @@ endif ( ) # Import target include ( ${CMAKE_CURRENT_LIST_DIR}/SuiteSparse_configTargets.cmake ) -if ( @SUITESPARSE_HAS_OPENMP@ ) +if ( @SUITESPARSE_CONFIG_HAS_OPENMP@ ) if ( TARGET SuiteSparse::SuiteSparseConfig ) get_property ( _suitesparse_config_aliased TARGET SuiteSparse::SuiteSparseConfig PROPERTY ALIASED_TARGET ) diff --git a/SuiteSparse_config/cmake_modules/SuiteSparsePolicy.cmake b/SuiteSparse_config/cmake_modules/SuiteSparsePolicy.cmake index 20a7fcf784..0cb6a6274f 100644 --- a/SuiteSparse_config/cmake_modules/SuiteSparsePolicy.cmake +++ b/SuiteSparse_config/cmake_modules/SuiteSparsePolicy.cmake @@ -120,7 +120,7 @@ set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake_modules ) # Use OpenMP -option ( SUITESPARSE_USE_OPENMP "ON (default): Use OpenMP if available. OFF: Do not use OpenMP" ON ) +option ( SUITESPARSE_USE_OPENMP "ON (default): Use OpenMP in libraries by default if available. OFF: Do not use OpenMP by default." ON ) # strict usage option ( SUITESPARSE_USE_STRICT "ON: treat all _USE__ settings as strict if they are ON. OFF (default): consider *_USE_* as preferences, not strict" OFF )