39template <
class IT,
class NT,
class Enable=
void>
58template <
class IT,
class NT>
59class FullyDist<
IT,
NT, typename
combblas::disable_if< combblas::is_boolean<NT>::value, NT >::type >
64 SpParHelper::Print(
"COMBBLAS Warning: It is dangerous to create (vector) objects without specifying the communicator, are you sure you want to create this object in MPI_COMM_WORLD?\n");
69 SpParHelper::Print(
"COMBBLAS Warning: It is dangerous to create (vector) objects without specifying the communicator, are you sure you want to create this object in MPI_COMM_WORLD?\n");
102 std::shared_ptr<CommGrid> commGrid;
110template <
class IT,
class NT>
115 int procrows = commGrid->GetGridRows();
125 own_procrow = procrows -1;
128 IT ind_withinrow = gind - (own_procrow * n_perprocrow);
129 if(own_procrow == procrows-1)
130 n_thisrow = glen - (n_perprocrow*(procrows-1));
132 n_thisrow = n_perprocrow;
134 int proccols = commGrid->GetGridCols();
135 IT n_perproc = n_thisrow / proccols;
140 own_proccol = std::min(
static_cast<int>(ind_withinrow / n_perproc), proccols-1);
144 own_proccol = proccols-1;
146 lind = ind_withinrow - (own_proccol * n_perproc);
149 return commGrid->GetRank(own_procrow, own_proccol);
158template <
class IT,
class NT>
159int FullyDist<IT,NT,typename combblas::disable_if< combblas::is_boolean<NT>::value,
NT >::type >
160::OwnerWithinRow(
IT n_thisrow,
IT ind_withinrow,
IT & lind)
const
162 int proccols = commGrid->GetGridCols();
163 IT n_perproc = n_thisrow / proccols;
168 own_proccol = std::min(
static_cast<int>(ind_withinrow / n_perproc), proccols-1);
172 own_proccol = proccols-1;
174 lind = ind_withinrow - (own_proccol * n_perproc);
179template <
class IT,
class NT>
180IT FullyDist<IT,NT,typename combblas::disable_if< combblas::is_boolean<NT>::value,
NT >::type >
183 int procrows = commGrid->GetGridRows();
184 int my_procrow = commGrid->GetRankInProcCol();
185 IT n_perprocrow = glen / procrows;
187 if(my_procrow == procrows-1)
188 n_thisrow = glen - (n_perprocrow*(procrows-1));
190 n_thisrow = n_perprocrow;
192 int proccols = commGrid->GetGridCols();
193 int my_proccol = commGrid->GetRankInProcRow();
194 IT n_perproc = n_thisrow / proccols;
195 return ((n_perprocrow * my_procrow)+(n_perproc*my_proccol));
199template <
class IT,
class NT>
200IT FullyDist<IT,NT,typename combblas::disable_if< combblas::is_boolean<NT>::value,
NT >::type >
203 int procrows = commGrid->GetGridRows();
204 int my_procrow = commGrid->GetRankInProcCol();
205 IT n_perprocrow = glen / procrows;
207 if(my_procrow == procrows-1)
208 n_thisrow = glen - (n_perprocrow*(procrows-1));
210 n_thisrow = n_perprocrow;
212 int proccols = commGrid->GetGridCols();
213 int my_proccol = commGrid->GetRankInProcRow();
214 IT n_perproc = n_thisrow / proccols;
215 return (n_perproc*my_proccol);
219template <
class IT,
class NT>
220IT FullyDist<IT,NT,typename combblas::disable_if< combblas::is_boolean<NT>::value,
NT >::type >
221::RowLenUntil(
int k)
const
223 int procrows = commGrid->GetGridRows();
224 int my_procrow = commGrid->GetRankInProcCol();
225 IT n_perprocrow = glen / procrows;
227 if(my_procrow == procrows-1)
228 n_thisrow = glen - (n_perprocrow*(procrows-1));
230 n_thisrow = n_perprocrow;
232 int proccols = commGrid->GetGridCols();
233 IT n_perproc = n_thisrow / proccols;
234 assert(k < proccols);
235 return (n_perproc*k);
238template <
class IT,
class NT>
239IT FullyDist<IT,NT, typename combblas::disable_if< combblas::is_boolean<NT>::value,
NT >::type>
242 int procrows = commGrid->GetGridRows();
243 int my_procrow = commGrid->GetRankInProcCol();
244 IT n_perprocrow = glen / procrows;
246 if(my_procrow == procrows-1)
247 n_thisrow = glen - (n_perprocrow*(procrows-1));
249 n_thisrow = n_perprocrow;
251 int proccols = commGrid->GetGridCols();
252 int my_proccol = commGrid->GetRankInProcRow();
253 IT n_perproc = n_thisrow / proccols;
254 if(my_proccol == proccols-1)
255 return (n_thisrow - (n_perproc*(proccols-1)));
261template <
class IT,
class NT>
262IT FullyDist<IT,NT,typename combblas::disable_if< combblas::is_boolean<NT>::value,
NT >::type>
265 int procrows = commGrid->GetGridRows();
266 int my_procrow = commGrid->GetRankInProcCol();
267 IT n_perprocrow = glen / procrows;
269 if(my_procrow == procrows-1)
270 n_thisrow = glen - (n_perprocrow*(procrows-1));
272 n_thisrow = n_perprocrow;
std::shared_ptr< CommGrid > commGrid
int OwnerWithinRow(IT n_thisrow, IT ind_withinrow, IT &lind) const
FullyDist(std::shared_ptr< CommGrid > grid, IT globallen)
int Owner(IT gind, IT &lind) const
FullyDist< IT, NT > & operator=(const FullyDist< IT, NT > &rhs)
FullyDist(std::shared_ptr< CommGrid > grid)
IT RowLenUntil(int k) const
static void Print(const std::string &s)