Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
group.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * thrill/net/group.hpp
3  *
4  * net::Group is a collection of net::Connections providing simple MPI-like
5  * collectives and point-to-point communication.
6  *
7  * Part of Project Thrill - http://project-thrill.org
8  *
9  * Copyright (C) 2015 Robert Hangu <[email protected]>
10  * Copyright (C) 2015-2016 Timo Bingmann <[email protected]>
11  * Copyright (C) 2015 Lorenz Hübschle-Schneider <[email protected]>
12  * Copyright (C) 2015 Emanuel Jöbstl <[email protected]>
13  *
14  * All rights reserved. Published under the BSD-2 license in the LICENSE file.
15  ******************************************************************************/
16 
17 #pragma once
18 #ifndef THRILL_NET_GROUP_HEADER
19 #define THRILL_NET_GROUP_HEADER
20 
22 #include <thrill/common/math.hpp>
24 
25 #include <algorithm>
26 #include <cstring>
27 #include <functional>
28 #include <thread>
29 #include <vector>
30 
31 namespace thrill {
32 namespace net {
33 
34 //! \addtogroup net_layer
35 //! \{
36 
37 /*!
38  * A network Group is a collection of enumerated communication links, which
39  * provides point-to-point communication and MPI-like collective primitives.
40  *
41  * Each communication link in the Group has a specific rank and a representative
42  * class Connection can be accessed via connection().
43  *
44  * The Group class is abstract, and subclasses must exist for every network
45  * implementation.
46  */
47 class Group
48 {
49 public:
50  //! initializing constructor
51  explicit Group(size_t my_rank) : my_rank_(my_rank) { }
52 
53  //! non-copyable: delete copy-constructor
54  Group(const Group&) = delete;
55  //! non-copyable: delete assignment operator
56  Group& operator = (const Group&) = delete;
57  //! move-constructor: default
58  Group(Group&&) = default;
59  //! move-assignment operator: default
60  Group& operator = (Group&&) = default;
61 
62  //! virtual destructor
63  virtual ~Group() { }
64 
65  //! \name Base Functions
66  //! \{
67 
68  //! Return our rank among hosts in this group.
69  size_t my_host_rank() const { return my_rank_; }
70 
71  //! Return number of connections in this group (= number computing hosts)
72  virtual size_t num_hosts() const = 0;
73 
74  //! Return Connection to client id.
75  virtual Connection& connection(size_t id) = 0;
76 
77  //! Close
78  virtual void Close() = 0;
79 
80  //! Number of parallel sends or recvs requests supported by net backend, or
81  //! zero if asyncs are processed sequentially as with TCP.
82  virtual size_t num_parallel_async() const;
83 
84  //! Construct a network dispatcher object for the network backend used by
85  //! this group, matching its internal implementation. A dispatcher may be
86  //! shared between groups of the same type.
87  virtual std::unique_ptr<class Dispatcher> ConstructDispatcher() const = 0;
88 
89  //! Number of of 1-factor iterations
90  size_t OneFactorSize() const {
92  }
93 
94  //! Calculate the peer of this host in the k-th iteration (of 0..p-1) of a
95  //! 1-factor based network exchange algorithm.
96  size_t OneFactorPeer(size_t round) const {
98  }
99 
100  //! \}
101 
102  //! \name Convenience Functions
103  //! \{
104 
105  /*!
106  * Sends a serializable type to the given peer.
107  *
108  * \param dest The peer to send the data to.
109  * \param data The data to send.
110  */
111  template <typename T>
112  void SendTo(size_t dest, const T& data) {
113  connection(dest).Send(data);
114  }
115 
116  /*!
117  * Receives a serializable type from the given peer.
118  *
119  * \param src The peer to receive the fixed length type from.
120  * \param data A pointer to the location where the received data should be stored.
121  */
122  template <typename T>
123  void ReceiveFrom(size_t src, T* data) {
124  connection(src).Receive(data);
125  }
126 
127  //! \}
128 
129  //! \name Synchronous Collective Communication Functions
130  //! \{
131 
132  //! Calculate inclusive prefix sum
133  template <typename T, typename BinarySumOp = std::plus<T> >
134  void PrefixSum(T& value, BinarySumOp sum_op = BinarySumOp(),
135  const T& initial = T());
136 
137  //! Calculate exclusive prefix sum
138  template <typename T, typename BinarySumOp = std::plus<T> >
139  void ExPrefixSum(T& value, BinarySumOp sum_op = BinarySumOp(),
140  const T& initial = T());
141 
142  //! Broadcast a value from the worker "origin"
143  template <typename T>
144  void Broadcast(T& value, size_t origin = 0);
145 
146  //! Reduce a value from all workers to the worker 0
147  template <typename T, typename BinarySumOp = std::plus<T> >
148  void Reduce(T& value, size_t root = 0, BinarySumOp sum_op = BinarySumOp());
149 
150  //! Reduce a value from all workers to all workers
151  template <typename T, typename BinarySumOp = std::plus<T> >
152  void AllReduce(T& value, BinarySumOp sum_op = BinarySumOp());
153 
154  //! \}
155 
156  //! \name Additional Synchronous Collective Communication Functions
157  //! Do not use these directly in user code.
158  //! \{
159 
160  template <typename T, typename BinarySumOp = std::plus<T> >
161  void PrefixSumSelect(T& value, BinarySumOp sum_op = BinarySumOp(),
162  const T& initial = T(), bool inclusive = true);
163 
164  template <typename T, typename BinarySumOp = std::plus<T> >
165  void PrefixSumDoubling(T& value, BinarySumOp sum_op = BinarySumOp(),
166  const T& initial = T(), bool inclusive = true);
167 
168  template <typename T, typename BinarySumOp = std::plus<T> >
169  void PrefixSumHypercube(T& value, BinarySumOp sum_op = BinarySumOp());
170 
171  /**************************************************************************/
172 
173  template <typename T>
174  void BroadcastSelect(T& value, size_t origin = 0);
175 
176  template <typename T>
177  void BroadcastTrivial(T& value, size_t origin = 0);
178 
179  template <typename T>
180  void BroadcastBinomialTree(T& value, size_t origin = 0);
181 
182  /**************************************************************************/
183 
184  template <typename T>
185  void AllGatherRecursiveDoublingPowerOfTwo(T* values, size_t n);
186 
187  template <typename T>
188  void AllGatherBruck(T* values, size_t n);
189 
190  /**************************************************************************/
191 
192  template <typename T, typename BinarySumOp = std::plus<T> >
193  void AllReduceSelect(T& value, BinarySumOp sum_op = BinarySumOp());
194 
195  template <typename T, typename BinarySumOp = std::plus<T> >
196  void AllReduceSimple(T& value, BinarySumOp sum_op = BinarySumOp());
197 
198  template <typename T, typename BinarySumOp = std::plus<T> >
199  void AllReduceAtRoot(T& value, BinarySumOp sum_op = BinarySumOp());
200 
201  template <typename T, typename BinarySumOp = std::plus<T> >
202  void AllReduceHypercube(T& value, BinarySumOp sum_op = BinarySumOp());
203 
204  template <typename T, typename BinarySumOp = std::plus<T> >
205  void AllReduceElimination(T& value, BinarySumOp sum_op = BinarySumOp());
206 
207  /**************************************************************************/
208 
209 protected:
210  /*!
211  * Helper method for AllReduce(). Sends, receives, and reduces a
212  * serializable type from the given peer and returns the value after
213  * reduction
214  *
215  * \param peer The peer to exchange the fixed length type with.
216  * \param value Reference to the value exchange.
217  * \param sum_op Reduction operation.
218  */
219  template <typename T, typename BinarySumOp>
220  T SendReceiveReduce(size_t peer, const T& value, BinarySumOp sum_op);
221 
222  //! Helper method for AllReduce().
223  template <typename T, typename BinarySumOp>
225  size_t host_id, size_t group_size, size_t remaining_hosts,
226  size_t send_to, T& value, BinarySumOp sum_op);
227 
228  //! \}
229 
230 protected:
231  //! our rank in the network group
232  size_t my_rank_;
233 
234  //! \name Virtual Synchronous Collectives to Override Implementations
235  //! \{
236 
237 /*[[[perl
238  for my $e (
239  ["int", "Int"], ["unsigned int", "UnsignedInt"],
240  ["long", "Long"], ["unsigned long", "UnsignedLong"],
241  ["long long", "LongLong"], ["unsigned long long", "UnsignedLongLong"])
242  {
243  print "virtual void PrefixSumPlus$$e[1]($$e[0]& value, const $$e[0]& initial);\n";
244  print "virtual void ExPrefixSumPlus$$e[1]($$e[0]& value, const $$e[0]& initial);\n";
245  print "virtual void Broadcast$$e[1]($$e[0]& value, size_t origin);\n";
246  print "virtual void AllReducePlus$$e[1]($$e[0]& value);\n";
247  print "virtual void AllReduceMinimum$$e[1]($$e[0]& value);\n";
248  print "virtual void AllReduceMaximum$$e[1]($$e[0]& value);\n";
249  }
250 ]]]*/
251  virtual void PrefixSumPlusInt(int& value, const int& initial);
252  virtual void ExPrefixSumPlusInt(int& value, const int& initial);
253  virtual void BroadcastInt(int& value, size_t origin);
254  virtual void AllReducePlusInt(int& value);
255  virtual void AllReduceMinimumInt(int& value);
256  virtual void AllReduceMaximumInt(int& value);
257  virtual void PrefixSumPlusUnsignedInt(unsigned int& value, const unsigned int& initial);
258  virtual void ExPrefixSumPlusUnsignedInt(unsigned int& value, const unsigned int& initial);
259  virtual void BroadcastUnsignedInt(unsigned int& value, size_t origin);
260  virtual void AllReducePlusUnsignedInt(unsigned int& value);
261  virtual void AllReduceMinimumUnsignedInt(unsigned int& value);
262  virtual void AllReduceMaximumUnsignedInt(unsigned int& value);
263  virtual void PrefixSumPlusLong(long& value, const long& initial);
264  virtual void ExPrefixSumPlusLong(long& value, const long& initial);
265  virtual void BroadcastLong(long& value, size_t origin);
266  virtual void AllReducePlusLong(long& value);
267  virtual void AllReduceMinimumLong(long& value);
268  virtual void AllReduceMaximumLong(long& value);
269  virtual void PrefixSumPlusUnsignedLong(unsigned long& value, const unsigned long& initial);
270  virtual void ExPrefixSumPlusUnsignedLong(unsigned long& value, const unsigned long& initial);
271  virtual void BroadcastUnsignedLong(unsigned long& value, size_t origin);
272  virtual void AllReducePlusUnsignedLong(unsigned long& value);
273  virtual void AllReduceMinimumUnsignedLong(unsigned long& value);
274  virtual void AllReduceMaximumUnsignedLong(unsigned long& value);
275  virtual void PrefixSumPlusLongLong(long long& value, const long long& initial);
276  virtual void ExPrefixSumPlusLongLong(long long& value, const long long& initial);
277  virtual void BroadcastLongLong(long long& value, size_t origin);
278  virtual void AllReducePlusLongLong(long long& value);
279  virtual void AllReduceMinimumLongLong(long long& value);
280  virtual void AllReduceMaximumLongLong(long long& value);
281  virtual void PrefixSumPlusUnsignedLongLong(unsigned long long& value, const unsigned long long& initial);
282  virtual void ExPrefixSumPlusUnsignedLongLong(unsigned long long& value, const unsigned long long& initial);
283  virtual void BroadcastUnsignedLongLong(unsigned long long& value, size_t origin);
284  virtual void AllReducePlusUnsignedLongLong(unsigned long long& value);
285  virtual void AllReduceMinimumUnsignedLongLong(unsigned long long& value);
286  virtual void AllReduceMaximumUnsignedLongLong(unsigned long long& value);
287 // [[[end]]]
288 
289  //! \}
290 };
291 
292 //! unique pointer to a Group.
293 using GroupPtr = std::unique_ptr<Group>;
294 
295 //! Construct a mock Group using a complete graph of local stream sockets for
296 //! testing, and starts a thread for each client, which gets passed the Group
297 //! object. This is ideal for testing network communication protocols.
298 template <typename Group, typename GroupCalled>
300  const std::vector<std::unique_ptr<Group> >& groups,
301  const std::function<void(GroupCalled*)>& thread_function) {
302  size_t num_hosts = groups.size();
303 
304  // create a thread for each Group object and run user program.
305  std::vector<std::thread> threads(num_hosts);
306 
307  for (size_t i = 0; i < num_hosts; ++i) {
308  threads[i] = std::thread(
309  [thread_function, g = groups[i].get()]() {
310  return thread_function(g);
311  });
312  }
313 
314  for (size_t i = 0; i < num_hosts; ++i) {
315  threads[i].join();
316  }
317 
318  // tear down mesh by closing all group objects
319  for (size_t i = 0; i < num_hosts; ++i)
320  groups[i]->Close();
321 }
322 
323 //! Construct a mock or tcp-loopback Group network and run a thread for each
324 //! client. The selected network implementation is platform dependent and must
325 //! run without further configuration.
327  size_t num_hosts,
328  const std::function<void(Group*)>& thread_function);
329 
330 /******************************************************************************/
331 // Template Specializations to call Virtual Overrides
332 
333 /*[[[perl
334  for my $e (
335  ["int", "Int"], ["unsigned int", "UnsignedInt"],
336  ["long", "Long"], ["unsigned long", "UnsignedLong"],
337  ["long long", "LongLong"], ["unsigned long long", "UnsignedLongLong"])
338  {
339  print "template <>\n";
340  print "inline void Group::PrefixSum($$e[0]& value, std::plus<$$e[0]>, const $$e[0]& initial) {\n";
341  print " return PrefixSumPlus$$e[1](value, initial);\n";
342  print "}\n";
343 
344  print "template <>\n";
345  print "inline void Group::ExPrefixSum($$e[0]& value, std::plus<$$e[0]>, const $$e[0]& initial) {\n";
346  print " return ExPrefixSumPlus$$e[1](value, initial);\n";
347  print "}\n";
348 
349  print "template <>\n";
350  print "inline void Group::Broadcast($$e[0]& value, size_t origin) {\n";
351  print " return Broadcast$$e[1](value, origin);\n";
352  print "}\n";
353 
354  print "template <>\n";
355  print "inline void Group::AllReduce($$e[0]& value, std::plus<$$e[0]>) {\n";
356  print " return AllReducePlus$$e[1](value);\n";
357  print "}\n";
358 
359  print "template <>\n";
360  print "inline void Group::AllReduce($$e[0]& value, common::minimum<$$e[0]>) {\n";
361  print " return AllReduceMinimum$$e[1](value);\n";
362  print "}\n";
363 
364  print "template <>\n";
365  print "inline void Group::AllReduce($$e[0]& value, common::maximum<$$e[0]>) {\n";
366  print " return AllReduceMaximum$$e[1](value);\n";
367  print "}\n";
368  }
369 ]]]*/
370 template <>
371 inline void Group::PrefixSum(int& value, std::plus<int>, const int& initial) {
372  return PrefixSumPlusInt(value, initial);
373 }
374 template <>
375 inline void Group::ExPrefixSum(int& value, std::plus<int>, const int& initial) {
376  return ExPrefixSumPlusInt(value, initial);
377 }
378 template <>
379 inline void Group::Broadcast(int& value, size_t origin) {
380  return BroadcastInt(value, origin);
381 }
382 template <>
383 inline void Group::AllReduce(int& value, std::plus<int>) {
384  return AllReducePlusInt(value);
385 }
386 template <>
387 inline void Group::AllReduce(int& value, common::minimum<int>) {
388  return AllReduceMinimumInt(value);
389 }
390 template <>
391 inline void Group::AllReduce(int& value, common::maximum<int>) {
392  return AllReduceMaximumInt(value);
393 }
394 template <>
395 inline void Group::PrefixSum(unsigned int& value, std::plus<unsigned int>, const unsigned int& initial) {
396  return PrefixSumPlusUnsignedInt(value, initial);
397 }
398 template <>
399 inline void Group::ExPrefixSum(unsigned int& value, std::plus<unsigned int>, const unsigned int& initial) {
400  return ExPrefixSumPlusUnsignedInt(value, initial);
401 }
402 template <>
403 inline void Group::Broadcast(unsigned int& value, size_t origin) {
404  return BroadcastUnsignedInt(value, origin);
405 }
406 template <>
407 inline void Group::AllReduce(unsigned int& value, std::plus<unsigned int>) {
408  return AllReducePlusUnsignedInt(value);
409 }
410 template <>
411 inline void Group::AllReduce(unsigned int& value, common::minimum<unsigned int>) {
412  return AllReduceMinimumUnsignedInt(value);
413 }
414 template <>
415 inline void Group::AllReduce(unsigned int& value, common::maximum<unsigned int>) {
416  return AllReduceMaximumUnsignedInt(value);
417 }
418 template <>
419 inline void Group::PrefixSum(long& value, std::plus<long>, const long& initial) {
420  return PrefixSumPlusLong(value, initial);
421 }
422 template <>
423 inline void Group::ExPrefixSum(long& value, std::plus<long>, const long& initial) {
424  return ExPrefixSumPlusLong(value, initial);
425 }
426 template <>
427 inline void Group::Broadcast(long& value, size_t origin) {
428  return BroadcastLong(value, origin);
429 }
430 template <>
431 inline void Group::AllReduce(long& value, std::plus<long>) {
432  return AllReducePlusLong(value);
433 }
434 template <>
435 inline void Group::AllReduce(long& value, common::minimum<long>) {
436  return AllReduceMinimumLong(value);
437 }
438 template <>
439 inline void Group::AllReduce(long& value, common::maximum<long>) {
440  return AllReduceMaximumLong(value);
441 }
442 template <>
443 inline void Group::PrefixSum(unsigned long& value, std::plus<unsigned long>, const unsigned long& initial) {
444  return PrefixSumPlusUnsignedLong(value, initial);
445 }
446 template <>
447 inline void Group::ExPrefixSum(unsigned long& value, std::plus<unsigned long>, const unsigned long& initial) {
448  return ExPrefixSumPlusUnsignedLong(value, initial);
449 }
450 template <>
451 inline void Group::Broadcast(unsigned long& value, size_t origin) {
452  return BroadcastUnsignedLong(value, origin);
453 }
454 template <>
455 inline void Group::AllReduce(unsigned long& value, std::plus<unsigned long>) {
456  return AllReducePlusUnsignedLong(value);
457 }
458 template <>
459 inline void Group::AllReduce(unsigned long& value, common::minimum<unsigned long>) {
460  return AllReduceMinimumUnsignedLong(value);
461 }
462 template <>
463 inline void Group::AllReduce(unsigned long& value, common::maximum<unsigned long>) {
464  return AllReduceMaximumUnsignedLong(value);
465 }
466 template <>
467 inline void Group::PrefixSum(long long& value, std::plus<long long>, const long long& initial) {
468  return PrefixSumPlusLongLong(value, initial);
469 }
470 template <>
471 inline void Group::ExPrefixSum(long long& value, std::plus<long long>, const long long& initial) {
472  return ExPrefixSumPlusLongLong(value, initial);
473 }
474 template <>
475 inline void Group::Broadcast(long long& value, size_t origin) {
476  return BroadcastLongLong(value, origin);
477 }
478 template <>
479 inline void Group::AllReduce(long long& value, std::plus<long long>) {
480  return AllReducePlusLongLong(value);
481 }
482 template <>
483 inline void Group::AllReduce(long long& value, common::minimum<long long>) {
484  return AllReduceMinimumLongLong(value);
485 }
486 template <>
487 inline void Group::AllReduce(long long& value, common::maximum<long long>) {
488  return AllReduceMaximumLongLong(value);
489 }
490 template <>
491 inline void Group::PrefixSum(unsigned long long& value, std::plus<unsigned long long>, const unsigned long long& initial) {
492  return PrefixSumPlusUnsignedLongLong(value, initial);
493 }
494 template <>
495 inline void Group::ExPrefixSum(unsigned long long& value, std::plus<unsigned long long>, const unsigned long long& initial) {
496  return ExPrefixSumPlusUnsignedLongLong(value, initial);
497 }
498 template <>
499 inline void Group::Broadcast(unsigned long long& value, size_t origin) {
500  return BroadcastUnsignedLongLong(value, origin);
501 }
502 template <>
503 inline void Group::AllReduce(unsigned long long& value, std::plus<unsigned long long>) {
504  return AllReducePlusUnsignedLongLong(value);
505 }
506 template <>
507 inline void Group::AllReduce(unsigned long long& value, common::minimum<unsigned long long>) {
508  return AllReduceMinimumUnsignedLongLong(value);
509 }
510 template <>
511 inline void Group::AllReduce(unsigned long long& value, common::maximum<unsigned long long>) {
512  return AllReduceMaximumUnsignedLongLong(value);
513 }
514 // [[[end]]]
515 
516 //! \}
517 
518 } // namespace net
519 } // namespace thrill
520 
521 #include <thrill/net/collective.hpp>
522 
523 #endif // !THRILL_NET_GROUP_HEADER
524 
525 /******************************************************************************/
virtual void AllReducePlusLongLong(long long &value)
Definition: group.cpp:274
virtual void BroadcastLong(long &value, size_t origin)
Definition: group.cpp:235
virtual void AllReducePlusUnsignedInt(unsigned int &value)
Definition: group.cpp:220
virtual void PrefixSumPlusLongLong(long long &value, const long long &initial)
Definition: group.cpp:265
Group(size_t my_rank)
initializing constructor
Definition: group.hpp:51
virtual void AllReduceMinimumUnsignedInt(unsigned int &value)
Definition: group.cpp:223
virtual void ExPrefixSumPlusLongLong(long long &value, const long long &initial)
Definition: group.cpp:268
void BroadcastSelect(T &value, size_t origin=0)
select broadcast implementation (often due to total number of processors)
Definition: collective.hpp:238
double T
virtual void ExPrefixSumPlusInt(int &value, const int &initial)
Definition: group.cpp:196
Group & operator=(const Group &)=delete
non-copyable: delete assignment operator
virtual void ExPrefixSumPlusUnsignedLongLong(unsigned long long &value, const unsigned long long &initial)
Definition: group.cpp:286
size_t my_rank_
our rank in the network group
Definition: group.hpp:232
virtual void AllReducePlusInt(int &value)
Definition: group.cpp:202
virtual void BroadcastInt(int &value, size_t origin)
Definition: group.cpp:199
virtual std::unique_ptr< class Dispatcher > ConstructDispatcher() const =0
static size_t CalcOneFactorPeer(size_t r, size_t p, size_t n)
Calculate a Perfect Matching (1-Factor) on a Complete Graph.
Definition: math.hpp:140
void ExecuteGroupThreads(const std::vector< std::unique_ptr< Group > > &groups, const std::function< void(GroupCalled *)> &thread_function)
Definition: group.hpp:299
virtual Connection & connection(size_t id)=0
Return Connection to client id.
void ExPrefixSum(T &value, BinarySumOp sum_op=BinarySumOp(), const T &initial=T())
Calculate exclusive prefix sum.
Definition: collective.hpp:164
virtual void AllReduceMinimumInt(int &value)
Definition: group.cpp:205
void AllReduceHypercube(T &value, BinarySumOp sum_op=BinarySumOp())
Perform an All-Reduce for powers of two.
Definition: collective.hpp:413
std::enable_if< std::is_pod< T >::value, void >::type Send(const T &value)
Definition: connection.hpp:105
void BroadcastBinomialTree(T &value, size_t origin=0)
Broadcasts the value of the worker with index "origin" to all the others.
Definition: collective.hpp:204
virtual void BroadcastUnsignedLong(unsigned long &value, size_t origin)
Definition: group.cpp:253
virtual void ExPrefixSumPlusLong(long &value, const long &initial)
Definition: group.cpp:232
size_t OneFactorPeer(size_t round) const
Definition: group.hpp:96
void AllReduce(T &value, BinarySumOp sum_op=BinarySumOp())
Reduce a value from all workers to all workers.
Definition: collective.hpp:567
virtual void PrefixSumPlusUnsignedLong(unsigned long &value, const unsigned long &initial)
Definition: group.cpp:247
virtual void PrefixSumPlusUnsignedLongLong(unsigned long long &value, const unsigned long long &initial)
Definition: group.cpp:283
virtual void AllReduceMinimumLong(long &value)
Definition: group.cpp:241
size_t OneFactorSize() const
Number of of 1-factor iterations.
Definition: group.hpp:90
virtual void AllReduceMaximumUnsignedLong(unsigned long &value)
Definition: group.cpp:262
virtual void Close()=0
Close.
size_t my_host_rank() const
Return our rank among hosts in this group.
Definition: group.hpp:69
virtual void AllReducePlusUnsignedLongLong(unsigned long long &value)
Definition: group.cpp:292
virtual void AllReduceMaximumLongLong(long long &value)
Definition: group.cpp:280
virtual void AllReduceMinimumUnsignedLong(unsigned long &value)
Definition: group.cpp:259
int value
Definition: gen_data.py:41
A Connection represents a link to another peer in a network group.
Definition: connection.hpp:49
void SendTo(size_t dest, const T &data)
Sends a serializable type to the given peer.
Definition: group.hpp:112
virtual void BroadcastUnsignedLongLong(unsigned long long &value, size_t origin)
Definition: group.cpp:289
void AllReduceElimination(T &value, BinarySumOp sum_op=BinarySumOp())
Perform an All-Reduce using the elimination protocol described in R.
Definition: collective.hpp:458
virtual size_t num_parallel_async() const
Definition: group.cpp:158
void PrefixSumHypercube(T &value, BinarySumOp sum_op=BinarySumOp())
Calculate for every worker his prefix sum.
Definition: collective.hpp:112
virtual void ExPrefixSumPlusUnsignedInt(unsigned int &value, const unsigned int &initial)
Definition: group.cpp:214
void Broadcast(T &value, size_t origin=0)
Broadcast a value from the worker "origin".
Definition: collective.hpp:251
virtual void AllReduceMaximumUnsignedLongLong(unsigned long long &value)
Definition: group.cpp:298
std::vector< T, Allocator< T > > vector
vector with Manager tracking
Definition: allocator.hpp:228
void BroadcastTrivial(T &value, size_t origin=0)
Broadcasts the value of the peer with index 0 to all the others.
Definition: collective.hpp:180
virtual void ExPrefixSumPlusUnsignedLong(unsigned long &value, const unsigned long &initial)
Definition: group.cpp:250
std::unique_ptr< Group > GroupPtr
unique pointer to a Group.
Definition: group.hpp:293
void AllGatherBruck(T *values, size_t n)
Definition: collective.hpp:278
void RunLoopbackGroupTest(size_t num_hosts, const std::function< void(Group *)> &thread_function)
Definition: group.cpp:27
virtual void BroadcastUnsignedInt(unsigned int &value, size_t origin)
Definition: group.cpp:217
virtual void AllReduceMaximumUnsignedInt(unsigned int &value)
Definition: group.cpp:226
std::enable_if< std::is_pod< T >::value, void >::type Receive(T *out_value)
Receive any serializable POD item T.
Definition: connection.hpp:184
void AllReduceAtRoot(T &value, BinarySumOp sum_op=BinarySumOp())
Broadcasts the value of the peer with index 0 to all the others.
Definition: collective.hpp:381
A network Group is a collection of enumerated communication links, which provides point-to-point comm...
Definition: group.hpp:47
virtual void AllReduceMaximumLong(long &value)
Definition: group.cpp:244
void AllGatherRecursiveDoublingPowerOfTwo(T *values, size_t n)
Definition: collective.hpp:259
void Reduce(T &value, size_t root=0, BinarySumOp sum_op=BinarySumOp())
Reduce a value from all workers to the worker 0.
Definition: collective.hpp:330
virtual void AllReduceMaximumInt(int &value)
Definition: group.cpp:208
static size_t CalcOneFactorSize(size_t n)
Number of rounds in Perfect Matching (1-Factor).
Definition: math.hpp:127
void AllReduceSimple(T &value, BinarySumOp sum_op=BinarySumOp())
Perform an All-Reduce on the workers.
Definition: collective.hpp:367
void AllReduceEliminationProcess(size_t host_id, size_t group_size, size_t remaining_hosts, size_t send_to, T &value, BinarySumOp sum_op)
Helper method for AllReduce().
Definition: collective.hpp:478
void PrefixSum(T &value, BinarySumOp sum_op=BinarySumOp(), const T &initial=T())
Calculate inclusive prefix sum.
Definition: collective.hpp:159
virtual void AllReduceMinimumUnsignedLongLong(unsigned long long &value)
Definition: group.cpp:295
void ReceiveFrom(size_t src, T *data)
Receives a serializable type from the given peer.
Definition: group.hpp:123
virtual ~Group()
virtual destructor
Definition: group.hpp:63
void PrefixSumSelect(T &value, BinarySumOp sum_op=BinarySumOp(), const T &initial=T(), bool inclusive=true)
select prefixsum implementation (often due to total number of processors)
Definition: collective.hpp:153
virtual void PrefixSumPlusUnsignedInt(unsigned int &value, const unsigned int &initial)
Definition: group.cpp:211
virtual void AllReduceMinimumLongLong(long long &value)
Definition: group.cpp:277
virtual void PrefixSumPlusInt(int &value, const int &initial)
Definition: group.cpp:193
virtual void AllReducePlusLong(long &value)
Definition: group.cpp:238
virtual size_t num_hosts() const =0
Return number of connections in this group (= number computing hosts)
virtual void AllReducePlusUnsignedLong(unsigned long &value)
Definition: group.cpp:256
void AllReduceSelect(T &value, BinarySumOp sum_op=BinarySumOp())
select allreduce implementation (often due to total number of processors)
Definition: collective.hpp:550
virtual void BroadcastLongLong(long long &value, size_t origin)
Definition: group.cpp:271
void PrefixSumDoubling(T &value, BinarySumOp sum_op=BinarySumOp(), const T &initial=T(), bool inclusive=true)
Calculate for every worker his prefix sum.
Definition: collective.hpp:51
virtual void PrefixSumPlusLong(long &value, const long &initial)
Definition: group.cpp:229
T SendReceiveReduce(size_t peer, const T &value, BinarySumOp sum_op)
Helper method for AllReduce().
Definition: collective.hpp:464