20 nproc=PE::Comm::instance().size();
21 irank=PE::Comm::instance().rank();
97 for (i=0; i<
nproc; i++)
98 for (j=0; j<
nproc; j++){
99 ptr_snddat[i*nproc+j]=(irank+1)*1000000+(i+1)*10000+(j+1);
100 ptr_rcvdat[i*nproc+j]=(i+1)*1000000+(irank+1)*10000+(j+1);
104 vec_snddat.assign(ptr_snddat,ptr_snddat+nproc*nproc);
105 vec_rcvdat.assign(ptr_rcvdat,ptr_rcvdat+nproc*nproc);
106 vec_snddatchr.assign((
char*)(ptr_snddat),(
char*)(ptr_snddat+nproc*nproc));
113 for (i=0; i<
nproc; i++){
114 ptr_sndcnt[i]=(i+irank*
irank)%nproc;
115 ptr_rcvcnt[i]=(i*i+
irank)%nproc;
117 for(i=0; i<nproc*
nproc; i++) {
122 for(i=0; i<
nproc; i++)
for(j=0; j<
nproc; j++) ptr_rcvmap[i][j]=0;
123 for(i=0, k=0; i<
nproc; i++)
124 for(j=0; j<ptr_sndcnt[i]; j++, k++)
125 ptr_snddat[k]=(irank+1)*1000000+(i+1)*10000+(j+1);
126 for(i=0, k=0; i<
nproc; i++)
127 for(j=0; j<ptr_rcvcnt[i]; j++, k++)
128 ptr_rcvdat[k]=(i+1)*1000000+(irank+1)*10000+(j+1);
129 for (i=0, k=0,l=0; i<
nproc; k+=ptr_sndcnt[i], i++)
130 for (j=0; j<ptr_sndcnt[i]; j++,l++)
131 ptr_sndmap[l]=k+ptr_sndcnt[i]-1-j;
132 for (i=0, k=0, l=0; i<
nproc; k+=ptr_rcvcnt[i], i++)
133 for (j=0; j<ptr_rcvcnt[i]; j++, l++)
134 ptr_rcvmap[i][j]=ptr_rcvcnt[i]-1-j;
135 for(i=0, sndcnt=0, rcvcnt=0; i<
nproc; i++){
136 sndcnt+=ptr_sndcnt[i];
137 rcvcnt+=ptr_rcvcnt[i];
139 vec_sndcnt.assign(ptr_sndcnt,ptr_sndcnt+nproc);
140 vec_rcvcnt.assign(ptr_rcvcnt,ptr_rcvcnt+nproc);
141 vec_snddat.assign(ptr_snddat,ptr_snddat+nproc*nproc);
142 vec_rcvdat.assign(ptr_rcvdat,ptr_rcvdat+nproc*nproc);
143 vec_sndmap.assign(ptr_sndmap,ptr_sndmap+nproc*nproc);
144 for (i=0; i<
nproc; i++) vec_rcvmap[i].assign(ptr_rcvmap[i],ptr_rcvmap[i]+nproc);
145 vec_snddatchr.assign((
char*)(ptr_snddat),(
char*)(ptr_snddat+nproc*nproc));
167 setup_data_constant();
169 for (r=0; r<nproc; r++) {
174 ptr_tmprcv=PE::Comm::instance().scatter(ptr_snddat, nproc, (
double*)0, r);
175 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[r*nproc+i] );
177 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=0.;
178 PE::Comm::instance().scatter(ptr_snddat, nproc, ptr_tmprcv, r);
179 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[r*nproc+i] );
181 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
182 PE::Comm::instance().scatter(ptr_tmprcv, nproc, ptr_tmprcv, r);
183 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[r*nproc+i] );
188 ptr_tmprcv=(
double*)PE::Comm::instance().scatter((
char*)ptr_snddat, nproc, (
char*)0, r,
sizeof(
double));
189 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[r*nproc+i] );
191 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=0.;
192 PE::Comm::instance().scatter((
char*)ptr_snddat, nproc, (
char*)ptr_tmprcv, r,
sizeof(
double));
193 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[r*nproc+i] );
195 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
196 PE::Comm::instance().scatter((
char*)ptr_tmprcv, nproc, (
char*)ptr_tmprcv, r,
sizeof(
double));
197 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ptr_tmprcv[i] , ptr_rcvdat[r*nproc+i] );
207 setup_data_constant();
209 for (r=0; r<nproc; r++) {
211 vec_tmprcv.resize(0);
212 vec_tmprcv.reserve(0);
213 PE::Comm::instance().scatter(vec_snddat, vec_tmprcv, r);
214 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmprcv[i] , vec_rcvdat[r*nproc+i] );
215 BOOST_CHECK_EQUAL( (
int)vec_tmprcv.size() , rcvcnt/nproc );
217 vec_tmprcv.assign(nproc*nproc,0.);
218 PE::Comm::instance().scatter(vec_snddat, vec_tmprcv, r);
219 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmprcv[i] , vec_rcvdat[r*nproc+i] );
221 vec_tmprcv=vec_snddat;
222 PE::Comm::instance().scatter(vec_tmprcv, vec_tmprcv, r);
223 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( vec_tmprcv[i] , vec_rcvdat[r*nproc+i] );
225 vec_tmprcvchr.resize(0);
226 vec_tmprcvchr.reserve(0);
227 PE::Comm::instance().scatter(vec_snddatchr, vec_tmprcvchr, r );
228 BOOST_CHECK_EQUAL( vec_tmprcvchr.size() ,
sizeof(double)*rcvcnt/nproc );
229 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i], vec_rcvdat[r*nproc+i] );
231 for (i=0; i<nproc*nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=0.;
232 PE::Comm::instance().scatter(vec_snddatchr, vec_tmprcvchr, r );
233 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i], vec_rcvdat[r*nproc+i] );
235 vec_tmprcvchr.assign((
char*)(ptr_snddat),(
char*)(ptr_snddat+nproc*nproc));
236 PE::Comm::instance().scatter(vec_tmprcvchr, vec_tmprcvchr, r );
237 for (i=0; i<nproc; i++) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[i], vec_rcvdat[r*nproc+i] );
247 setup_data_variable();
249 for (r=0; r<nproc; r++) {
253 ptr_tmprcv=PE::Comm::instance().scatter(ptr_snddat, ptr_sndcnt, (
double*)0, ptr_rcvcnt[r], r);
254 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
256 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) ptr_tmprcv[j]=0.;
257 PE::Comm::instance().scatter(ptr_snddat, ptr_sndcnt, ptr_tmprcv, ptr_rcvcnt[r], r);
258 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
261 ptr_tmprcv=
new double[nproc*nproc];
262 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
263 PE::Comm::instance().scatter(ptr_tmprcv, ptr_sndcnt, ptr_tmprcv, ptr_rcvcnt[r], r);
264 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
268 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
269 ptr_tmprcv=PE::Comm::instance().scatter(ptr_snddat, ptr_sndcnt, (
double*)0, ptr_tmpcnt[r], r);
270 BOOST_CHECK_EQUAL( ptr_tmpcnt[r] , ptr_rcvcnt[r] );
271 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
273 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) ptr_tmprcv[j]=0.;
274 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
275 PE::Comm::instance().scatter(ptr_snddat, ptr_sndcnt, ptr_tmprcv, ptr_tmpcnt[r], r);
276 BOOST_CHECK_EQUAL( ptr_tmpcnt[r] , ptr_rcvcnt[r] );
277 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
280 ptr_tmprcv=
new double[nproc*nproc];
281 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
282 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
283 PE::Comm::instance().scatter(ptr_tmprcv, ptr_sndcnt, ptr_tmprcv, ptr_tmpcnt[r], r);
284 BOOST_CHECK_EQUAL( ptr_tmpcnt[r] , ptr_rcvcnt[r] );
285 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
289 ptr_tmprcv=PE::Comm::instance().scatter(ptr_snddat, ptr_sndcnt, ptr_sndmap, (
double*)0, ptr_rcvcnt[r], ptr_rcvmap[r], r);
290 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
292 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) ptr_tmprcv[j]=0.;
293 PE::Comm::instance().scatter(ptr_snddat, ptr_sndcnt, ptr_sndmap, ptr_tmprcv, ptr_rcvcnt[r], ptr_rcvmap[r], r);
294 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
297 ptr_tmprcv=
new double[nproc*nproc];
298 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
299 PE::Comm::instance().scatter(ptr_tmprcv, ptr_sndcnt, ptr_sndmap, ptr_tmprcv, ptr_rcvcnt[r], ptr_rcvmap[r], r);
300 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
304 ptr_tmprcv=(
double*)PE::Comm::instance().scatter((
char*)ptr_snddat, ptr_sndcnt, (
char*)0, ptr_rcvcnt[r], r,
sizeof(
double));
305 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
307 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) ptr_tmprcv[j]=0.;
308 PE::Comm::instance().scatter((
char*)ptr_snddat, ptr_sndcnt, (
char*)ptr_tmprcv, ptr_rcvcnt[r], r,
sizeof(
double));
309 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
312 ptr_tmprcv=
new double[nproc*nproc];
313 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
314 PE::Comm::instance().scatter((
char*)ptr_tmprcv, ptr_sndcnt, (
char*)ptr_tmprcv, ptr_rcvcnt[r], r,
sizeof(
double));
315 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
319 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
320 ptr_tmprcv=(
double*)PE::Comm::instance().scatter((
char*)ptr_snddat, ptr_sndcnt, (
char*)0, ptr_tmpcnt[r], r,
sizeof(
double));
321 BOOST_CHECK_EQUAL( ptr_tmpcnt[r] , ptr_rcvcnt[r] );
322 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
324 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) ptr_tmprcv[j]=0.;
325 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
326 PE::Comm::instance().scatter((
char*)ptr_snddat, ptr_sndcnt, (
char*)ptr_tmprcv, ptr_tmpcnt[r], r,
sizeof(
double));
327 BOOST_CHECK_EQUAL( ptr_tmpcnt[r] , ptr_rcvcnt[r] );
328 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
331 ptr_tmprcv=
new double[nproc*nproc];
332 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
333 for(i=0; i<nproc; i++) ptr_tmpcnt[i]=-1;
334 PE::Comm::instance().scatter((
char*)ptr_tmprcv, ptr_sndcnt, (
char*)ptr_tmprcv, ptr_tmpcnt[r], r,
sizeof(
double));
335 BOOST_CHECK_EQUAL( ptr_tmpcnt[r] , ptr_rcvcnt[r] );
336 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++ )
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
340 ptr_tmprcv=(
double*)PE::Comm::instance().scatter((
char*)ptr_snddat, ptr_sndcnt, ptr_sndmap, (
char*)0, ptr_rcvcnt[r], ptr_rcvmap[r], r,
sizeof(
double));
341 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
343 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) ptr_tmprcv[j]=0.;
344 PE::Comm::instance().scatter((
char*)ptr_snddat, ptr_sndcnt, ptr_sndmap, (
char*)ptr_tmprcv, ptr_rcvcnt[r], ptr_rcvmap[r], r,
sizeof(
double));
345 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
348 ptr_tmprcv=
new double[nproc*nproc];
349 for (i=0; i<nproc*nproc; i++) ptr_tmprcv[i]=ptr_snddat[i];
350 PE::Comm::instance().scatter((
char*)ptr_tmprcv, ptr_sndcnt, ptr_sndmap, (
char*)ptr_tmprcv, ptr_rcvcnt[r], ptr_rcvmap[r], r,
sizeof(
double));
351 for (i=0, k=0; i<nproc; i++)
for (j=0; j<ptr_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ptr_tmprcv[j] , ptr_rcvdat[k] );
361 setup_data_variable();
363 for (r=0; r<nproc; r++) {
365 vec_tmprcv.resize(0);
366 vec_tmprcv.reserve(0);
367 PE::Comm::instance().scatter(vec_snddat, vec_sndcnt, vec_tmprcv, vec_rcvcnt[r], r);
368 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( vec_tmprcv[j] , vec_rcvdat[k] );
370 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) vec_tmprcv[j]=0.;
371 PE::Comm::instance().scatter(vec_snddat, vec_sndcnt, vec_tmprcv, vec_rcvcnt[r], r);
372 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( vec_tmprcv[j] , vec_rcvdat[k] );
374 vec_tmprcv.resize(nproc*nproc);
375 vec_tmprcv.reserve(nproc*nproc);
376 for (i=0; i<nproc*nproc; i++) vec_tmprcv[i]=vec_snddat[i];
377 PE::Comm::instance().scatter(vec_tmprcv, vec_sndcnt, vec_tmprcv, vec_rcvcnt[r], r);
378 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( vec_tmprcv[j] , vec_rcvdat[k] );
380 vec_tmprcv.resize(0);
381 vec_tmprcv.reserve(0);
382 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
383 PE::Comm::instance().scatter(vec_snddat, vec_sndcnt, vec_tmprcv, vec_tmpcnt[r], r);
384 BOOST_CHECK_EQUAL( vec_tmpcnt[r] , vec_rcvcnt[r] );
385 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( vec_tmprcv[j] , vec_rcvdat[k] );
387 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) vec_tmprcv[j]=0.;
388 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
389 PE::Comm::instance().scatter(vec_snddat, vec_sndcnt, vec_tmprcv, vec_tmpcnt[r], r);
390 BOOST_CHECK_EQUAL( vec_tmpcnt[r] , vec_rcvcnt[r] );
391 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( vec_tmprcv[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 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
397 PE::Comm::instance().scatter(vec_tmprcv, vec_sndcnt, vec_tmprcv, vec_tmpcnt[r], r);
398 BOOST_CHECK_EQUAL( vec_tmpcnt[r] , vec_rcvcnt[r] );
399 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( vec_tmprcv[j] , vec_rcvdat[k] );
401 vec_tmprcv.resize(0);
402 vec_tmprcv.reserve(0);
403 PE::Comm::instance().scatter(vec_snddat, vec_sndcnt, vec_sndmap, vec_tmprcv, vec_rcvcnt[r], vec_rcvmap[r], r);
404 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( vec_tmprcv[j] , vec_rcvdat[k] );
406 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) vec_tmprcv[j]=0.;
407 PE::Comm::instance().scatter(vec_snddat, vec_sndcnt, vec_sndmap, vec_tmprcv, vec_rcvcnt[r], vec_rcvmap[r], r);
408 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( vec_tmprcv[j] , vec_rcvdat[k] );
410 vec_tmprcv.resize(nproc*nproc);
411 vec_tmprcv.reserve(nproc*nproc);
412 for (i=0; i<nproc*nproc; i++) vec_tmprcv[i]=vec_snddat[i];
413 PE::Comm::instance().scatter(vec_tmprcv, vec_sndcnt, vec_sndmap, vec_tmprcv, vec_rcvcnt[r], vec_rcvmap[r], r);
414 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( vec_tmprcv[j] , vec_rcvdat[k] );
416 vec_tmprcvchr.resize(0);
417 vec_tmprcvchr.reserve(0);
418 PE::Comm::instance().scatter(vec_snddatchr, vec_sndcnt, vec_tmprcvchr, vec_rcvcnt[r], r,
sizeof(
double));
419 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[j] , vec_rcvdat[k] );
421 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) ((
double*)(&vec_tmprcvchr[0]))[j]=0.;
422 PE::Comm::instance().scatter(vec_snddatchr, vec_sndcnt, vec_tmprcvchr, vec_rcvcnt[r], r,
sizeof(
double));
423 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[j] , vec_rcvdat[k] );
425 vec_tmprcvchr.resize(nproc*nproc*
sizeof(
double));
426 vec_tmprcvchr.reserve(nproc*nproc*
sizeof(
double));
427 for (i=0; i<nproc*nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=vec_snddat[i];
428 PE::Comm::instance().scatter(vec_tmprcvchr, vec_sndcnt, vec_tmprcvchr, vec_rcvcnt[r], r,
sizeof(
double));
429 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[j] , vec_rcvdat[k] );
431 vec_tmprcvchr.resize(0);
432 vec_tmprcvchr.reserve(0);
433 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
434 PE::Comm::instance().scatter(vec_snddatchr, vec_sndcnt, vec_tmprcvchr, vec_tmpcnt[r], r,
sizeof(
double));
435 BOOST_CHECK_EQUAL( vec_tmpcnt[r] , vec_rcvcnt[r] );
436 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[j] , vec_rcvdat[k] );
438 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) ((
double*)(&vec_tmprcvchr[0]))[j]=0.;
439 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
440 PE::Comm::instance().scatter(vec_snddatchr, vec_sndcnt, vec_tmprcvchr, vec_tmpcnt[r], r,
sizeof(
double));
441 BOOST_CHECK_EQUAL( vec_tmpcnt[r] , vec_rcvcnt[r] );
442 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[j] , vec_rcvdat[k] );
444 vec_tmprcvchr.resize(nproc*nproc*
sizeof(
double));
445 vec_tmprcvchr.reserve(nproc*nproc*
sizeof(
double));
446 for (i=0; i<nproc*nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=vec_snddat[i];
447 for(i=0; i<nproc; i++) vec_tmpcnt[i]=-1;
448 PE::Comm::instance().scatter(vec_tmprcvchr, vec_sndcnt, vec_tmprcvchr, vec_tmpcnt[r], r,
sizeof(
double));
449 BOOST_CHECK_EQUAL( vec_tmpcnt[r] , vec_rcvcnt[r] );
450 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[j] , vec_rcvdat[k] );
452 vec_tmprcvchr.resize(0);
453 vec_tmprcvchr.reserve(0);
454 PE::Comm::instance().scatter(vec_snddatchr, vec_sndcnt, vec_sndmap, vec_tmprcvchr, vec_rcvcnt[r], vec_rcvmap[r], r,
sizeof(
double));
455 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[j] , vec_rcvdat[k] );
457 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) ((
double*)&vec_tmprcvchr[0])[j]=0.;
458 PE::Comm::instance().scatter(vec_snddatchr, vec_sndcnt, vec_sndmap, vec_tmprcvchr, vec_rcvcnt[r], vec_rcvmap[r], r,
sizeof(
double));
459 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[j] , vec_rcvdat[k] );
461 vec_tmprcvchr.resize(nproc*nproc*
sizeof(
double));
462 vec_tmprcvchr.reserve(nproc*nproc*
sizeof(
double));
463 for (i=0; i<nproc*nproc; i++) ((
double*)(&vec_tmprcvchr[0]))[i]=vec_snddat[i];
464 PE::Comm::instance().scatter(vec_tmprcvchr, vec_sndcnt, vec_sndmap, vec_tmprcvchr, vec_rcvcnt[r], vec_rcvmap[r], r,
sizeof(
double));
465 for (i=0, k=0; i<nproc; i++)
for (j=0; j<vec_rcvcnt[i]; j++, k++)
if (i==r) BOOST_CHECK_EQUAL( ((
double*)(&vec_tmprcvchr[0]))[j] , vec_rcvdat[k] );
471 BOOST_AUTO_TEST_SUITE_END()
473
#define CFinfo
these are always defined
void setup_data_constant()
helper function for constant size data - setting up input and verification data
int sndcnt
data for raw pointers
std::vector< char > vec_snddatchr
BOOST_AUTO_TEST_CASE(scatter)
int nproc
number of processes
std::vector< double > vec_rcvdat
T * scatter(const Communicator &comm, const T *in_values, const int in_n, T *out_values, const int root, const int stride=1)
std::vector< std::vector< int > > vec_rcvmap
std::vector< int > vec_rcvcnt
std::vector< int > vec_sndmap
std::vector< double > vec_tmprcv
std::vector< double > vec_snddat
~PEScatterFixture()
common tear-down for each test case
std::vector< int > vec_sndcnt
data for std::vectors
PEScatterFixture()
common setup for each test case
void setup_data_variable()
helper function for variable size data - setting up input and verification data
std::vector< int > vec_tmpcnt
std::vector< char > vec_tmprcvchr
#define PEProcessSortedExecute(irank, expression)