Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ddb1933
Add MPI layer CMake setup
pratikvn Oct 22, 2021
7e1a4b9
Add basic classes and hooks
pratikvn Oct 22, 2021
a56a6ff
Update with MPI version
pratikvn Oct 22, 2021
426e48b
Add a EnableSharedCreate interface
pratikvn Oct 22, 2021
a76b727
Add new macros for instantiations
pratikvn Oct 22, 2021
0e8a031
Add exception handling and helpers
pratikvn Oct 22, 2021
bdb5f87
Add MPI bindings and binding helpers
pratikvn Oct 22, 2021
4f5db6b
Add MPI tests and CUDA Aware check helper
pratikvn Oct 22, 2021
7ba1c81
Add a few MPI jobs for CI
pratikvn Oct 22, 2021
4e869f6
Add docs, and some tests.
pratikvn Oct 22, 2021
da8f2c4
Review update, more tests
pratikvn Oct 25, 2021
13d1c53
Add an example as an integration test
pratikvn Oct 25, 2021
91aadba
Disable MPI compilation when not being used.
pratikvn Oct 28, 2021
518be63
Fix test_install and MPI run as root
pratikvn Oct 29, 2021
64bd141
Make init_finalize a singleton
pratikvn Nov 2, 2021
320ab30
Review WIP
pratikvn Nov 3, 2021
09ff8f5
Review update 2: comm, req, and win
pratikvn Nov 4, 2021
ff15e67
WIP: Moving funcs to public header
pratikvn Nov 4, 2021
3a6d2df
Move all wrappers to headers
pratikvn Nov 5, 2021
25d5e62
Update init_finalize
pratikvn Nov 5, 2021
8544262
Remove ginkgo_mpi library, move to core
pratikvn Nov 5, 2021
fb95689
Format files
ginkgo-bot Nov 5, 2021
fcdcb79
Rem unnecessary ex and code in gtest-mpi-listener
pratikvn Nov 8, 2021
06a4f36
Format files
ginkgo-bot Nov 9, 2021
4f5ae1d
Library fixes and gtes-mpi-listener updates
pratikvn Nov 10, 2021
c0a82cb
Some more fixes for cmake and MPI types
pratikvn Nov 10, 2021
1b148ec
Remove init finalize exception handling.
pratikvn Nov 12, 2021
7f2cd88
Make nb functions return requests
pratikvn Nov 16, 2021
cf965ad
Some test updates
pratikvn Nov 16, 2021
1c681bb
Update tests to TYPED_TESTS
pratikvn Nov 16, 2021
f4b89ef
Review update.
pratikvn Nov 17, 2021
fa1d910
Remove info struct and use MPI_Info
pratikvn Nov 17, 2021
b377bec
Make MPI calls inline
pratikvn Nov 17, 2021
0b9a510
Overhaul communicator
pratikvn Nov 18, 2021
7d11a47
Fix MPI_Win, MPI_Put consistency issues
pratikvn Nov 19, 2021
df080b6
Fix GPU Aware functionality
pratikvn Nov 20, 2021
b1c264d
Update docs and fix types
pratikvn Nov 21, 2021
ced2a61
Make sync a comm member function
pratikvn Nov 22, 2021
4ecb5a1
Review update.
pratikvn Nov 25, 2021
c2d9679
Store MPI_Comm in a shared_ptr
pratikvn Nov 25, 2021
509ca6c
Move everything to member funcs of comm and window
pratikvn Nov 26, 2021
e913f55
Add request and status wrappers
pratikvn Nov 27, 2021
37b8a44
Review updates.
pratikvn Nov 27, 2021
a5f5e93
Merge: Add a MPI layer, CMake setup and test framework
pratikvn Nov 27, 2021
96ba143
adds partition class
MarcelKoch Oct 22, 2021
83b9071
add sorting tests to partition
MarcelKoch Aug 24, 2021
a193c90
Format files
ginkgo-bot Sep 7, 2021
06404d2
add partition kernels
upsj Oct 23, 2021
8b09820
use kernel stubs
MarcelKoch Oct 25, 2021
94624ce
rename range_ranks to range_starting_indices
MarcelKoch Oct 26, 2021
382eeb0
add partition builder from global size
MarcelKoch Oct 26, 2021
7219260
move distributed typedefs to a centralized place
MarcelKoch Oct 27, 2021
fa194fa
review updates
MarcelKoch Oct 27, 2021
eb9f52f
allow only const access to partition data
MarcelKoch Oct 28, 2021
b55e267
review update
MarcelKoch Oct 28, 2021
1720ca3
add template for global_index_type
MarcelKoch Oct 28, 2021
8d550fb
review updates
MarcelKoch Nov 24, 2021
42b25bc
disables dpcpp for partition common test
MarcelKoch Nov 25, 2021
810d86c
fix kernel launch issues for certain cuda versions
MarcelKoch Nov 25, 2021
5bb5436
review updates
MarcelKoch Nov 29, 2021
ed77851
Merge: Add a class for partitions of intervals
MarcelKoch Nov 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add MPI layer CMake setup
  • Loading branch information
pratikvn committed Nov 20, 2021
commit ddb19336ad7d85c1242e6d3096ce501b45f0b4fe
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ option(GINKGO_BUILD_EXAMPLES "Build Ginkgo's examples" ON)
option(GINKGO_BUILD_BENCHMARKS "Build Ginkgo's benchmarks" ON)
option(GINKGO_BUILD_REFERENCE "Compile reference CPU kernels" ON)
option(GINKGO_BUILD_OMP "Compile OpenMP kernels for CPU" ${GINKGO_HAS_OMP})
option(GINKGO_BUILD_MPI "Compile the MPI module" ${GINKGO_HAS_MPI})
option(GINKGO_BUILD_DPCPP
"Compile DPC++ kernels for Intel GPUs or other DPC++ enabled hardware" ${GINKGO_HAS_DPCPP})
option(GINKGO_BUILD_CUDA "Compile kernels for NVIDIA GPUs" ${GINKGO_HAS_CUDA})
Expand Down Expand Up @@ -189,6 +190,33 @@ else()
message(STATUS "HWLOC is being forcibly switched off")
endif()

set(GINKGO_HAVE_MPI 0)
set(GINKGO_HAVE_CUDA_AWARE_MPI 0)
if(GINKGO_BUILD_MPI)
find_package(MPI REQUIRED)
set(GINKGO_HAVE_MPI 1)
if(GINKGO_BUILD_CUDA AND (${GINKGO_FORCE_CUDA_AWARE_MPI} MATCHES "") )
enable_language(CUDA)
try_run(GKO_CUDA_AWARE_RUN_STATUS GKO_CUDA_AWARE_COMPILE_STATUS
"${CMAKE_BINARY_DIR}" SOURCES "${CMAKE_SOURCE_DIR}/mpi/test/cuda-aware-mpi-test.cu"
COMPILE_DEFINITIONS ""
LINK_LIBRARIES MPI::MPI_C
RUN_OUTPUT_VARIABLE GKO_CUDA_AWARE_RUN_OUT
COMPILE_OUTPUT_VARIABLE GKO_CUDA_AWARE_COMPILE_OUT)
if( ${GKO_CUDA_AWARE_RUN_STATUS} MATCHES "FAILED_TO_RUN" )
message(STATUS "MPI does not support CUDA, disabling CUDA-Aware features, everything will be staged through the host.")
else()
message(STATUS "MPI supports CUDA, enabling CUDA-Aware features")
set(GINKGO_HAVE_CUDA_AWARE_MPI 1)
endif()
endif()
if( ${GINKGO_FORCE_CUDA_AWARE_MPI} MATCHES "YES" )
set(GINKGO_HAVE_CUDA_AWARE_MPI 1)
elseif( ${GINKGO_FORCE_CUDA_AWARE_MPI} MATCHES "NO" )
set(GINKGO_HAVE_CUDA_AWARE_MPI 0)
endif()
endif()

