core 1.5.0
Shared MPI block decomposition, asynchronous ghost-layer exchange, SDF geometry, load balancing (header-only C++20)
Loading...
Searching...
No Matches
anderson_mpi.hpp
Go to the documentation of this file.
1// core — the MPI side of the Anderson accelerator: AndersonComm from an MPI_Comm.
2//
3// solver/anderson.hpp is MPI-free and takes its collectives as callables; this header builds them
4// (MPI_Allreduce SUM of doubles, MPI_Bcast of bytes from rank 0) and is therefore on the MPI side
5// of core's boundary (it includes common/mpi.hpp; docs/CORE_BOUNDARY.md §2.1). Built against the
6// no-MPI stub (PECLET_CORE_NO_MPI) both collectives are single-rank identities.
7#ifndef PECLET_CORE_SOLVER_ANDERSON_MPI_HPP
8#define PECLET_CORE_SOLVER_ANDERSON_MPI_HPP
9
10#include <cstddef>
11#include <vector>
12
15
16namespace peclet::core::solver {
17
21 MPI_Comm_rank(comm, &c.rank);
22 c.sumAll = [comm](double* data, int count) {
23 std::vector<double> send(data, data + count); // no MPI_IN_PLACE: the no-MPI stub lacks it
24 MPI_Allreduce(send.data(), data, count, MPI_DOUBLE, MPI_SUM, comm);
25 };
26 c.broadcast = [comm](void* data, std::size_t bytes) {
27 MPI_Bcast(data, static_cast<int>(bytes), MPI_BYTE, 0, comm);
28 };
29 return c;
30}
31
32} // namespace peclet::core::solver
33
34#endif // PECLET_CORE_SOLVER_ANDERSON_MPI_HPP
int MPI_Bcast(void *, int, MPI_Datatype, int, MPI_Comm)
Definition mpi_stub.hpp:120
int MPI_Allreduce(const void *sbuf, void *rbuf, int count, MPI_Datatype dt, MPI_Op, MPI_Comm)
Definition mpi_stub.hpp:114
int MPI_Comm
Definition mpi_stub.hpp:17
#define MPI_BYTE
Definition mpi_stub.hpp:38
#define MPI_SUM
Definition mpi_stub.hpp:43
#define MPI_DOUBLE
Definition mpi_stub.hpp:41
int MPI_Comm_rank(MPI_Comm, int *r)
Definition mpi_stub.hpp:66
AndersonComm andersonComm(MPI_Comm comm)
The collectives of comm for an AndersonState. The communicator must outlive the accelerator.
Kokkos::View< T *, MemSpace > View
1D device array.
Definition view.hpp:26
The collectives of a distributed run.
Definition anderson.hpp:44
std::function< void(void *data, std::size_t bytes)> broadcast
Definition anderson.hpp:46
int rank
this rank in the communicator; rank 0's decisions win (design §6.1)
Definition anderson.hpp:47
std::function< void(double *data, int count)> sumAll
Definition anderson.hpp:45