23 int me = comm->getRank();
24 int np = comm->getSize();
26 double *sendBuf =
new double[ndoubles];
27 for (
int i = 0; i < ndoubles; i++) sendBuf[i] = 0.;
28 int nMy = ndoubles / np + (me < (ndoubles % np));
29 int myBegin = (ndoubles / np) * me;
30 myBegin += ((ndoubles % np) < me ? (ndoubles % np) : me);
31 int myEnd = myBegin + nMy;
32 for (
int i = myBegin; i < myEnd; ++i) sendBuf[i] = me;
34 double *recvBuf =
new double[ndoubles];
37 std::cout <<
"Trying reduceAll with ndoubles = " << ndoubles << std::endl;
39 std::cout << *comm << std::endl;
42 ndoubles, sendBuf, recvBuf);
49 int main(
int narg,
char **arg)
55 int me = comm->getRank();
59 std::cout <<
"Usage: a.out [Y|N] \n"
60 <<
" a.out Y ==> duplicate communicator \n"
61 <<
" a.out N ==> do not duplicate communicator \n"
66 bool dupComm = (arg[1][0] ==
'Y' ?
true :
false);
74 std::cout <<
"PASSED with "
75 << (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.