From e178f12056f3be6031060feb53194e973bbfbdf0 Mon Sep 17 00:00:00 2001 From: program-- Date: Fri, 15 Mar 2024 12:01:47 -0700 Subject: [PATCH 1/4] mpi: add MPI detour library Co-authored-by: Phil Miller - NOAA --- src/utilities/mpi/CMakeLists.txt | 1 + src/utilities/mpi/MPIDetour.c | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 src/utilities/mpi/CMakeLists.txt create mode 100644 src/utilities/mpi/MPIDetour.c diff --git a/src/utilities/mpi/CMakeLists.txt b/src/utilities/mpi/CMakeLists.txt new file mode 100644 index 0000000000..6e1bdac4b0 --- /dev/null +++ b/src/utilities/mpi/CMakeLists.txt @@ -0,0 +1 @@ +add_library(MPIDetour SHARED "${CMAKE_CURRENT_LIST_DIR}/MPIDetour.c") diff --git a/src/utilities/mpi/MPIDetour.c b/src/utilities/mpi/MPIDetour.c new file mode 100644 index 0000000000..57586826c4 --- /dev/null +++ b/src/utilities/mpi/MPIDetour.c @@ -0,0 +1,3 @@ +int MPI_Finalize() { + return 0; +} From 9821ac48bca86c14fc2c6e93f333f8c61d8a4a38 Mon Sep 17 00:00:00 2001 From: program-- Date: Fri, 15 Mar 2024 12:03:07 -0700 Subject: [PATCH 2/4] ngen: MPI_Finalize -> PMPI_Finalize Co-authored-by: Phil Miller - NOAA --- src/NGen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NGen.cpp b/src/NGen.cpp index 74817737db..d4f721da41 100644 --- a/src/NGen.cpp +++ b/src/NGen.cpp @@ -150,7 +150,7 @@ int main(int argc, char *argv[]) { } // if (mpi_rank == 0) #if NGEN_WITH_MPI - MPI_Finalize(); + PMPI_Finalize(); #endif exit(1); @@ -587,7 +587,7 @@ int main(int argc, char *argv[]) { } #ifdef NGEN_MPI_ACTIVE - MPI_Finalize(); + PMPI_Finalize(); #endif return 0; From 7cf8df5b3816e429c26246774f802b8a865a38a7 Mon Sep 17 00:00:00 2001 From: program-- Date: Fri, 15 Mar 2024 15:29:24 -0700 Subject: [PATCH 3/4] cmake: add mpi detour to root listfile and link to ngen --- CMakeLists.txt | 5 +++++ src/utilities/mpi/CMakeLists.txt | 1 + 2 files changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4e604a5c9..39f86278ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,6 +330,7 @@ add_subdirectory("src/forcing") add_subdirectory("src/utilities/mdarray") add_subdirectory("src/utilities/mdframe") add_subdirectory("src/utilities/logging") +add_subdirectory("src/utilities/mpi") target_link_libraries(ngen PUBLIC @@ -344,6 +345,10 @@ target_link_libraries(ngen NGen::logging ) +if(NGEN_WITH_MPI) + target_link_libraries(ngen PUBLIC NGen::MPI_Detour) +endif() + if(NGEN_WITH_SQLITE) add_subdirectory("src/geopackage") target_link_libraries(ngen PUBLIC NGen::geopackage) diff --git a/src/utilities/mpi/CMakeLists.txt b/src/utilities/mpi/CMakeLists.txt index 6e1bdac4b0..6a60ce387b 100644 --- a/src/utilities/mpi/CMakeLists.txt +++ b/src/utilities/mpi/CMakeLists.txt @@ -1 +1,2 @@ add_library(MPIDetour SHARED "${CMAKE_CURRENT_LIST_DIR}/MPIDetour.c") +add_library(NGen::MPI_Detour ALIAS MPIDetour) From 82a00a5a712aaffb9a0fac4e6cbc75d58c49104c Mon Sep 17 00:00:00 2001 From: program-- Date: Thu, 21 Mar 2024 07:35:12 -0700 Subject: [PATCH 4/4] fix: move MPIDetour linkage above other ngen links --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39f86278ad..eea6e5c5e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -332,6 +332,10 @@ add_subdirectory("src/utilities/mdframe") add_subdirectory("src/utilities/logging") add_subdirectory("src/utilities/mpi") +if(NGEN_WITH_MPI) + target_link_libraries(ngen PUBLIC NGen::MPI_Detour) +endif() + target_link_libraries(ngen PUBLIC NGen::config_header @@ -345,10 +349,6 @@ target_link_libraries(ngen NGen::logging ) -if(NGEN_WITH_MPI) - target_link_libraries(ngen PUBLIC NGen::MPI_Detour) -endif() - if(NGEN_WITH_SQLITE) add_subdirectory("src/geopackage") target_link_libraries(ngen PUBLIC NGen::geopackage)