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

fix meshblock pack issues coming from template shadowing and add a test #572

Merged
merged 3 commits into from
Jul 26, 2021

Conversation

Yurlungur
Copy link
Collaborator

@Yurlungur Yurlungur commented Jul 23, 2021

PR Summary

Downstream, @brryan noticed that calls to MeshData::PackVariables with a PackIndexMap, for example

// MeshData *rc defined above
PackIndexMap imap;
rc->PackVariables(names, imap);

cause compile-time errors. The issue was introduced in the sparse interface update, #535 , where this machinery changed significantly. In short, in that update, explicit overloads were replaced with variatic templates. Unfortunately, C++ does not resolve these templates appropriately, and they shadow each other, causing bugs. We didn't catch this until now because templated functions are optimized out if they're not called.

This MR resolves #570 . I replace the variatics with explicit overloads again, with a few changes to reduce line number as best I can. I also add a call to this machinery in the calculate pi example, so this issue should be caught by regression tests in the future.

Note that the full regression test suite is currently failing. (See #571 ). So we should either merge this in without triggering the full suite on the CI, or we should wait for #571 to be resolved. I lean towards the former. Thoughts?

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
  • CI has been triggered on Darwin for performance regression tests.
  • (@lanl.gov employees) Update copyright on changed files

@Yurlungur Yurlungur added the bug Something isn't working label Jul 23, 2021
@Yurlungur Yurlungur self-assigned this Jul 23, 2021
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.

Pending the minor question, looks good! Thanks.
I'm also fine with merging this in while #571 is not fixed yet, but we should still run the full test suite here manually and see if nothing else new fails.

Comment on lines +397 to +407
const auto &PackVariablesAndFluxes(const std::vector<int> &sparse_ids,
vpack_types::StringPair &key) {
return PackVariablesAndFluxesImpl(nullptr, &key, sparse_ids);
}
const auto &PackVariablesAndFluxes(const std::vector<int> &sparse_ids,
PackIndexMap &map) {
return PackVariablesAndFluxesImpl(&map, nullptr, sparse_ids);
}
const auto &PackVariablesAndFluxes(const std::vector<int> &sparse_ids) {
return PackVariablesAndFluxesImpl(nullptr, nullptr, sparse_ids);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these actually required?
If I'm not missing something they're matching the

  const auto &PackVariablesAndFluxes(const std::vector<Elem> &names_or_flags,
                                     PackIndexMap &map, vpack_types::StringPair &key)

above, aren't they?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These exclude either the PackIndexMap or the key, or both. Whereas the one you quoted has both of them. They're just syntactic sugar overloads.

@Yurlungur
Copy link
Collaborator Author

Thanks @pgrete . Agreed, I'll run the full test suite

Copy link
Collaborator

@brryan brryan left a comment

Choose a reason for hiding this comment

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

Just one question for my own edification. Looks good, thanks for adding a typical use case to the calculate_pi example.

src/interface/mesh_data.hpp Show resolved Hide resolved
@Yurlungur
Copy link
Collaborator Author

Pending the minor question, looks good! Thanks.
I'm also fine with merging this in while #571 is not fixed yet, but we should still run the full test suite here manually and see if nothing else new fails.

Looks like the only error is the Input metadata diff

@Yurlungur Yurlungur merged commit ab21a69 into develop Jul 26, 2021
@Yurlungur Yurlungur deleted the jmm/fix-meshblock-pack branch July 26, 2021 18:23
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.

Sparse interface update broke meshblockpacks
4 participants