18 nproc=PE::Comm::instance().size();
19 irank=PE::Comm::instance().rank();
92 for (i=0; i<
nproc; i++)
93 for (j=0; j<
nproc; j++){
94 ptr_snddat[i*nproc+j]=(irank+1)*1000000+(i+1)*10000+(j+1);
95 ptr_rcvdat[i*nproc+j]=(i+1)*1000000+(irank+1)*10000+(j+1);
99 vec_snddat.assign(ptr_snddat,ptr_snddat+nproc*nproc);
100 vec_rcvdat.assign(ptr_rcvdat,ptr_rcvdat+nproc*nproc);
101 vec_snddatchr.assign((
char*)(ptr_snddat),(
char*)(ptr_snddat+nproc*nproc));
108 for (i=0; i<
nproc; i++){
109 ptr_sndcnt[i]=(i+irank*
irank)%nproc;
110 ptr_rcvcnt[i]=(i*i+
irank)%nproc;
112 for(i=0; i<nproc*
nproc; i++) {
118 for(i=0, k=0; i<
nproc; i++)
119 for(j=0; j<ptr_sndcnt[i]; j++, k++)
120 ptr_snddat[k]=(irank+1)*1000000+(i+1)*10000+(j+1);
121 for(i=0, k=0; i<
nproc; i++)
122 for(j=0; j<ptr_rcvcnt[i]; j++, k++)
123 ptr_rcvdat[k]=(i+1)*1000000+(irank+1)*10000+(j+1);
124 for (i=0, k=0,l=0; i<
nproc; k+=ptr_sndcnt[i], i++)
125 for (j=0; j<ptr_sndcnt[i]; j++,l++)
126 ptr_sndmap[l]=k+ptr_sndcnt[i]-1-j;
127 for (i=0, k=0, l=0; i<
nproc; k+=ptr_rcvcnt[i], i++)
128 for (j=0; j<ptr_rcvcnt[i]; j++, l++)
129 ptr_rcvmap[l]=i*nproc+ptr_rcvcnt[i]-1-j;
130 for(i=0, sndcnt=0, rcvcnt=0; i<
nproc; i++){
131 sndcnt+=ptr_sndcnt[i];
132 rcvcnt+=ptr_rcvcnt[i];
134 vec_sndcnt.assign(ptr_sndcnt,ptr_sndcnt+nproc);
135 vec_rcvcnt.assign(ptr_rcvcnt,ptr_rcvcnt+nproc);
136 vec_snddat.assign(ptr_snddat,ptr_snddat+nproc*nproc);
137 vec_rcvdat.assign(ptr_rcvdat,ptr_rcvdat+nproc*nproc);
138 vec_sndmap.assign(ptr_sndmap,ptr_sndmap+nproc*nproc);
139 vec_rcvmap.assign(ptr_rcvmap,ptr_rcvmap+nproc*nproc);
140 vec_snddatchr.assign((
char*)(ptr_snddat),(
char*)(ptr_snddat+nproc*nproc));
162 setup_data_constant();
167 ptr_tmprcv=PE::Comm::instance().all_to_all(ptr_snddat, nproc, (
double*)0);
168 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
170 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=0.;
171 PE::Comm::instance().all_to_all(ptr_snddat, nproc, ptr_tmprcv);
172 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
174 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
175 PE::Comm::instance().all_to_all(ptr_tmprcv, nproc, ptr_tmprcv);
176 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
180 ptr_tmprcv=(
double*)PE::Comm::instance().all_to_all((
char*)ptr_snddat, nproc, (
char*)0,
sizeof(
double));
181 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
183 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=0.;
184 PE::Comm::instance().all_to_all((
char*)ptr_snddat, nproc, (
char*)ptr_tmprcv,
sizeof(
double));
185 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
187 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
188 PE::Comm::instance().all_to_all((
char*)ptr_tmprcv, nproc, (
char*)ptr_tmprcv,
sizeof(
double));
189 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[i] );
198 setup_data_constant();
200 vec_tmprcv.resize(0);
201 vec_tmprcv.reserve(0);
202 PE::Comm::instance().all_to_all(vec_snddat, vec_tmprcv);
203 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( vec_tmprcv[i] , vec_rcvdat[i] );
204 BOOST_CHECK_EQUAL( (
int)vec_tmprcv.size() , rcvcnt );
206 vec_tmprcv.assign(nproc*nproc,0.);
207 PE::Comm::instance().all_to_all(vec_snddat, vec_tmprcv);
208 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( vec_tmprcv[i] , vec_rcvdat[i] );
210 vec_tmprcv=vec_snddat;
211 PE::Comm::instance().all_to_all(vec_tmprcv, vec_tmprcv);
212 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( vec_tmprcv[i] , vec_rcvdat[i] );
214 vec_tmprcvchr.resize(0);
215 vec_tmprcvchr.reserve(0);
216 PE::Comm::instance().all_to_all(vec_snddatchr, vec_tmprcvchr );
217 BOOST_CHECK_EQUAL( vec_tmprcvchr.size() ,
sizeof(double)*rcvcnt );
218 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i], vec_rcvdat[i] );
220 for (i=0; i<nproc*nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=0.;
221 PE::Comm::instance().all_to_all(vec_snddatchr, vec_tmprcvchr );
222 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i], vec_rcvdat[i] );
224 vec_tmprcvchr.assign((
char*)(ptr_snddat),(
char*)(ptr_snddat+nproc*nproc));
225 PE::Comm::instance().all_to_all(vec_tmprcvchr, vec_tmprcvchr );
226 for (i=0; i<nproc*nproc; i++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i], vec_rcvdat[i] );
235 setup_data_variable();
239 ptr_tmprcv=PE::Comm::instance().all_to_all(ptr_snddat, ptr_sndcnt, (
double*)0, ptr_rcvcnt);
240 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] );
242 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
243 PE::Comm::instance().all_to_all(ptr_snddat, ptr_sndcnt, ptr_tmprcv, ptr_rcvcnt);
244 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] );
247 ptr_tmprcv=
new double[nproc*nproc];
248 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
249 PE::Comm::instance().all_to_all(ptr_tmprcv, ptr_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_to_all(ptr_snddat, ptr_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_to_all(ptr_snddat, ptr_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; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
268 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
269 PE::Comm::instance().all_to_all(ptr_tmprcv, ptr_sndcnt, ptr_tmprcv, ptr_tmpcnt);
270 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
271 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 ptr_tmprcv=PE::Comm::instance().all_to_all(ptr_snddat, ptr_sndcnt, ptr_sndmap, (
double*)0, ptr_rcvcnt, ptr_rcvmap);
276 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] );
278 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[i*nproc+j]=0.;
279 PE::Comm::instance().all_to_all(ptr_snddat, ptr_sndcnt, ptr_sndmap, ptr_tmprcv, ptr_rcvcnt, ptr_rcvmap);
280 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] );
283 ptr_tmprcv=
new double[nproc*nproc];
284 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
285 PE::Comm::instance().all_to_all(ptr_tmprcv, ptr_sndcnt, ptr_sndmap, ptr_tmprcv, ptr_rcvcnt, ptr_rcvmap);
286 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] );
290 ptr_tmprcv=(
double*)PE::Comm::instance().all_to_all((
char*)ptr_snddat, ptr_sndcnt, (
char*)0, ptr_rcvcnt,
sizeof(
double));
291 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] );
293 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
294 PE::Comm::instance().all_to_all((
char*)ptr_snddat, ptr_sndcnt, (
char*)ptr_tmprcv, ptr_rcvcnt,
sizeof(
double));
295 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=
new double[nproc*nproc];
299 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
300 PE::Comm::instance().all_to_all((
char*)ptr_tmprcv, ptr_sndcnt, (
char*)ptr_tmprcv, ptr_rcvcnt,
sizeof(
double));
301 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] );
305 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
306 ptr_tmprcv=(
double*)PE::Comm::instance().all_to_all((
char*)ptr_snddat, ptr_sndcnt, (
char*)0, ptr_tmpcnt,
sizeof(
double));
307 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
308 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] );
310 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[k]=0.;
311 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
312 PE::Comm::instance().all_to_all((
char*)ptr_snddat, ptr_sndcnt, (
char*)ptr_tmprcv, ptr_tmpcnt,
sizeof(
double));
313 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
314 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 ptr_tmprcv=
new double[nproc*nproc];
318 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
319 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
320 PE::Comm::instance().all_to_all((
char*)ptr_tmprcv, ptr_sndcnt, (
char*)ptr_tmprcv, ptr_tmpcnt,
sizeof(
double));
321 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmpcnt[i] , ptr_rcvcnt[i] );
322 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] );
326 ptr_tmprcv=(
double*)PE::Comm::instance().all_to_all((
char*)ptr_snddat, ptr_sndcnt, ptr_sndmap, (
char*)0, ptr_rcvcnt, ptr_rcvmap,
sizeof(
double));
327 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] );
329 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++) ptr_tmprcv[i*nproc+j]=0.;
330 PE::Comm::instance().all_to_all((
char*)ptr_snddat, ptr_sndcnt, ptr_sndmap, (
char*)ptr_tmprcv, 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] );
334 ptr_tmprcv=
new double[nproc*nproc];
335 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
336 PE::Comm::instance().all_to_all((
char*)ptr_tmprcv, ptr_sndcnt, ptr_sndmap, (
char*)ptr_tmprcv, ptr_rcvcnt, ptr_rcvmap,
sizeof(
double));
337 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] );
346 setup_data_variable();
348 vec_tmprcv.resize(0);
349 vec_tmprcv.reserve(0);
350 PE::Comm::instance().all_to_all(vec_snddat, vec_sndcnt, vec_tmprcv, vec_rcvcnt);
351 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] );
353 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[k]=0.;
354 PE::Comm::instance().all_to_all(vec_snddat, vec_sndcnt, vec_tmprcv, vec_rcvcnt);
355 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] );
357 vec_tmprcv.resize(nproc*nproc);
358 vec_tmprcv.reserve(nproc*nproc);
359 for (i=0; i<nproc*nproc; i++) vec_tmprcv[i]=vec_snddat[i];
360 PE::Comm::instance().all_to_all(vec_tmprcv, vec_sndcnt, vec_tmprcv, vec_rcvcnt);
361 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] );
363 vec_tmprcv.resize(0);
364 vec_tmprcv.reserve(0);
365 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
366 PE::Comm::instance().all_to_all(vec_snddat, vec_sndcnt, vec_tmprcv, vec_tmpcnt);
367 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
368 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] );
370 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[k]=0.;
371 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
372 PE::Comm::instance().all_to_all(vec_snddat, vec_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 vec_tmprcv.resize(nproc*nproc);
377 vec_tmprcv.reserve(nproc*nproc);
378 for (i=0; i<nproc*nproc; i++) vec_tmprcv[i]=vec_snddat[i];
379 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
380 PE::Comm::instance().all_to_all(vec_tmprcv, vec_sndcnt, vec_tmprcv, vec_tmpcnt);
381 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
382 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] );
384 vec_tmprcv.resize(0);
385 vec_tmprcv.reserve(0);
386 PE::Comm::instance().all_to_all(vec_snddat, vec_sndcnt, vec_sndmap, vec_tmprcv, vec_rcvcnt, vec_rcvmap);
387 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] );
389 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) vec_tmprcv[i*nproc+j]=0.;
390 PE::Comm::instance().all_to_all(vec_snddat, vec_sndcnt, vec_sndmap, vec_tmprcv, vec_rcvcnt, vec_rcvmap);
391 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] );
393 vec_tmprcv.resize(nproc*nproc);
394 vec_tmprcv.reserve(nproc*nproc);
395 for (i=0; i<nproc*nproc; i++) vec_tmprcv[i]=vec_snddat[i];
396 PE::Comm::instance().all_to_all(vec_tmprcv, vec_sndcnt, vec_sndmap, vec_tmprcv, vec_rcvcnt, vec_rcvmap);
397 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] );
399 vec_tmprcvchr.resize(0);
400 vec_tmprcvchr.reserve(0);
401 PE::Comm::instance().all_to_all(vec_snddatchr, vec_sndcnt, vec_tmprcvchr, vec_rcvcnt,
sizeof(
double));
402 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] );
404 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) ((
double*)(&vec_tmprcvchr[0]))[
k]=0.;
405 PE::Comm::instance().all_to_all(vec_snddatchr, vec_sndcnt, vec_tmprcvchr, vec_rcvcnt,
sizeof(
double));
406 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] );
408 vec_tmprcvchr.resize(nproc*nproc*
sizeof(
double));
409 vec_tmprcvchr.reserve(nproc*nproc*
sizeof(
double));
410 for (i=0; i<nproc*nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=vec_snddat[i];
411 PE::Comm::instance().all_to_all(vec_tmprcvchr, vec_sndcnt, vec_tmprcvchr, vec_rcvcnt,
sizeof(
double));
412 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] );
414 vec_tmprcvchr.resize(0);
415 vec_tmprcvchr.reserve(0);
416 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
417 PE::Comm::instance().all_to_all(vec_snddatchr, vec_sndcnt, vec_tmprcvchr, vec_tmpcnt,
sizeof(
double));
418 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
419 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] );
421 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++) ((
double*)(&vec_tmprcvchr[0]))[
k]=0.;
422 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
423 PE::Comm::instance().all_to_all(vec_snddatchr, vec_sndcnt, vec_tmprcvchr, vec_tmpcnt,
sizeof(
double));
424 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
425 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] );
427 vec_tmprcvchr.resize(nproc*nproc*
sizeof(
double));
428 vec_tmprcvchr.reserve(nproc*nproc*
sizeof(
double));
429 for (i=0; i<nproc*nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=vec_snddat[i];
430 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
431 PE::Comm::instance().all_to_all(vec_tmprcvchr, vec_sndcnt, vec_tmprcvchr, vec_tmpcnt,
sizeof(
double));
432 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmpcnt[i] , vec_rcvcnt[i] );
433 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] );
435 vec_tmprcvchr.resize(0);
436 vec_tmprcvchr.reserve(0);
437 PE::Comm::instance().all_to_all(vec_snddatchr, vec_sndcnt, vec_sndmap, vec_tmprcvchr, vec_rcvcnt, vec_rcvmap,
sizeof(
double));
438 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] );
440 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.;
442 PE::Comm::instance().all_to_all(vec_snddatchr, vec_sndcnt, vec_sndmap, vec_tmprcvchr, vec_rcvcnt, vec_rcvmap,
sizeof(
double));
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]))[i*nproc+j] , vec_rcvdat[k] );
445 vec_tmprcvchr.resize(nproc*nproc*
sizeof(
double));
446 vec_tmprcvchr.reserve(nproc*nproc*
sizeof(
double));
447 for (i=0; i<nproc*nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=vec_snddat[i];
448 PE::Comm::instance().all_to_all(vec_tmprcvchr, vec_sndcnt, vec_sndmap, vec_tmprcvchr, vec_rcvcnt, vec_rcvmap,
sizeof(
double));
449 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] );
455 BOOST_AUTO_TEST_SUITE_END()
457 #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_tmprcv
std::vector< char > vec_snddatchr
std::vector< char > vec_tmprcvchr
T * all_to_all(const Communicator &comm, const T *in_values, const int in_n, T *out_values, const int stride=1)
std::vector< int > vec_tmpcnt
std::vector< int > vec_sndmap
void setup_data_constant()
helper function for constant size data - setting up input and verification data
std::vector< int > vec_sndcnt
data for std::vectors
int sndcnt
data for raw pointers
PEAllToAllFixture()
common setup for each test case
std::vector< int > vec_rcvcnt
BOOST_AUTO_TEST_CASE(all_to_all)
~PEAllToAllFixture()
common tear-down for each test case
std::vector< int > vec_rcvmap
int nproc
number of processes
#define PEProcessSortedExecute(irank, expression)
std::vector< double > vec_snddat
std::vector< double > vec_rcvdat