22 #ifndef THRILL_NET_MPI_GROUP_HEADER 23 #define THRILL_NET_MPI_GROUP_HEADER 64 static constexpr
bool debug =
false;
76 bool IsValid() const final {
return true; }
79 int peer()
const {
return peer_; }
83 std::ostream& OutputOstream(std::ostream& os)
const final;
91 const void* data,
size_t size,
Flags = NoFlags)
final;
94 const void* data,
size_t size,
Flags flags = NoFlags)
final {
95 SyncSend(data, size, flags);
104 void SyncRecv(
void* out_data,
size_t size)
final;
106 ssize_t
RecvOne(
void* out_data,
size_t size)
final {
107 SyncRecv(out_data, size);
116 void SyncSendRecv(
const void* send_data,
size_t send_size,
117 void* recv_data,
size_t recv_size)
final;
118 void SyncRecvSend(
const void* send_data,
size_t send_size,
119 void* recv_data,
size_t recv_size)
final;
139 static constexpr
bool debug =
false;
146 Group(
size_t my_rank,
int group_tag,
size_t group_size,
148 : net::
Group(my_rank),
149 group_tag_(group_tag),
151 dispatcher_(dispatcher) {
153 for (
size_t i = 0; i < group_size; ++i)
154 conns_[i].
Initialize(
this, static_cast<int>(i));
161 size_t num_hosts() const final {
return conns_.size(); }
167 assert(peer < conns_.size());
174 size_t num_parallel_async()
const final;
179 std::unique_ptr<net::Dispatcher> ConstructDispatcher()
const final;
196 template <
typename MpiCall>
197 void WaitForRequest(MpiCall call);
216 void PrefixSumPlusInt(
int&
value,
const int& initial)
final;
217 void ExPrefixSumPlusInt(
int&
value,
const int& initial)
final;
218 void BroadcastInt(
int&
value,
size_t origin)
final;
219 void AllReducePlusInt(
int&
value)
final;
220 void AllReduceMinimumInt(
int&
value)
final;
221 void AllReduceMaximumInt(
int&
value)
final;
222 void PrefixSumPlusUnsignedInt(
unsigned int&
value,
const unsigned int& initial)
final;
223 void ExPrefixSumPlusUnsignedInt(
unsigned int&
value,
const unsigned int& initial)
final;
224 void BroadcastUnsignedInt(
unsigned int&
value,
size_t origin)
final;
225 void AllReducePlusUnsignedInt(
unsigned int&
value)
final;
226 void AllReduceMinimumUnsignedInt(
unsigned int&
value)
final;
227 void AllReduceMaximumUnsignedInt(
unsigned int&
value)
final;
228 void PrefixSumPlusLong(
long&
value,
const long& initial)
final;
229 void ExPrefixSumPlusLong(
long&
value,
const long& initial)
final;
230 void BroadcastLong(
long&
value,
size_t origin)
final;
231 void AllReducePlusLong(
long&
value)
final;
232 void AllReduceMinimumLong(
long&
value)
final;
233 void AllReduceMaximumLong(
long&
value)
final;
234 void PrefixSumPlusUnsignedLong(
unsigned long&
value,
const unsigned long& initial)
final;
235 void ExPrefixSumPlusUnsignedLong(
unsigned long&
value,
const unsigned long& initial)
final;
236 void BroadcastUnsignedLong(
unsigned long&
value,
size_t origin)
final;
237 void AllReducePlusUnsignedLong(
unsigned long&
value)
final;
238 void AllReduceMinimumUnsignedLong(
unsigned long&
value)
final;
239 void AllReduceMaximumUnsignedLong(
unsigned long&
value)
final;
240 void PrefixSumPlusLongLong(
long long&
value,
const long long& initial)
final;
241 void ExPrefixSumPlusLongLong(
long long&
value,
const long long& initial)
final;
242 void BroadcastLongLong(
long long&
value,
size_t origin)
final;
243 void AllReducePlusLongLong(
long long&
value)
final;
244 void AllReduceMinimumLongLong(
long long&
value)
final;
245 void AllReduceMaximumLongLong(
long long&
value)
final;
246 void PrefixSumPlusUnsignedLongLong(
unsigned long long&
value,
const unsigned long long& initial)
final;
247 void ExPrefixSumPlusUnsignedLongLong(
unsigned long long&
value,
const unsigned long long& initial)
final;
248 void BroadcastUnsignedLongLong(
unsigned long long&
value,
size_t origin)
final;
249 void AllReducePlusUnsignedLongLong(
unsigned long long&
value)
final;
250 void AllReduceMinimumUnsignedLongLong(
unsigned long long&
value)
final;
251 void AllReduceMaximumUnsignedLongLong(
unsigned long long&
value)
final;
269 std::unique_ptr<Group>* groups,
size_t group_count);
285 #endif // !THRILL_NET_MPI_GROUP_HEADER int peer_
Outgoing peer id of this Connection.
size_t num_hosts() const final
number of hosts configured.
DispatcherThread & dispatcher_
reference to the main MPI dispatcher thread
ssize_t RecvOne(void *out_data, size_t size) final
A derived exception class which looks up MPI error strings.
ssize_t SendOne(const void *data, size_t size, Flags flags=NoFlags) final
int group_tag_
this group's MPI tag
A Exception is thrown by Connection on all errors instead of returning error codes.
std::vector< Connection > conns_
vector of virtual connection objects to remote peers
A Connection represents a link to another peer in a network group.
Group(size_t my_rank, int group_tag, size_t group_size, DispatcherThread &dispatcher)
Initialize a Group for the given size and rank.
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
static constexpr bool debug
size_t MpiRank()
Return the rank of this process in the MPI COMM WORLD.
A network Group is a collection of enumerated communication links, which provides point-to-point comm...
A net group backed by virtual MPI connection.
int peer() const
return the MPI peer number
Exception(const std::string &what)
static void Initialize()
run MPI_Init() if not already done (can be called multiple times).
int group_tag() const
return MPI tag used to communicate
Flags
Additional flags for sending or receiving.
size_t NumMpiProcesses()
Return the number of MPI processes.
static std::string GetErrorString(int error_code)
return the MPI error string
Virtual MPI connection class.
net::Connection & connection(size_t peer) final
Return Connection to client id.
bool IsValid() const final
check whether the connection is (still) valid.
void Initialize(Group *group, int peer)
construct from group tag and MPI peer
Group * group_
Group reference.
DispatcherThread contains a net::Dispatcher object and an associated thread that runs in the dispatch...
DispatcherThread & dispatcher()
reference to the main MPI dispatcher thread
bool Construct(size_t group_size, DispatcherThread &dispatcher, std::unique_ptr< Group > *groups, size_t group_count)
Construct Group which connects to peers using MPI.