1 #ifndef DIY_ASSIGNER_HPP
2 #define DIY_ASSIGNER_HPP
21 size_(size), nblocks_(nblocks) {}
24 int size()
const {
return size_; }
30 virtual void local_gids(
int rank, std::vector<int>& gids)
const =0;
32 virtual int rank(
int gid)
const =0;
54 int rank(
int gid)
const override
58 int r = gid / (div + 1);
64 return mod + (gid - (div + 1)*mod)/div;
86 int rank(
int gid)
const override {
return gid %
size(); }
101 from = rank * (div + 1);
103 from = mod * (div + 1) + (rank - mod) * div;
106 to = (rank + 1) * (div + 1);
108 to = mod * (div + 1) + (rank + 1 - mod) * div;
110 for (
int gid = from; gid < to; ++gid)
119 while (cur < nblocks())
void local_gids(int rank, std::vector< int > &gids) const override
gets the local gids for a given process rank
Definition: assigner.hpp:116
Definition: assigner.hpp:39
Definition: assigner.hpp:71
int nblocks() const
returns the total number of global blocks
Definition: assigner.hpp:26
void set_nblocks(int nblocks)
sets the total number of global blocks
Definition: assigner.hpp:28
virtual int rank(int gid) const =0
returns the process rank of the block with global id gid (need not be local)
int size() const
returns the total number of process ranks
Definition: assigner.hpp:24
Definition: assigner.hpp:11
int rank(int gid) const override
returns the process rank of the block with global id gid (need not be local)
Definition: assigner.hpp:54
int rank(int gid) const override
returns the process rank of the block with global id gid (need not be local)
Definition: assigner.hpp:86
ContiguousAssigner(int size, int nblocks)
Assigns blocks to processes in contiguous gid (block global id) order.
Definition: assigner.hpp:46
void local_gids(int rank, std::vector< int > &gids) const override
gets the local gids for a given process rank
Definition: assigner.hpp:94
virtual void local_gids(int rank, std::vector< int > &gids) const =0
gets the local gids for a given process rank
RoundRobinAssigner(int size, int nblocks)
Assigns blocks to processes in cyclic or round-robin gid (block global id) order. ...
Definition: assigner.hpp:78
Assigner(int size, int nblocks)
Manages how blocks are assigned to processes.
Definition: assigner.hpp:18