Fix MPI tally reductions for counts larger than INT_MAX - #4037
Merged
Conversation
Contributor
|
There are more places in the code using MPI_Reduce: |
Contributor
Author
|
I didn't touch the other reductions since they operate on small, fixed-size buffers just to limit the scope of this PR. I can update them though if you feel strongly. |
Contributor
|
In some of the cases it is not clear to me that the reductions are over small size buffers. |
Contributor
Author
|
@GuySten Good point; I've updated a few of more variable-length reductions to be safe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes silent tally corruption in MPI runs when a tally result buffer contains more than
INT_MAXelements. The existing reductions passedsize_tcounts directly toMPI_Reduce, whose legacy C API accepts anint. Large counts could therefore be narrowed silently, leaving part of the tally unreduced. In my implementation, the large-countMPI_Reduce_cfunction from MPI-4 is used if available (checked via CMake capability detection). However, because MPI-4 support is not universal, it will fall back to correctly boundedMPI_Reducechunks that are no more thanINT_MAXelements.Note that I was hesitant to add a test that allocates a > 2 GB buffer in CI, so at present there is no associated test.
Separately, while working on this, I ran into a compile-time error when building OpenMC with MPI against a LibMesh build that wasn't built against MPI; small fix for that is also included.
Checklist