Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer-pack-in-one #359

Merged
merged 51 commits into from
Jan 21, 2021
Merged

Buffer-pack-in-one #359

merged 51 commits into from
Jan 21, 2021

Conversation

pgrete
Copy link
Collaborator

@pgrete pgrete commented Nov 11, 2020

PR Summary

WIP to have a central place to keep track of performance numbers.

PR Checklist

  • Code passes cpplint
  • New features are documented.
  • Adds a test for any bugs fixed. Adds tests for new features.
  • Code is formatted
  • Changes are summarized in CHANGELOG.md

Open questions

  • Are we still using vbvar->var_cc extensively or can than functionality go as it it effectively absorbed by VariablePacks`?

Copy link
Collaborator

@Yurlungur Yurlungur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our local resources are down for maintenance at the moment. But when we're back up, we'll try this with riot.

@pgrete pgrete force-pushed the pgrete/buffer-in-one branch from 14423bf to dcb2f4f Compare January 12, 2021 20:17
@AndrewGaspar
Copy link
Contributor

@pgrete I'm in the middle of reviewing this. will publish soon.

ScratchPad2D<Real> &ql, ScratchPad2D<Real> &qr) {
template <typename T>
KOKKOS_FORCEINLINE_FUNCTION void
DonorCellX1(parthenon::team_mbr_t const &member, const int k, const int j, const int il,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me why this was made a template. If it's for an external code, that's fine, but I don't see any motivation in this PR myself. I think the only place this is called is in advection_package.cpp, and it doesn't look like the types used there changed at all.

If it's for an external code, just put a comment in the PR explaining why this was changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was actually pulled in from #365 (this branch here has been active for so long I fixed a couple of things along the go to make things work downstream).
Would you prefer that I update #365 to just include those reconstruction changes, get that merged in, and then update this branch
or
add another line in the changelog saying this happenend here, merge this branch and close #365 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now updated the changelog here to also reflect this change (as well as the "un-/pack" -> "pack and unpack" change you requested).
@AndrewGaspar If you're happy feel free to merge (or schedule for merge once the pipeline passes).

ScratchPad2D<Real> &dqm) {
template <typename T>
KOKKOS_INLINE_FUNCTION void
PiecewiseLinearX1(parthenon::team_mbr_t const &member, const int k, const int j,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as on DonorCell

CHANGELOG.md Outdated
- [[PR 400]](https://github.com/lanl/parthenon/pull/400) Extend `StateDescriptor` for customizable output via user-customizable function pointers `PreStepDiagnosticsMesh` and `PostStepDiagnosticsMesh`
- [[PR 391]](https://github.com/lanl/parthenon/pull/391) Add `VariablePack<T>::GetSparseId` and `VariablePack<T>::GetSparseIndex` to return global sparse ids and pack-local sparse index, repsectively.
- [[PR 381]](https://github.com/lanl/parthenon/pull/381) Overload `DataCollection::Add` to build `MeshData` and `MeshBlockData` objects with a subset of variables.
- [[PR 378]](https://github.com/lanl/parthenon/pull/378) Add Kokkos profiling regions throughout the code to allow the collection characteristic application profiles
- [[PR 359]](https://github.com/lanl/parthenon/pull/359) MeshBlockPack support for buffer un-/pack of CellCentered Variables
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"un-/pack" - took me a second to understand what this was trying to say... probably better as

Suggested change
- [[PR 359]](https://github.com/lanl/parthenon/pull/359) MeshBlockPack support for buffer un-/pack of CellCentered Variables
- [[PR 359]](https://github.com/lanl/parthenon/pull/359) MeshBlockPack support for buffer pack and unpack of CellCentered Variables

@pgrete
Copy link
Collaborator Author

pgrete commented Jan 21, 2021

With respect to getting this PR merged, would you @AndrewGaspar @Yurlungur like to keep the option to switch between MeshBlock and MeshBlockPack in the advection example or should I remove it?
I'm in favor of keeping it for now and update once the proxy app is ready so that we have one example using MeshBlock based version and another (separate) example using the MeshBlockPack based versions.

Also, @Yurlungur did you get the chance to test this downstream for more than one Variable in riot or shall we merge in good faith for now and fix if there's an issue later? I verified that it works in principle by just adding another independent variable, so MPI signaling seems to work, but I didn't test for correctness (but I fairly optimistic that it is) .
I'm in favor of merging now so that we can continue to work (on all the other open issues) on "clean" branches.

@Yurlungur
Copy link
Collaborator

With respect to getting this PR merged, would you @AndrewGaspar @Yurlungur like to keep the option to switch between MeshBlock and MeshBlockPack in the advection example or should I remove it?
I'm in favor of keeping it for now and update once the proxy app is ready so that we have one example using MeshBlock based version and another (separate) example using the MeshBlockPack based versions.

Agreed, let's keep the switch for now and remove it once @jlippuner has the proxy app working.

Also, @Yurlungur did you get the chance to test this downstream for more than one Variable in riot or shall we merge in good faith for now and fix if there's an issue later? I verified that it works in principle by just adding another independent variable, so MPI signaling seems to work, but I didn't test for correctness (but I fairly optimistic that it is) .
I'm in favor of merging now so that we can continue to work (on all the other open issues) on "clean" branches.

Apologies, @pgrete I was sick last week, so didn't get a chance to do this yet. Let's go ahead and merge and I will push on the riot version and engage with you if things don't work.

ek -= pmb->block_size.nx3 / 2 - pmb->cnghost;
}
}
cell_centered_bvars::CalcIndicesLoadToFiner(si, ei, sj, ej, sk, ek, nb, pmb.get());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines -252 to +217
auto CalcIndices = [](int ox, int &s, int &e, const IndexRange &bounds) {
if (ox == 0) {
s = bounds.s;
e = bounds.e;
} else if (ox > 0) {
s = bounds.e + 1;
e = bounds.e + NGHOST;
} else {
s = bounds.s - NGHOST;
e = bounds.s - 1;
}
};

IndexDomain interior = IndexDomain::interior;
CalcIndices(nb.ni.ox1, si, ei, cellbounds.GetBoundsI(interior));
CalcIndices(nb.ni.ox2, sj, ej, cellbounds.GetBoundsJ(interior));
CalcIndices(nb.ni.ox3, sk, ek, cellbounds.GetBoundsK(interior));
cell_centered_bvars::CalcIndicesSetSame(nb.ni.ox1, si, ei,
cellbounds.GetBoundsI(interior));
cell_centered_bvars::CalcIndicesSetSame(nb.ni.ox2, sj, ej,
cellbounds.GetBoundsJ(interior));
cell_centered_bvars::CalcIndicesSetSame(nb.ni.ox3, sk, ek,
cellbounds.GetBoundsK(interior));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +531 to +578
for (auto &v : rc->GetCellVariableVector()) {
if (v->IsSet(parthenon::Metadata::FillGhost)) {
for (int n = 0; n < pmb->pbval->nneighbor; n++) {
parthenon::NeighborBlock &nb = pmb->pbval->neighbor[n];
auto *pbd_var_ = v->vbvar->GetPBdVar();

auto &si = boundary_info_h(b).si;
auto &ei = boundary_info_h(b).ei;
auto &sj = boundary_info_h(b).sj;
auto &ej = boundary_info_h(b).ej;
auto &sk = boundary_info_h(b).sk;
auto &ek = boundary_info_h(b).ek;
auto &Nv = boundary_info_h(b).Nv;
Nv = v->GetDim(4);

if (nb.snb.level == mylevel) {
const parthenon::IndexShape &cellbounds = pmb->cellbounds;
CalcIndicesSetSame(nb.ni.ox1, si, ei, cellbounds.GetBoundsI(interior));
CalcIndicesSetSame(nb.ni.ox2, sj, ej, cellbounds.GetBoundsJ(interior));
CalcIndicesSetSame(nb.ni.ox3, sk, ek, cellbounds.GetBoundsK(interior));
boundary_info_h(b).var = v->data.Get<4>();
} else if (nb.snb.level < mylevel) {
const IndexShape &c_cellbounds = pmb->c_cellbounds;
const auto &cng = pmb->cnghost;
CalcIndicesSetFromCoarser(nb.ni.ox1, si, ei,
c_cellbounds.GetBoundsI(interior), pmb->loc.lx1,
cng, true);
CalcIndicesSetFromCoarser(nb.ni.ox2, sj, ej,
c_cellbounds.GetBoundsJ(interior), pmb->loc.lx2,
cng, pmb->block_size.nx2 > 1);
CalcIndicesSetFromCoarser(nb.ni.ox3, sk, ek,
c_cellbounds.GetBoundsK(interior), pmb->loc.lx3,
cng, pmb->block_size.nx3 > 1);

boundary_info_h(b).var = v->vbvar->coarse_buf.Get<4>();
} else {
CalcIndicesSetFromFiner(si, ei, sj, ej, sk, ek, nb, pmb.get());
boundary_info_h(b).var = v->data.Get<4>();
}
boundary_info_h(b).buf = pbd_var_->recv[nb.bufid];
// safe to set completed here as the kernel updating all buffers is
// called immediately afterwards
pbd_var_->flag[nb.bufid] = parthenon::BoundaryStatus::completed;
b++;
}
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fairly confident this should work for multiple variables.

@AndrewGaspar AndrewGaspar merged commit a8505cf into develop Jan 21, 2021
@AndrewGaspar AndrewGaspar deleted the pgrete/buffer-in-one branch January 21, 2021 22:59
@pgrete pgrete mentioned this pull request Jan 22, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants