File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments