7 void runTest(
int ndoubles, MPI_Comm &comm)
 
   10   MPI_Comm_rank(comm, &me);
 
   11   MPI_Comm_size(comm, &np);
 
   13   double *sendBuf = 
new double[ndoubles];
 
   14   for (
int i = 0; i < ndoubles; i++) sendBuf[i] = 0.;
 
   15   int nMy = ndoubles / np + (me < (ndoubles % np));
 
   16   int myBegin = (ndoubles / np) * me;
 
   17   myBegin += ((ndoubles % np) < me ? (ndoubles % np) : me);
 
   18   int myEnd = myBegin + nMy;
 
   19   for (
int i = myBegin; i < myEnd; ++i) sendBuf[i] = me;
 
   21   double *recvBuf = 
new double[ndoubles];
 
   24     std::cout << 
"Trying reduceAll with ndoubles = " << ndoubles << std::endl;
 
   26   MPI_Allreduce(sendBuf, recvBuf, ndoubles, MPI_DOUBLE, MPI_SUM, comm);
 
   33 int main(
int narg, 
char **arg)
 
   35   MPI_Init(&narg, &arg);
 
   36   MPI_Comm comm = MPI_COMM_WORLD;
 
   39   MPI_Comm_rank(comm, &me);
 
   43       std::cout << 
"Usage:  a.out [Y|N] \n" 
   44                 << 
"        a.out Y ==> duplicate communicator \n" 
   45                 << 
"        a.out N ==> do not duplicate communicator \n" 
   50   bool dupComm = (arg[1][0] == 
'Y' ? 
true : 
false);
 
   54     MPI_Comm_dup(comm, &commdup);
 
   59     std::cout << 
"PASSED with "  
   60               << (dupComm ? 
"comm duplication " : 
"no comm duplication ")
 
   63   if (dupComm) MPI_Comm_free(&commdup);
 
void runTest(int ndoubles, MPI_Comm &comm)
 
int main(int argc, char *argv[])