@@ -48,6 +48,7 @@ static int nbc_alltoallv_init(const void* sendbuf, const int *sendcounts, const
4848 mca_coll_base_module_t * module , bool persistent )
4949{
5050 int rank , p , res ;
51+ size_t sdtype_size , rdtype_size ;
5152 MPI_Aint sndext , rcvext ;
5253 NBC_Schedule * schedule ;
5354 char * rbuf , * sbuf , inplace ;
@@ -60,6 +61,7 @@ static int nbc_alltoallv_init(const void* sendbuf, const int *sendcounts, const
6061 rank = ompi_comm_rank (comm );
6162 p = ompi_comm_size (comm );
6263
64+ ompi_datatype_type_size (recvtype , & rdtype_size );
6365 res = ompi_datatype_type_extent (recvtype , & rcvext );
6466 if (MPI_SUCCESS != res ) {
6567 NBC_Error ("MPI Error in ompi_datatype_type_extent() (%i)" , res );
@@ -92,22 +94,29 @@ static int nbc_alltoallv_init(const void* sendbuf, const int *sendcounts, const
9294 sendcounts = recvcounts ;
9395 sdispls = rdispls ;
9496 sndext = rcvext ;
97+ sdtype_size = rdtype_size ;
9598 } else {
99+ ompi_datatype_type_size (sendtype , & sdtype_size );
96100 res = ompi_datatype_type_extent (sendtype , & sndext );
97101 if (MPI_SUCCESS != res ) {
98102 NBC_Error ("MPI Error in ompi_datatype_type_extent() (%i)" , res );
99103 return res ;
100104 }
101105 }
102106
107+ if (0 == sdtype_size || 0 == rdtype_size ) {
108+ /* Nothing to exchange */
109+ ompi_coll_base_nbc_reserve_tags (comm , 1 );
110+ return nbc_get_noop_request (persistent , request );
111+ }
112+
103113 schedule = OBJ_NEW (NBC_Schedule );
104114 if (OPAL_UNLIKELY (NULL == schedule )) {
105115 free (tmpbuf );
106116 return OMPI_ERR_OUT_OF_RESOURCE ;
107117 }
108118
109-
110- if (!inplace && sendcounts [rank ] != 0 ) {
119+ if (!inplace && 0 < sendcounts [rank ]) {
111120 rbuf = (char * ) recvbuf + rdispls [rank ] * rcvext ;
112121 sbuf = (char * ) sendbuf + sdispls [rank ] * sndext ;
113122 res = NBC_Sched_copy (sbuf , false, sendcounts [rank ], sendtype ,
@@ -177,10 +186,18 @@ static int nbc_alltoallv_inter_init (const void* sendbuf, const int *sendcounts,
177186 mca_coll_base_module_t * module , bool persistent )
178187{
179188 int res , rsize ;
189+ size_t sdtype_size , rdtype_size ;
180190 MPI_Aint sndext , rcvext ;
181191 NBC_Schedule * schedule ;
182192 ompi_coll_libnbc_module_t * libnbc_module = (ompi_coll_libnbc_module_t * ) module ;
183193
194+ ompi_datatype_type_size (sendtype , & sdtype_size );
195+ ompi_datatype_type_size (recvtype , & rdtype_size );
196+ if (0 == sdtype_size || 0 == rdtype_size ) {
197+ /* Nothing to exchange */
198+ ompi_coll_base_nbc_reserve_tags (comm , 1 );
199+ return nbc_get_noop_request (persistent , request );
200+ }
184201
185202 res = ompi_datatype_type_extent (sendtype , & sndext );
186203 if (MPI_SUCCESS != res ) {
@@ -203,7 +220,7 @@ static int nbc_alltoallv_inter_init (const void* sendbuf, const int *sendcounts,
203220
204221 for (int i = 0 ; i < rsize ; i ++ ) {
205222 /* post all sends */
206- if (sendcounts [i ] != 0 ) {
223+ if (0 < sendcounts [i ]) {
207224 char * sbuf = (char * ) sendbuf + sdispls [i ] * sndext ;
208225 res = NBC_Sched_send (sbuf , false, sendcounts [i ], sendtype , i , schedule , false);
209226 if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
@@ -212,7 +229,7 @@ static int nbc_alltoallv_inter_init (const void* sendbuf, const int *sendcounts,
212229 }
213230 }
214231 /* post all receives */
215- if (recvcounts [i ] != 0 ) {
232+ if (0 < recvcounts [i ]) {
216233 char * rbuf = (char * ) recvbuf + rdispls [i ] * rcvext ;
217234 res = NBC_Sched_recv (rbuf , false, recvcounts [i ], recvtype , i , schedule , false);
218235 if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
@@ -272,7 +289,7 @@ static inline int a2av_sched_linear(int rank, int p, NBC_Schedule *schedule,
272289 }
273290
274291 /* post send */
275- if (sendcounts [i ] != 0 ) {
292+ if (0 < sendcounts [i ]) {
276293 char * sbuf = ((char * ) sendbuf ) + (sdispls [i ] * sndext );
277294 res = NBC_Sched_send (sbuf , false, sendcounts [i ], sendtype , i , schedule , false);
278295 if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
@@ -281,7 +298,7 @@ static inline int a2av_sched_linear(int rank, int p, NBC_Schedule *schedule,
281298 }
282299
283300 /* post receive */
284- if (recvcounts [i ] != 0 ) {
301+ if (0 < recvcounts [i ]) {
285302 char * rbuf = ((char * ) recvbuf ) + (rdispls [i ] * rcvext );
286303 res = NBC_Sched_recv (rbuf , false, recvcounts [i ], recvtype , i , schedule , false);
287304 if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
@@ -306,7 +323,7 @@ static inline int a2av_sched_pairwise(int rank, int p, NBC_Schedule *schedule,
306323 int rcvpeer = (rank + p - i ) %p ;
307324
308325 /* post send */
309- if (sendcounts [sndpeer ] != 0 ) {
326+ if (0 < sendcounts [sndpeer ]) {
310327 char * sbuf = ((char * ) sendbuf ) + (sdispls [sndpeer ] * sndext );
311328 res = NBC_Sched_send (sbuf , false, sendcounts [sndpeer ], sendtype , sndpeer , schedule , false);
312329 if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
@@ -315,7 +332,7 @@ static inline int a2av_sched_pairwise(int rank, int p, NBC_Schedule *schedule,
315332 }
316333
317334 /* post receive */
318- if (recvcounts [rcvpeer ] != 0 ) {
335+ if (0 < recvcounts [rcvpeer ]) {
319336 char * rbuf = ((char * ) recvbuf ) + (rdispls [rcvpeer ] * rcvext );
320337 res = NBC_Sched_recv (rbuf , false, recvcounts [rcvpeer ], recvtype , rcvpeer , schedule , true);
321338 if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
@@ -338,34 +355,34 @@ static inline int a2av_sched_inplace(int rank, int p, NBC_Schedule *schedule,
338355 char * sbuf = (char * ) buf + displs [speer ] * ext ;
339356 char * rbuf = (char * ) buf + displs [rpeer ] * ext ;
340357
341- if (0 != counts [rpeer ]) {
358+ if (0 < counts [rpeer ]) {
342359 res = NBC_Sched_copy (rbuf , false, counts [rpeer ], type ,
343360 (void * )(- gap ), true, counts [rpeer ], type ,
344361 schedule , true);
345362 if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
346363 return res ;
347364 }
348365 }
349- if (0 != counts [speer ]) {
366+ if (0 < counts [speer ]) {
350367 res = NBC_Sched_send (sbuf , false , counts [speer ], type , speer , schedule , false);
351368 if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
352369 return res ;
353370 }
354371 }
355- if (0 != counts [rpeer ]) {
372+ if (0 < counts [rpeer ]) {
356373 res = NBC_Sched_recv (rbuf , false , counts [rpeer ], type , rpeer , schedule , true);
357374 if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
358375 return res ;
359376 }
360377 }
361378
362- if (0 != counts [rpeer ]) {
379+ if (0 < counts [rpeer ]) {
363380 res = NBC_Sched_send ((void * )(- gap ), true, counts [rpeer ], type , rpeer , schedule , false);
364381 if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
365382 return res ;
366383 }
367384 }
368- if (0 != counts [speer ]) {
385+ if (0 < counts [speer ]) {
369386 res = NBC_Sched_recv (sbuf , false, counts [speer ], type , speer , schedule , true);
370387 if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
371388 return res ;
@@ -374,15 +391,17 @@ static inline int a2av_sched_inplace(int rank, int p, NBC_Schedule *schedule,
374391 }
375392 if (0 == (p %2 )) {
376393 int peer = (rank + p /2 ) % p ;
377-
378394 char * tbuf = (char * ) buf + displs [peer ] * ext ;
379- res = NBC_Sched_copy (tbuf , false, counts [peer ], type ,
380- (void * )(- gap ), true, counts [peer ], type ,
381- schedule , true);
382- if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
383- return res ;
395+
396+ if (0 < counts [peer ]) {
397+ res = NBC_Sched_copy (tbuf , false, counts [peer ], type , (void * ) (- gap ), true, counts [peer ],
398+ type , schedule , true);
399+ if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
400+ return res ;
401+ }
384402 }
385- if (0 != counts [peer ]) {
403+
404+ if (0 < counts [peer ]) {
386405 res = NBC_Sched_send ((void * )(- gap ), true , counts [peer ], type , peer , schedule , false);
387406 if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
388407 return res ;
0 commit comments