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

Add sparse seed nans flag to output #902

Merged
merged 4 commits into from
Jul 6, 2023
Merged

Add sparse seed nans flag to output #902

merged 4 commits into from
Jul 6, 2023

Conversation

Yurlungur
Copy link
Collaborator

@Yurlungur Yurlungur commented Jul 6, 2023

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 with std::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

  • 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.
  • Docs build
  • (@lanl.gov employees) Update copyright on changed files

@@ -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()
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

@lroberts36 lroberts36 left a 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

@Yurlungur Yurlungur enabled auto-merge July 6, 2023 17:15
@Yurlungur Yurlungur disabled auto-merge July 6, 2023 17:22
@Yurlungur Yurlungur enabled auto-merge July 6, 2023 17:22
@Yurlungur Yurlungur disabled auto-merge July 6, 2023 21:24
@Yurlungur Yurlungur enabled auto-merge July 6, 2023 21:24
@Yurlungur Yurlungur disabled auto-merge July 6, 2023 21:28
@Yurlungur Yurlungur merged commit 9ae95ff into develop Jul 6, 2023
@Yurlungur Yurlungur deleted the jmm/sparse-is-nan branch July 6, 2023 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants