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();
165 ptr_tmprcv=PE::Comm::instance().all_gather(ptr_snddat, nproc, (
double*)0);
166 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
168 for (i=0; i<nproc; i++) ptr_tmprcv[i]=0.;
169 PE::Comm::instance().all_gather(ptr_snddat, nproc, ptr_tmprcv);
170 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
172 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
173 PE::Comm::instance().all_gather(ptr_tmprcv, nproc, ptr_tmprcv);
174 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
178 ptr_tmprcv=(
double*)PE::Comm::instance().all_gather((
char*)ptr_snddat, nproc, (
char*)0,
sizeof(
double));
179 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
181 for (i=0; i<nproc; i++) ptr_tmprcv[i]=0.;
182 PE::Comm::instance().all_gather((
char*)ptr_snddat, nproc, (
char*)ptr_tmprcv,
sizeof(
double));
183 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
185 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
186 PE::Comm::instance().all_gather((
char*)ptr_tmprcv, nproc, (
char*)ptr_tmprcv,
sizeof(
double));
187 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
196 setup_data_constant();
198 vec_tmprcv.resize(0);
199 vec_tmprcv.reserve(0);
200 PE::Comm::instance().all_gather(vec_snddat, vec_tmprcv);
201 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( vec_tmprcv[i] , vec_rcvdat[i] );
202 BOOST_CHECK_EQUAL( (
int)vec_tmprcv.size() , rcvcnt );
204 vec_tmprcv.assign(nproc*nproc,0.);
205 PE::Comm::instance().all_gather(vec_snddat, vec_tmprcv);
206 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( vec_tmprcv[i] , vec_rcvdat[i] );
208 vec_tmprcv=vec_snddat;
209 PE::Comm::instance().all_gather(vec_tmprcv, vec_tmprcv);
210 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( vec_tmprcv[i] , vec_rcvdat[i] );
212 vec_tmprcvchr.resize(0);
213 vec_tmprcvchr.reserve(0);
214 PE::Comm::instance().all_gather(vec_snddatchr, vec_tmprcvchr );
215 BOOST_CHECK_EQUAL( vec_tmprcvchr.size() ,
sizeof(double)*rcvcnt );
216 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i], vec_rcvdat[i] );
218 for (i=0; i<nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=0.;
219 PE::Comm::instance().all_gather(vec_snddatchr, vec_tmprcvchr );
220 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i], vec_rcvdat[i] );
222 vec_tmprcvchr.assign((
char*)(ptr_snddat),(
char*)(ptr_snddat+nproc));
223 PE::Comm::instance().all_gather(vec_tmprcvchr, vec_tmprcvchr );
224 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i], vec_rcvdat[i] );
234 setup_data_variable();
238 ptr_tmprcv=PE::Comm::instance().all_gather(ptr_snddat, sndcnt, (
double*)0, ptr_rcvcnt);
239 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] );
241 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
242 PE::Comm::instance().all_gather(ptr_snddat, sndcnt, ptr_tmprcv, ptr_rcvcnt);
243 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] );
246 ptr_tmprcv=
new double[nproc*nproc];
247 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
248 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
249 PE::Comm::instance().all_gather(ptr_tmprcv, sndcnt, ptr_tmprcv, ptr_rcvcnt);
250 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] );
254 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
255 ptr_tmprcv=PE::Comm::instance().all_gather(ptr_snddat, sndcnt, (
double*)0, ptr_tmpcnt);
256 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
257 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] );
259 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
260 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
261 PE::Comm::instance().all_gather(ptr_snddat, sndcnt, ptr_tmprcv, ptr_tmpcnt);
262 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
263 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] );
266 ptr_tmprcv=
new double[nproc*nproc];
267 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
268 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
269 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
270 PE::Comm::instance().all_gather(ptr_tmprcv, sndcnt, ptr_tmprcv, ptr_tmpcnt);
271 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
272 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] );
276 ptr_tmprcv=PE::Comm::instance().all_gather(ptr_snddat, sndcnt, ptr_sndmap, (
double*)0, ptr_rcvcnt, ptr_rcvmap);
277 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] );
279 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[i*nproc+j]=0.;
280 PE::Comm::instance().all_gather(ptr_snddat, sndcnt, ptr_sndmap, ptr_tmprcv, ptr_rcvcnt, ptr_rcvmap);
281 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] );
284 ptr_tmprcv=
new double[nproc*nproc];
285 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[i*nproc+j]=0.;
286 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
287 PE::Comm::instance().all_gather(ptr_tmprcv, sndcnt, ptr_sndmap, ptr_tmprcv, ptr_rcvcnt, ptr_rcvmap);
288 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] );
292 ptr_tmprcv=(
double*)PE::Comm::instance().all_gather((
char*)ptr_snddat, sndcnt, (
char*)0, ptr_rcvcnt,
sizeof(
double));
293 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] );
295 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
296 PE::Comm::instance().all_gather((
char*)ptr_snddat, sndcnt, (
char*)ptr_tmprcv, ptr_rcvcnt,
sizeof(
double));
297 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] );
300 ptr_tmprcv=
new double[nproc*nproc];
301 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
302 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
303 PE::Comm::instance().all_gather((
char*)ptr_tmprcv, sndcnt, (
char*)ptr_tmprcv, ptr_rcvcnt,
sizeof(
double));
304 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] );
308 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
309 ptr_tmprcv=(
double*)PE::Comm::instance().all_gather((
char*)ptr_snddat, sndcnt, (
char*)0, ptr_tmpcnt,
sizeof(
double));
310 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
311 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] );
313 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
314 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
315 PE::Comm::instance().all_gather((
char*)ptr_snddat, sndcnt, (
char*)ptr_tmprcv, ptr_tmpcnt,
sizeof(
double));
316 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
317 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] );
320 ptr_tmprcv=
new double[nproc*nproc];
321 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
322 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
323 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
324 PE::Comm::instance().all_gather((
char*)ptr_tmprcv, sndcnt, (
char*)ptr_tmprcv, ptr_tmpcnt,
sizeof(
double));
325 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
326 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] );
330 ptr_tmprcv=(
double*)PE::Comm::instance().all_gather((
char*)ptr_snddat, sndcnt, ptr_sndmap, (
char*)0, ptr_rcvcnt, ptr_rcvmap,
sizeof(
double));
331 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] );
333 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[i*nproc+j]=0.;
334 PE::Comm::instance().all_gather((
char*)ptr_snddat, sndcnt, ptr_sndmap, (
char*)ptr_tmprcv, ptr_rcvcnt, ptr_rcvmap,
sizeof(
double));
335 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] );
338 ptr_tmprcv=
new double[nproc*nproc];
339 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[i*nproc+j]=0.;
340 for (i=0; i<nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
341 PE::Comm::instance().all_gather((
char*)ptr_tmprcv, sndcnt, ptr_sndmap, (
char*)ptr_tmprcv, ptr_rcvcnt, ptr_rcvmap,
sizeof(
double));
342 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] );
351 setup_data_variable();
353 vec_tmprcv.resize(0);
354 vec_tmprcv.reserve(0);
355 PE::Comm::instance().all_gather(vec_snddat, sndcnt, vec_tmprcv, vec_rcvcnt);
356 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] );
358 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[k]=0.;
359 PE::Comm::instance().all_gather(vec_snddat, sndcnt, vec_tmprcv, vec_rcvcnt);
360 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] );
362 vec_tmprcv.resize(nproc*nproc);
363 vec_tmprcv.reserve(nproc*nproc);
364 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[k]=0.;
365 for (i=0; i<nproc; i++) vec_tmprcv[i]=vec_snddat[i];
366 PE::Comm::instance().all_gather(vec_tmprcv, sndcnt, vec_tmprcv, vec_rcvcnt);
367 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] );
369 vec_tmprcv.resize(0);
370 vec_tmprcv.reserve(0);
371 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
372 PE::Comm::instance().all_gather(vec_snddat, sndcnt, vec_tmprcv, vec_tmpcnt);
373 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
374 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] );
376 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[k]=0.;
377 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
378 PE::Comm::instance().all_gather(vec_snddat, sndcnt, vec_tmprcv, vec_tmpcnt);
379 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
380 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] );
382 vec_tmprcv.resize(nproc*nproc);
383 vec_tmprcv.reserve(nproc*nproc);
384 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[k]=0.;
385 for (i=0; i<nproc; i++) vec_tmprcv[i]=vec_snddat[i];
386 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
387 PE::Comm::instance().all_gather(vec_tmprcv, sndcnt, vec_tmprcv, vec_tmpcnt);
388 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
389 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] );
391 vec_tmprcv.resize(0);
392 vec_tmprcv.reserve(0);
393 PE::Comm::instance().all_gather(vec_snddat, sndcnt, vec_sndmap, vec_tmprcv, vec_rcvcnt, vec_rcvmap);
394 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] );
396 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[i*nproc+j]=0.;
397 PE::Comm::instance().all_gather(vec_snddat, sndcnt, vec_sndmap, vec_tmprcv, vec_rcvcnt, vec_rcvmap);
398 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] );
400 vec_tmprcv.resize(nproc*nproc);
401 vec_tmprcv.reserve(nproc*nproc);
402 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[i*nproc+j]=0.;
403 for (i=0; i<nproc; i++) vec_tmprcv[i]=vec_snddat[i];
404 PE::Comm::instance().all_gather(vec_tmprcv, sndcnt, vec_sndmap, vec_tmprcv, vec_rcvcnt, vec_rcvmap);
405 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] );
407 vec_tmprcvchr.resize(0);
408 vec_tmprcvchr.reserve(0);
409 PE::Comm::instance().all_gather(vec_snddatchr, sndcnt, vec_tmprcvchr, vec_rcvcnt,
sizeof(
double));
410 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] );
412 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) ((
double*)(&vec_tmprcvchr[0]))[
k]=0.;
413 PE::Comm::instance().all_gather(vec_snddatchr, sndcnt, vec_tmprcvchr, vec_rcvcnt,
sizeof(
double));
414 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] );
416 vec_tmprcvchr.resize(nproc*nproc*
sizeof(
double));
417 vec_tmprcvchr.reserve(nproc*nproc*
sizeof(
double));
418 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) ((
double*)(&vec_tmprcvchr[0]))[
k]=0.;
419 for (i=0; i<nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=vec_snddat[i];
420 PE::Comm::instance().all_gather(vec_tmprcvchr, sndcnt, vec_tmprcvchr, vec_rcvcnt,
sizeof(
double));
421 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] );
423 vec_tmprcvchr.resize(0);
424 vec_tmprcvchr.reserve(0);
425 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
426 PE::Comm::instance().all_gather(vec_snddatchr, sndcnt, vec_tmprcvchr, vec_tmpcnt,
sizeof(
double));
427 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
428 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] );
430 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) ((
double*)(&vec_tmprcvchr[0]))[
k]=0.;
431 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
432 PE::Comm::instance().all_gather(vec_snddatchr, sndcnt, vec_tmprcvchr, vec_tmpcnt,
sizeof(
double));
433 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
434 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] );
436 vec_tmprcvchr.resize(nproc*nproc*
sizeof(
double));
437 vec_tmprcvchr.reserve(nproc*nproc*
sizeof(
double));
438 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) ((
double*)(&vec_tmprcvchr[0]))[
k]=0.;
439 for (i=0; i<nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=vec_snddat[i];
440 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
441 PE::Comm::instance().all_gather(vec_tmprcvchr, sndcnt, vec_tmprcvchr, vec_tmpcnt,
sizeof(
double));
442 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
443 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] );
445 vec_tmprcvchr.resize(0);
446 vec_tmprcvchr.reserve(0);
447 PE::Comm::instance().all_gather(vec_snddatchr, sndcnt, vec_sndmap, vec_tmprcvchr, vec_rcvcnt, vec_rcvmap,
sizeof(
double));
448 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] );
450 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.;
451 PE::Comm::instance().all_gather(vec_snddatchr, sndcnt, vec_sndmap, vec_tmprcvchr, vec_rcvcnt, vec_rcvmap,
sizeof(
double));
452 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] );
454 vec_tmprcvchr.resize(nproc*nproc*
sizeof(
double));
455 vec_tmprcvchr.reserve(nproc*nproc*
sizeof(
double));
456 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.;
457 for (i=0; i<nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=vec_snddat[i];
458 PE::Comm::instance().all_gather(vec_tmprcvchr, sndcnt, vec_sndmap, vec_tmprcvchr, vec_rcvcnt, vec_rcvmap,
sizeof(
double));
459 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] );
464 BOOST_AUTO_TEST_SUITE_END()
466 int nproc
number of processes
#define CFinfo
these are always defined
void setup_data_variable()
helper function for variable size data - setting up input and verification data
std::vector< double > vec_snddat
std::vector< double > vec_rcvdat
std::vector< double > vec_tmprcv
void setup_data_constant()
helper function for constant size data - setting up input and verification data
~PEAllGatherFixture()
common tear-down for each test case
T * all_gather(const Communicator &comm, const T *in_values, const int in_n, T *out_values, const int stride=1)
std::vector< char > vec_tmprcvchr
BOOST_AUTO_TEST_CASE(all_gather)
PEAllGatherFixture()
common setup for each test case
int sndcnt
data for raw pointers
std::vector< int > vec_rcvcnt
data for std::vectors
std::vector< char > vec_snddatchr
std::vector< int > vec_tmpcnt
std::vector< int > vec_sndmap
std::vector< int > vec_rcvmap
#define PEProcessSortedExecute(irank, expression)