5 #include "Teuchos_CommHelpers.hpp"
6 #include "Teuchos_DefaultComm.hpp"
7 #include "Teuchos_RCP.hpp"
10 int main(
int narg,
char **arg)
12 Teuchos::GlobalMPISession mpiSession(&narg,&arg);
14 Teuchos::RCP<const Teuchos::Comm<int> >
15 comm = Teuchos::DefaultComm<int>::getComm();
16 int me = comm->getRank();
19 std::cout << std::endl
20 <<
"Usage: Zoltan2_teuchosCommTest.exe [#_of_allreduces_to_do]"
22 <<
" default number is 4000"
27 if (narg > 1) niter = atoi(arg[1]);
32 double din = me * 2., dout;
35 for (
int i = 0; i < niter; i++) {
36 reduceAll(*comm, Teuchos::REDUCE_SUM, 1, &iin, &iout);
37 reduceAll(*comm, Teuchos::REDUCE_SUM, 1, &din, &dout);
41 std::cout <<
"reduceAll time using Teuchos::Comm = "
42 << tend - tstart << std::endl;
45 for (
int i = 0; i < niter; i++) {
46 MPI_Allreduce(&iin, &iout, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
47 MPI_Allreduce(&din, &dout, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
51 std::cout <<
"Allreduce time using MPI_Allreduce = "
52 << tend - tstart << std::endl;
55 std::cout << std::endl <<
"PASS" << std::endl;
int main(int narg, char **arg)