14 #include "Teuchos_CommHelpers.hpp"
15 #include "Teuchos_DefaultComm.hpp"
16 #include "Teuchos_RCP.hpp"
19 int main(
int narg,
char **arg)
21 Teuchos::GlobalMPISession mpiSession(&narg,&arg);
23 Teuchos::RCP<const Teuchos::Comm<int> >
24 comm = Teuchos::DefaultComm<int>::getComm();
25 int me = comm->getRank();
28 std::cout << std::endl
29 <<
"Usage: Zoltan2_teuchosCommTest.exe [#_of_allreduces_to_do]"
31 <<
" default number is 4000"
36 if (narg > 1) niter = atoi(arg[1]);
41 double din = me * 2., dout;
44 for (
int i = 0; i < niter; i++) {
45 reduceAll(*comm, Teuchos::REDUCE_SUM, 1, &iin, &iout);
46 reduceAll(*comm, Teuchos::REDUCE_SUM, 1, &din, &dout);
50 std::cout <<
"reduceAll time using Teuchos::Comm = "
51 << tend - tstart << std::endl;
54 for (
int i = 0; i < niter; i++) {
55 MPI_Allreduce(&iin, &iout, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
56 MPI_Allreduce(&din, &dout, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
60 std::cout <<
"Allreduce time using MPI_Allreduce = "
61 << tend - tstart << std::endl;
64 std::cout << std::endl <<
"PASS" << std::endl;
int main(int narg, char **arg)