31 #ifndef BITMAPCAROUSEL_H 32 #define BITMAPCAROUSEL_H 41 template <
class IT,
class NT>
44 BitMapCarousel(std::shared_ptr<CommGrid> grid, IT glen,
int local_subword_disp) {
48 my_procrow = commGrid->GetRankInProcCol();
49 my_proccol = commGrid->GetRankInProcRow();
50 procrows = commGrid->GetGridRows();
51 proccols = commGrid->GetGridCols();
54 IT biggest_size = global_size -
RotLengthUntil(procrows-1, proccols-1) + 63;
55 bm =
new BitMap(biggest_size);
56 recv_buff =
new BitMap(biggest_size);
57 old_bm =
new BitMap(biggest_size);
58 sub_disps =
new int[proccols];
59 sub_disps[my_proccol] = local_subword_disp;
60 MPI_Allgather(MPI_IN_PLACE, 1, MPI_INT, sub_disps, 1, MPI_INT, commGrid->GetRowWorld());
61 curr_subword_disp = local_subword_disp;
82 return rotlenuntil + local_size;
90 return bm->
get_bit(index - rotlenuntil + curr_subword_disp);
94 bm->
set_bit(index - rotlenuntil + curr_subword_disp);
102 if (it.GetValue() != -1)
103 bm->
set_bit(it.GetLocIndex() + curr_subword_disp);
107 int curr_col = (my_proccol + rotation_index) % proccols;
112 IT n_perprocrow = global_size / procrows;
114 if(my_procrow == procrows-1)
115 n_thisrow = global_size - (n_perprocrow*(procrows-1));
117 n_thisrow = n_perprocrow;
118 IT n_perproc = n_thisrow / proccols;
119 return ((n_perprocrow * my_procrow)+(n_perproc*my_proccol));
123 int curr_col = (my_proccol + rotation_index) % proccols;
129 if (my_proccol == (proccols-1)) {
130 if (my_procrow == (procrows-1)) {
131 my_upper_limit = global_size;
136 my_upper_limit =
RotLengthUntil(my_procrow, (my_proccol+1) % proccols);
142 int source = (my_proccol+1) % proccols;
143 int dest = (my_proccol+(proccols-1)) % proccols;
144 rotation_index = (rotation_index + 1) % proccols;
145 long send_words = (local_size + 63 + curr_subword_disp)>>6;
146 long recv_words = (
SizeOfChunk() + 63 + sub_disps[(my_proccol+rotation_index)%proccols])>>6;
148 MPI_Comm RowWorld = commGrid->GetRowWorld();
155 std::swap(bm, recv_buff);
156 curr_subword_disp = sub_disps[(my_proccol+rotation_index)%proccols];
160 uint64_t* dest = bm_fringe.
AccessBM()->data();
161 uint64_t* curr = bm->
data();
162 uint64_t* old = old_bm->
data();
163 IT num_words = (local_size + 63 + curr_subword_disp) / 64;
164 for (IT i=0; i<num_words; i++) {
165 dest[i] = curr[i] ^ old[i];
174 std::shared_ptr<CommGrid> commGrid;
180 int curr_subword_disp;
192 #endif // BITMAPCAROUSEL_H bool GetBit(IT index) const
void copy_from(const BitMap *other)
bool get_bit(uint64_t pos)
IT GetGlobalStartOfLocal(int col) const
void UpdateFringe(BitMapFringe< IT, NT > &bm_fringe)
IT GetGlobalEndOfLocal() const
MPI_Datatype MPIType< uint64_t >(void)
IT SizeOfChunk(int my_procrow, int my_proccol) const
IT GetGlobalStartOfLocal() const
IT RotLengthUntil(int my_procrow, int my_proccol) const
BitMapCarousel(std::shared_ptr< CommGrid > grid, IT glen, int local_subword_disp)
IT GetGlobalEndOfLocal(int col) const
void LoadVec(FullyDistVec< IT, NT1 > &x)
void set_bit(uint64_t pos)