Skip to content

Commit 9c1db66

Browse files
authored
Remove unecessary solver communication (#1344)
* Add solver timing blocks * fixes to example * Add boundary communication changes * cpp-py-formatter * changelog * increase timeout
1 parent 6ed9db0 commit 9c1db66

File tree

6 files changed

+19
-8
lines changed

6 files changed

+19
-8
lines changed

.github/workflows/ci-extended.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
export ASAN_OPTIONS=abort_on_error=1:fast_unwind_on_malloc=1
9191
export UBSAN_OPTIONS=print_stacktrace=0
9292
export LSAN_OPTIONS=detect_leaks=0
93-
ctest -L regression -L ${{ matrix.parallel }} -LE perf-reg --timeout 3600
93+
ctest -L regression -L ${{ matrix.parallel }} -LE perf-reg --timeout 7200
9494
9595
# Test Ascent integration (only most complex setup with MPI and on device)
9696
- name: Ascent tests

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Current develop
44

55
### Added (new features/APIs/variables/...)
6+
- [[PR 1344]](https://github.com/parthenon-hpc-lab/parthenon/pull/1344) Add option to communicate single layer of ghosts, only communicate required two-level composite boundaries
67

78

89
### Changed (changing behavior/API/variables/...)

example/poisson_gmg/poisson_package.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
123123
// for the standard Poisson equation.
124124
pkg->AddField(D::name(), mD);
125125

126-
std::vector<MetadataFlag> flags{Metadata::Cell, Metadata::Independent,
127-
Metadata::FillGhost, Metadata::WithFluxes,
128-
Metadata::GMGRestrict, Metadata::GMGProlongate};
126+
std::vector<MetadataFlag> flags{Metadata::Cell, Metadata::Independent,
127+
Metadata::FillGhost, Metadata::WithFluxes,
128+
Metadata::GMGRestrict, Metadata::GMGProlongate,
129+
Metadata::CommunicateOne};
129130
auto mflux_comm = Metadata(flags);
130131
if (prolong == "Linear") {
131132
mflux_comm.RegisterRefinementOps<ProlongateSharedLinear, RestrictAverage>();

src/bvals/comms/bnd_info.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,14 @@ CalcIndices(const NeighborBlock &nb, MeshBlock *pmb,
150150
TopologicalOffsetK(el)};
151151
std::array<int, 3> block_offset = nb.offsets;
152152

153+
int communicated_ghosts = Globals::nghost;
154+
if (!prores && loc.level() == nb.origin_loc.level() &&
155+
v->IsSet(Metadata::CommunicateOne))
156+
communicated_ghosts = 1;
153157
int interior_offset =
154-
ir_type == IndexRangeType::BoundaryInteriorSend ? Globals::nghost : 0;
158+
ir_type == IndexRangeType::BoundaryInteriorSend ? communicated_ghosts : 0;
155159
int exterior_offset =
156-
ir_type == IndexRangeType::BoundaryExteriorRecv ? Globals::nghost : 0;
160+
ir_type == IndexRangeType::BoundaryExteriorRecv ? communicated_ghosts : 0;
157161
if (prores) {
158162
// The coarse ghosts cover twice as much volume as the fine ghosts, so when working in
159163
// the exterior (i.e. ghosts) we must only go over the coarse ghosts that have

src/interface/metadata.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@
128128
PARTHENON_INTERNAL_FOR_FLAG(CellMemAligned) \
129129
/** Particles in a Swarm will not contain a persistent, unique id field **/ \
130130
PARTHENON_INTERNAL_FOR_FLAG(NoPersistentParticleIds) \
131+
/** Only communicate one layer of ghosts at same-to-same boundaries **/ \
132+
PARTHENON_INTERNAL_FOR_FLAG(CommunicateOne) \
131133
/************************************************/ \
132134
/** Vars specifying coordinates for visualization purposes **/ \
133135
/** You can specify a single 3D var **/ \

src/utils/loop_utils.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ inline auto func_caller(F func, Args &&...args) -> typename std::enable_if<
7777
// need to be a template parameter, it could just be a function argument]
7878
template <BoundaryType bound = BoundaryType::any, class F>
7979
inline void ForEachBoundary(std::shared_ptr<MeshData<Real>> &md, F func) {
80+
int fine_level = md->grid.logical_level;
8081
for (int block = 0; block < md->NumBlocks(); ++block) {
8182
auto &rc = md->GetBlockData(block);
8283
auto pmb = rc->GetBlockPointer();
@@ -125,8 +126,10 @@ inline void ForEachBoundary(std::shared_ptr<MeshData<Real>> &md, F func) {
125126
} else if constexpr (bound == BoundaryType::gmg_same) {
126127
if (v->IsSet(Metadata::FillGhost)) {
127128
for (auto &nb : *gmg_same) {
128-
if (func_caller(func, pmb, rc, nb, v) == LoopControl::break_out) {
129-
return;
129+
if (pmb->loc.level() == fine_level || nb.loc.level() == fine_level) {
130+
if (func_caller(func, pmb, rc, nb, v) == LoopControl::break_out) {
131+
return;
132+
}
130133
}
131134
}
132135
}

0 commit comments

Comments
 (0)