14 int me = comm->getRank();
15 int np = comm->getSize();
17 double *sendBuf =
new double[ndoubles];
18 for (
int i = 0; i < ndoubles; i++) sendBuf[i] = 0.;
19 int nMy = ndoubles / np + (me < (ndoubles % np));
20 int myBegin = (ndoubles / np) * me;
21 myBegin += ((ndoubles % np) < me ? (ndoubles % np) : me);
22 int myEnd = myBegin + nMy;
23 for (
int i = myBegin; i < myEnd; ++i) sendBuf[i] = me;
25 double *recvBuf =
new double[ndoubles];
28 std::cout <<
"Trying reduceAll with ndoubles = " << ndoubles << std::endl;
30 std::cout << *comm << std::endl;
33 ndoubles, sendBuf, recvBuf);
40 int main(
int narg,
char **arg)
46 int me = comm->getRank();
50 std::cout <<
"Usage: a.out [Y|N] \n"
51 <<
" a.out Y ==> duplicate communicator \n"
52 <<
" a.out N ==> do not duplicate communicator \n"
57 bool dupComm = (arg[1][0] ==
'Y' ? true :
false);
65 std::cout <<
"PASSED with "
66 << (dupComm ?
"comm duplication " :
"no comm duplication ")