Chi-Tech
chi_mpi_commset.h
Go to the documentation of this file.
1#ifndef CHITECH_CHI_MPI_COMMSET_H
2#define CHITECH_CHI_MPI_COMMSET_H
3
4#include <mpi.h>
5#include "mesh/chi_mesh.h"
6#include "chi_runtime.h"
7
8namespace chi
9{
10
11//################################################################### Class def
12/**Simple implementation a communicator set.
13 * Definitions:
14 * P = total amount of processors.
15 * locI = process I in [0,P]*/
17{
18private:
19 /**A list of communicators, size P, contains a communicator for
20 * only communicating with the neighbors of locI.*/
21 std::vector<MPI_Comm> communicators_;
22 /**A list of groupings, size P, allows mapping of the rank of locJ
23 * relative to the local communicator.*/
24 std::vector<MPI_Group> location_groups_;
25 /**Used to translate ranks.*/
26 MPI_Group world_group_;
27
28public:
29 ChiMPICommunicatorSet(std::vector<MPI_Comm>& communicators,
30 std::vector<MPI_Group>& location_groups,
31 MPI_Group& world_group) :
32 communicators_(communicators),
33 location_groups_(location_groups),
34 world_group_(world_group)
35 {}
36
37 MPI_Comm LocICommunicator(int locI) const
38 {
39 return communicators_[locI];
40 }
41
42 int MapIonJ(int locI, int locJ) const
43 {
44 int group_rank;
45 MPI_Group_translate_ranks(world_group_, 1, &locI,
46 location_groups_[locJ], &group_rank);
47
48 return group_rank;
49 }
50};
51}//namespace chi_objects
52
53
54
55
56#endif //CHITECH_CHI_MPI_COMMSET_H
std::vector< MPI_Group > location_groups_
MPI_Comm LocICommunicator(int locI) const
std::vector< MPI_Comm > communicators_
ChiMPICommunicatorSet(std::vector< MPI_Comm > &communicators, std::vector< MPI_Group > &location_groups, MPI_Group &world_group)
int MapIonJ(int locI, int locJ) const