forked from deepmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpara_bgroup_world.h
More file actions
67 lines (55 loc) · 1.74 KB
/
Copy pathpara_bgroup_world.h
File metadata and controls
67 lines (55 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef PARA_BGROUP_WORLD_H
#define PARA_BGROUP_WORLD_H
#include "para_world.h"
namespace Parallel
{
/**
* @brief bgroup parallel domain: band group communication topology.
*
* Self-contained replacement for INT_BGROUP + BP_WORLD +
* GlobalV::MY_BNDGROUP/NPROC_IN_BNDGROUP/RANK_IN_BPGROUP.
*
* The band group domain has two communicators:
* - intra: INT_BGROUP (same band group, different k/pw)
* - inter: BP_WORLD (different band groups, same k)
*
* Tests only need this header.
*/
class ParaBgroupWorld : public ParaWorld
{
public:
/**
* @brief Construct a serial bgroup domain (single band group).
*/
ParaBgroupWorld();
#ifdef __MPI
/**
* @brief Construct a bgroup domain from intra and inter communicators.
*
* @param[in] intra_comm intra-group communicator (e.g. INT_BGROUP)
* @param[in] inter_comm inter-group communicator (e.g. BP_WORLD)
* @param[in] nbndgroup number of band groups
*/
ParaBgroupWorld(const MPI_Comm& intra_comm, const MPI_Comm& inter_comm, int nbndgroup);
#endif
/// Band group index of this process.
int my_bndgroup() const { return my_bndgroup_; }
/// Number of band groups.
int nbndgroup() const { return nbndgroup_; }
/// Rank within the band group (alias for rank()).
int rank_in_bpgroup() const { return rank(); }
/// Number of processes in the band group (alias for size()).
int nproc_in_bndgroup() const { return size(); }
#ifdef __MPI
/// Inter-group communicator (BP_WORLD equivalent).
MPI_Comm inter_comm() const { return inter_comm_; }
#endif
private:
int my_bndgroup_ = 0;
int nbndgroup_ = 1;
#ifdef __MPI
MPI_Comm inter_comm_ = MPI_COMM_NULL;
#endif
};
} // namespace Parallel
#endif // PARA_BGROUP_WORLD_H