@@ -125,7 +125,6 @@ int mca_coll_han_scatterv_intra(const void *sbuf, const int *scounts, const int
125125 int need_bounce_buf = 0 , total_up_scounts = 0 , * up_displs = NULL , * up_scounts = NULL ,
126126 * up_peer_lb = NULL , * up_peer_ub = NULL ;
127127 char * reorder_sbuf = (char * ) sbuf , * bounce_buf = NULL ;
128- size_t sdsize ;
129128
130129 low_scounts = malloc (low_size * sizeof (int ));
131130 low_displs = malloc (low_size * sizeof (int ));
@@ -144,8 +143,6 @@ int mca_coll_han_scatterv_intra(const void *sbuf, const int *scounts, const int
144143 low_scounts [low_peer ] = scounts [w_peer ];
145144 }
146145
147- ompi_datatype_type_size (sdtype , & sdsize );
148-
149146 up_scounts = calloc (up_size , sizeof (int ));
150147 up_displs = malloc (up_size * sizeof (int ));
151148 up_peer_ub = calloc (up_size , sizeof (int ));
@@ -201,11 +198,14 @@ int mca_coll_han_scatterv_intra(const void *sbuf, const int *scounts, const int
201198 }
202199
203200 if (need_bounce_buf ) {
204- bounce_buf = malloc (sdsize * total_up_scounts );
201+ ptrdiff_t ssize , sgap ;
202+ ssize = opal_datatype_span (& rdtype -> super , total_up_scounts , & sgap );
203+ bounce_buf = malloc (ssize );
205204 if (!bounce_buf ) {
206205 err = OMPI_ERR_OUT_OF_RESOURCE ;
207206 goto root_out ;
208207 }
208+ reorder_sbuf = bounce_buf - sgap ;
209209
210210 /* Calculate displacements for the inter-node scatterv */
211211 for (up_peer = 0 ; up_peer < up_size ; ++ up_peer ) {
@@ -214,7 +214,8 @@ int mca_coll_han_scatterv_intra(const void *sbuf, const int *scounts, const int
214214 }
215215
216216 /* Use a temp buffer to reorder the send buffer if needed */
217- ptrdiff_t offset = 0 ;
217+ ptrdiff_t offset = 0 , sdext ;
218+ ompi_datatype_type_extent (sdtype , & sdext );
218219
219220 for (int i = 0 ; i < w_size ; ++ i ) {
220221 up_peer = topo [2 * i ];
@@ -225,13 +226,11 @@ int mca_coll_han_scatterv_intra(const void *sbuf, const int *scounts, const int
225226 w_peer = topo [2 * i + 1 ];
226227
227228 ompi_datatype_copy_content_same_ddt (sdtype , (size_t ) scounts [w_peer ],
228- bounce_buf + offset ,
229+ reorder_sbuf + offset ,
229230 (char * ) sbuf
230- + (size_t ) displs [w_peer ] * sdsize );
231- offset += sdsize * (size_t ) scounts [w_peer ];
231+ + (size_t ) displs [w_peer ] * sdext );
232+ offset += sdext * (size_t ) scounts [w_peer ];
232233 }
233-
234- reorder_sbuf = bounce_buf ;
235234 }
236235
237236 /* Up Iscatterv */
0 commit comments