19 cg_global_(comm, false),
20 cg_intra_(create_intra_comm(), enable_shared_memory_),
21 cg_inter_(create_inter_comm(), enable_shared_memory_),
22 process_map_(create_process_map()),
23 intra2global_rank_(create_intra2global_rank()),
24 inter2global_rank_(create_inter2global_rank()),
26 numa_nodes_all_(create_intra_numa_nodes()),
27 numa_nodemask_all_(get_numa_bitmask(numa_nodes_all_)) {}
32 MPI_Comm
mpicomm()
const {
return cg_global_.mpicomm; }
47 return process_map_[global_rank].intra_rank;
53 return process_map_[global_rank].inter_rank;
85 return get_unique_numa_nodes(numa_nodes_all_).size();
89 return numa_nodemask_all_;
96 MPI_Comm
mpicomm = MPI_COMM_NULL;
97 bool own_comm =
false;
99 comm_group(MPI_Comm comm,
bool own)
101 mpicomm(comm), own_comm(own) {}
110 struct process_map_entry {
115 MPI_Comm create_intra_comm() {
116 if (enable_shared_memory_) {
118 MPI_Comm_split_type(
mpicomm(), MPI_COMM_TYPE_SHARED,
my_rank(), MPI_INFO_NULL, &h);
121 return MPI_COMM_SELF;
125 MPI_Comm create_inter_comm() {
126 if (enable_shared_memory_) {
135 std::vector<process_map_entry> create_process_map() {
137 std::vector<process_map_entry> ret(
n_ranks());
138 MPI_Allgather(&my_entry,
139 sizeof(process_map_entry),
142 sizeof(process_map_entry),
148 std::vector<rank_t> create_intra2global_rank() {
149 std::vector<rank_t> ret;
159 std::vector<rank_t> create_inter2global_rank() {
160 std::vector<rank_t> ret;
171 std::vector<numa::node_t> create_intra_numa_nodes()
const {
176 std::vector<numa::node_t> get_unique_numa_nodes(std::vector<numa::node_t> nodes)
const {
178 nodes.erase(std::unique(nodes.begin(), nodes.end()), nodes.end());
182 numa::node_bitmask get_numa_bitmask(std::vector<numa::node_t> nodes)
const {
183 auto unique_nodes = get_unique_numa_nodes(nodes);
184 numa::node_bitmask nodemask;
185 for (
const auto& node : unique_nodes) {
186 nodemask.setbit(node);
191 bool enable_shared_memory_;
192 comm_group cg_global_;
193 comm_group cg_intra_;
194 comm_group cg_inter_;
195 std::vector<process_map_entry> process_map_;
196 std::vector<rank_t> intra2global_rank_;
197 std::vector<rank_t> inter2global_rank_;
200 std::vector<numa::node_t> numa_nodes_all_;
201 numa::node_bitmask numa_nodemask_all_;
static auto & get()
Definition: util.hpp:180
Definition: topology.hpp:14
rank_t inter_my_rank() const
Definition: topology.hpp:41
numa::node_t numa_my_node() const
Definition: topology.hpp:80
topology(const topology &)=delete
rank_t n_ranks() const
Definition: topology.hpp:34
topology & operator=(const topology &)=delete
numa::node_t numa_n_nodes() const
Definition: topology.hpp:84
rank_t intra_rank(rank_t global_rank) const
Definition: topology.hpp:44
topology()
Definition: topology.hpp:16
bool numa_enabled() const
Definition: topology.hpp:72
rank_t intra2global_rank(rank_t intra_rank) const
Definition: topology.hpp:56
topology(MPI_Comm comm)
Definition: topology.hpp:17
rank_t inter_rank(rank_t global_rank) const
Definition: topology.hpp:50
rank_t inter2global_rank(rank_t inter_rank) const
Definition: topology.hpp:62
rank_t intra_n_ranks() const
Definition: topology.hpp:38
MPI_Comm mpicomm() const
Definition: topology.hpp:32
rank_t inter_n_ranks() const
Definition: topology.hpp:42
MPI_Comm inter_mpicomm() const
Definition: topology.hpp:40
rank_t my_rank() const
Definition: topology.hpp:33
MPI_Comm intra_mpicomm() const
Definition: topology.hpp:36
numa::node_t numa_node(rank_t intra_rank) const
Definition: topology.hpp:74
const numa::node_bitmask & numa_nodemask_all() const
Definition: topology.hpp:88
bool is_locally_accessible(rank_t target_global_rank) const
Definition: topology.hpp:68
rank_t intra_my_rank() const
Definition: topology.hpp:37
#define ITYR_CHECK(cond)
Definition: util.hpp:48
int node_t
Definition: numa.hpp:76
bool enabled()
Definition: numa.hpp:86
node_t get_current_node()
Definition: numa.hpp:87
Definition: topology.hpp:10
numa::node_t numa_node(rank_t intra_rank)
Definition: topology.hpp:229
rank_t inter_my_rank()
Definition: topology.hpp:215
bool numa_enabled()
Definition: topology.hpp:226
rank_t n_ranks()
Definition: topology.hpp:208
int rank_t
Definition: topology.hpp:12
rank_t inter_rank(rank_t global_rank)
Definition: topology.hpp:219
MPI_Comm mpicomm()
Definition: topology.hpp:206
rank_t inter_n_ranks()
Definition: topology.hpp:216
rank_t intra_my_rank()
Definition: topology.hpp:211
const numa::node_bitmask & numa_nodemask_all()
Definition: topology.hpp:230
bool is_locally_accessible(rank_t target_global_rank)
Definition: topology.hpp:224
rank_t inter2global_rank(rank_t inter_rank)
Definition: topology.hpp:222
MPI_Comm inter_mpicomm()
Definition: topology.hpp:214
MPI_Comm intra_mpicomm()
Definition: topology.hpp:210
rank_t intra_n_ranks()
Definition: topology.hpp:212
numa::node_t numa_n_nodes()
Definition: topology.hpp:228
rank_t intra_rank(rank_t global_rank)
Definition: topology.hpp:218
rank_t my_rank()
Definition: topology.hpp:207
numa::node_t numa_my_node()
Definition: topology.hpp:227
rank_t intra2global_rank(rank_t intra_rank)
Definition: topology.hpp:221
std::vector< T > mpi_allgather_value(const T &value, MPI_Comm comm)
Definition: mpi_util.hpp:218
int mpi_comm_rank(MPI_Comm comm)
Definition: mpi_util.hpp:28
int mpi_comm_size(MPI_Comm comm)
Definition: mpi_util.hpp:35
void sort(const ExecutionPolicy &policy, RandomAccessIterator first, RandomAccessIterator last, Compare comp)
Sort a range.
Definition: parallel_sort.hpp:210
Definition: options.hpp:117