CommMPI struct
MPI-based communication manager.
Manages MPI communication between ranks, handling serialization, asynchronous operations, and message dispatch
Public types
- class BufferIntInterpreter
- Helper class for interpreting buffer headers.
Public functions
- void init(int& argc, char**& argv, MPI_Comm comm = MPI_COMM_NULL)
- Initialize CommMPI.
- auto clone(bool dup_comm = true) const -> CommMPI
- Clone the communicator to create a distinct termination scope.
- auto numRanks() const -> int
- Get the number of ranks in the communicator.
- auto getRank() const -> int
- Get this process's rank.
- void finalize()
- Finalize MPI.
- void barrier()
- MPI barrier.
-
template<typename T>auto registerInstanceCollective(T* obj) -> ClassHandle<T>
- Register an instance for collective operations.
- void unregisterInstanceCollective(std::size_t idx)
- Unregister a previously registered instance.
- auto getInstanceCollective(std::size_t idx) -> void*
- Get a registered instance by index.
-
template<auto fn, typename ProxyT, typename... Args>void send(int dest, ProxyT proxy, Args && ... args)
- Send data to a destination rank.
- auto poll() -> bool
- Poll for incoming messages and process them.
-
template<typename T>auto allgather(T const* sendbuf, int sendcount) -> std::unordered_map<int, std::vector<T>>
- Gather values from all ranks, with varying counts per rank, and remember per-rank contribution.
Function documentation
int comm:: CommMPI:: numRanks() const
Get the number of ranks in the communicator.
| Returns | Number of ranks |
|---|
template<typename T>
ClassHandle<T> comm:: CommMPI:: registerInstanceCollective(T* obj)
Register an instance for collective operations.
| Parameters | |
|---|---|
| obj | Pointer to the object to register |
| Returns | A handle for the registered instance |
void comm:: CommMPI:: unregisterInstanceCollective(std::size_t idx)
Unregister a previously registered instance.
| Parameters | |
|---|---|
| idx | Index of the instance to unregister |
void* comm:: CommMPI:: getInstanceCollective(std::size_t idx)
Get a registered instance by index.
| Parameters | |
|---|---|
| idx | Index of the instance |
| Returns | Pointer to the registered instance |
template<auto fn, typename ProxyT, typename... Args>
void comm:: CommMPI:: send(int dest,
ProxyT proxy,
Args && ... args)
Send data to a destination rank.
| Parameters | |
|---|---|
| dest | Destination rank |
| proxy | |
| args | Arguments to serialize and send |
| Exceptions | |
| std::runtime_error | if destination rank is invalid |
bool comm:: CommMPI:: poll()
Poll for incoming messages and process them.
| Returns | true when termination occurs, false otherwise |
|---|---|
| Exceptions | |
| std::runtime_error | if received message is invalid |
Checks for new messages and processes them, also cleans up completed sends
template<typename T>
std::unordered_map<int, std::vector<T>> comm:: CommMPI:: allgather(T const* sendbuf,
int sendcount)
Gather values from all ranks, with varying counts per rank, and remember per-rank contribution.
| Template parameters | |
|---|---|
| T | Type of the elements to gather (must be trivially copyable and one of the supported basic types) |
| Parameters | |
| sendbuf | Pointer to the local data to send |
| sendcount | Number of elements to send from this rank |
| Returns | A map from rank -> vector of values contributed by that rank |