Skip to content

Commit

Permalink
Merge pull request #745 from mmuetzel/cmake
Browse files Browse the repository at this point in the history
CMake: Try to handle `*_USE_OPENMP` more consistently.
  • Loading branch information
DrTimothyAldenDavis authored Jan 20, 2024
2 parents b47afa1 + 3a84dd9 commit 4a9a291
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CHOLMOD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion GraphBLAS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion LAGraph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion LAGraph/experimental/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ( )
Expand Down
2 changes: 1 addition & 1 deletion LAGraph/experimental/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ( )
Expand Down
2 changes: 1 addition & 1 deletion LAGraph/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ( )
Expand Down
2 changes: 1 addition & 1 deletion LAGraph/src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ( )
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions SuiteSparse_config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ( )
Expand All @@ -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 ( )
Expand Down Expand Up @@ -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} ")
Expand Down
4 changes: 2 additions & 2 deletions SuiteSparse_config/Config/README.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions SuiteSparse_config/Config/SuiteSparse_configConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion SuiteSparse_config/cmake_modules/SuiteSparsePolicy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down

0 comments on commit 4a9a291

Please sign in to comment.