Implemented Gathering/Scattering of Data with MPI_GATHERV/MPI_SCATTERV #40
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.
In distributed-memory parallel applications with serial I/O files, data is scattered from global to tiled arrays during reading and gathered from tiled to global arrays during writing. The ROMS
distribute.F
module includes routinesmp_scatter2d
,mp_scatter3d
,mp_gather2d
, andmp_gather3d
for such I/O processing.For scattering,
mp_scatter2d
andmp_scatter3d
usesMPI_BCAST
routine if the ROMS C-preprocessing optionSCATTER_BCAST
is activated. Otherwise, it will default to the more efficient collective communications routineMPI_SCATTERV
.For gathering,
mp_gather2d
andmp_gather3d
usesMPI_ISEND
/MPI_IRECV
routines if the ROMS C-preprocessing optionGATHER_SENDRECV
. Otherwise, it will default to calling the collective communications routineMPI_GATHERV
.Using
MPI_SCATTERV
andMPI_GATHERV
is complicated to implement in applications when the grid size is not an exact multiple of the number of processor layouts, leading to parallel tiles of different sizes. In addition, the partition of data segments is not contiguous in Fortran memory. Strategies to manipulate the chunks of parallel data with MPI types and subarrays (say,MPI_TYPE_CREATE_SUBARRAY
) are available, but these are inefficient with multiple-dimensional data. However, achieving a generic solution for any ROMS grid can be challenging.After some experimentation, an alternative, efficient, and generic solution was achieved. For example, in mp_scatter3d we now have:
Its inverse gathering communication is more straightforward in
mp_gather3d
:The counts and displacements (counts, displs) vectors for mpi_scatterv and mpi_gatherv are computed as follows: