ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
mpi_ensemble.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2024 - 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <ryujin/base/compile_time_options.h>
10
11#include <deal.II/base/mpi.h>
12#include <deal.II/base/utilities.h>
13
14#include <string>
15
16namespace ryujin
17{
29 class MPIEnsemble final
30 {
31 public:
43 MPIEnsemble(const MPI_Comm &mpi_communicator,
44 const int n_ensembles = 1,
45 const bool global_synchronization = true);
46
48
53
57 ACCESSOR_READ_ONLY(global_synchronization);
58
62 ACCESSOR_READ_ONLY(world_rank);
63
67 ACCESSOR_READ_ONLY(n_world_ranks);
68
74
78 ACCESSOR_READ_ONLY(n_ensembles);
79
83 ACCESSOR_READ_ONLY(ensemble_rank);
84
88 ACCESSOR_READ_ONLY(n_ensemble_ranks);
89
95 ACCESSOR_READ_ONLY_NO_DEREFERENCE(ensemble_communicator);
96
102 DEAL_II_ALWAYS_INLINE inline const MPI_Comm &
104 {
105 if (global_synchronization_)
106 return world_communicator_;
107 else
108 return ensemble_communicator_;
109 }
110
116 ACCESSOR_READ_ONLY_NO_DEREFERENCE(ensemble_leader_communicator);
117
125
131 std::string base_name(const std::string &base_name) const;
132
133 private:
134 const MPI_Comm world_communicator_;
135
136 bool global_synchronization_;
137
138 int world_rank_;
139 int n_world_ranks_;
140 int ensemble_;
141 int n_ensembles_;
142 int ensemble_rank_;
143 int n_ensemble_ranks_;
144
145 MPI_Group world_group_;
146 std::vector<MPI_Group> ensemble_groups_;
147 MPI_Group ensemble_leader_group_;
148
149 MPI_Comm ensemble_communicator_;
150 MPI_Comm ensemble_leader_communicator_;
151 MPI_Comm peer_communicator_;
152 };
153} // namespace ryujin
ACCESSOR_READ_ONLY_NO_DEREFERENCE(ensemble_leader_communicator)
ACCESSOR_READ_ONLY(n_ensembles)
ACCESSOR_READ_ONLY_NO_DEREFERENCE(peer_communicator)
ACCESSOR_READ_ONLY(n_ensemble_ranks)
std::string base_name(const std::string &base_name) const
ACCESSOR_READ_ONLY_NO_DEREFERENCE(world_communicator)
MPIEnsemble(const MPI_Comm &mpi_communicator, const int n_ensembles=1, const bool global_synchronization=true)
ACCESSOR_READ_ONLY_NO_DEREFERENCE(ensemble_communicator)
ACCESSOR_READ_ONLY(ensemble)
ACCESSOR_READ_ONLY(global_synchronization)
DEAL_II_ALWAYS_INLINE const MPI_Comm & synchronization_communicator() const
ACCESSOR_READ_ONLY(ensemble_rank)
ACCESSOR_READ_ONLY(world_rank)
ACCESSOR_READ_ONLY(n_world_ranks)