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

Updates to DataCollection #1092

Merged
merged 18 commits into from
Jun 15, 2024

Conversation

lroberts36
Copy link
Collaborator

@lroberts36 lroberts36 commented May 29, 2024

PR Summary

This PR makes some changes to DataCollection so that calling pmesh->mesh_data.GetOrAdd(some_label, partition) works whether or not some_label has been previously added to the MeshBlockData container. Additionally, it makes it so that Add will now work correctly for MeshData (previously it didn't use the correct labeling and containers could be overwritten).

Possible other things to do:

  • Formalize partitioning and move it to Mesh
  • Get all of the DataCollection interface to work with both Mesh and MeshData
  • Remove Initialize methods and replace them with constructors since they break RAII

PR Checklist

  • [Breaking change] Add fine field option #991 is merged
  • 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
  • Change is breaking (API, behavior, ...)
    • Change is additionally added to CHANGELOG.md in the breaking section
    • PR is marked as breaking
    • Short summary API changes at the top of the PR (plus optionally with an automated update/fix script)
  • CI has been triggered on Darwin for performance regression tests.
  • Docs build
  • (@lanl.gov employees) Update copyright on changed files

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.

Thanks for cleaning this up. I think these are good changes.

src/interface/meshblock_data.hpp Outdated Show resolved Hide resolved
src/interface/meshblock_data.hpp Show resolved Hide resolved
Comment on lines +194 to +197
if (stage_name_ == "base") {
const auto &swarm_container = GetSwarmData();
swarm_container->Initialize(resolved_packages, GetBlockSharedPointer());
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see any issue with this. Swarms are OneCopy-like and always belong to the base stage so it doesn't really make sense to Add a new MeshBlockData to the DataCollection based on an existing MeshBlockData. We have thought a bit about the best way to express this through the parthenon interface but don't have any good thoughts at the moment.

Copy link
Collaborator

@pdmullen pdmullen May 30, 2024

Choose a reason for hiding this comment

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

What was the concern here? Sorry I am late to the party...

We currently adopt a model wherein the "base" MeshBlockData register contains our swarm data. We have checks that swarms are only accessed through said register.

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 just wanted to know if this was the desired behavior and if there were any side effects of what I did.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll test downstream first thing tomorrow.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did the test happen? @pdmullen

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They did, there is an old comment from Patrick below.

src/interface/data_collection.hpp Outdated Show resolved Hide resolved
src/interface/data_collection.hpp Show resolved Hide resolved
src/utils/concepts_lite.hpp Show resolved Hide resolved
@pdmullen
Copy link
Collaborator

w.r.t. swarms, I tested this downstream and all looks good. I noticed that this PR is targeting lroberts36/add-fine-variables instead of develop... intentional?

@lroberts36
Copy link
Collaborator Author

I noticed that this PR is targeting lroberts36/add-fine-variables instead of develop... intentional?

@pdmullen: yeah, but only because I was using the new test I added there to check that removing the MeshBlockData boiler plate worked.

@Yurlungur
Copy link
Collaborator

@lroberts36 are we waiting for someone to review this?

@lroberts36
Copy link
Collaborator Author

@lroberts36 are we waiting for someone to review this?

@Yurlungur: @pgrete said he would on Thursday, but I think he has been under the weather the last few days.

@lroberts36 lroberts36 changed the base branch from lroberts36/add-fine-variables to develop June 10, 2024 19:44
@lroberts36 lroberts36 changed the base branch from develop to lroberts36/add-fine-variables June 10, 2024 19:44
@lroberts36 lroberts36 changed the base branch from lroberts36/add-fine-variables to develop June 13, 2024 18:11
Copy link
Collaborator

@pgrete pgrete left a comment

Choose a reason for hiding this comment

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

LGTM

"Remove Initialize methods and replace them with constructors since they break RAII" is possibly meant for a future PR, isn't it? In that case -> new issue?

Comment on lines +134 to +138
std::string GetKey(const std::string &stage_label, std::optional<int> partition_id,
std::optional<int> gmg_level) {
std::string key = stage_label;
if (partition_id) key = key + "_part-" + std::to_string(*partition_id);
if (gmg_level) key = key + "_gmg-" + std::to_string(*gmg_level);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should there be a debug_require that only partition_id or gmg_level or neither is passed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no, the GMG levels are also partitioned. Although to be fair, partitioning has always been broken for multigrid, i.e. it only works when all blocks are included in the partition. This is on my list of things to fix.

Comment on lines +194 to +197
if (stage_name_ == "base") {
const auto &swarm_container = GetSwarmData();
swarm_container->Initialize(resolved_packages, GetBlockSharedPointer());
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did the test happen? @pdmullen

Comment on lines -65 to -74
if (stage == 1) {
for (int i = 0; i < blocks.size(); i++) {
auto &pmb = blocks[i];
// first make other useful containers
auto &base = pmb->meshblock_data.Get();
pmb->meshblock_data.Add("dUdt", base);
for (int s = 1; s < integrator->nstages; s++)
pmb->meshblock_data.Add(stage_name[s], base);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be removed in the other examples, too, to decrease likelihood of reusing this pattern?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably, but let's leave it for a future PR. I think it would be nice to work to clean up the examples in the near future.

@lroberts36
Copy link
Collaborator Author

"Remove Initialize methods and replace them with constructors since they break RAII" is possibly meant for a future PR, isn't it? In that case -> new issue?

@pgrete: I think I was just annoyed when I wrote this comment. It is probably not worth the effort to remove the initialization methods and replace them with constructors.

@lroberts36 lroberts36 merged commit 7eb6190 into develop Jun 15, 2024
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants