Skip to content

Commit 359cdf2

Browse files
committed
osc/ucx: Fix data corruption with non-contiguous accumulates
Signed-off-by: Nysal Jan K.A <[email protected]> (cherry picked from commit 3529d44)
1 parent 86794e5 commit 359cdf2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ompi/mca/osc/ucx/osc_ucx_comm.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,12 +566,13 @@ int ompi_osc_ucx_accumulate(const void *origin_addr, int origin_count,
566566
if ((op != &ompi_mpi_op_maxloc.op && op != &ompi_mpi_op_minloc.op) ||
567567
ompi_datatype_is_contiguous_memory_layout(temp_dt, temp_count)) {
568568
size_t temp_size;
569+
char *curr_temp_addr = (char *)temp_addr;
569570
ompi_datatype_type_size(temp_dt, &temp_size);
570571
while (origin_ucx_iov_idx < origin_ucx_iov_count) {
571572
int curr_count = origin_ucx_iov[origin_ucx_iov_idx].len / temp_size;
572573
ompi_op_reduce(op, origin_ucx_iov[origin_ucx_iov_idx].addr,
573-
temp_addr, curr_count, temp_dt);
574-
temp_addr = (void *)((char *)temp_addr + curr_count * temp_size);
574+
curr_temp_addr, curr_count, temp_dt);
575+
curr_temp_addr += curr_count * temp_size;
575576
origin_ucx_iov_idx++;
576577
}
577578
} else {
@@ -811,12 +812,13 @@ int ompi_osc_ucx_get_accumulate(const void *origin_addr, int origin_count,
811812
if ((op != &ompi_mpi_op_maxloc.op && op != &ompi_mpi_op_minloc.op) ||
812813
ompi_datatype_is_contiguous_memory_layout(temp_dt, temp_count)) {
813814
size_t temp_size;
815+
char *curr_temp_addr = (char *)temp_addr;
814816
ompi_datatype_type_size(temp_dt, &temp_size);
815817
while (origin_ucx_iov_idx < origin_ucx_iov_count) {
816818
int curr_count = origin_ucx_iov[origin_ucx_iov_idx].len / temp_size;
817819
ompi_op_reduce(op, origin_ucx_iov[origin_ucx_iov_idx].addr,
818-
temp_addr, curr_count, temp_dt);
819-
temp_addr = (void *)((char *)temp_addr + curr_count * temp_size);
820+
curr_temp_addr, curr_count, temp_dt);
821+
curr_temp_addr += curr_count * temp_size;
820822
origin_ucx_iov_idx++;
821823
}
822824
} else {

0 commit comments

Comments
 (0)