-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add sparse seed nans flag to output #902
Conversation
src/outputs/parthenon_hdf5.cpp
Outdated
@@ -538,7 +538,10 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm | |||
varSize = | |||
vinfo.nx6 * vinfo.nx5 * vinfo.nx4 * vinfo.nx3 * vinfo.nx2 * vinfo.nx1; | |||
} | |||
memset(tmpData.data() + index, 0, varSize * sizeof(OutT)); | |||
auto fill_val = output_params.sparse_seed_nans | |||
? std::numeric_limits<OutT>::signaling_NaN() |
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.
here we use signaling_NaN()
rather than quiet_NaN()
because if we are doing any operations on output data then we should signal?
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.
You know to be honest I didn't think that through carefully. I just reflexively use signalling NaN for this kind of thing basically for that reason. But I'm not married to it, if you'd prefer a quiet NaN.
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.
Changed to quiet_NaN()
since that should be a bit more performant and no ops are happening here anyway.
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.
LGTM, I heartily approve
PR Summary
When debugging sparse variables, it's useful to be able to output where sparse variables are specifically de-allocated, as opposed to just exactly zero. This small PR adds a tiny tweak to parthenon_hdf5 output which allows the user to output NaNs for sparse variables which are de-allocated, making them easy to find in output.
This is essentially a debugging tool and it's opt-in. However, it does have the advantage that by replacing
memset
withstd::fill
we could change what that fill value is at a later date to, for example, set it to whatever value the sparse field would be initialized to, if that value is not zero.PR Checklist