# We keep using NVCC/HCC for consistency with previous releases even if AMD
# updated everything to use NVIDIA/AMD in ROCM 4.1
set(GINKGO_HIP_PLATFORM_NVCC 0)
Expand Down Expand Up @@ -261,6 +289,9 @@ endif()
if (GINKGO_BUILD_OMP)
add_subdirectory(omp) # High-performance omp kernels
endif()
if(GINKGO_BUILD_MPI)
add_subdirectory(mpi) # The MPI module
endif()
add_subdirectory(core) # Core Ginkgo types and top-level functions
add_subdirectory(include) # Public API self-contained check
if (GINKGO_BUILD_TESTS)
Expand Down
9 changes: 9 additions & 0 deletions cmake/autodetect_executors.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
set(GINKGO_HAS_OMP OFF)
set(GINKGO_HAS_MPI OFF)
set(GINKGO_HAS_CUDA OFF)
set(GINKGO_HAS_DPCPP OFF)
set(GINKGO_HAS_HIP OFF)
find_package(OpenMP 3.0)
find_package(MPI)
include(CheckLanguage)
check_language(CUDA)
try_compile(GKO_CAN_COMPILE_DPCPP ${PROJECT_BINARY_DIR}/dpcpp
Expand All @@ -16,6 +18,13 @@ if(OpenMP_CXX_FOUND)
set(GINKGO_HAS_OMP ON)
endif()

if(MPI_FOUND)
if(NOT DEFINED GINKGO_BUILD_MPI)
message(STATUS "Enabling MPI executor")
endif()
set(GINKGO_HAS_MPI ON)
endif()

if(CMAKE_CUDA_COMPILER)
if(NOT DEFINED GINKGO_BUILD_CUDA)
message(STATUS "Enabling CUDA executor")
Expand Down
27 changes: 27 additions & 0 deletions cmake/create_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,33 @@ function(ginkgo_create_thread_test test_name)
ginkgo_set_test_target_properties(${test_name} ${test_target_name})
endfunction(ginkgo_create_thread_test)

function(ginkgo_create_mpi_test test_name num_mpi_procs)
file(RELATIVE_PATH REL_BINARY_DIR
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}")
add_executable(${TEST_TARGET_NAME} ${test_name}.cpp)
target_include_directories("${TEST_TARGET_NAME}"
PRIVATE
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
${MPI_INCLUDE_PATH}
)
set_target_properties(${TEST_TARGET_NAME} PROPERTIES
OUTPUT_NAME ${test_name})
if (GINKGO_CHECK_CIRCULAR_DEPS)
target_link_libraries(${TEST_TARGET_NAME} PRIVATE "${GINKGO_CIRCULAR_DEPS_FLAGS}")
endif()
if("${GINKGO_MPI_EXEC_SUFFIX}" MATCHES ".openmpi" AND MPI_RUN_AS_ROOT)
set(OPENMPI_RUN_AS_ROOT_FLAG "--allow-run-as-root")
else()
set(OPENMPI_RUN_AS_ROOT_FLAG "")
endif()
target_link_libraries(${TEST_TARGET_NAME} PRIVATE ginkgo GTest::Main GTest::GTest ${ARGN})
target_link_libraries(${TEST_TARGET_NAME} PRIVATE ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
set(test_param ${MPIEXEC_NUMPROC_FLAG} ${num_mpi_procs} ${OPENMPI_RUN_AS_ROOT_FLAG} ${CMAKE_BINARY_DIR}/${REL_BINARY_DIR}/${test_name})
add_test(NAME ${REL_BINARY_DIR}/${test_name}
COMMAND ${MPIEXEC_EXECUTABLE} ${test_param} )
endfunction(ginkgo_create_mpi_test)

function(ginkgo_create_test_cpp_cuda_header test_name)
ginkgo_build_test_name(${test_name} test_target_name)
add_executable(${test_target_name} ${test_name}.cpp)
Expand Down
6 changes: 5 additions & 1 deletion cmake/get_info.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ foreach(log_type ${log_types})
ginkgo_print_module_footer(${${log_type}} "User configuration:")
ginkgo_print_module_footer(${${log_type}} " Enabled modules:")
ginkgo_print_foreach_variable(${${log_type}}
"GINKGO_BUILD_OMP;GINKGO_BUILD_REFERENCE;GINKGO_BUILD_CUDA;GINKGO_BUILD_HIP;GINKGO_BUILD_DPCPP")
"GINKGO_BUILD_OMP;GINKGO_BUILD_MPI;GINKGO_BUILD_REFERENCE;GINKGO_BUILD_CUDA;GINKGO_BUILD_HIP;GINKGO_BUILD_DPCPP")
ginkgo_print_module_footer(${${log_type}} " Enabled features:")
ginkgo_print_foreach_variable(${${log_type}}
"GINKGO_MIXED_PRECISION")
Expand Down Expand Up @@ -155,6 +155,10 @@ IF(GINKGO_BUILD_OMP)
include(omp/get_info.cmake)
ENDIF()

IF(GINKGO_BUILD_MPI)
include(mpi/get_info.cmake)
ENDIF()

IF(GINKGO_BUILD_CUDA)
include(cuda/get_info.cmake)
ENDIF()
Expand Down
7 changes: 6 additions & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ if(GINKGO_HAVE_PAPI_SDE)
target_sources(ginkgo PRIVATE log/papi.cpp)
endif()

if (GINKGO_BUILD_MPI)
target_link_libraries(ginkgo PUBLIC "${MPI_C_LIBRARIES}" "${MPI_CXX_LIBRARIES}")
target_include_directories(ginkgo SYSTEM PUBLIC ${MPI_INCLUDE_PATH})
endif()

ginkgo_compile_features(ginkgo)

target_compile_options(ginkgo PRIVATE "${GINKGO_COMPILER_FLAGS}")
# add a namespace alias so Ginkgo can always be included as Ginkgo::ginkgo
# regardless of whether it is installed or added as a subdirectory
add_library(Ginkgo::ginkgo ALIAS ginkgo)
target_link_libraries(ginkgo
PUBLIC ginkgo_device ginkgo_omp ginkgo_cuda ginkgo_reference ginkgo_hip ginkgo_dpcpp)
PUBLIC ginkgo_device ginkgo_omp ginkgo_mpi ginkgo_cuda ginkgo_reference ginkgo_hip ginkgo_dpcpp)
# The PAPI dependency needs to be exposed to the user.
set(GKO_RPATH_ADDITIONS "")
if (GINKGO_HAVE_PAPI_SDE)
Expand Down
9 changes: 9 additions & 0 deletions core/device_hooks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ if (NOT GINKGO_BUILD_OMP)
ginkgo_install_library(ginkgo_omp)
endif()

