From 0f23037775d215e021d4631ac2d43bcb02ee9a3e Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Mon, 19 Oct 2015 16:47:59 +0900 Subject: [PATCH] coll/base: fix memory allocation in mca_coll_base_alltoall_intra_basic_inplace --- ompi/mca/coll/base/coll_base_alltoall.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ompi/mca/coll/base/coll_base_alltoall.c b/ompi/mca/coll/base/coll_base_alltoall.c index 273e836caa..5b1f13160a 100644 --- a/ompi/mca/coll/base/coll_base_alltoall.c +++ b/ompi/mca/coll/base/coll_base_alltoall.c @@ -46,7 +46,7 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount, MPI_Request *preq; char *tmp_buffer; size_t max_size; - ptrdiff_t ext; + ptrdiff_t ext, true_lb, true_ext; /* Initialize. */ @@ -60,13 +60,15 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount, /* Find the largest receive amount */ ompi_datatype_type_extent (rdtype, &ext); - max_size = ext * rcount; + ompi_datatype_get_true_extent ( rdtype, &true_lb, &true_ext); + max_size = true_ext + ext * (rcount-1); /* Allocate a temporary buffer */ tmp_buffer = calloc (max_size, 1); if (NULL == tmp_buffer) { return OMPI_ERR_OUT_OF_RESOURCE; } + max_size = ext * rcount; /* in-place alltoall slow algorithm (but works) */ for (i = 0 ; i < size ; ++i) {