1616 * Author(s): Torsten Hoefler <htor@cs.indiana.edu>
1717 *
1818 * 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.
2020 * Copyright (c) 2017 Ian Bradley Morgan and Anthony Skjellum. All
2121 * rights reserved.
2222 * 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
119119}
120120
121121/* 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 ) {
123123 NBC_Args_send send_args ;
124124 int ret ;
125125
@@ -143,16 +143,16 @@ static int NBC_Sched_send_internal (const void* buf, char tmpbuf, int count, MPI
143143 return OMPI_SUCCESS ;
144144}
145145
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 ) {
147147 return NBC_Sched_send_internal (buf , tmpbuf , count , datatype , dest , false, schedule , barrier );
148148}
149149
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 ) {
151151 return NBC_Sched_send_internal (buf , tmpbuf , count , datatype , dest , true, schedule , barrier );
152152}
153153
154154/* 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 ) {
156156 NBC_Args_recv recv_args ;
157157 int ret ;
158158
@@ -176,16 +176,16 @@ static int NBC_Sched_recv_internal (void* buf, char tmpbuf, int count, MPI_Datat
176176 return OMPI_SUCCESS ;
177177}
178178
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 ) {
180180 return NBC_Sched_recv_internal (buf , tmpbuf , count , datatype , source , false, schedule , barrier );
181181}
182182
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 ) {
184184 return NBC_Sched_recv_internal (buf , tmpbuf , count , datatype , source , true, schedule , barrier );
185185}
186186
187187/* 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 ,
189189 MPI_Op op , NBC_Schedule * schedule , bool barrier ) {
190190 NBC_Args_op op_args ;
191191 int ret ;
@@ -212,7 +212,8 @@ int NBC_Sched_op (const void* buf1, char tmpbuf1, void* buf2, char tmpbuf2, int
212212}
213213
214214/* 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 ,
216217 MPI_Datatype tgttype , NBC_Schedule * schedule , bool barrier ) {
217218 NBC_Args_copy copy_args ;
218219 int ret ;
@@ -240,7 +241,7 @@ int NBC_Sched_copy (void *src, char tmpsrc, int srccount, MPI_Datatype srctype,
240241}
241242
242243/* 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 ,
244245 NBC_Schedule * schedule , bool barrier ) {
245246 NBC_Args_unpack unpack_args ;
246247 int ret ;
@@ -534,7 +535,31 @@ static inline int NBC_Start_round(NBC_Handle *handle) {
534535 } else {
535536 buf2 = opargs .buf2 ;
536537 }
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+ }
538563 break ;
539564 case COPY :
540565 NBC_DEBUG (5 , " COPY (offset %li) " , offset );
0 commit comments