commit 58e780bb0548abafa9a6d2c11b33836362c42475
parent e967b683eda904860b9fff9f201acd21b53b5802
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 8 Dec 2023 12:14:00 +0100
Update the way work is distributed between processes
Ensure that distributed indexes are continuous per process. This makes
no difference to the distribution of realisations, since the indexes are
not used, but they are used when distributing probes: they reference the
probes and must remain in the order submitted by the caller.
In any case, the previous implementation was buggy: the index ranges
overlapped.
Diffstat:
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/sdis.c b/src/sdis.c
@@ -479,20 +479,30 @@ compute_process_index_range
range[1] = range[0] + per_process_indices; /* Upper bound is _exclusive */
ASSERT(range[0] <= range[1]);
- /* Set the remaining number of indexes that are not managed by 1 process */
+ /* Set the remaining number of indexes that are not managed by one process */
remaining_indices =
nindices - per_process_indices * (size_t)dev->mpi_nprocs;
- /* Distribute the remaining indices onto the processes */
+ /* Distribute the remaining indices among the processes. Each process whose
+ * rank is lower than the number of remaining indices takes an additional
+ * index. To ensure continuity of indices per process, subsequent processes
+ * shift their initial rank accordingly, i.e. process 1 shifts its indices
+ * by 1, process 2 shifts them by 2 and so on until there are no more
+ * indices to distribute. From then on, subsequent processes simply shift
+ * their index range by the number of remaining indices that have been
+ * distributed. */
if((size_t)dev->mpi_rank < remaining_indices) {
- range[1] += 1;
+ range[0] += (size_t)dev->mpi_rank;
+ range[1] += (size_t)dev->mpi_rank + 1/* Take one more index */;
+ } else {
+ range[0] += remaining_indices;
+ range[1] += remaining_indices;
}
}
#endif
return range[1] - range[0];
}
-
#ifndef SDIS_ENABLE_MPI
res_T
gather_accumulators