Class documentation of Concepts

Loading...
Searching...
No Matches
communicators.hh
Go to the documentation of this file.
1
6#ifndef communicators_hh
7#define communicators_hh
8
9#include "basics.hh"
10#include "using_p.hh"
11
12// ********************************* forward declarations **
13
14#ifdef MPICH
15typedef union MPIR_HANDLE *MPI_Request;
16#else
17typedef struct _req *MPI_Request;
18#endif
19
20namespace parallel {
21
22 // ************************************ MissingDataType **
23
29
30
31 // *************************************** Communicator **
32
36
37 public:
38 virtual ~Communicator() {};
39
40 virtual int rank() const = 0;
41 virtual int nrank() const = 0;
42
43 // receive
44 virtual int receive(void *rbuf, uint cnt, uint src) = 0;
45 virtual int receive(uint *rbuf, uint cnt, uint src) = 0;
46 virtual int receive(Real *rbuf, uint cnt, uint src) = 0;
47
48 // non-blocking operations
49 virtual int nbsend(void *sbuf, uint cnt, uint* dest, uint ndest) = 0;
50 virtual int nbsend(uint *sbuf, uint cnt, uint* dest, uint ndest) = 0;
51 virtual int nbsend(Real *sbuf, uint cnt, uint* dest, uint ndest) = 0;
52 virtual int waitall() = 0;
53
54 // allgather
55 virtual int allgather(void *sbuf, uint cnt, void *rbuf) = 0;
56 virtual int allgather(uint *sbuf, uint cnt, uint *rbuf) = 0;
57 virtual int allgather(Real *sbuf, uint cnt, Real *rbuf) = 0;
58
59 // alltoall
60 virtual int alltoallV(void *sbuf, int *nsdata, int *sdataoffset,
61 void *rbuf, int *nrdata, int *rdataoffset) = 0;
62 virtual int alltoallV(uint *sbuf, int *nsdata, int *sdataoffset,
63 uint *rbuf, int *nrdata, int *rdataoffset) = 0;
64
65 // barrier
66 virtual int barrier() = 0;
67 };
68
69
70 // ********************************************* ComMPI **
71
74 class ComMPI : public Communicator {
75
76 class Request {
77 Request *lnk_;
78 MPI_Request *request_;
79 uint nreq_;
80
81 public:
82 Request(Request *lnk, uint nreq);
83 ~Request();
84
85 MPI_Request* operator[](uint i);
86 inline MPI_Request* request() {return request_;};
87 inline uint nrequest() const {return nreq_;};
88 inline Request* link() const {return lnk_;};
89 };
90
92 int rnk_;
93 int nrnk_;
94
95 Request *request_;
96
97 protected:
98 std::ostream& info(std::ostream& os) const {
99 return os << "ComMPI(rank=" << rnk_ << ", nrank=" << nrnk_ << ")";
100 };
101
102 public:
103 ComMPI(int *argc, char ***argv);
104 ~ComMPI();
105
106 int rank() const {return rnk_;};
107 int nrank() const {return nrnk_;};
108
109 // receive
110 int receive(void *rbuf, uint cnt, uint src);
111 int receive(uint *rbuf, uint cnt, uint src);
112 int receive(Real *rbuf, uint cnt, uint src);
113
114 // non-blocking operations
115 int nbsend(void *sbuf, uint cnt, uint* dest, uint ndest);
116 int nbsend(uint *sbuf, uint cnt, uint* dest, uint ndest);
117 int nbsend(Real *sbuf, uint cnt, uint* dest, uint ndest);
118 int waitall();
119
120 // allgather
121 int allgather(void *sbuf, uint cnt, void *rbuf);
122 int allgather(uint *sbuf, uint cnt, uint *rbuf);
123 int allgather(Real *sbuf, uint cnt, Real *rbuf);
124
125 // alltoall
126 int alltoallV(void *sndbuf, int *sndcounts, int *sdispls,
127 void *recvbuf, int *recvcounts, int *rdispls);
128 int alltoallV(uint *sndbuf, int *sndcounts, int *sdispls,
129 uint *recvbuf, int *recvcounts, int *rdispls);
130
131 // barrier
132 int barrier();
133 };
134
135
136} // namespace parallel
137
138#endif // communicators_hh
std::ostream & info(std::ostream &os) const
Returns information in an output stream.