Skip to content

Commit 4ad8c07

Browse files
committed
osc/rdma: fix osc_rdma_get_remote_segment() length parameter
a buffer defined by (buf, count, dt) will have data starting at buf+offset and ending len bytes later with len = opal_datatype_span(&dt.super, count, &offset); Signed-off-by: Gilles Gouaillardet <[email protected]> (back-ported from commit open-mpi/ompi@`e622ca8c1c06d253005bcedd61f576af0dfbe68f)
1 parent ba594de commit 4ad8c07

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

ompi/mca/osc/rdma/osc_rdma_accumulate.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@ int ompi_osc_rdma_compare_and_swap (const void *origin_addr, const void *compare
968968
mca_btl_base_registration_handle_t *target_handle;
969969
ompi_osc_rdma_sync_t *sync;
970970
uint64_t target_address;
971+
ptrdiff_t true_lb, true_extent;
971972
int ret;
972973

973974
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "cswap: 0x%lx, 0x%lx, 0x%lx, %s, %d, %d, %s",
@@ -979,7 +980,12 @@ int ompi_osc_rdma_compare_and_swap (const void *origin_addr, const void *compare
979980
return OMPI_ERR_RMA_SYNC;
980981
}
981982

982-
ret = osc_rdma_get_remote_segment (module, peer, target_disp, dt->super.size, &target_address, &target_handle);
983+
ret = ompi_datatype_get_true_extent(dt, &true_lb, &true_extent);
984+
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
985+
return ret;
986+
}
987+
988+
ret = osc_rdma_get_remote_segment (module, peer, target_disp, true_lb+true_extent, &target_address, &target_handle);
983989
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
984990
return ret;
985991
}
@@ -1016,7 +1022,7 @@ int ompi_osc_rdma_rget_accumulate_internal (ompi_osc_rdma_sync_t *sync, const vo
10161022
ompi_osc_rdma_module_t *module = sync->module;
10171023
mca_btl_base_registration_handle_t *target_handle;
10181024
uint64_t target_address;
1019-
ptrdiff_t lb, origin_extent, target_extent;
1025+
ptrdiff_t lb, origin_extent, target_span;
10201026
int ret;
10211027

10221028
/* short-circuit case. note that origin_count may be 0 if op is MPI_NO_OP */
@@ -1068,9 +1074,11 @@ int ompi_osc_rdma_rget_accumulate_internal (ompi_osc_rdma_sync_t *sync, const vo
10681074
}
10691075
}
10701076

1071-
(void) ompi_datatype_get_extent (target_datatype, &lb, &target_extent);
1077+
target_span = opal_datatype_span(&target_datatype->super, target_count, &lb);
10721078

1073-
ret = osc_rdma_get_remote_segment (module, peer, target_disp, target_extent * target_count, &target_address, &target_handle);
1079+
// a buffer defined by (buf, count, dt)
1080+
// will have data starting at buf+offset and ending len bytes later:
1081+
ret = osc_rdma_get_remote_segment (module, peer, target_disp, target_span+lb, &target_address, &target_handle);
10741082
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
10751083
return ret;
10761084
}

ompi/mca/osc/rdma/osc_rdma_comm.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ static inline int ompi_osc_rdma_get_w_req (ompi_osc_rdma_sync_t *sync, void *ori
814814
ompi_osc_rdma_module_t *module = sync->module;
815815
mca_btl_base_registration_handle_t *source_handle;
816816
uint64_t source_address;
817+
ptrdiff_t source_span, source_lb;
817818
int ret;
818819

819820
/* short-circuit case */
@@ -825,7 +826,11 @@ static inline int ompi_osc_rdma_get_w_req (ompi_osc_rdma_sync_t *sync, void *ori
825826
return OMPI_SUCCESS;
826827
}
827828

828-
ret = osc_rdma_get_remote_segment (module, peer, source_disp, source_datatype->super.size * source_count,
829+
// a buffer defined by (buf, count, dt)
830+
// will have data starting at buf+offset and ending len bytes later:
831+
source_span = opal_datatype_span(&source_datatype->super, source_count, &source_lb);
832+
833+
ret = osc_rdma_get_remote_segment (module, peer, source_disp, source_span+source_lb,
829834
&source_address, &source_handle);
830835
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
831836
return ret;

0 commit comments

Comments
 (0)