20 nproc=PE::Comm::instance().size();
21 irank=PE::Comm::instance().rank();
90 for (i=0; i<
nproc; i++){
91 ptr_snddat[i]=(irank+1)*1000+(i+1);
92 for (j=0; j<
nproc; j++){
93 ptr_rcvdat[i*nproc+j]=(i+1)*1000+(j+1);
98 vec_snddat.assign(ptr_snddat,ptr_snddat+nproc);
99 vec_rcvdat.assign(ptr_rcvdat,ptr_rcvdat+nproc*nproc);
100 vec_snddatchr.assign((
char*)(ptr_snddat),(
char*)(ptr_snddat+nproc));
107 for (i=0; i<
nproc; i++){
110 if (nproc==1) ptr_rcvcnt[0]=1;
111 sndcnt=ptr_rcvcnt[
irank];
112 for(i=0; i<nproc*
nproc; i++) {
116 for(i=0; i<
nproc; i++) {
120 for(i=0; i<
nproc; i++)
121 ptr_snddat[i]=(irank+1)*1000+(i+1);
122 for (i=0, k=0; i<
nproc; i++)
123 for (j=0; j<ptr_rcvcnt[i]; j++,k++)
124 ptr_rcvdat[k]=(i+1)*1000+(j+1);
126 ptr_sndmap[i]=sndcnt-1-i;
127 for (i=0, k=0; i<
nproc; i++)
128 for (j=0; j<ptr_rcvcnt[i]; j++,k++)
129 ptr_rcvmap[k]=i*nproc+ptr_rcvcnt[i]-j-1;
130 for(i=0, rcvcnt=0; i<
nproc; i++){
131 rcvcnt+=ptr_rcvcnt[i];
133 vec_rcvcnt.assign(ptr_rcvcnt,ptr_rcvcnt+nproc);
134 vec_snddat.assign(ptr_snddat,ptr_snddat+nproc);
135 vec_rcvdat.assign(ptr_rcvdat,ptr_rcvdat+nproc*nproc);
136 vec_sndmap.assign(ptr_sndmap,ptr_sndmap+nproc);
137 vec_rcvmap.assign(ptr_rcvmap,ptr_rcvmap+nproc*nproc);
138 vec_snddatchr.assign((
char*)(ptr_snddat),(
char*)(ptr_snddat+nproc));
160 setup_data_constant();
162 for (r=0; r<nproc; r++){
167 ptr_tmprcv=PE::Comm::instance().gather(ptr_snddat, nproc, (
double*)0, r);
168 if (r==irank)
for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
169 if (r!=irank) BOOST_CHECK_EQUAL( ptr_tmprcv , (
double*)0 );
171 if (r==irank)
for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=0.;
172 PE::Comm::instance().gather(ptr_snddat, nproc, ptr_tmprcv, r);
173 if (r==irank)
for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
175 ptr_tmprcv=
new double[nproc*nproc];
176 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=0.;
177 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
178 PE::Comm::instance().gather(ptr_tmprcv, nproc, ptr_tmprcv, r);
179 if (r==irank)
for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
184 ptr_tmprcv=(
double*)PE::Comm::instance().gather((
char*)ptr_snddat, nproc, (
char*)0, r,
sizeof(
double));
185 if (r==irank)
for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
186 if (r!=irank) BOOST_CHECK_EQUAL( ptr_tmprcv , (
double*)0 );
188 if (r==irank)
for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=0.;
189 PE::Comm::instance().gather((
char*)ptr_snddat, nproc, (
char*)ptr_tmprcv, r,
sizeof(
double));
190 if (r==irank)
for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
192 ptr_tmprcv=
new double[nproc*nproc];
193 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=0.;
194 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
195 PE::Comm::instance().gather((
char*)ptr_tmprcv, nproc, (
char*)ptr_tmprcv, r,
sizeof(
double));
196 if (r==irank)
for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
207 setup_data_constant();
209 for (r=0; r<nproc; r++){
211 vec_tmprcv.resize(0);
212 vec_tmprcv.reserve(0);
214 PE::Comm::instance().gather(vec_snddat, vec_tmprcv, r);
215 if (r==irank)
for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( vec_tmprcv[i] , vec_rcvdat[i] );
216 if (r==irank) BOOST_CHECK_EQUAL( (
int)vec_tmprcv.size() , rcvcnt );
217 if (r!=irank) BOOST_CHECK_EQUAL( (
int)vec_tmprcv.size() , 0 );
219 if (r==irank) vec_tmprcv.assign(nproc*nproc,0.);
220 PE::Comm::instance().gather(vec_snddat, vec_tmprcv, r);
221 if (r==irank)
for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( vec_tmprcv[i] , vec_rcvdat[i] );
223 vec_tmprcv=vec_snddat;
224 PE::Comm::instance().gather(vec_tmprcv, vec_tmprcv, r);
225 if (r==irank)
for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( vec_tmprcv[i] , vec_rcvdat[i] );
227 vec_tmprcvchr.resize(0);
228 vec_tmprcvchr.reserve(0);
230 PE::Comm::instance().gather(vec_snddatchr, vec_tmprcvchr, r);
231 if (r==irank) BOOST_CHECK_EQUAL( vec_tmprcvchr.size() ,
sizeof(double)*rcvcnt );
232 if (r==irank)
for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i], vec_rcvdat[i] );
233 if (r!=irank) BOOST_CHECK_EQUAL( (
int)vec_tmprcvchr.size() , 0 );
235 if (r==irank)
for (i=0; i<nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=0.;
236 PE::Comm::instance().gather(vec_snddatchr, vec_tmprcvchr, r);
237 if (r==irank)
for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i], vec_rcvdat[i] );
239 vec_tmprcvchr.assign((
char*)(ptr_snddat),(
char*)(ptr_snddat+nproc));
240 PE::Comm::instance().gather(vec_tmprcvchr, vec_tmprcvchr, r);
241 if (r==irank)
for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i], vec_rcvdat[i] );
252 setup_data_variable();
254 for (r=0; r<nproc; r++){
258 ptr_tmprcv=PE::Comm::instance().gather(ptr_snddat, sndcnt, (
double*)0, ptr_rcvcnt, r);
259 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[k] , ptr_rcvdat[k] );
260 if (r!=irank) BOOST_CHECK_EQUAL( ptr_tmprcv , (
double*)0 );
262 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
263 PE::Comm::instance().gather(ptr_snddat, sndcnt, ptr_tmprcv, ptr_rcvcnt, r);
264 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[k] , ptr_rcvdat[k] );
267 ptr_tmprcv=
new double[nproc*nproc];
268 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
269 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
270 PE::Comm::instance().gather(ptr_tmprcv, sndcnt, ptr_tmprcv, ptr_rcvcnt, r);
271 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[k] , ptr_rcvdat[k] );
275 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
276 ptr_tmprcv=PE::Comm::instance().gather(ptr_snddat, sndcnt, (
double*)0, ptr_tmpcnt, r);
277 if (r==irank)
for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
278 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[k] , ptr_rcvdat[k] );
279 if (r!=irank) BOOST_CHECK_EQUAL( ptr_tmprcv , (
double*)0 );
281 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
282 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
283 PE::Comm::instance().gather(ptr_snddat, sndcnt, ptr_tmprcv, ptr_tmpcnt, r);
284 if (r==irank)
for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
285 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[k] , ptr_rcvdat[k] );
288 ptr_tmprcv=
new double[nproc*nproc];
289 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
290 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
291 for (i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
292 PE::Comm::instance().gather(ptr_tmprcv, sndcnt, ptr_tmprcv, ptr_tmpcnt, r);
293 if (r==irank)
for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
294 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[k] , ptr_rcvdat[k] );
298 ptr_tmprcv=PE::Comm::instance().gather(ptr_snddat, sndcnt, ptr_sndmap, (
double*)0, ptr_rcvcnt, ptr_rcvmap, r);
299 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[i*nproc+j] , ptr_rcvdat[k] );
300 if (r!=irank) BOOST_CHECK_EQUAL( ptr_tmprcv , (
double*)0 );
302 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[i*nproc+j]=0.;
303 PE::Comm::instance().gather(ptr_snddat, sndcnt, ptr_sndmap, ptr_tmprcv, ptr_rcvcnt, ptr_rcvmap, r);
304 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[i*nproc+j] , ptr_rcvdat[k] );
307 ptr_tmprcv=
new double[nproc*nproc];
308 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[i*nproc+j]=0.;
309 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
310 PE::Comm::instance().gather(ptr_tmprcv, sndcnt, ptr_sndmap, ptr_tmprcv, ptr_rcvcnt, ptr_rcvmap, r);
311 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[i*nproc+j] , ptr_rcvdat[k] );
315 ptr_tmprcv=(
double*)PE::Comm::instance().gather((
char*)ptr_snddat, sndcnt, (
char*)0, ptr_rcvcnt, r,
sizeof(
double));
316 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[k] , ptr_rcvdat[k] );
317 if (r!=irank) BOOST_CHECK_EQUAL( ptr_tmprcv , (
double*)0 );
319 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
320 PE::Comm::instance().gather((
char*)ptr_snddat, sndcnt, (
char*)ptr_tmprcv, ptr_rcvcnt, r,
sizeof(
double));
321 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[k] , ptr_rcvdat[k] );
324 ptr_tmprcv=
new double[nproc*nproc];
325 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
326 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
327 PE::Comm::instance().gather((
char*)ptr_tmprcv, sndcnt, (
char*)ptr_tmprcv, ptr_rcvcnt, r,
sizeof(
double));
328 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[k] , ptr_rcvdat[k] );
332 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
333 ptr_tmprcv=(
double*)PE::Comm::instance().gather((
char*)ptr_snddat, sndcnt, (
char*)0, ptr_tmpcnt, r,
sizeof(
double));
334 if (r==irank)
for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
335 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[k] , ptr_rcvdat[k] );
336 if (r!=irank) BOOST_CHECK_EQUAL( ptr_tmprcv , (
double*)0 );
338 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
339 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
340 PE::Comm::instance().gather((
char*)ptr_snddat, sndcnt, (
char*)ptr_tmprcv, ptr_tmpcnt, r,
sizeof(
double));
341 if (r==irank)
for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
342 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[k] , ptr_rcvdat[k] );
345 ptr_tmprcv=
new double[nproc*nproc];
346 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
347 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
348 for (i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
349 PE::Comm::instance().gather((
char*)ptr_tmprcv, sndcnt, (
char*)ptr_tmprcv, ptr_tmpcnt, r,
sizeof(
double));
350 if (r==irank)
for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
351 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[k] , ptr_rcvdat[k] );
355 ptr_tmprcv=(
double*)PE::Comm::instance().gather((
char*)ptr_snddat, sndcnt, ptr_sndmap, (
char*)0, ptr_rcvcnt, ptr_rcvmap, r,
sizeof(
double));
356 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[i*nproc+j] , ptr_rcvdat[k] );
357 if (r!=irank) BOOST_CHECK_EQUAL( ptr_tmprcv , (
double*)0 );
359 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[i*nproc+j]=0.;
360 PE::Comm::instance().gather((
char*)ptr_snddat, sndcnt, ptr_sndmap, (
char*)ptr_tmprcv, ptr_rcvcnt, ptr_rcvmap, r,
sizeof(
double));
361 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[i*nproc+j] , ptr_rcvdat[k] );
364 ptr_tmprcv=
new double[nproc*nproc];
365 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[i*nproc+j]=0.;
366 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
367 PE::Comm::instance().gather((
char*)ptr_tmprcv, sndcnt, ptr_sndmap, (
char*)ptr_tmprcv, ptr_rcvcnt, ptr_rcvmap, r,
sizeof(
double));
368 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ptr_tmprcv[i*nproc+j] , ptr_rcvdat[k] );
378 setup_data_variable();
380 for (r=0; r<nproc; r++){
382 vec_tmprcv.resize(0);
383 vec_tmprcv.reserve(0);
385 PE::Comm::instance().gather(vec_snddat, sndcnt, vec_tmprcv, vec_rcvcnt, r);
386 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( vec_tmprcv[k] , vec_rcvdat[k] );
387 if (r!=irank) BOOST_CHECK_EQUAL( (
int)vec_tmprcv.size() , 0 );
389 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[k]=0.;
390 PE::Comm::instance().gather(vec_snddat, sndcnt, vec_tmprcv, vec_rcvcnt, r);
391 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( vec_tmprcv[k] , vec_rcvdat[k] );
393 vec_tmprcv.resize(nproc*nproc);
394 vec_tmprcv.reserve(nproc*nproc);
395 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[k]=0.;
396 for (i=0; i<nproc; i++) vec_tmprcv[i]=vec_snddat[i];
397 PE::Comm::instance().gather(vec_tmprcv, sndcnt, vec_tmprcv, vec_rcvcnt, r);
398 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( vec_tmprcv[k] , vec_rcvdat[k] );
400 vec_tmprcv.resize(0);
401 vec_tmprcv.reserve(0);
402 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
403 PE::Comm::instance().gather(vec_snddat, sndcnt, vec_tmprcv, vec_tmpcnt, r);
404 if (r==irank)
for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
405 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( vec_tmprcv[k] , vec_rcvdat[k] );
406 if (r!=irank) BOOST_CHECK_EQUAL( (
int)vec_tmprcv.size() , 0 );
408 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[k]=0.;
409 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
410 PE::Comm::instance().gather(vec_snddat, sndcnt, vec_tmprcv, vec_tmpcnt, r);
411 if (r==irank)
for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
412 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( vec_tmprcv[k] , vec_rcvdat[k] );
414 vec_tmprcv.resize(nproc*nproc);
415 vec_tmprcv.reserve(nproc*nproc);
416 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[k]=0.;
417 for (i=0; i<nproc; i++) vec_tmprcv[i]=vec_snddat[i];
418 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
419 PE::Comm::instance().gather(vec_tmprcv, sndcnt, vec_tmprcv, vec_tmpcnt, r);
420 if (r==irank)
for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
421 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( vec_tmprcv[k] , vec_rcvdat[k] );
423 vec_tmprcv.resize(0);
424 vec_tmprcv.reserve(0);
425 PE::Comm::instance().gather(vec_snddat, sndcnt, vec_sndmap, vec_tmprcv, vec_rcvcnt, vec_rcvmap, r);
426 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( vec_tmprcv[i*nproc+j] , vec_rcvdat[k] );
427 if (r!=irank) BOOST_CHECK_EQUAL( (
int)vec_tmprcv.size() , 0 );
429 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[i*nproc+j]=0.;
430 PE::Comm::instance().gather(vec_snddat, sndcnt, vec_sndmap, vec_tmprcv, vec_rcvcnt, vec_rcvmap, r);
431 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( vec_tmprcv[i*nproc+j] , vec_rcvdat[k] );
433 vec_tmprcv.resize(nproc*nproc);
434 vec_tmprcv.reserve(nproc*nproc);
435 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[i*nproc+j]=0.;
436 for (i=0; i<nproc; i++) vec_tmprcv[i]=vec_snddat[i];
437 PE::Comm::instance().gather(vec_tmprcv, sndcnt, vec_sndmap, vec_tmprcv, vec_rcvcnt, vec_rcvmap, r);
438 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( vec_tmprcv[i*nproc+j] , vec_rcvdat[k] );
440 vec_tmprcvchr.resize(0);
441 vec_tmprcvchr.reserve(0);
442 PE::Comm::instance().gather(vec_snddatchr, sndcnt, vec_tmprcvchr, vec_rcvcnt, r,
sizeof(
double));
443 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[k] , vec_rcvdat[k] );
444 if (r!=irank) BOOST_CHECK_EQUAL( (
int)vec_tmprcvchr.size() , 0 );
446 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) ((
double*)(&vec_tmprcvchr[0]))[
k]=0.;
447 PE::Comm::instance().gather(vec_snddatchr, sndcnt, vec_tmprcvchr, vec_rcvcnt, r,
sizeof(
double));
448 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[k] , vec_rcvdat[k] );
450 vec_tmprcvchr.resize(nproc*nproc*
sizeof(
double));
451 vec_tmprcvchr.reserve(nproc*nproc*
sizeof(
double));
452 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) ((
double*)(&vec_tmprcvchr[0]))[
k]=0.;
453 for (i=0; i<nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=vec_snddat[i];
454 PE::Comm::instance().gather(vec_tmprcvchr, sndcnt, vec_tmprcvchr, vec_rcvcnt, r,
sizeof(
double));
455 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[k] , vec_rcvdat[k] );
457 vec_tmprcvchr.resize(0);
458 vec_tmprcvchr.reserve(0);
459 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
460 PE::Comm::instance().gather(vec_snddatchr, sndcnt, vec_tmprcvchr, vec_tmpcnt, r,
sizeof(
double));
461 if (r==irank)
for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
462 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[k] , vec_rcvdat[k] );
463 if (r!=irank) BOOST_CHECK_EQUAL( (
int)vec_tmprcvchr.size() , 0 );
465 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) ((
double*)(&vec_tmprcvchr[0]))[
k]=0.;
466 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
467 PE::Comm::instance().gather(vec_snddatchr, sndcnt, vec_tmprcvchr, vec_tmpcnt, r,
sizeof(
double));
468 if (r==irank)
for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
469 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[k] , vec_rcvdat[k] );
471 vec_tmprcvchr.resize(nproc*nproc*
sizeof(
double));
472 vec_tmprcvchr.reserve(nproc*nproc*
sizeof(
double));
473 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) ((
double*)(&vec_tmprcvchr[0]))[
k]=0.;
474 for (i=0; i<nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=vec_snddat[i];
475 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
476 PE::Comm::instance().gather(vec_tmprcvchr, sndcnt, vec_tmprcvchr, vec_tmpcnt, r,
sizeof(
double));
477 if (r==irank)
for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
478 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[k] , vec_rcvdat[k] );
480 vec_tmprcvchr.resize(0);
481 vec_tmprcvchr.reserve(0);
482 PE::Comm::instance().gather(vec_snddatchr, sndcnt, vec_sndmap, vec_tmprcvchr, vec_rcvcnt, vec_rcvmap, r,
sizeof(
double));
483 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i*nproc+j] , vec_rcvdat[k] );
484 if (r!=irank) BOOST_CHECK_EQUAL( (
int)vec_tmprcvchr.size() , 0 );
486 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) ((
double*)(&vec_tmprcvchr[0]))[i*nproc+j]=0.;
487 PE::Comm::instance().gather(vec_snddatchr, sndcnt, vec_sndmap, vec_tmprcvchr, vec_rcvcnt, vec_rcvmap, r,
sizeof(
double));
488 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i*nproc+j] , vec_rcvdat[k] );
490 vec_tmprcvchr.resize(nproc*nproc*
sizeof(
double));
491 vec_tmprcvchr.reserve(nproc*nproc*
sizeof(
double));
492 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) ((
double*)(&vec_tmprcvchr[0]))[i*nproc+j]=0.;
493 for (i=0; i<nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=vec_snddat[i];
494 PE::Comm::instance().gather(vec_tmprcvchr, sndcnt, vec_sndmap, vec_tmprcvchr, vec_rcvcnt, vec_rcvmap, r,
sizeof(
double));
495 if (r==irank)
for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i*nproc+j] , vec_rcvdat[k] );
501 BOOST_AUTO_TEST_SUITE_END()
503 #define CFinfo
these are always defined
void setup_data_constant()
helper function for constant size data - setting up input and verification data
std::vector< int > vec_rcvmap
std::vector< int > vec_rcvcnt
data for std::vectors
T * gather(const Communicator &comm, const T *in_values, const int in_n, T *out_values, const int root, const int stride=1)
BOOST_AUTO_TEST_CASE(gather)
std::vector< double > vec_rcvdat
void setup_data_variable()
helper function for variable size data - setting up input and verification data
std::vector< char > vec_snddatchr
std::vector< int > vec_tmpcnt
std::vector< double > vec_snddat
~PEGatherFixture()
common tear-down for each test case
int nproc
number of processes
std::vector< char > vec_tmprcvchr
std::vector< int > vec_sndmap
std::vector< double > vec_tmprcv
int sndcnt
data for raw pointers
PEGatherFixture()
common setup for each test case
#define PEProcessSortedExecute(irank, expression)