Skip to content

Commit

Permalink
Merge pull request #8626 from mkurnosov/scatter-bmtree-fix-tmpbuf
Browse files Browse the repository at this point in the history
coll/base: reduce memory consumption in Scatter
  • Loading branch information
jsquyres authored Mar 16, 2021
2 parents 2383393 + a2cd6a9 commit 1da3f93
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ompi/mca/coll/base/coll_base_scatter.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,14 @@ ompi_coll_base_scatter_intra_binomial(
scount = (int)packed_sizet;

sdtype = MPI_PACKED; /* default to MPI_PACKED as the send type */
packed_size = scount * (size+1)/2; /* non-root, non-leaf nodes, allocate temp buffer for recv
* the most we need is rcount*size/2 */

/* non-root, non-leaf nodes, allocate temp buffer for recv the most we need is rcount*size/2 (an upper bound) */
int vparent = (bmtree->tree_prev - root + size) % size;
int subtree_size = vrank - vparent;
if (size - vrank < subtree_size)
subtree_size = size - vrank;
packed_size = scount * subtree_size;

ptmp = tempbuf = (char *)malloc(packed_size);
if (NULL == tempbuf) {
err = OMPI_ERR_OUT_OF_RESOURCE; line = __LINE__; goto err_hndl;
Expand Down

0 comments on commit 1da3f93

Please sign in to comment.