@@ -107,25 +107,25 @@ int mca_scoll_mpi_collect(struct oshmem_group_t *group,
107
107
bool nlong_type ,
108
108
int alg )
109
109
{
110
+ ompi_datatype_t * stype = & ompi_mpi_char .dt ;
111
+ ompi_datatype_t * rtype = & ompi_mpi_char .dt ;
110
112
mca_scoll_mpi_module_t * mpi_module ;
111
- ompi_datatype_t * stype ;
112
- ompi_datatype_t * rtype ;
113
113
int rc ;
114
+ int len ;
115
+ int i ;
114
116
void * sbuf , * rbuf ;
117
+ int * disps , * recvcounts ;
115
118
MPI_COLL_VERBOSE (20 ,"RUNNING MPI ALLGATHER" );
116
119
mpi_module = (mca_scoll_mpi_module_t * ) group -> g_scoll .scoll_collect_module ;
117
120
118
121
if (nlong_type == true) {
119
-
120
122
/* Do nothing on zero-length request */
121
123
if (OPAL_UNLIKELY (!nlong )) {
122
124
return OSHMEM_SUCCESS ;
123
125
}
124
126
125
127
sbuf = (void * ) source ;
126
128
rbuf = target ;
127
- stype = & ompi_mpi_char .dt ;
128
- rtype = & ompi_mpi_char .dt ;
129
129
/* Open SHMEM specification has the following constrains (page 85):
130
130
* "If using C/C++, nelems must be of type integer. If you are using Fortran, it must be a
131
131
* default integer value". And also fortran signature says "INTEGER".
@@ -159,15 +159,52 @@ int mca_scoll_mpi_collect(struct oshmem_group_t *group,
159
159
SCOLL_DEFAULT_ALG );
160
160
}
161
161
} 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 );
170
206
}
207
+ complete :
171
208
return rc ;
172
209
}
173
210
0 commit comments