Skip to content

Commit

Permalink
Merge pull request #3299 from heplesser/fix-openmp-cmake
Browse files Browse the repository at this point in the history
Allow passing OpenMP root directory to -Dwith-openmp
  • Loading branch information
heplesser authored Feb 20, 2025
2 parents 36d182e + fe0476a commit 2848292
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 42 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/nestbuildmatrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,7 @@ jobs:
-Dwith-optimize=${{ contains(matrix.use, 'optimize') && 'ON' || 'OFF' }} \
-Dwith-warning=${{ contains(matrix.use, 'warning') && 'ON' || 'OFF' }} \
-Dwith-boost=${{ contains(matrix.use, 'boost') && 'ON' || 'OFF' }} \
-Dwith-openmp=${{ contains(matrix.use, 'openmp') && 'ON' || 'OFF' }} \
${{ contains(matrix.use, 'openmp') && '-DOpenMP_ROOT=$(brew --prefix libomp)' }} \
-Dwith-openmp=${{ contains(matrix.use, 'openmp') && '$(brew --prefix libomp)' || 'OFF' }} \
-Dwith-mpi=${{ contains(matrix.use, 'mpi') && 'ON' || 'OFF' }} \
-Dwith-python=${{ contains(matrix.use, 'python') && 'ON' || 'OFF' }} \
-Dwith-gsl=${{ contains(matrix.use, 'gsl') && 'ON' || 'OFF' }} \
Expand Down
51 changes: 26 additions & 25 deletions cmake/ConfigureSummary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,32 @@ function( NEST_PRINT_CONFIG_SUMMARY )
message( "Python bindings : No" )
endif ()

message( "" )
if ( OpenMP_FOUND )
message( "Use threading : Yes (OpenMP: ${OpenMP_CXX_FLAGS})" )
message( " Libraries : ${OpenMP_CXX_LIBRARIES}" )
else ()
message( "Use threading : No" )
endif ()

message( "" )
if ( HAVE_MPI )
message( "Use MPI : Yes (MPI: ${MPI_CXX_COMPILER})" )
message( " Includes : ${MPI_CXX_INCLUDE_PATH}" )
message( " Libraries : ${MPI_CXX_LIBRARIES}" )
if ( MPI_CXX_COMPILE_FLAGS )
message( " Compile Flags : ${MPI_CXX_COMPILE_FLAGS}" )
endif ()
if ( MPI_CXX_LINK_FLAGS )
message( " Link Flags : ${MPI_CXX_LINK_FLAGS}" )
endif ()
set( MPI_LAUNCHER "${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} <np> ${MPIEXEC_PREFLAGS} <prog> ${MPIEXEC_POSTFLAGS} <args>" )
string(REPLACE " " " " MPI_LAUNCHER ${MPI_LAUNCHER})
message( " Launcher : ${MPI_LAUNCHER}")
else ()
message( "Use MPI : No" )
endif ()

message( "" )
if ( BUILD_DOCS )
message( "Documentation : Yes" )
Expand All @@ -85,13 +111,6 @@ function( NEST_PRINT_CONFIG_SUMMARY )
message( "Documentation : No" )
endif ()

message( "" )
if ( OPENMP_FOUND )
message( "Use threading : Yes (OpenMP: ${OpenMP_CXX_FLAGS})" )
message( " Libraries : ${OpenMP_CXX_LIBRARIES}" )
else ()
message( "Use threading : No" )
endif ()

message( "" )
if ( HAVE_GSL )
Expand Down Expand Up @@ -125,24 +144,6 @@ function( NEST_PRINT_CONFIG_SUMMARY )
endif ()
endif ()

