-
Notifications
You must be signed in to change notification settings - Fork 189
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
Optimize FixConservatives #5633
Optimize FixConservatives #5633
Conversation
if (const auto tilde_d_mask = | ||
rest_mass_density_times_lorentz_factor < | ||
rest_mass_density_times_lorentz_factor_cutoff_; | ||
simd::any(tilde_d_mask)) { | ||
needed_fixing = true; |
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.
I believe this block should be masking modifications with tilde_d_mask
.
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.
I think this is done mostly correctly in " fixup: FixConservatives simd " (I'll squash this into the other commit where it is wrong). However, the rest_mass_density_times_lorentz_factor
was not set correctly with a mask, like you said. I'm doing that in a fixup. Would you mind just double checking in the final code to make sure?
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.
This looks good now.
b_tilde_squared * one_over_sqrt_det_g * one_over_d_tilde; | ||
const SimdType s_dot_tilde_b_tilde = get(tilde_s_dot_tilde_b)[s]; |
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.
It seems like s_tilde_dot_b_tilde
matches the other names better.
static std::array<T, 4> nonzero_bound( | ||
const T& b_squared_over_d, const T& tau_over_d, | ||
const T& normalized_s_dot_b, const T& lower_bound, | ||
const T& sqr_normalized_s_dot_b_times_b_squared_over_d) { | ||
return std::array{ | ||
-0.5 * b_squared_over_d * | ||
(1.0 + | ||
square(normalized_s_dot_b) * tau_over_d * (tau_over_d + 2.0)), |
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.
This is probably better? Unless there are significant speed differences in operations that I don't know about.
-0.5 * (b_squared_over_d +
sqr_normalized_s_dot_b_times_b_squared_over_d * tau_over_d * (tau_over_d + 2.0))
const bool non_zero_mag = | ||
magnetic_field_treatment_ == hydro::MagneticFieldTreatment::AssumeNonZero | ||
? true | ||
: (magnetic_field_treatment_ != | ||
hydro::MagneticFieldTreatment::AssumeZero); |
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.
Equivalent: const bool non_zero_mag = magnetic_field_treatment_ != hydro::MagneticFieldTreatment::AssumeZero
(or == AssumeNonZero
since you overwrite it in the third case).
return square(1.0 + local_lorentz_factor_minus_one) * | ||
local_lorentz_factor_minus_one * | ||
(2.0 + local_lorentz_factor_minus_one) / | ||
square(1.0 + local_lorentz_factor_minus_one) * | ||
square(d_tilde); |
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.
The square(1.0 + local_lorentz_factor_minus_one)
factors cancel.
src/Evolution/Systems/GrMhd/ValenciaDivClean/FixConservatives.cpp
Outdated
Show resolved
Hide resolved
25015c5
to
12e21cb
Compare
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.
Thanks for the reviews and sorry for the delay! I pushed a couple fixups. I'll squash all the SIMD stuff once you're happy :)
if (const auto tilde_d_mask = | ||
rest_mass_density_times_lorentz_factor < | ||
rest_mass_density_times_lorentz_factor_cutoff_; | ||
simd::any(tilde_d_mask)) { | ||
needed_fixing = true; |
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.
I think this is done mostly correctly in " fixup: FixConservatives simd " (I'll squash this into the other commit where it is wrong). However, the rest_mass_density_times_lorentz_factor
was not set correctly with a mask, like you said. I'm doing that in a fixup. Would you mind just double checking in the final code to make sure?
12e21cb
to
aed9250
Compare
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.
Looks good.
if (const auto tilde_d_mask = | ||
rest_mass_density_times_lorentz_factor < | ||
rest_mass_density_times_lorentz_factor_cutoff_; | ||
simd::any(tilde_d_mask)) { | ||
needed_fixing = true; |
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.
This looks good now.
0caab91
to
269b890
Compare
269b890
to
b3bdfe6
Compare
This is now rebased and squashed :) Thanks for the reviews! |
Proposed changes
note: I've left fixup commits that I will squash with the goal of making the PR easier to review.
dot_product
for magnitude computationUpgrade instructions
Code review checklist
make doc
to generate the documentation locally intoBUILD_DIR/docs/html
.Then open
index.html
.code review guide.
bugfix
ornew feature
if appropriate.Further comments