Skip to content

Commit

Permalink
[coll-comm] disable neighbor comm if open-mpi version < 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelKoch committed Aug 9, 2024
1 parent d9e8dcc commit a926ffe
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ if(GINKGO_BUILD_HWLOC AND (MSVC OR WIN32 OR CYGWIN OR APPLE))
endif()

set(GINKGO_HAVE_GPU_AWARE_MPI OFF)
set(GINKGO_FORCE_SPMV_BLOCKING_COMM OFF)
set(GINKGO_HAVE_OPENMPI_PRE_4_1_X OFF)
if(GINKGO_BUILD_MPI)
find_package(MPI 3.1 COMPONENTS CXX REQUIRED)
if(GINKGO_FORCE_GPU_AWARE_MPI)
Expand All @@ -226,12 +226,14 @@ if(GINKGO_BUILD_MPI)
)
if(NOT valid_openmpi_version)
message(WARNING
"OpenMPI v4.0.x has a bug that forces us to use blocking communication in our distributed "
"OpenMPI v4.0.x has several bugs that forces us to use non-optimal communication in our distributed "
"matrix class. To enable faster, non-blocking communication, consider updating your OpenMPI version or "
"switch to a different vendor.")
set(GINKGO_FORCE_SPMV_BLOCKING_COMM ON)
set(GINKGO_HAVE_OPENMPI_PRE_4_1_X ON)
endif()
unset(valid_openmpi_version)
endif()
unset(uses_openmpi)
endif()

# Try to find the third party packages before using our subdirectories
Expand Down
6 changes: 5 additions & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,13 @@ if(GINKGO_BUILD_MPI)
distributed/dense_communicator.cpp
distributed/matrix.cpp
distributed/partition_helpers.cpp
distributed/neighborhood_communicator.cpp
distributed/vector.cpp
distributed/preconditioner/schwarz.cpp)
if(NOT GINKGO_HAVE_OPENMPI_PRE_4_1_X)
target_sources(${ginkgo_core}
PRIVATE
distributed/neighborhood_communicator.cpp)
endif()
endif()

# MSVC/shared: make ginkgo be the major library
Expand Down
2 changes: 1 addition & 1 deletion core/distributed/dense_communicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ request DenseCommunicator::i_all_to_all_v(std::shared_ptr<const Executor> exec,
void* recv_buffer,
MPI_Datatype recv_type) const
{
#ifdef GINKGO_FORCE_SPMV_BLOCKING_COMM
#ifdef GINKGO_HAVE_OPENMPI_PRE_4_1_X
comm_.all_to_all_v(exec, send_buffer, send_sizes_.data(),
send_offsets_.data(), send_type, recv_buffer,
recv_sizes_.data(), recv_offsets_.data(), recv_type);
Expand Down
2 changes: 1 addition & 1 deletion core/distributed/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ mpi::request Matrix<ValueType, LocalIndexType, GlobalIndexType>::communicate(
auto recv_ptr = use_host_buffer ? host_recv_buffer_->get_values()
: recv_buffer_->get_values();
exec->synchronize();
#ifdef GINKGO_FORCE_SPMV_BLOCKING_COMM
#ifdef GINKGO_HAVE_OPENMPI_PRE_4_1_X
comm.all_to_all_v(use_host_buffer ? exec->get_master() : exec, send_ptr,
send_sizes_.data(), send_offsets_.data(), type.get(),
recv_ptr, recv_sizes_.data(), recv_offsets_.data(),
Expand Down
5 changes: 4 additions & 1 deletion core/test/mpi/distributed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
ginkgo_create_test(helpers MPI_SIZE 1)
ginkgo_create_test(matrix MPI_SIZE 1)
ginkgo_create_test(dense_communicator MPI_SIZE 6)
ginkgo_create_test(neighborhood_communicator MPI_SIZE 6)

if(NOT GINKGO_HAVE_OPENMPI_PRE_4_1_X)
ginkgo_create_test(neighborhood_communicator MPI_SIZE 6)
endif()

add_subdirectory(preconditioner)
add_subdirectory(solver)
2 changes: 1 addition & 1 deletion include/ginkgo/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

/* Do we need to use blocking communication in our SpMV? */
// clang-format off
#cmakedefine GINKGO_FORCE_SPMV_BLOCKING_COMM
#cmakedefine01 GINKGO_HAVE_OPENMPI_PRE_4_1_X
// clang-format on


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <ginkgo/config.hpp>


#if GINKGO_BUILD_MPI
#if GINKGO_BUILD_MPI && !GINKGO_HAVE_OPENMPI_PRE_4_1_X

#include <ginkgo/core/base/mpi.hpp>
#include <ginkgo/core/distributed/collective_communicator.hpp>
Expand Down

0 comments on commit a926ffe

Please sign in to comment.