33 MPI_Init(&argc, &argv);
55 MPI_Initialized(&mpi_init);
72 using U = std::remove_const_t<T>;
73 if constexpr (std::is_same_v<U, bool>)
77 if constexpr (std::is_same_v<U, char>)
81 if constexpr (std::is_same_v<U, double>)
85 if constexpr (std::is_same_v<U, float>)
89 if constexpr (std::is_same_v<U, int>)
93 if constexpr (std::is_same_v<U, std::size_t>)
95 return MPI_UNSIGNED_LONG;
97 if constexpr (std::is_same_v<U, unsigned int>)
106 std::vector<T> result(mpi.
size);
115static std::vector<T>
allgather(std::vector<T>
const& vector,
Mpi const& mpi)
117 std::size_t
const size = vector.size();
119 std::vector<T> result(mpi.
size * size);
121 MPI_Allgather(vector.data(), size,
mpiType<T>(), result.data(), size,
115static std::vector<T>
allgather(std::vector<T>
const& vector,
Mpi const& mpi) {
…}
128static T
allreduce(T
const& value, MPI_Op
const& mpi_op,
Mpi const& mpi)
137static std::vector<T>
allreduce(std::vector<T>
const& vector,
138 MPI_Op
const& mpi_op,
Mpi const& mpi)
140 std::size_t
const size = vector.size();
141 std::vector<T> result(vector.size());
143 MPI_Allreduce(vector.data(), result.data(), size,
mpiType<T>(), mpi_op,
137static std::vector<T>
allreduce(std::vector<T>
const& vector, {
…}
150 MPI_Op
const& mpi_op,
153 MPI_Allreduce(MPI_IN_PLACE,
165 std::span<T>
const send_buffer,
166 std::vector<std::remove_const_t<T>>& receive_buffer,
170 int const size =
static_cast<int>(send_buffer.size());
173 std::vector<int>
const sizes =
allgather(size, mpi);
179 receive_buffer.resize(offsets.back());
181 MPI_Allgatherv(send_buffer.data(), size,
mpiType<T>(),
182 receive_buffer.data(), sizes.data(), offsets.data(),
191static inline bool anyOf(
bool const val
191static inline bool anyOf(
bool const val {
…}
static void allreduceInplace(std::vector< T > &vector, MPI_Op const &mpi_op, Mpi const &mpi)
static bool anyOf(bool const val, Mpi const &mpi=Mpi{OGS_COMM_WORLD})
static std::vector< int > allgatherv(std::span< T > const send_buffer, std::vector< std::remove_const_t< T > > &receive_buffer, Mpi const &mpi)
static T allreduce(T const &value, MPI_Op const &mpi_op, Mpi const &mpi)
constexpr MPI_Datatype mpiType()
static std::vector< T > allgather(T const &value, Mpi const &mpi)
std::vector< ranges::range_value_t< R > > sizesToOffsets(R const &sizes)
Mpi(MPI_Comm const communicator=OGS_COMM_WORLD)
Setup(int argc, char *argv[])