Skip to content

Commit 3c4e693

Browse files
committed
Decrease the runtime of GridBasedGrid::init
GloMethod::compute_new_local_cells uses GloMethod::rank_of internally to determine if a cell is owned by the calling process. This is very compute intensive for GridBasedGrid because it checks all Octagons (initially *all*, later all neighboring). This commit adds an override GridBasedGrid::compute_new_local_cells that only checks the Octagon of the calling process itself.
1 parent d55f9be commit 3c4e693

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

repa/grids/gridbased.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ util::const_span<rank_type> GridBasedGrid::neighbor_ranks() const
114114
return util::make_const_span(const_neighborhood);
115115
}
116116

117+
std::vector<global_cell_index_type>
118+
GridBasedGrid::compute_new_local_cells() const
119+
{
120+
std::vector<global_cell_index_type> res;
121+
for (const auto i : gbox.global_cells()) {
122+
if (my_dom.contains(gbox.midpoint(i))) {
123+
res.push_back(i);
124+
}
125+
}
126+
return res;
127+
}
128+
117129
void GridBasedGrid::pre_init(bool firstcall)
118130
{
119131
if (firstcall) {

repa/grids/gridbased.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ struct GridBasedGrid : public GloMethod {
4949
// neighborhood.
5050
util::const_span<rank_type> neighbor_ranks() const override;
5151

52+
// GloMethod::compute_new_local_cells uses rank_of() to determine if a cell
53+
// belongs to this process. This is, however, very compute intensive for
54+
// GridBasedGrid because it checks all neighboring (and initially *all*)
55+
// subdomains. This implementation only checks the own Octagon if it
56+
// includes a certain cell or not.
57+
virtual std::vector<global_cell_index_type>
58+
compute_new_local_cells() const override;
59+
5260
private:
5361
// Indicator if the decomposition currently is a regular grid,
5462
// which is the case directly after instantiation.

0 commit comments

Comments
 (0)