From 6dfe3ed4d6a184366d417b419c7a899336f21792 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Tue, 28 Jan 2020 15:59:20 +0200 Subject: [PATCH] Added out-of-the-box support for MPI (though not enabled by default). Previously the user had to pass mpicxx explicitly as the cmake compiler in order to compile MPI code, but this was bad practice and it's better to let cmake handle the include and compilation flags. --- CMakeLists.txt | 8 -------- src/core/CMakeLists.txt | 11 +++++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b44ed0..4356517 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,14 +70,6 @@ endif () add_definitions(-DAC_DEFAULT_CONFIG="${CMAKE_SOURCE_DIR}/config/astaroth.conf") -if (MULTIGPU_ENABLED) # Deprecated - add_definitions(-DAC_MULTIGPU_ENABLED=1) -endif () - -if (MPI_ENABLED) - add_definitions(-DAC_MPI_ENABLED=1) -endif() - ## Includes include_directories(include) # Library headers include_directories(src/common) # Common headers diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 677e6c2..6e18185 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,3 +1,14 @@ ## Astaroth Core add_library(astaroth_core STATIC device.cc node.cc astaroth.cc) target_link_libraries(astaroth_core astaroth_utils astaroth_kernels cudart) + +## Options +if (MPI_ENABLED) + find_package(MPI) + target_link_libraries(astaroth_core MPI::MPI_CXX) + target_compile_definitions(astaroth_core PRIVATE -DAC_MPI_ENABLED=1) +endif() + +if (MULTIGPU_ENABLED) + target_compile_definitions(astaroth_core PRIVATE -DAC_MULTIGPU_ENABLED=1) +endif ()