message( "" )
if ( HAVE_MPI )
message( "Use MPI : Yes (MPI: ${MPI_CXX_COMPILER})" )
message( " Includes : ${MPI_CXX_INCLUDE_PATH}" )
message( " Libraries : ${MPI_CXX_LIBRARIES}" )
if ( MPI_CXX_COMPILE_FLAGS )
message( " Compile Flags : ${MPI_CXX_COMPILE_FLAGS}" )
endif ()
if ( MPI_CXX_LINK_FLAGS )
message( " Link Flags : ${MPI_CXX_LINK_FLAGS}" )
endif ()
set( MPI_LAUNCHER "${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} <np> ${MPIEXEC_PREFLAGS} <prog> ${MPIEXEC_POSTFLAGS} <args>" )
string(REPLACE " " " " MPI_LAUNCHER ${MPI_LAUNCHER})
message( " Launcher : ${MPI_LAUNCHER}")
else ()
message( "Use MPI : No" )
endif ()

message( "" )
if ( TIMER_DETAILED )
message( "Detailed timers : Yes" )
Expand Down
5 changes: 2 additions & 3 deletions cmake/FindSIONlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ if ( NOT SIONLIB_CONFIG STREQUAL "SIONLIB_CONFIG-NOTFOUND" )
# get arguments for sionconfig --cflags and --libs
set( CONF_FLAGS "--cxx" ) # we use cxx
# find parallelization
if ( OPENMP_FOUND AND MPI_CXX_FOUND )
if ( OpenMP_FOUND AND MPI_CXX_FOUND )
set( CONF_FLAGS ${CONF_FLAGS} "--ompi" )
elseif ( OPENMP_FOUND )
elseif ( OpenMP_FOUND )
set( CONF_FLAGS ${CONF_FLAGS} "--omp" )
elseif ( MPI_CXX_FOUND )
set( CONF_FLAGS ${CONF_FLAGS} "--mpi" )
Expand All @@ -70,7 +70,6 @@ if ( NOT SIONLIB_CONFIG STREQUAL "SIONLIB_CONFIG-NOTFOUND" )
set( CONF_FLAGS ${CONF_FLAGS} "--gcc" )
endif ()


# use sionconfig to get --cflags
execute_process(
COMMAND ${SIONLIB_CONFIG} ${CONF_FLAGS} --cflags
Expand Down
21 changes: 9 additions & 12 deletions cmake/ProcessOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -382,20 +382,17 @@ endfunction()

function( NEST_PROCESS_WITH_OPENMP )
# Find OPENMP
if ( with-openmp )
if ( NOT "${with-openmp}" STREQUAL "OFF" )
if ( NOT "${with-openmp}" STREQUAL "ON" )
printInfo( "Set OpenMP argument: ${with-openmp}")
# set variables in this scope
set( OPENMP_FOUND ON )
set( OpenMP_C_FLAGS "${with-openmp}" )
set( OpenMP_CXX_FLAGS "${with-openmp}" )
set( OpenMP_CXX_LIBRARIES "${with-openmp}" )
else ()
find_package( OpenMP )
# if set, use this prefix
set( OpenMP_ROOT "${with-openmp}" )
endif ()
if ( OPENMP_FOUND )

find_package( OpenMP REQUIRED )

if ( OpenMP_FOUND )
# export found variables to parent scope
set( OPENMP_FOUND "${OPENMP_FOUND}" PARENT_SCOPE )
set( OpenMP_FOUND "${OpenMP_FOUND}" PARENT_SCOPE )
set( OpenMP_C_FLAGS "${OpenMP_C_FLAGS}" PARENT_SCOPE )
set( OpenMP_CXX_FLAGS "${OpenMP_CXX_FLAGS}" PARENT_SCOPE )
set( OpenMP_CXX_LIBRARIES "${OpenMP_CXX_LIBRARIES}" PARENT_SCOPE )
Expand All @@ -405,7 +402,7 @@ function( NEST_PROCESS_WITH_OPENMP )
else()
printError( "CMake can not find OpenMP." )
endif ()
endif ()
endif () # if NOT OFF

# Provide a dummy OpenMP::OpenMP_CXX if no OpenMP or if flags explicitly
# given. Needed to avoid problems where OpenMP::OpenMP_CXX is used.
Expand Down

0 comments on commit 2848292

Please sign in to comment.