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 ")
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
Return the default global communicator.
Initialize, finalize, and query the global MPI session.
void runTest(int ndoubles, MPI_Comm &comm)
void reduceAll< int, double >(const Comm< int > &comm, const EReductionType reductType, const int count, const double sendBuffer[], double globalReducts[])
int main(int argc, char *argv[])
Smart reference counting pointer class for automatic garbage collection.
Reference-counted pointer class and non-member templated function implementations.