Skip to content

Commit d55504f

Browse files
committed
osc/rdma: fix amo-based accumulate
This fixes an issue in osc/rdma when AMOs are used for accumulate operations (vs get-accumulate). In this case a temporary buffer is needed to hold the result of the operation (since fetching atomics are used). This buffer was 1) zero-sized, and 2) not freed. Both of these issues are fixed in this commit. There was also an issue with unpacking due to using an uninitialized convertor. The convertor is no longer passed in when no result is required. Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 56ed3a6 commit d55504f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ompi/mca/osc/rdma/osc_rdma_accumulate.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,14 @@ static inline int ompi_osc_rdma_gacc_amo (ompi_osc_rdma_module_t *module, ompi_o
260260
{
261261
const bool use_amo = module->acc_use_amo;
262262
const size_t dt_size = datatype->super.size;
263+
void *to_free = NULL;
263264
uint64_t offset = 0;
264265
int ret;
265266

266267
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "using network atomics for accumulate operation with count %d", count);
267268

268-
/* only one can be non-NULL */
269-
assert (NULL == result || NULL == result_convertor);
270-
271-
if (NULL == result && NULL != result_convertor) {
272-
result = malloc (request->len);
269+
if (NULL == result) {
270+
to_free = result = malloc (request->len);
273271
if (OPAL_UNLIKELY(NULL == result)) {
274272
return OMPI_ERR_OUT_OF_RESOURCE;
275273
}
@@ -316,6 +314,8 @@ static inline int ompi_osc_rdma_gacc_amo (ompi_osc_rdma_module_t *module, ompi_o
316314
ompi_osc_rdma_request_complete (request, MPI_SUCCESS);
317315
}
318316

317+
free (to_free);
318+
319319
return OMPI_SUCCESS;
320320
}
321321

@@ -331,6 +331,8 @@ static inline int ompi_osc_rdma_gacc_contig (ompi_osc_rdma_sync_t *sync, const v
331331
char *ptr = NULL;
332332
int ret;
333333

334+
request->len = target_datatype->super.size * module->network_amo_max_count;
335+
334336
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "initiating accumulate on contiguous region of %lu bytes to remote address %" PRIx64
335337
", sync %p", len, target_address, (void *) sync);
336338

@@ -582,7 +584,7 @@ static inline int ompi_osc_rdma_gacc_master (ompi_osc_rdma_sync_t *sync, const v
582584
}
583585

584586
ret = ompi_osc_rdma_gacc_contig (sync, source_iovec[source_iov_index].iov_base, acc_len / target_primitive->super.size,
585-
target_primitive, NULL, 0, NULL, &result_convertor, peer,
587+
target_primitive, NULL, 0, NULL, result_datatype ? &result_convertor : NULL, peer,
586588
(uint64_t) (intptr_t) target_iovec[target_iov_index].iov_base, target_handle,
587589
acc_len / target_primitive->super.size, target_primitive, op, subreq);
588590
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {

0 commit comments

Comments
 (0)