Skip to content

Commit 3529d44

Browse files
committed
osc/ucx: Fix data corruption with non-contiguous accumulates
Signed-off-by: Nysal Jan K.A <[email protected]>
1 parent 94f26f5 commit 3529d44

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
@@ -510,12 +510,13 @@ int ompi_osc_ucx_accumulate(const void *origin_addr, int origin_count,
510510
if ((op != &ompi_mpi_op_maxloc.op && op != &ompi_mpi_op_minloc.op) ||
511511
ompi_datatype_is_contiguous_memory_layout(temp_dt, temp_count)) {
512512
size_t temp_size;
513+
char *curr_temp_addr = (char *)temp_addr;
513514
ompi_datatype_type_size(temp_dt, &temp_size);
514515
while (origin_ucx_iov_idx < origin_ucx_iov_count) {
515516
int curr_count = origin_ucx_iov[origin_ucx_iov_idx].len / temp_size;
516517
ompi_op_reduce(op, origin_ucx_iov[origin_ucx_iov_idx].addr,
517-
temp_addr, curr_count, temp_dt);
518-
temp_addr = (void *)((char *)temp_addr + curr_count * temp_size);
518+
curr_temp_addr, curr_count, temp_dt);
519+
curr_temp_addr += curr_count * temp_size;
519520
origin_ucx_iov_idx++;
520521
}
521522
} else {
@@ -730,12 +731,13 @@ int ompi_osc_ucx_get_accumulate(const void *origin_addr, int origin_count,
730731
if ((op != &ompi_mpi_op_maxloc.op && op != &ompi_mpi_op_minloc.op) ||
731732
ompi_datatype_is_contiguous_memory_layout(temp_dt, temp_count)) {
732733
size_t temp_size;
734+
char *curr_temp_addr = (char *)temp_addr;
733735
ompi_datatype_type_size(temp_dt, &temp_size);
734736
while (origin_ucx_iov_idx < origin_ucx_iov_count) {
735737
int curr_count = origin_ucx_iov[origin_ucx_iov_idx].len / temp_size;
736738
ompi_op_reduce(op, origin_ucx_iov[origin_ucx_iov_idx].addr,
737-
temp_addr, curr_count, temp_dt);
738-
temp_addr = (void *)((char *)temp_addr + curr_count * temp_size);
739+
curr_temp_addr, curr_count, temp_dt);
740+
curr_temp_addr += curr_count * temp_size;
739741
origin_ucx_iov_idx++;
740742
}
741743
} else {

0 commit comments

Comments
 (0)