Skip to content

Commit a2cd6a9

Browse files
committed
coll/base: reduce memory consumption in Scatter
This PR reduces memory consumption in non-root and non-leaf processes of binomial tree algorithm for Scatter operation. Signed-off-by: Mikhail Kurnosov <[email protected]>
1 parent 2383393 commit a2cd6a9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ompi/mca/coll/base/coll_base_scatter.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ ompi_coll_base_scatter_intra_binomial(
138138
scount = (int)packed_sizet;
139139

140140
sdtype = MPI_PACKED; /* default to MPI_PACKED as the send type */
141-
packed_size = scount * (size+1)/2; /* non-root, non-leaf nodes, allocate temp buffer for recv
142-
* the most we need is rcount*size/2 */
141+
142+
/* non-root, non-leaf nodes, allocate temp buffer for recv the most we need is rcount*size/2 (an upper bound) */
143+
int vparent = (bmtree->tree_prev - root + size) % size;
144+
int subtree_size = vrank - vparent;
145+
if (size - vrank < subtree_size)
146+
subtree_size = size - vrank;
147+
packed_size = scount * subtree_size;
148+
143149
ptmp = tempbuf = (char *)malloc(packed_size);
144150
if (NULL == tempbuf) {
145151
err = OMPI_ERR_OUT_OF_RESOURCE; line = __LINE__; goto err_hndl;

0 commit comments

Comments
 (0)