From ba594def118fefdc3f636dea13990c4ce07332e8 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Wed, 24 May 2017 15:00:18 +0900 Subject: [PATCH 1/2] osc/rdma: use extent of the appropriate datatype in ompi_osc_rdma_rget_accumulate_internal() origin_datatype and target_datatype might be different and hence have different extent, so use either origin_extent or target_extent when appropriate. Refs open-mpi/ompi#3569 Signed-off-by: Gilles Gouaillardet (back-ported from commit open-mpi/ompi@0f79259b944becdd893aaa4f327ea243dbcad179) --- ompi/mca/osc/rdma/osc_rdma_accumulate.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ompi/mca/osc/rdma/osc_rdma_accumulate.c b/ompi/mca/osc/rdma/osc_rdma_accumulate.c index 2d0cf71a9c7..9bb29a39d9a 100644 --- a/ompi/mca/osc/rdma/osc_rdma_accumulate.c +++ b/ompi/mca/osc/rdma/osc_rdma_accumulate.c @@ -1016,7 +1016,7 @@ int ompi_osc_rdma_rget_accumulate_internal (ompi_osc_rdma_sync_t *sync, const vo ompi_osc_rdma_module_t *module = sync->module; mca_btl_base_registration_handle_t *target_handle; uint64_t target_address; - ptrdiff_t lb, extent; + ptrdiff_t lb, origin_extent, target_extent; int ret; /* short-circuit case. note that origin_count may be 0 if op is MPI_NO_OP */ @@ -1068,20 +1068,22 @@ int ompi_osc_rdma_rget_accumulate_internal (ompi_osc_rdma_sync_t *sync, const vo } } - (void) ompi_datatype_get_extent (origin_datatype, &lb, &extent); + (void) ompi_datatype_get_extent (target_datatype, &lb, &target_extent); - ret = osc_rdma_get_remote_segment (module, peer, target_disp, extent * target_count, &target_address, &target_handle); + ret = osc_rdma_get_remote_segment (module, peer, target_disp, target_extent * target_count, &target_address, &target_handle); if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) { return ret; } - if (module->acc_single_intrinsic && extent <= 8) { + (void) ompi_datatype_get_extent (origin_datatype, &lb, &origin_extent); + + if (module->acc_single_intrinsic && origin_extent <= 8) { if (module->acc_use_amo && ompi_datatype_is_predefined (origin_datatype)) { if (NULL == result_addr) { - ret = ompi_osc_rdma_acc_single_atomic (sync, origin_addr, origin_datatype, extent, peer, target_address, + ret = ompi_osc_rdma_acc_single_atomic (sync, origin_addr, origin_datatype, origin_extent, peer, target_address, target_handle, op, request); } else { - ret = ompi_osc_rdma_fetch_and_op_atomic (sync, origin_addr, result_addr, origin_datatype, extent, peer, target_address, + ret = ompi_osc_rdma_fetch_and_op_atomic (sync, origin_addr, result_addr, origin_datatype, origin_extent, peer, target_address, target_handle, op, request); } @@ -1090,7 +1092,7 @@ int ompi_osc_rdma_rget_accumulate_internal (ompi_osc_rdma_sync_t *sync, const vo } } - ret = ompi_osc_rdma_fetch_and_op_cas (sync, origin_addr, result_addr, origin_datatype, extent, peer, target_address, + ret = ompi_osc_rdma_fetch_and_op_cas (sync, origin_addr, result_addr, origin_datatype, origin_extent, peer, target_address, target_handle, op, request); if (OMPI_SUCCESS == ret) { return OMPI_SUCCESS; From 4ad8c07b7c745d5570024e5da79b9fc9b5666c1f Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Mon, 29 May 2017 11:07:10 +0900 Subject: [PATCH 2/2] 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 (back-ported from commit open-mpi/ompi@`e622ca8c1c06d253005bcedd61f576af0dfbe68f) --- ompi/mca/osc/rdma/osc_rdma_accumulate.c | 16 ++++++++++++---- ompi/mca/osc/rdma/osc_rdma_comm.c | 7 ++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ompi/mca/osc/rdma/osc_rdma_accumulate.c b/ompi/mca/osc/rdma/osc_rdma_accumulate.c index 9bb29a39d9a..aaf6c0a07cc 100644 --- a/ompi/mca/osc/rdma/osc_rdma_accumulate.c +++ b/ompi/mca/osc/rdma/osc_rdma_accumulate.c @@ -968,6 +968,7 @@ int ompi_osc_rdma_compare_and_swap (const void *origin_addr, const void *compare mca_btl_base_registration_handle_t *target_handle; ompi_osc_rdma_sync_t *sync; uint64_t target_address; + ptrdiff_t true_lb, true_extent; int ret; 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 return OMPI_ERR_RMA_SYNC; } - ret = osc_rdma_get_remote_segment (module, peer, target_disp, dt->super.size, &target_address, &target_handle); + ret = ompi_datatype_get_true_extent(dt, &true_lb, &true_extent); + if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) { + return ret; + } + + ret = osc_rdma_get_remote_segment (module, peer, target_disp, true_lb+true_extent, &target_address, &target_handle); if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) { return ret; } @@ -1016,7 +1022,7 @@ int ompi_osc_rdma_rget_accumulate_internal (ompi_osc_rdma_sync_t *sync, const vo ompi_osc_rdma_module_t *module = sync->module; mca_btl_base_registration_handle_t *target_handle; uint64_t target_address; - ptrdiff_t lb, origin_extent, target_extent; + ptrdiff_t lb, origin_extent, target_span; int ret; /* 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 } } - (void) ompi_datatype_get_extent (target_datatype, &lb, &target_extent); + target_span = opal_datatype_span(&target_datatype->super, target_count, &lb); - ret = osc_rdma_get_remote_segment (module, peer, target_disp, target_extent * target_count, &target_address, &target_handle); + // a buffer defined by (buf, count, dt) + // will have data starting at buf+offset and ending len bytes later: + ret = osc_rdma_get_remote_segment (module, peer, target_disp, target_span+lb, &target_address, &target_handle); if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) { return ret; } diff --git a/ompi/mca/osc/rdma/osc_rdma_comm.c b/ompi/mca/osc/rdma/osc_rdma_comm.c index 7efde7c39be..777f4602513 100644 --- a/ompi/mca/osc/rdma/osc_rdma_comm.c +++ b/ompi/mca/osc/rdma/osc_rdma_comm.c @@ -814,6 +814,7 @@ static inline int ompi_osc_rdma_get_w_req (ompi_osc_rdma_sync_t *sync, void *ori ompi_osc_rdma_module_t *module = sync->module; mca_btl_base_registration_handle_t *source_handle; uint64_t source_address; + ptrdiff_t source_span, source_lb; int ret; /* short-circuit case */ @@ -825,7 +826,11 @@ static inline int ompi_osc_rdma_get_w_req (ompi_osc_rdma_sync_t *sync, void *ori return OMPI_SUCCESS; } - ret = osc_rdma_get_remote_segment (module, peer, source_disp, source_datatype->super.size * source_count, + // a buffer defined by (buf, count, dt) + // will have data starting at buf+offset and ending len bytes later: + source_span = opal_datatype_span(&source_datatype->super, source_count, &source_lb); + + ret = osc_rdma_get_remote_segment (module, peer, source_disp, source_span+source_lb, &source_address, &source_handle); if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) { return ret;