if(NOT GINKGO_BUILD_MPI)
add_library(ginkgo_mpi
$<TARGET_OBJECTS:ginkgo_mpi_device>
mpi_hooks.cpp)
ginkgo_compile_features(ginkgo_mpi)
ginkgo_default_includes(ginkgo_mpi)
ginkgo_install_library(ginkgo_mpi mpi)
endif()

if (NOT GINKGO_BUILD_REFERENCE)
add_library(ginkgo_reference
$<TARGET_OBJECTS:ginkgo_reference_device>
Expand Down
1 change: 1 addition & 0 deletions devices/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ add_subdirectory(cuda)
add_subdirectory(dpcpp)
add_subdirectory(hip)
add_subdirectory(omp)
add_subdirectory(mpi)
add_subdirectory(reference)
2 changes: 2 additions & 0 deletions devices/mpi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ginkgo_add_object_library(ginkgo_mpi_device
dummy.cpp)
31 changes: 31 additions & 0 deletions mpi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
find_package(MPI REQUIRED)

add_library(ginkgo_mpi $<TARGET_OBJECTS:ginkgo_mpi_device> "")
target_sources(ginkgo_mpi
PRIVATE
base/exception.cpp
base/bindings.cpp
base/version.cpp
)

ginkgo_compile_features(ginkgo_mpi)
target_include_directories(ginkgo_mpi
SYSTEM PRIVATE ${MPI_INCLUDE_PATH})
target_link_libraries(ginkgo_mpi PRIVATE "${MPI_C_LIBRARIES}" "${MPI_CXX_LIBRARIES}")
target_compile_options(ginkgo_mpi PRIVATE "${GINKGO_COMPILER_FLAGS}")

ginkgo_default_includes(ginkgo_mpi)
ginkgo_install_library(ginkgo_mpi mpi)

if (GINKGO_CHECK_CIRCULAR_DEPS)
ginkgo_check_headers(ginkgo_mpi)
endif()

if(GINKGO_BUILD_TESTS)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/test)
add_subdirectory(test)
endif()

# Propagate some useful information
set(MPI_C_VERSION ${MPI_C_VERSION} PARENT_SCOPE)
set(MPI_C_LIBRARIES ${MPI_C_LIBRARIES} PARENT_SCOPE)
48 changes: 48 additions & 0 deletions mpi/base/version.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*******************************<GINKGO LICENSE>******************************
Copyright (c) 2017-2021, the Ginkgo authors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************<GINKGO LICENSE>*******************************/

#include <ginkgo/core/base/version.hpp>


namespace gko {


version version_info::get_mpi_version() noexcept
{
// When compiling the module, the header version is the same as the library
// version. Mismatch between the header and the module versions may happen
// if using shared libraries from different versions of Ginkgo.
return version_info::get_header_version();
}


} // namespace gko
17 changes: 17 additions & 0 deletions mpi/get_info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ginkgo_print_module_header(${detailed_log} "MPI")
ginkgo_print_variable(${detailed_log} "GINKGO_FORCE_CUDA_AWARE_MPI")
ginkgo_print_variable(${detailed_log} "GKO_CUDA_AWARE_RUN_STATUS")
ginkgo_print_variable(${detailed_log} "MPI_C_COMPILER")
ginkgo_print_variable(${detailed_log} "MPI_CXX_COMPILER")
ginkgo_print_variable(${detailed_log} "MPI_CXX_COMPILE_OPTIONS")
ginkgo_print_variable(${detailed_log} "MPI_CXX_LINK_FLAGS")
ginkgo_print_variable(${detailed_log} "MPI_CXX_LIB_NAMES")
ginkgo_print_variable(${detailed_log} "MPI_CXX_HEADER_DIR")
ginkgo_print_variable(${detailed_log} "MPI_mpi_LIBRARY")
ginkgo_print_variable(${detailed_log} "MPIEXEC_EXECUTABLE")
ginkgo_print_variable(${detailed_log} "MPIEXEC_MAX_NUMPROCS")
ginkgo_print_variable(${detailed_log} "MPIEXEC_NUMPROC_FLAG")
ginkgo_print_module_footer(${detailed_log} "MPI variables:")
ginkgo_print_variable(${detailed_log} "GINKGO_COMPILER_FLAGS")
ginkgo_print_variable(${detailed_log} "MPI_RUN_AS_ROOT")
ginkgo_print_module_footer(${detailed_log} "")