@@ -107,25 +107,25 @@ int mca_scoll_mpi_collect(struct oshmem_group_t *group,
107107 bool nlong_type ,
108108 int alg )
109109{
110+ ompi_datatype_t * stype = & ompi_mpi_char .dt ;
111+ ompi_datatype_t * rtype = & ompi_mpi_char .dt ;
110112 mca_scoll_mpi_module_t * mpi_module ;
111- ompi_datatype_t * stype ;
112- ompi_datatype_t * rtype ;
113113 int rc ;
114+ int len ;
115+ int i ;
114116 void * sbuf , * rbuf ;
117+ int * disps , * recvcounts ;
115118 MPI_COLL_VERBOSE (20 ,"RUNNING MPI ALLGATHER" );
116119 mpi_module = (mca_scoll_mpi_module_t * ) group -> g_scoll .scoll_collect_module ;
117120
118121 if (nlong_type == true) {
119-
120122 /* Do nothing on zero-length request */
121123 if (OPAL_UNLIKELY (!nlong )) {
122124 return OSHMEM_SUCCESS ;
123125 }
124126
125127 sbuf = (void * ) source ;
126128 rbuf = target ;
127- stype = & ompi_mpi_char .dt ;
128- rtype = & ompi_mpi_char .dt ;
129129 /* Open SHMEM specification has the following constrains (page 85):
130130 * "If using C/C++, nelems must be of type integer. If you are using Fortran, it must be a
131131 * default integer value". And also fortran signature says "INTEGER".
@@ -159,15 +159,52 @@ int mca_scoll_mpi_collect(struct oshmem_group_t *group,
159159 SCOLL_DEFAULT_ALG );
160160 }
161161 } else {
162- MPI_COLL_VERBOSE (20 ,"RUNNING FALLBACK COLLECT" );
163- PREVIOUS_SCOLL_FN (mpi_module , collect , group ,
164- target ,
165- source ,
166- nlong ,
167- pSync ,
168- nlong_type ,
169- SCOLL_DEFAULT_ALG );
162+ if (INT_MAX < nlong ) {
163+ MPI_COLL_VERBOSE (20 ,"RUNNING FALLBACK COLLECT" );
164+ PREVIOUS_SCOLL_FN (mpi_module , collect , group ,
165+ target ,
166+ source ,
167+ nlong ,
168+ pSync ,
169+ nlong_type ,
170+ SCOLL_DEFAULT_ALG );
171+ return rc ;
172+ }
173+
174+ len = nlong ;
175+ disps = malloc (group -> proc_count * sizeof (* disps ));
176+ if (disps == NULL ) {
177+ rc = OSHMEM_ERR_OUT_OF_RESOURCE ;
178+ goto complete ;
179+ }
180+
181+ recvcounts = malloc (group -> proc_count * sizeof (* recvcounts ));
182+ if (recvcounts == NULL ) {
183+ rc = OSHMEM_ERR_OUT_OF_RESOURCE ;
184+ goto failed_mem ;
185+ }
186+
187+ rc = mpi_module -> comm -> c_coll -> coll_allgather (& len , sizeof (len ), stype , recvcounts ,
188+ sizeof (len ), rtype , mpi_module -> comm ,
189+ mpi_module -> comm -> c_coll -> coll_allgather_module );
190+ if (rc != OSHMEM_SUCCESS ) {
191+ goto failed_allgather ;
192+ }
193+
194+ disps [0 ] = 0 ;
195+ for (i = 1 ; i < group -> proc_count ; i ++ ) {
196+ disps [i ] = disps [i - 1 ] + recvcounts [i - 1 ];
197+ }
198+
199+ rc = mpi_module -> comm -> c_coll -> coll_allgatherv (source , nlong , stype , target , recvcounts ,
200+ disps , rtype , mpi_module -> comm ,
201+ mpi_module -> comm -> c_coll -> coll_allgatherv_module );
202+ failed_allgather :
203+ free (recvcounts );
204+ failed_mem :
205+ free (disps );
170206 }
207+ complete :
171208 return rc ;
172209}
173210
0 commit comments