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

enable volatile params #623

Merged
merged 6 commits into from
Dec 17, 2021
Merged

enable volatile params #623

merged 6 commits into from
Dec 17, 2021

Conversation

Yurlungur
Copy link
Collaborator

@Yurlungur Yurlungur commented Dec 14, 2021

PR Summary

This is motivated by @brryan 's comment in issue #621 . I modify Params to enable the user to tag a param as "volatile." The effect of this is that the user can optionally extract the non-const pointer from the Params object with GetVolatile in the Params object or VolatileParam in the StateDescriptor object. If the user attempts to extract a non-volatile param with GetVolatile, a runtime error is raised.

I thought about returning a non-const reference, but the pointer felt safer and more explicit, without being any more cumbersome really. On the other hand, returning a pointer with GetVolatile means that the two Get methods return different types, which is a little weird. So I'd be open to returning a non-const reference instead, if people would like that better.

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
Copy link
Collaborator Author

Pinging @brryan @pgrete @jdolence @nmsriram @forrestglines as people with stakes in this machinery and/or who wrote the original version

@dholladay00
Copy link
Collaborator

small nomenclature suggestion: find-replace volatile with mutable.

@Yurlungur
Copy link
Collaborator Author

small nomenclature suggestion: find-replace volatile with mutable.

This is a good idea.

@Yurlungur
Copy link
Collaborator Author

small nomenclature suggestion: find-replace volatile with mutable.

done.

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.

👍 I like this approach to be more specific.

The one additional change I'd like to see before approving is an update to the Update function.
From a consistency point of view, I think that if we differentiate between mutable and non-mutable parameter, then Update should also check if the parameter is mutable and otherwise throw an error.

src/interface/params.hpp Outdated Show resolved Hide resolved
Comment on lines 49 to 50
myTypes_.emplace(make_pair(key, std::type_index(typeid(value))));
myMutable_[key] = make_mutable;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity, is there a reason to use emplace in one case and the direct assignment in the other case?
Also, I wonder, if it wouldn't be cleaner the only use one map (e.g., with a struct) instead of three, but that's probably a separate discussion.

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 used assignment because it was easier. I don't know why the original was emplace. I can copy that if it's preferred.

@Yurlungur
Copy link
Collaborator Author

@pgrete take a look now. I added a check for mutable in Params::Update and renamed make_mutable to is_mutable.

@Yurlungur
Copy link
Collaborator Author

Pinging @gshipman to review and @pgrete to approve as discussed on the parthenon call.

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.

Looks good to go!

@codecov
Copy link

codecov bot commented Dec 17, 2021

Codecov Report

Merging #623 (ae694ee) into develop (a671af0) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #623      +/-   ##
===========================================
+ Coverage    54.25%   54.28%   +0.02%     
===========================================
  Files          125      125              
  Lines        13699    13701       +2     
===========================================
+ Hits          7433     7438       +5     
+ Misses        6266     6263       -3     
Impacted Files Coverage Δ
src/interface/params.hpp 90.90% <100.00%> (+7.57%) ⬆️
src/interface/state_descriptor.hpp 95.83% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a671af0...ae694ee. Read the comment docs.

@Yurlungur Yurlungur linked an issue Dec 17, 2021 that may be closed by this pull request
@Yurlungur Yurlungur enabled auto-merge December 17, 2021 16:03
@Yurlungur Yurlungur merged commit 05e2f5b into develop Dec 17, 2021
@Yurlungur Yurlungur deleted the jmm/volatile-params branch December 15, 2022 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Const correctness in Params
5 participants