From 0b7c73c0f6f25df1630e31c47035119461882caf Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Tue, 18 Jun 2024 12:37:43 +0200 Subject: [PATCH 1/3] Make link targets private, as expected --- CMakeLists.txt | 2 +- src/backends/dlb/CMakeLists.txt | 2 +- src/backends/extrae/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52ea6be..e4a13b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ endif() if(WITH_MPI) find_package(MPI REQUIRED COMPONENTS CXX) - target_link_libraries(${PROJECT_NAME} PUBLIC MPI::MPI_CXX) + target_link_libraries(${PROJECT_NAME} PRIVATE MPI::MPI_CXX) target_compile_definitions(nesmik PRIVATE "WITH_MPI") endif() diff --git a/src/backends/dlb/CMakeLists.txt b/src/backends/dlb/CMakeLists.txt index 3a432c4..1dbebc9 100644 --- a/src/backends/dlb/CMakeLists.txt +++ b/src/backends/dlb/CMakeLists.txt @@ -2,7 +2,7 @@ find_package(DLB REQUIRED) if(DLB_FOUND) target_include_directories(nesmik PRIVATE ${DLB_INCLUDE_DIRS}) -target_link_libraries(nesmik PUBLIC ${DLB_LIBRARIES}) +target_link_libraries(nesmik PRIVATE ${DLB_LIBRARIES}) target_compile_definitions(nesmik PRIVATE "ENABLE_DLB") add_subdirectory(dlb) diff --git a/src/backends/extrae/CMakeLists.txt b/src/backends/extrae/CMakeLists.txt index 787ac74..0889e70 100644 --- a/src/backends/extrae/CMakeLists.txt +++ b/src/backends/extrae/CMakeLists.txt @@ -3,7 +3,7 @@ target_sources(nesmik PRIVATE extrae_type_stack.cpp) if(Extrae_FOUND) target_include_directories(nesmik PRIVATE ${Extrae_INCLUDE_DIRS}) -target_link_libraries(nesmik PUBLIC ${Extrae_LIBRARIES}) +target_link_libraries(nesmik PRIVATE ${Extrae_LIBRARIES}) target_compile_definitions(nesmik PRIVATE "ENABLE_EXTRAE") endif() -- GitLab From cefe202866cb97df05e19e5d8c88c984937674e3 Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Fri, 21 Jun 2024 14:44:32 +0200 Subject: [PATCH 2/3] centralize the linking a bit --- CMakeLists.txt | 25 +++++++++++++++++++++++++ src/backends/dlb/CMakeLists.txt | 8 -------- src/backends/extrae/CMakeLists.txt | 8 -------- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4a13b3..3412f91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,31 @@ if(WITH_MPI) target_compile_definitions(nesmik PRIVATE "WITH_MPI") endif() +if(ENABLE_EXTRAE) + find_package(Extrae REQUIRED) + if(Extrae_FOUND) + target_include_directories(nesmik + PRIVATE ${Extrae_INCLUDE_DIRS}) + # We link publicy with seqtrace, as we need it to be in the right order to libc to find malloc with dlsym .. + target_link_libraries(nesmik PUBLIC ${Extrae_LIBRARIES}) + target_compile_definitions(nesmik PRIVATE "ENABLE_EXTRAE") + else() + message(FATAL_ERROR "Couldnt find Extrae") + endif() +endif() + +if(ENABLE_DLB) + find_package(DLB REQUIRED) + if(DLB_FOUND) + target_include_directories(nesmik + PRIVATE ${DLB_INCLUDE_DIRS}) + target_link_libraries(nesmik PRIVATE ${DLB_LIBRARIES}) + target_compile_definitions(nesmik PRIVATE "ENABLE_DLB") + else() + message(FATAL_ERROR "Couldnt find DLB") + endif() +endif() + include(FetchContent) diff --git a/src/backends/dlb/CMakeLists.txt b/src/backends/dlb/CMakeLists.txt index 1dbebc9..dad14ce 100644 --- a/src/backends/dlb/CMakeLists.txt +++ b/src/backends/dlb/CMakeLists.txt @@ -1,10 +1,2 @@ -find_package(DLB REQUIRED) -if(DLB_FOUND) -target_include_directories(nesmik - PRIVATE ${DLB_INCLUDE_DIRS}) -target_link_libraries(nesmik PRIVATE ${DLB_LIBRARIES}) -target_compile_definitions(nesmik PRIVATE "ENABLE_DLB") - add_subdirectory(dlb) add_subdirectory(dlb_talp_tree) -endif() diff --git a/src/backends/extrae/CMakeLists.txt b/src/backends/extrae/CMakeLists.txt index 0889e70..319ef9c 100644 --- a/src/backends/extrae/CMakeLists.txt +++ b/src/backends/extrae/CMakeLists.txt @@ -1,9 +1 @@ -find_package(Extrae REQUIRED) target_sources(nesmik PRIVATE extrae_type_stack.cpp) -if(Extrae_FOUND) -target_include_directories(nesmik - PRIVATE ${Extrae_INCLUDE_DIRS}) -target_link_libraries(nesmik PRIVATE ${Extrae_LIBRARIES}) -target_compile_definitions(nesmik PRIVATE "ENABLE_EXTRAE") -endif() - -- GitLab From fdd7b70657c1f14337c07980925cfbefc49fb6dc Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Fri, 21 Jun 2024 14:44:49 +0200 Subject: [PATCH 3/3] make the tests work (only call MPI if its inited) --- src/backends/detection/detection.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/backends/detection/detection.cpp b/src/backends/detection/detection.cpp index 4217fbc..a317a0c 100644 --- a/src/backends/detection/detection.cpp +++ b/src/backends/detection/detection.cpp @@ -151,16 +151,15 @@ void DetectionStrategy::Finalize() noexcept { } } + + #ifdef WITH_MPI - if(mpi_helper_.IsRankNumber(0)){ - PMPI_Reduce(MPI_IN_PLACE,&has_been_called_from_threads,1, MPI_INT, MPI_SUM,0,MPI_COMM_WORLD); - PMPI_Reduce(MPI_IN_PLACE,&has_errors,1, MPI_INT, MPI_SUM,0,MPI_COMM_WORLD); - } - else{ - int localUnused; - PMPI_Reduce(&has_been_called_from_threads,&localUnused,1, MPI_INT, MPI_SUM,0,MPI_COMM_WORLD); - PMPI_Reduce(&has_errors,&localUnused,1, MPI_INT, MPI_SUM,0,MPI_COMM_WORLD); - } + int local_has_been_called_from_threads = has_been_called_from_threads; + int local_has_errors = has_errors; + if(mpi_helper_.IsUsingMPI()){ + PMPI_Reduce(&local_has_been_called_from_threads,&has_been_called_from_threads,1, MPI_INT, MPI_SUM,0,MPI_COMM_WORLD); + PMPI_Reduce(&local_has_errors,&has_errors,1, MPI_INT, MPI_SUM,0,MPI_COMM_WORLD); + } #endif -- GitLab