@@ -48,6 +48,7 @@ static int nbc_alltoallv_init(const void* sendbuf, const int *sendcounts, const
48
48
mca_coll_base_module_t * module , bool persistent )
49
49
{
50
50
int rank , p , res ;
51
+ size_t sdtype_size , rdtype_size ;
51
52
MPI_Aint sndext , rcvext ;
52
53
NBC_Schedule * schedule ;
53
54
char * rbuf , * sbuf , inplace ;
@@ -60,6 +61,7 @@ static int nbc_alltoallv_init(const void* sendbuf, const int *sendcounts, const
60
61
rank = ompi_comm_rank (comm );
61
62
p = ompi_comm_size (comm );
62
63
64
+ ompi_datatype_type_size (recvtype , & rdtype_size );
63
65
res = ompi_datatype_type_extent (recvtype , & rcvext );
64
66
if (MPI_SUCCESS != res ) {
65
67
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
92
94
sendcounts = recvcounts ;
93
95
sdispls = rdispls ;
94
96
sndext = rcvext ;
97
+ sdtype_size = rdtype_size ;
95
98
} else {
99
+ ompi_datatype_type_size (sendtype , & sdtype_size );
96
100
res = ompi_datatype_type_extent (sendtype , & sndext );
97
101
if (MPI_SUCCESS != res ) {
98
102
NBC_Error ("MPI Error in ompi_datatype_type_extent() (%i)" , res );
99
103
return res ;
100
104
}
101
105
}
102
106
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
+
103
113
schedule = OBJ_NEW (NBC_Schedule );
104
114
if (OPAL_UNLIKELY (NULL == schedule )) {
105
115
free (tmpbuf );
106
116
return OMPI_ERR_OUT_OF_RESOURCE ;
107
117
}
108
118
109
-
110
- if (!inplace && sendcounts [rank ] != 0 ) {
119
+ if (!inplace && 0 < sendcounts [rank ]) {
111
120
rbuf = (char * ) recvbuf + rdispls [rank ] * rcvext ;
112
121
sbuf = (char * ) sendbuf + sdispls [rank ] * sndext ;
113
122
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,
177
186
mca_coll_base_module_t * module , bool persistent )
178
187
{
179
188
int res , rsize ;
189
+ size_t sdtype_size , rdtype_size ;
180
190
MPI_Aint sndext , rcvext ;
181
191
NBC_Schedule * schedule ;
182
192
ompi_coll_libnbc_module_t * libnbc_module = (ompi_coll_libnbc_module_t * ) module ;
183
193
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
+ }
184
201
185
202
res = ompi_datatype_type_extent (sendtype , & sndext );
186
203
if (MPI_SUCCESS != res ) {
@@ -203,7 +220,7 @@ static int nbc_alltoallv_inter_init (const void* sendbuf, const int *sendcounts,
203
220
204
221
for (int i = 0 ; i < rsize ; i ++ ) {
205
222
/* post all sends */
206
- if (sendcounts [i ] != 0 ) {
223
+ if (0 < sendcounts [i ]) {
207
224
char * sbuf = (char * ) sendbuf + sdispls [i ] * sndext ;
208
225
res = NBC_Sched_send (sbuf , false, sendcounts [i ], sendtype , i , schedule , false);
209
226
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
@@ -212,7 +229,7 @@ static int nbc_alltoallv_inter_init (const void* sendbuf, const int *sendcounts,
212
229
}
213
230
}
214
231
/* post all receives */
215
- if (recvcounts [i ] != 0 ) {
232
+ if (0 < recvcounts [i ]) {
216
233
char * rbuf = (char * ) recvbuf + rdispls [i ] * rcvext ;
217
234
res = NBC_Sched_recv (rbuf , false, recvcounts [i ], recvtype , i , schedule , false);
218
235
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
@@ -272,7 +289,7 @@ static inline int a2av_sched_linear(int rank, int p, NBC_Schedule *schedule,
272
289
}
273
290
274
291
/* post send */
275
- if (sendcounts [i ] != 0 ) {
292
+ if (0 < sendcounts [i ]) {
276
293
char * sbuf = ((char * ) sendbuf ) + (sdispls [i ] * sndext );
277
294
res = NBC_Sched_send (sbuf , false, sendcounts [i ], sendtype , i , schedule , false);
278
295
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
@@ -281,7 +298,7 @@ static inline int a2av_sched_linear(int rank, int p, NBC_Schedule *schedule,
281
298
}
282
299
283
300
/* post receive */
284
- if (recvcounts [i ] != 0 ) {
301
+ if (0 < recvcounts [i ]) {
285
302
char * rbuf = ((char * ) recvbuf ) + (rdispls [i ] * rcvext );
286
303
res = NBC_Sched_recv (rbuf , false, recvcounts [i ], recvtype , i , schedule , false);
287
304
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
@@ -306,7 +323,7 @@ static inline int a2av_sched_pairwise(int rank, int p, NBC_Schedule *schedule,
306
323
int rcvpeer = (rank + p - i ) %p ;
307
324
308
325
/* post send */
309
- if (sendcounts [sndpeer ] != 0 ) {
326
+ if (0 < sendcounts [sndpeer ]) {
310
327
char * sbuf = ((char * ) sendbuf ) + (sdispls [sndpeer ] * sndext );
311
328
res = NBC_Sched_send (sbuf , false, sendcounts [sndpeer ], sendtype , sndpeer , schedule , false);
312
329
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
@@ -315,7 +332,7 @@ static inline int a2av_sched_pairwise(int rank, int p, NBC_Schedule *schedule,
315
332
}
316
333
317
334
/* post receive */
318
- if (recvcounts [rcvpeer ] != 0 ) {
335
+ if (0 < recvcounts [rcvpeer ]) {
319
336
char * rbuf = ((char * ) recvbuf ) + (rdispls [rcvpeer ] * rcvext );
320
337
res = NBC_Sched_recv (rbuf , false, recvcounts [rcvpeer ], recvtype , rcvpeer , schedule , true);
321
338
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
@@ -338,34 +355,34 @@ static inline int a2av_sched_inplace(int rank, int p, NBC_Schedule *schedule,
338
355
char * sbuf = (char * ) buf + displs [speer ] * ext ;
339
356
char * rbuf = (char * ) buf + displs [rpeer ] * ext ;
340
357
341
- if (0 != counts [rpeer ]) {
358
+ if (0 < counts [rpeer ]) {
342
359
res = NBC_Sched_copy (rbuf , false, counts [rpeer ], type ,
343
360
(void * )(- gap ), true, counts [rpeer ], type ,
344
361
schedule , true);
345
362
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
346
363
return res ;
347
364
}
348
365
}
349
- if (0 != counts [speer ]) {
366
+ if (0 < counts [speer ]) {
350
367
res = NBC_Sched_send (sbuf , false , counts [speer ], type , speer , schedule , false);
351
368
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
352
369
return res ;
353
370
}
354
371
}
355
- if (0 != counts [rpeer ]) {
372
+ if (0 < counts [rpeer ]) {
356
373
res = NBC_Sched_recv (rbuf , false , counts [rpeer ], type , rpeer , schedule , true);
357
374
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
358
375
return res ;
359
376
}
360
377
}
361
378
362
- if (0 != counts [rpeer ]) {
379
+ if (0 < counts [rpeer ]) {
363
380
res = NBC_Sched_send ((void * )(- gap ), true, counts [rpeer ], type , rpeer , schedule , false);
364
381
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
365
382
return res ;
366
383
}
367
384
}
368
- if (0 != counts [speer ]) {
385
+ if (0 < counts [speer ]) {
369
386
res = NBC_Sched_recv (sbuf , false, counts [speer ], type , speer , schedule , true);
370
387
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
371
388
return res ;
@@ -374,15 +391,17 @@ static inline int a2av_sched_inplace(int rank, int p, NBC_Schedule *schedule,
374
391
}
375
392
if (0 == (p %2 )) {
376
393
int peer = (rank + p /2 ) % p ;
377
-
378
394
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
+ }
384
402
}
385
- if (0 != counts [peer ]) {
403
+
404
+ if (0 < counts [peer ]) {
386
405
res = NBC_Sched_send ((void * )(- gap ), true , counts [peer ], type , peer , schedule , false);
387
406
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
388
407
return res ;
0 commit comments