-
Notifications
You must be signed in to change notification settings - Fork 196
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
Clean up BeamRelevant with TypeMultiplier #4798
Clean up BeamRelevant with TypeMultiplier #4798
Conversation
The BeamRelevant reduced diagnostics had a lot of code where `amrex::ReduceOps` were constructed from lists of types. It is hard to see immediately how many types are in that list. The `TypeMultiplier` utility can reduce this to make it more legible and this was done here.
The variables `num_red_ops_*` are used for the TypeMultiplier and also for the length of the output vectors for the reduced diagnostics. This commit changes their type from `const int` to `constexpr size_t` because this is more appropriate for a vector length, and with constexpr we indicate that the value is constant and can be evaluated at compile time already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice :)
And maybe as a follow-up, we can make this a one-time pass reduction :)
* ux_mean, uy_mean, uz_mean, gm_mean | ||
*/ | ||
amrex::constexpr_for<0, num_red_ops_1> ([&](auto i) { | ||
values_per_rank_1st[i] = amrex::get<i>(r1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, @AlexanderSinn uses this syntax in HiPACE++:
values_per_rank_1st[i] = amrex::get<i>(r1); | |
values_per_rank_1st[i.value] = amrex::get<i.value>(r1); |
* charge | ||
*/ | ||
amrex::constexpr_for<0, num_red_ops_2> ([&](auto i) { | ||
values_per_rank_2nd[i] = amrex::get<i>(r2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
The
BeamRelevant
reduced diagnostics had a lot of code whereamrex::ReduceOps
were constructed from lists of types. This PR cleans it up with theTypeMultiplier
utility that makes it more legible.Credit goes to @AlexanderSinn's work in Hi-PACE/hipace#1052 and AMReX-Codes/amrex#3718.