Skip to content

Commit

Permalink
Merge pull request #196 from maelk3/fix-cmake-openmpi-comm-type-share…
Browse files Browse the repository at this point in the history
…d-check

CMake: fix check for MPI_COMM_SHARED_TYPE using openMPI
  • Loading branch information
cburstedde authored Jul 18, 2024
2 parents 54f6d03 + 309ae0d commit d6ea917
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 3 deletions.
18 changes: 18 additions & 0 deletions cmake/check_mpicommshared.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
include(CheckCSourceCompiles)
function(check_mpicommshared)

set(CMAKE_REQUIRED_LIBRARIES MPI::MPI_C)

check_c_source_compiles(
"
#include <mpi.h>
int main(void) {
int temp = MPI_COMM_TYPE_SHARED;
return 0;
}
"
SC_ENABLE_MPICOMMSHARED)

endfunction()

check_mpicommshared()
19 changes: 19 additions & 0 deletions cmake/check_mpithread.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
include(CheckCSourceCompiles)
function(check_mpithread)

set(CMAKE_REQUIRED_LIBRARIES MPI::MPI_C)

check_c_source_compiles(
"
#include <mpi.h>
int main(int argc, char** argv) {
int thread_support_provided;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &thread_support_provided);
return 0;
}
"
SC_ENABLE_MPITHREAD)

endfunction()

check_mpithread()
20 changes: 20 additions & 0 deletions cmake/check_mpiwinshared.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
include(CheckCSourceCompiles)
function(check_mpiwinshared)

set(CMAKE_REQUIRED_LIBRARIES MPI::MPI_C)

check_c_source_compiles(
"
#include <mpi.h>
int main(void) {
int* window_buffer;
MPI_Win window;
MPI_Win_allocate_shared(sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &window_buffer, &window);
return 0;
}
"
SC_ENABLE_MPIWINSHARED)

endfunction()

check_mpiwinshared()
9 changes: 6 additions & 3 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ if(NOT SC_ENABLE_MPI EQUAL CACHE{SC_ENABLE_MPI})
endif()

if( SC_ENABLE_MPI )
check_symbol_exists(MPI_COMM_TYPE_SHARED mpi.h SC_ENABLE_MPICOMMSHARED)
# perform check to set SC_ENABLE_MPICOMMSHARED
include(cmake/check_mpicommshared.cmake)
# perform check to set SC_ENABLE_MPIIO
include(cmake/check_mpiio.cmake)
check_symbol_exists(MPI_Init_thread mpi.h SC_ENABLE_MPITHREAD)
check_symbol_exists(MPI_Win_allocate_shared mpi.h SC_ENABLE_MPIWINSHARED)
# perform check to set SC_ENABLE_MPITHREAD
include(cmake/check_mpithread.cmake)
# perform check to set SC_ENABLE_MPIWINSHARED
include(cmake/check_mpiwinshared.cmake)
endif()


Expand Down
2 changes: 2 additions & 0 deletions doc/author_karembe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
I place my contributions to libsc under the FreeBSD license.
Mael Karembe (mael.karembe@dlr.de)
1 change: 1 addition & 0 deletions doc/release_notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ There have been breaking changes, very strictly speaking.
- Add CMake option to run tests with Valgrind.
- Warn if configuring MPI on and MPI I/O off.
- Renaming of CMake build system variables
- Make MPI checking functionality more robust in CMake.

### Functionality

Expand Down

0 comments on commit d6ea917

Please sign in to comment.