Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
TimeMonitor_Issue3868.cpp
Go to the documentation of this file.
1// @HEADER
2// @HEADER
3
8#ifdef HAVE_TEUCHOS_MPI
10#endif // HAVE_TEUCHOS_MPI
11
12TEUCHOS_UNIT_TEST(TimeMonitor, Issue3868) {
14 using Teuchos::Comm;
15 using Teuchos::outArg;
16 using Teuchos::RCP;
18 using Teuchos::reduceAll;
19
20 RCP<const Comm<int> > comm = Teuchos::DefaultComm<int>::getComm ();
21
22 const int numProcs = comm->getSize ();
23 TEST_ASSERT( numProcs > 1 );
24 if (numProcs < 4) {
25 out << "This test requires at least 4 MPI processes." << std::endl;
26 return;
27 }
28
29 const int myRank = comm->getRank();
30
31 if (myRank == 3) {
32 Teuchos::TimeMonitor timer(*Teuchos::TimeMonitor::getNewTimer(std::string("myTimer")));
33 }
34
35 std::ostringstream out1;
36 Teuchos::TimeMonitor::summarize(out1,false,true,false,Teuchos::Union,"",true);
37 int test = (out1.str().find("myTimer") != std::string::npos);
38
39 int gblTest = false; // output argument
40 reduceAll<int, int> (*comm, REDUCE_MAX, test, outArg (gblTest));
41 TEST_EQUALITY(gblTest, 1);
42
43}
Implementation of Teuchos wrappers for MPI.
#define TEST_ASSERT(v1)
Assert the given statement is true.
#define TEST_EQUALITY(v1, v2)
Assert the equality of v1 and v2.
Scope guard for Teuchos::Time, with MPI collective timer reporting.
Unit testing support.
#define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME)
Macro for defining a (non-templated) unit test.
Abstract interface for distributed-memory communication.
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
Return the default global communicator.
Smart reference counting pointer class for automatic garbage collection.
Scope guard for Time, that can compute MPI collective timer statistics.
static void summarize(Ptr< const Comm< int > > comm, std::ostream &out=std::cout, const bool alwaysWriteLocal=false, const bool writeGlobalStats=true, const bool writeZeroTimers=true, const ECounterSetOp setOp=Intersection, const std::string &filter="", const bool ignoreZeroTimers=false)
Print summary statistics for all timers on the given communicator.
static RCP< Time > getNewTimer(const std::string &name)
Return a new timer with the given name (class method).