DIY 3.0 data-parallel out-of-core C++ library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List

All Classes Namespaces Functions Typedefs Groups Pages
communicator.hpp
1 namespace diy
2 {
3 namespace mpi
4 {
5
8 class communicator
9 {
10 public:
11 communicator(MPI_Comm comm = MPI_COMM_WORLD):
12 comm_(comm) { MPI_Comm_rank(comm_, &rank_); MPI_Comm_size(comm_, &size_); }
13
14 int rank() const { return rank_; }
15 int size() const { return size_; }
16
17 //void send(int dest,
18 // int tag,
19 // const void* buf,
20 // MPI_Datatype datatype) const { }
21
23 template<class T>
24 void send(int dest, int tag, const T& x) const { detail::send<T>()(comm_, dest, tag, x); }
25
28 template<class T>
29 status recv(int source, int tag, T& x) const { return detail::recv<T>()(comm_, source, tag, x); }
30
32 template<class T>
33 request isend(int dest, int tag, const T& x) const { return detail::isend<T>()(comm_, dest, tag, x); }
34
37 template<class T>
38 request irecv(int source, int tag, T& x) const { return detail::irecv<T>()(comm_, source, tag, x); }
39
41 status probe(int source, int tag) const { status s; MPI_Probe(source, tag, comm_, &s.s); return s; }
42
44 inline
45 optional<status>
46 iprobe(int source, int tag) const;
47
49 void barrier() const { MPI_Barrier(comm_); }
50
51 operator MPI_Comm() const { return comm_; }
52
53 private:
54 MPI_Comm comm_;
55 int rank_;
56 int size_;
57 };
58 }
59 }
60
61 diy::mpi::optional<diy::mpi::status>
62 diy::mpi::communicator::
63 iprobe(int source, int tag) const
64 {
65 status s;
66 int flag;
67 MPI_Iprobe(source, tag, comm_, &flag, &s.s);
68 if (flag)
69 return s;
70 return optional<status>();
71 }
72
diy::mpi::communicator::isend
request isend(int dest, int tag, const T &x) const
Non-blocking version of send().
Definition: communicator.hpp:33
diy::mpi::communicator
Simple wrapper around MPI_Comm.
Definition: communicator.hpp:8
diy::mpi::communicator::irecv
request irecv(int source, int tag, T &x) const
Non-blocking version of recv(). If T is an std::vector<...>, its size must be big enough to accomodat...
Definition: communicator.hpp:38
diy::mpi::communicator::barrier
void barrier() const
barrier
Definition: communicator.hpp:49
diy::mpi::status
Definition: status.hpp:5
diy::mpi::communicator::recv
status recv(int source, int tag, T &x) const
Receive x from dest using tag (blocking). If T is an std::vector<...>, recv will resize it to fit exa...
Definition: communicator.hpp:29
diy::mpi::communicator::iprobe
optional< status > iprobe(int source, int tag) const
iprobe
Definition: communicator.hpp:63
diy::mpi::optional
Definition: optional.hpp:6
diy::mpi::request
Definition: request.hpp:5
diy::mpi::communicator::send
void send(int dest, int tag, const T &x) const
Send x to processor dest using tag (blocking).
Definition: communicator.hpp:24
diy::mpi::communicator::probe
status probe(int source, int tag) const
probe
Definition: communicator.hpp:41