Skip to content

Commit

Permalink
Merge: Add basic distributed capability (MPI + Partition)
Browse files Browse the repository at this point in the history
This PR merges the basic distributed capability into Ginkgo, namely

1. MPI layer (#908)
2. Partition class and kernels (#909)

The discussion regarding the interfaces for the above functionalities can be found in the above linked PR's.

Related PR: #932
  • Loading branch information
pratikvn committed Nov 29, 2021
2 parents 00226d0 + ed77851 commit f7dd61b
Show file tree
Hide file tree
Showing 54 changed files with 5,041 additions and 42 deletions.
49 changes: 49 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ include:
BUILD_CUDA: "OFF"
BUILD_HIP: "OFF"
BUILD_HWLOC: "ON"
BUILD_MPI: "OFF"
MPI_AS_ROOT: "OFF"
FAST_TESTS: "OFF"
DPCPP_SINGLE_MODE: "OFF"
MIXED_PRECISION: "ON"
Expand Down Expand Up @@ -74,6 +76,8 @@ include:
-DGINKGO_DEVEL_TOOLS=OFF -DGINKGO_BUILD_REFERENCE=${BUILD_REFERENCE}
-DGINKGO_BUILD_OMP=${BUILD_OMP} -DGINKGO_BUILD_CUDA=${BUILD_CUDA}
-DGINKGO_BUILD_HIP=${BUILD_HIP}
-DGINKGO_BUILD_MPI=${BUILD_MPI} -DGINKGO_MPI_EXEC_SUFFIX=${MPI_SUFFIX}
-DMPI_RUN_AS_ROOT=${MPI_AS_ROOT}
-DGINKGO_BUILD_HWLOC=${BUILD_HWLOC}
-DGINKGO_BUILD_TESTS=ON -DGINKGO_BUILD_EXAMPLES=ON
-DGINKGO_FAST_TESTS=${FAST_TESTS}
Expand Down Expand Up @@ -109,6 +113,8 @@ include:
-DGINKGO_DEVEL_TOOLS=OFF -DGINKGO_BUILD_REFERENCE=${BUILD_REFERENCE}
-DGINKGO_BUILD_OMP=${BUILD_OMP} -DGINKGO_BUILD_CUDA=${BUILD_CUDA}
-DGINKGO_BUILD_HIP=${BUILD_HIP}
-DGINKGO_BUILD_MPI=${BUILD_MPI} -DGINKGO_MPI_EXEC_SUFFIX=${MPI_SUFFIX}
-DMPI_RUN_AS_ROOT=${MPI_RUN_AS_ROOT}
-DGINKGO_BUILD_HWLOC=${BUILD_HWLOC}
-DGINKGO_BUILD_TESTS=ON -DGINKGO_BUILD_EXAMPLES=ON
-DGINKGO_FAST_TESTS=${FAST_TESTS}
Expand Down Expand Up @@ -553,6 +559,49 @@ build/amd/clang/hip_wo_omp/release/shared:
BUILD_HIP: "ON"
BUILD_TYPE: "Release"

# mpi job test debug shared
build/nocuda/gcc/mpi/debug/shared:
<<: *default_build_with_test
extends:
- .quick_test_condition
- .use_gko-nocuda-gnu9-llvm8-intel
variables:
<<: *default_variables
BUILD_MPI: "ON"
MPI_AS_ROOT: "ON"
BUILD_TYPE: "Debug"
BUILD_SHARED_LIBS: "ON"

# mpi job test release static
build/nocuda/gcc/mpi/release/static:
<<: *default_build_with_test
extends:
- .full_test_condition
- .use_gko-nocuda-gnu9-llvm8-intel
variables:
<<: *default_variables
BUILD_MPI: "ON"
MPI_AS_ROOT: "ON"
BUILD_TYPE: "Release"
BUILD_SHARED_LIBS: "OFF"

# mpi job with cuda 10.0
build/cuda100/mpi/gcc/all/debug/shared:
<<: *default_build
extends:
- .quick_test_condition
- .use_gko-cuda100-gnu7-llvm60-intel2018
variables:
<<: *default_variables
BUILD_OMP: "ON"
BUILD_CUDA: "ON"
BUILD_MPI: "ON"
MPI_AS_ROOT: "ON"
BUILD_HIP: "ON"
BUILD_TYPE: "Debug"
FAST_TESTS: "ON"
CUDA_ARCH: 61

# no cuda but latest gcc and clang
build/nocuda/gcc/core/debug/static:
<<: *default_build_with_test
Expand Down
32 changes: 32 additions & 0 deletions ABOUT-LICENSING.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,35 @@ __NOTE:__ Some of the options that pull additional software when compiling
Ginkgo are ON by default, and have to be disabled manually to prevent
third-party licensing. Refer to the [Installation section in
INSTALL.md](INSTALL.md#Building) for more details.


When using testing with MPI switched on, the gtest-mpi-listener header only library is used for testing MPI functionality. The repository is licensed triple licensed under BSD-3, MIT and Apache 2.0. The License duplicated below. More details on the License and the library are [available on github](https://github.com/LLNL/gtest-mpi-listener)


> # Copyright 2005, Google Inc. All rights reserved.
> #
> # Redistribution and use in source and binary forms, with or without
> # modification, are permitted provided that the following conditions are
> # met:
> #
> # * Redistributions of source code must retain the above copyright
> # notice, this list of conditions and the following disclaimer.
> # * 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.
> # * Neither the name of Google Inc. 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
> # OWNER 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.
5 changes: 5 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,10 @@ else()
message(STATUS "HWLOC is being forcibly switched off")
endif()

if(GINKGO_BUILD_MPI)
find_package(MPI REQUIRED)
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
9 changes: 8 additions & 1 deletion cmake/GinkgoConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ set(GINKGO_BUILD_REFERENCE @GINKGO_BUILD_REFERENCE@)
set(GINKGO_BUILD_OMP @GINKGO_BUILD_OMP@)
set(GINKGO_BUILD_CUDA @GINKGO_BUILD_CUDA@)
set(GINKGO_BUILD_HIP @GINKGO_BUILD_HIP@)
set(GINKGO_BUILD_MPI @GINKGO_BUILD_MPI@)
set(GINKGO_BUILD_DPCPP @GINKGO_BUILD_DPCPP@)

set(GINKGO_DEVEL_TOOLS @GINKGO_DEVEL_TOOLS@)
Expand Down Expand Up @@ -81,10 +82,11 @@ set(GINKGO_DPCPP_FLAGS @GINKGO_DPCPP_FLAGS@)
set(GINKGO_MKL_ROOT @GINKGO_MKL_ROOT@)
set(GINKGO_DPL_ROOT @GINKGO_DPL_ROOT@)

set(GINKGO_BUILD_MPI @GINKGO_BUILD_MPI@)

set(GINKGO_HAVE_PAPI_SDE @GINKGO_HAVE_PAPI_SDE@)

set(GINKGO_HAVE_HWLOC @GINKGO_HAVE_HWLOC@)
set(GINKGO_BUILD_HWLOC @GINKGO_BUILD_HWLOC@)

# Ginkgo installation configuration
set(GINKGO_CONFIG_FILE_PATH "${CMAKE_CURRENT_LIST_DIR}")
Expand Down Expand Up @@ -151,6 +153,11 @@ if(GINKGO_HAVE_HWLOC)
find_package(HWLOC REQUIRED)
endif()

# Check for MPI if it is enabled
if(GINKGO_BUILD_MPI)
find_package(MPI REQUIRED)
endif()

# HIP and OpenMP depend on Threads::Threads in some circumstances, but don't find it
if (GINKGO_BUILD_HIP OR GINKGO_BUILD_OMP)
find_package(Threads REQUIRED)
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 support")
endif()
set(GINKGO_HAS_MPI ON)
endif()

if(CMAKE_CUDA_COMPILER)
if(NOT DEFINED GINKGO_BUILD_CUDA)
message(STATUS "Enabling CUDA executor")
Expand Down
30 changes: 28 additions & 2 deletions cmake/create_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ 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)
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::MPI_main GTest::GTest ${ARGN})
target_link_libraries(${TEST_TARGET_NAME} PRIVATE MPI::MPI_CXX)
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 Expand Up @@ -141,6 +163,7 @@ ginkgo_build_test_name(${test_name} test_target_name)
endfunction(ginkgo_create_hip_test)

function(ginkgo_create_common_test test_name)
cmake_parse_arguments(PARSE_ARGV 1 common_test "" "" "DISABLE_EXECUTORS;ADDITIONAL_LIBRARIES")
set(executors)
if(GINKGO_BUILD_OMP)
list(APPEND executors omp)
Expand All @@ -154,6 +177,9 @@ function(ginkgo_create_common_test test_name)
if(GINKGO_BUILD_DPCPP)
list(APPEND executors dpcpp)
endif()
foreach(disabled_exec ${common_test_DISABLE_EXECUTORS})
list(REMOVE_ITEM executors ${disabled_exec})
endforeach()
foreach(exec ${executors})
ginkgo_build_test_name(${test_name} test_target_name)
# build executor typename out of shorthand
Expand All @@ -167,7 +193,7 @@ function(ginkgo_create_common_test test_name)
target_compile_features(${test_target_name} PUBLIC cxx_std_14)
target_compile_options(${test_target_name} PRIVATE ${GINKGO_COMPILER_FLAGS})
target_compile_definitions(${test_target_name} PRIVATE EXEC_TYPE=${exec_type} EXEC_NAMESPACE=${exec})
target_link_libraries(${test_target_name} PRIVATE ${ARGN})
target_link_libraries(${test_target_name} PRIVATE ${common_test_ADDITIONAL_LIBRARIES})
# use float for DPC++ if necessary
if((exec STREQUAL "dpcpp") AND GINKGO_DPCPP_SINGLE_MODE)
target_compile_definitions(${test_target_name} PRIVATE GINKGO_COMMON_SINGLE_MODE=1)
Expand All @@ -187,4 +213,4 @@ function(ginkgo_create_common_and_reference_test test_name)
target_compile_definitions(${test_target_name} PRIVATE EXEC_TYPE=ReferenceExecutor EXEC_NAMESPACE=reference)
target_link_libraries(${test_target_name} PRIVATE ${ARGN})
ginkgo_set_test_target_properties(${test_name}_reference ${test_target_name})
endfunction()
endfunction()
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(core/mpi/get_info.cmake)
ENDIF()

IF(GINKGO_BUILD_CUDA)
include(cuda/get_info.cmake)
ENDIF()
Expand Down
1 change: 1 addition & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(UNIFIED_SOURCES
components/fill_array_kernels.cpp
components/precision_conversion_kernels.cpp
components/reduce_array_kernels.cpp
distributed/partition_kernels.cpp
matrix/coo_kernels.cpp
matrix/csr_kernels.cpp
matrix/dense_kernels.cpp
Expand Down
Loading

0 comments on commit f7dd61b

Please sign in to comment.