Skip to content

Commit 0f23037

Browse files
committed
coll/base: fix memory allocation in mca_coll_base_alltoall_intra_basic_inplace
1 parent 7dac5d3 commit 0f23037

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ompi/mca/coll/base/coll_base_alltoall.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
4646
MPI_Request *preq;
4747
char *tmp_buffer;
4848
size_t max_size;
49-
ptrdiff_t ext;
49+
ptrdiff_t ext, true_lb, true_ext;
5050

5151
/* Initialize. */
5252

@@ -60,13 +60,15 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
6060

6161
/* Find the largest receive amount */
6262
ompi_datatype_type_extent (rdtype, &ext);
63-
max_size = ext * rcount;
63+
ompi_datatype_get_true_extent ( rdtype, &true_lb, &true_ext);
64+
max_size = true_ext + ext * (rcount-1);
6465

6566
/* Allocate a temporary buffer */
6667
tmp_buffer = calloc (max_size, 1);
6768
if (NULL == tmp_buffer) {
6869
return OMPI_ERR_OUT_OF_RESOURCE;
6970
}
71+
max_size = ext * rcount;
7072

7173
/* in-place alltoall slow algorithm (but works) */
7274
for (i = 0 ; i < size ; ++i) {

0 commit comments

Comments
 (0)