From 39052065eaa4eee41e5ad9c5e3df41c09faa2c60 Mon Sep 17 00:00:00 2001 From: Marcel Koch Date: Wed, 12 Jul 2023 09:06:26 +0200 Subject: [PATCH 1/4] fix missing mpi in stencil example --- examples/custom-matrix-format/CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/custom-matrix-format/CMakeLists.txt b/examples/custom-matrix-format/CMakeLists.txt index 47eeda0143c..631bc917b8d 100644 --- a/examples/custom-matrix-format/CMakeLists.txt +++ b/examples/custom-matrix-format/CMakeLists.txt @@ -15,16 +15,21 @@ endif() set(CMAKE_CUDA_STANDARD 14) set(CMAKE_CUDA_STANDARD_REQUIRED ON) -add_executable(custom-matrix-format custom-matrix-format.cpp stencil_kernel.cu) -target_link_libraries(custom-matrix-format Ginkgo::ginkgo OpenMP::OpenMP_CXX) +# device code that includes has to be compiled separately +# because +add_library(stencil stencil_kernel.cu) +target_link_libraries(stencil Ginkgo::ginkgo) # inherit CUDA architecture flags from Ginkgo -target_compile_options(custom-matrix-format +target_compile_options(stencil PRIVATE "$<$:${GINKGO_CUDA_ARCH_FLAGS}>") # we handle CUDA architecture flags for now, disable CMake handling if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) - set_target_properties(custom-matrix-format PROPERTIES CUDA_ARCHITECTURES OFF) + set_target_properties(stencil PROPERTIES CUDA_ARCHITECTURES OFF) endif() +add_executable(custom-matrix-format custom-matrix-format.cpp) +target_link_libraries(custom-matrix-format stencil Ginkgo::ginkgo OpenMP::OpenMP_CXX) + # workaround for clang-cuda/g++ interaction set_target_properties(custom-matrix-format PROPERTIES POSITION_INDEPENDENT_CODE ON) From 1b679159f3889b11449988c30d39db9b25bad850 Mon Sep 17 00:00:00 2001 From: Marcel Koch Date: Wed, 12 Jul 2023 09:22:58 +0200 Subject: [PATCH 2/4] Revert "fix missing mpi in stencil example" This reverts commit 39052065eaa4eee41e5ad9c5e3df41c09faa2c60. --- examples/custom-matrix-format/CMakeLists.txt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/examples/custom-matrix-format/CMakeLists.txt b/examples/custom-matrix-format/CMakeLists.txt index 631bc917b8d..47eeda0143c 100644 --- a/examples/custom-matrix-format/CMakeLists.txt +++ b/examples/custom-matrix-format/CMakeLists.txt @@ -15,21 +15,16 @@ endif() set(CMAKE_CUDA_STANDARD 14) set(CMAKE_CUDA_STANDARD_REQUIRED ON) -# device code that includes has to be compiled separately -# because -add_library(stencil stencil_kernel.cu) -target_link_libraries(stencil Ginkgo::ginkgo) +add_executable(custom-matrix-format custom-matrix-format.cpp stencil_kernel.cu) +target_link_libraries(custom-matrix-format Ginkgo::ginkgo OpenMP::OpenMP_CXX) # inherit CUDA architecture flags from Ginkgo -target_compile_options(stencil +target_compile_options(custom-matrix-format PRIVATE "$<$:${GINKGO_CUDA_ARCH_FLAGS}>") # we handle CUDA architecture flags for now, disable CMake handling if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) - set_target_properties(stencil PROPERTIES CUDA_ARCHITECTURES OFF) + set_target_properties(custom-matrix-format PROPERTIES CUDA_ARCHITECTURES OFF) endif() -add_executable(custom-matrix-format custom-matrix-format.cpp) -target_link_libraries(custom-matrix-format stencil Ginkgo::ginkgo OpenMP::OpenMP_CXX) - # workaround for clang-cuda/g++ interaction set_target_properties(custom-matrix-format PROPERTIES POSITION_INDEPENDENT_CODE ON) From 4081a116da68cbcdb10dbd9837ddf32580bec4aa Mon Sep 17 00:00:00 2001 From: Marcel Koch Date: Wed, 12 Jul 2023 09:40:15 +0200 Subject: [PATCH 3/4] remove unnecessary ginkgo include --- examples/custom-matrix-format/stencil_kernel.cu | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/custom-matrix-format/stencil_kernel.cu b/examples/custom-matrix-format/stencil_kernel.cu index 8474d3bc793..f06508566c4 100644 --- a/examples/custom-matrix-format/stencil_kernel.cu +++ b/examples/custom-matrix-format/stencil_kernel.cu @@ -32,8 +32,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include - #define INSTANTIATE_FOR_EACH_VALUE_TYPE(_macro) \ template _macro(float); \ From fad6f8a6b0b64202affe0c875452b81d1e87836f Mon Sep 17 00:00:00 2001 From: Marcel Koch Date: Wed, 12 Jul 2023 10:00:11 +0200 Subject: [PATCH 4/4] don't use MPI from compiler wrapper directly Using MPI from the MPI compiler wrapper directly means that no include path or library is added for MPI. This gives errors if a file that is not compiled by the wrappers and is linked against/includes ginkgo can't find the MPI headers or implementation. This mostly effects device code, since they will most likely not be compiled with the MPI wrapper compilers. --- cmake/autodetect_executors.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/autodetect_executors.cmake b/cmake/autodetect_executors.cmake index 315e0eb3e38..74ca038c3a8 100644 --- a/cmake/autodetect_executors.cmake +++ b/cmake/autodetect_executors.cmake @@ -14,7 +14,10 @@ if (NOT DEFINED GINKGO_BUILD_OMP) endif() endif() -if (NOT DEFINED GINKGO_BUILD_MPI) +if(NOT DEFINED GINKGO_BUILD_MPI) + set(GINKGO_MPI_ASSUME_NO_BUILTIN_MPI ON CACHE BOOL "Disables using MPI wrapper compiler directly.") + mark_as_advanced(GIKNGO_MPI_ASSUME_NO_BUILTIN_MPI) + set(MPI_ASSUME_NO_BUILTIN_MPI ${GINKGO_MPI_ASSUME_NO_BUILTIN_MPI}) find_package(MPI 3.1 COMPONENTS CXX) if(MPI_FOUND) message(STATUS "Enabling MPI support")