DIY  3.0
data-parallel out-of-core C++ library
 All Classes Namespaces Functions Typedefs Groups Pages
swap.hpp
1 #ifndef DIY_PARTNERS_SWAP_HPP
2 #define DIY_PARTNERS_SWAP_HPP
3 
4 #include "common.hpp"
5 
6 namespace diy
7 {
8 
9 class Master;
10 
17 {
18  typedef RegularPartners Parent;
19 
20  // contiguous parameter indicates whether to match partners contiguously or in a round-robin fashion;
21  // contiguous is useful when data needs to be united;
22  // round-robin is useful for vector-"halving"
23  template<class Decomposer>
24  RegularSwapPartners(const Decomposer& decomposer,
25  int k,
26  bool contiguous = true
27  ):
28  Parent(decomposer, k, contiguous) {}
29  RegularSwapPartners(const DivisionVector& divs,
30  const KVSVector& kvs,
31  bool contiguous = true
32  ):
33  Parent(divs, kvs, contiguous) {}
34 
35  bool active(int round, int gid, const Master&) const { return true; } // in swap-reduce every block is always active
36 
37  void incoming(int round, int gid, std::vector<int>& partners, const Master&) const { Parent::fill(round - 1, gid, partners); }
38  void outgoing(int round, int gid, std::vector<int>& partners, const Master&) const { Parent::fill(round, gid, partners); }
39 };
40 
41 } // diy
42 
43 #endif
Definition: common.hpp:10
Decomposes a regular (discrete or continuous) domain into even blocks; creates Links with Bounds alon...
Definition: decomposition.hpp:75
RegularSwapPartners(const DivisionVector &divs, const KVSVector &kvs, bool contiguous=true)
Definition: swap.hpp:29
RegularSwapPartners(const Decomposer &decomposer, int k, bool contiguous=true)
Definition: swap.hpp:24
Definition: master.hpp:35
Partners for swap-reduce.
Definition: swap.hpp:16