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

Add deallocation check for fine, sparse fields #1131

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- [[PR 1004]](https://github.com/parthenon-hpc-lab/parthenon/pull/1004) Allow parameter modification from an input file for restarts

### Fixed (not changing behavior/API/variables/...)
- [[PR 1131]](https://github.com/parthenon-hpc-lab/parthenon/pull/1131) Make deallocation of fine and sparse fields work
- [[PR 1127]](https://github.com/parthenon-hpc-lab/parthenon/pull/1127) Add WithFluxes to IsRefined check
- [[PR 1111]](https://github.com/parthenon-hpc-lab/parthenon/pull/1111) Fix undefined behavior due to bitshift of negative number in LogicalLocation
- [[PR 1092]](https://github.com/parthenon-hpc-lab/parthenon/pull/1092) Updates to DataCollection and MeshData to remove requirement of predefining MeshBlockData
Expand Down
9 changes: 0 additions & 9 deletions src/interface/metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,6 @@ bool Metadata::IsValid(bool throw_on_fail) const {
}
}

// Limitations on fine fields
if (CountSet({Fine, Sparse}) > 1) {
valid = false;
if (throw_on_fail) {
PARTHENON_THROW(
"Sparse deallocation routine is not written to handle fine fields.");
}
}

return valid;
}

Expand Down
8 changes: 3 additions & 5 deletions src/interface/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,11 @@ TaskStatus SparseDealloc(MeshData<Real> *md) {
const auto &var = pack(b, v);
const Real threshold = var.deallocation_threshold;
bool all_zero = true;
const auto &var_raw = var.data();
Kokkos::parallel_reduce(
Kokkos::TeamThreadRange<>(team_member, NkNjNi),
Kokkos::TeamThreadRange<>(team_member, var.size()),
[&](const int idx, bool &lall_zero) {
const int k = kb.s + idx / NjNi;
const int j = jb.s + (idx % NjNi) / Ni;
const int i = ib.s + idx % Ni;
if (std::abs(var(k, j, i)) > threshold) {
if (std::abs(var_raw[idx]) > threshold) {
lall_zero = false;
return;
}
Expand Down
Loading