Skip to content

Commit 5e9be76

Browse files
Merge pull request #3600 from ggouaillardet/topic/osc_rdma_get_segment
osc/rdma: fix osc_rdma_get_remote_segment() length parameter
2 parents 4c00e2c + e622ca8 commit 5e9be76

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
@@ -967,6 +967,7 @@ int ompi_osc_rdma_compare_and_swap (const void *origin_addr, const void *compare
967967
mca_btl_base_registration_handle_t *target_handle;
968968
ompi_osc_rdma_sync_t *sync;
969969
uint64_t target_address;
970+
ptrdiff_t true_lb, true_extent;
970971
int ret;
971972

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

981-
ret = osc_rdma_get_remote_segment (module, peer, target_disp, dt->super.size, &target_address, &target_handle);
982+
ret = ompi_datatype_get_true_extent(dt, &true_lb, &true_extent);
983+
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
984+
return ret;
985+
}
986+
987+
ret = osc_rdma_get_remote_segment (module, peer, target_disp, true_lb+true_extent, &target_address, &target_handle);
982988
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
983989
return ret;
984990
}
@@ -1015,7 +1021,7 @@ int ompi_osc_rdma_rget_accumulate_internal (ompi_osc_rdma_sync_t *sync, const vo
10151021
ompi_osc_rdma_module_t *module = sync->module;
10161022
mca_btl_base_registration_handle_t *target_handle;
10171023
uint64_t target_address;
1018-
ptrdiff_t lb, origin_extent, target_extent;
1024+
ptrdiff_t lb, origin_extent, target_span;
10191025
int ret;
10201026

10211027
/* short-circuit case. note that origin_count may be 0 if op is MPI_NO_OP */
@@ -1027,9 +1033,11 @@ int ompi_osc_rdma_rget_accumulate_internal (ompi_osc_rdma_sync_t *sync, const vo
10271033
return OMPI_SUCCESS;
10281034
}
10291035

1030-
(void) ompi_datatype_get_extent (target_datatype, &lb, &target_extent);
1036+
target_span = opal_datatype_span(&target_datatype->super, target_count, &lb);
10311037

1032-
ret = osc_rdma_get_remote_segment (module, peer, target_disp, target_extent * target_count, &target_address, &target_handle);
1038+
// a buffer defined by (buf, count, dt)
1039+
// will have data starting at buf+offset and ending len bytes later:
1040+
ret = osc_rdma_get_remote_segment (module, peer, target_disp, target_span+lb, &target_address, &target_handle);
10331041
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
10341042
return ret;
10351043
}

ompi/mca/osc/rdma/osc_rdma_comm.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@ static inline int ompi_osc_rdma_get_w_req (ompi_osc_rdma_sync_t *sync, void *ori
825825
ompi_osc_rdma_module_t *module = sync->module;
826826
mca_btl_base_registration_handle_t *source_handle;
827827
uint64_t source_address;
828+
ptrdiff_t source_span, source_lb;
828829
int ret;
829830

830831
/* short-circuit case */
@@ -836,7 +837,11 @@ static inline int ompi_osc_rdma_get_w_req (ompi_osc_rdma_sync_t *sync, void *ori
836837
return OMPI_SUCCESS;
837838
}
838839

839-
ret = osc_rdma_get_remote_segment (module, peer, source_disp, source_datatype->super.size * source_count,
840+
// a buffer defined by (buf, count, dt)
841+
// will have data starting at buf+offset and ending len bytes later:
842+
source_span = opal_datatype_span(&source_datatype->super, source_count, &source_lb);
843+
844+
ret = osc_rdma_get_remote_segment (module, peer, source_disp, source_span+source_lb,
840845
&source_address, &source_handle);
841846
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
842847
return ret;

0 commit comments

Comments
 (0)