16
16
* Author(s): Torsten Hoefler <htor@cs.indiana.edu>
17
17
*
18
18
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
19
- * Copyright (c) 2016 IBM Corporation. All rights reserved.
19
+ * Copyright (c) 2016-2021 IBM Corporation. All rights reserved.
20
20
* Copyright (c) 2017 Ian Bradley Morgan and Anthony Skjellum. All
21
21
* rights reserved.
22
22
* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
@@ -119,7 +119,7 @@ static int nbc_schedule_round_append (NBC_Schedule *schedule, void *data, int da
119
119
}
120
120
121
121
/* this function puts a send into the schedule */
122
- static int NBC_Sched_send_internal (const void * buf , char tmpbuf , int count , MPI_Datatype datatype , int dest , bool local , NBC_Schedule * schedule , bool barrier ) {
122
+ static int NBC_Sched_send_internal (const void * buf , char tmpbuf , size_t count , MPI_Datatype datatype , int dest , bool local , NBC_Schedule * schedule , bool barrier ) {
123
123
NBC_Args_send send_args ;
124
124
int ret ;
125
125
@@ -143,16 +143,16 @@ static int NBC_Sched_send_internal (const void* buf, char tmpbuf, int count, MPI
143
143
return OMPI_SUCCESS ;
144
144
}
145
145
146
- int NBC_Sched_send (const void * buf , char tmpbuf , int count , MPI_Datatype datatype , int dest , NBC_Schedule * schedule , bool barrier ) {
146
+ int NBC_Sched_send (const void * buf , char tmpbuf , size_t count , MPI_Datatype datatype , int dest , NBC_Schedule * schedule , bool barrier ) {
147
147
return NBC_Sched_send_internal (buf , tmpbuf , count , datatype , dest , false, schedule , barrier );
148
148
}
149
149
150
- int NBC_Sched_local_send (const void * buf , char tmpbuf , int count , MPI_Datatype datatype , int dest , NBC_Schedule * schedule , bool barrier ) {
150
+ int NBC_Sched_local_send (const void * buf , char tmpbuf , size_t count , MPI_Datatype datatype , int dest , NBC_Schedule * schedule , bool barrier ) {
151
151
return NBC_Sched_send_internal (buf , tmpbuf , count , datatype , dest , true, schedule , barrier );
152
152
}
153
153
154
154
/* this function puts a receive into the schedule */
155
- static int NBC_Sched_recv_internal (void * buf , char tmpbuf , int count , MPI_Datatype datatype , int source , bool local , NBC_Schedule * schedule , bool barrier ) {
155
+ static int NBC_Sched_recv_internal (void * buf , char tmpbuf , size_t count , MPI_Datatype datatype , int source , bool local , NBC_Schedule * schedule , bool barrier ) {
156
156
NBC_Args_recv recv_args ;
157
157
int ret ;
158
158
@@ -176,16 +176,16 @@ static int NBC_Sched_recv_internal (void* buf, char tmpbuf, int count, MPI_Datat
176
176
return OMPI_SUCCESS ;
177
177
}
178
178
179
- int NBC_Sched_recv (void * buf , char tmpbuf , int count , MPI_Datatype datatype , int source , NBC_Schedule * schedule , bool barrier ) {
179
+ int NBC_Sched_recv (void * buf , char tmpbuf , size_t count , MPI_Datatype datatype , int source , NBC_Schedule * schedule , bool barrier ) {
180
180
return NBC_Sched_recv_internal (buf , tmpbuf , count , datatype , source , false, schedule , barrier );
181
181
}
182
182
183
- int NBC_Sched_local_recv (void * buf , char tmpbuf , int count , MPI_Datatype datatype , int source , NBC_Schedule * schedule , bool barrier ) {
183
+ int NBC_Sched_local_recv (void * buf , char tmpbuf , size_t count , MPI_Datatype datatype , int source , NBC_Schedule * schedule , bool barrier ) {
184
184
return NBC_Sched_recv_internal (buf , tmpbuf , count , datatype , source , true, schedule , barrier );
185
185
}
186
186
187
187
/* this function puts an operation into the schedule */
188
- int NBC_Sched_op (const void * buf1 , char tmpbuf1 , void * buf2 , char tmpbuf2 , int count , MPI_Datatype datatype ,
188
+ int NBC_Sched_op (const void * buf1 , char tmpbuf1 , void * buf2 , char tmpbuf2 , size_t count , MPI_Datatype datatype ,
189
189
MPI_Op op , NBC_Schedule * schedule , bool barrier ) {
190
190
NBC_Args_op op_args ;
191
191
int ret ;
@@ -212,7 +212,8 @@ int NBC_Sched_op (const void* buf1, char tmpbuf1, void* buf2, char tmpbuf2, int
212
212
}
213
213
214
214
/* this function puts a copy into the schedule */
215
- int NBC_Sched_copy (void * src , char tmpsrc , int srccount , MPI_Datatype srctype , void * tgt , char tmptgt , int tgtcount ,
215
+ int NBC_Sched_copy (void * src , char tmpsrc , size_t srccount , MPI_Datatype srctype ,
216
+ void * tgt , char tmptgt , size_t tgtcount ,
216
217
MPI_Datatype tgttype , NBC_Schedule * schedule , bool barrier ) {
217
218
NBC_Args_copy copy_args ;
218
219
int ret ;
@@ -240,7 +241,7 @@ int NBC_Sched_copy (void *src, char tmpsrc, int srccount, MPI_Datatype srctype,
240
241
}
241
242
242
243
/* this function puts a unpack into the schedule */
243
- int NBC_Sched_unpack (void * inbuf , char tmpinbuf , int count , MPI_Datatype datatype , void * outbuf , char tmpoutbuf ,
244
+ int NBC_Sched_unpack (void * inbuf , char tmpinbuf , size_t count , MPI_Datatype datatype , void * outbuf , char tmpoutbuf ,
244
245
NBC_Schedule * schedule , bool barrier ) {
245
246
NBC_Args_unpack unpack_args ;
246
247
int ret ;
@@ -534,7 +535,31 @@ static inline int NBC_Start_round(NBC_Handle *handle) {
534
535
} else {
535
536
buf2 = opargs .buf2 ;
536
537
}
537
- ompi_op_reduce (opargs .op , buf1 , buf2 , opargs .count , opargs .datatype );
538
+
539
+ /* If the count is > INT_MAX then we need to call ompi_op_reduce()
540
+ * in iterations of counts <= INT_MAX since it has an `int count`
541
+ * parameter.
542
+ */
543
+ if ( OPAL_UNLIKELY (opargs .count > INT_MAX ) ) {
544
+ size_t done_count = 0 , shift ;
545
+ int iter_count ;
546
+ ptrdiff_t ext , lb ;
547
+
548
+ ompi_datatype_get_extent (opargs .datatype , & lb , & ext );
549
+
550
+ while (done_count < opargs .count ) {
551
+ if ( done_count + INT_MAX > opargs .count ) {
552
+ iter_count = opargs .count - done_count ;
553
+ } else {
554
+ iter_count = INT_MAX ;
555
+ }
556
+ shift = done_count * ext ;
557
+ ompi_op_reduce (opargs .op , buf1 + shift , buf2 + shift , iter_count , opargs .datatype );
558
+ done_count += iter_count ;
559
+ }
560
+ } else {
561
+ ompi_op_reduce (opargs .op , buf1 , buf2 , opargs .count , opargs .datatype );
562
+ }
538
563
break ;
539
564
case COPY :
540
565
NBC_DEBUG (5 , " COPY (offset %li) " , offset );
0 commit comments