43 #include "Teuchos_CommHelpers.hpp" 44 #include "Teuchos_DefaultComm.hpp" 47 #include "Teuchos_StandardParameterEntryValidators.hpp" 105 template<
class Ordinal,
class ScalarType,
class IndexType>
110 reduce (
const Ordinal count,
111 const std::pair<ScalarType, IndexType> inBuffer[],
112 std::pair<ScalarType, IndexType> inoutBuffer[])
const;
115 template<
class Ordinal>
116 class MaxLoc<Ordinal, double, int> :
120 reduce (
const Ordinal count,
121 const std::pair<double, int> inBuffer[],
122 std::pair<double, int> inoutBuffer[])
const 124 for (Ordinal ind = 0; ind < count; ++ind) {
125 const std::pair<double, int>& in = inBuffer[ind];
126 std::pair<double, int>& inout = inoutBuffer[ind];
128 if (in.first > inout.first) {
129 inout.first = in.first;
130 inout.second = in.second;
131 }
else if (in.first < inout.first) {
134 inout.first = in.first;
135 inout.second = std::min (in.second, inout.second);
167 template<
class Ordinal,
class ScalarType,
class IndexType>
172 reduce (
const Ordinal count,
173 const std::pair<ScalarType, IndexType> inBuffer[],
174 std::pair<ScalarType, IndexType> inoutBuffer[])
const;
177 template<
class Ordinal>
178 class MinLoc<Ordinal, double, int> :
182 reduce (
const Ordinal count,
183 const std::pair<double, int> inBuffer[],
184 std::pair<double, int> inoutBuffer[])
const 186 for (Ordinal ind = 0; ind < count; ++ind) {
187 const std::pair<double, int>& in = inBuffer[ind];
188 std::pair<double, int>& inout = inoutBuffer[ind];
190 if (in.first < inout.first) {
191 inout.first = in.first;
192 inout.second = in.second;
193 }
else if (in.first > inout.first) {
196 inout.first = in.first;
197 inout.second = std::min (in.second, inout.second);
206 template<
class Ordinal,
class ScalarType,
class IndexType>
211 reduce (
const Ordinal count,
212 const std::pair<ScalarType, IndexType> inBuffer[],
213 std::pair<ScalarType, IndexType> inoutBuffer[])
const;
216 template<
class Ordinal>
221 reduce (
const Ordinal count,
222 const std::pair<double, int> inBuffer[],
223 std::pair<double, int> inoutBuffer[])
const 225 for (Ordinal ind = 0; ind < count; ++ind) {
226 const std::pair<double, int>& in = inBuffer[ind];
227 std::pair<double, int>& inout = inoutBuffer[ind];
229 if ( (in.first < inout.first && in.first != 0) || (inout.first == 0 && in.first != 0) ) {
230 inout.first = in.first;
231 inout.second = in.second;
232 }
else if (in.first > inout.first) {
235 inout.first = in.first;
236 inout.second = std::min (in.second, inout.second);
246 typedef std::map<std::string, std::pair<double, int> > timer_map_t;
263 timer == null, std::invalid_argument,
264 "TimeMonitor::disableTimer: Invalid timer \"" << name <<
"\"");
273 timer == null, std::invalid_argument,
274 "TimeMonitor::enableTimer: Invalid timer \"" << name <<
"\"");
281 typedef std::map<std::string, RCP<Time> > map_type;
282 typedef map_type::iterator iter_type;
290 for (iter_type it = ctrs.begin(); it != ctrs.end(); ++it) {
296 it->second->isRunning (), std::runtime_error,
297 "Timer \"" << it->second->name () <<
"\" is currently running. " 298 "You are not allowed to reset running timers.");
300 #endif // TEUCHOS_DEBUG 302 for (iter_type it = ctrs.begin(); it != ctrs.end(); ++it) {
303 it->second->reset ();
316 std::pair<std::string, std::pair<double, int> >
317 makeEmptyTimerDatum (
const std::string& name)
319 return std::make_pair (name, std::make_pair (
double(0),
int(0)));
340 collectLocalTimerData (timer_map_t& localData,
341 const std::map<std::string,
RCP<Time> >& localCounters,
342 const std::string& filter=
"")
344 using std::make_pair;
345 typedef timer_map_t::iterator iter_t;
347 timer_map_t theLocalData;
348 for (std::map<std::string,
RCP<Time> >::const_iterator it = localCounters.begin();
349 it != localCounters.end(); ++it) {
350 const std::string& name = it->second->name ();
354 const bool skipThisOne = (filter !=
"" && name.find (filter) != 0);
356 const double timing = it->second->totalElapsedTime ();
357 const int numCalls = it->second->numCalls ();
361 iter_t loc = theLocalData.find (name);
362 if (loc == theLocalData.end()) {
364 theLocalData.insert (loc, make_pair (name, make_pair (timing, numCalls)));
367 loc->second.first += timing;
368 loc->second.second += numCalls;
374 localData.swap (theLocalData);
381 filterZeroData (timer_map_t& timerData)
385 timer_map_t newTimerData;
386 for (timer_map_t::const_iterator it = timerData.begin();
387 it != timerData.end(); ++it) {
388 if (it->second.second > 0) {
389 newTimerData[it->first] = it->second;
392 timerData.swap (newTimerData);
417 collectLocalTimerDataAndNames (timer_map_t& localTimerData,
419 const std::map<std::string,
RCP<Time> >& localTimers,
420 const bool writeZeroTimers,
421 const std::string& filter=
"")
424 collectLocalTimerData (localTimerData, localTimers, filter);
430 if (! writeZeroTimers) {
431 filterZeroData (localTimerData);
436 localTimerNames.
reserve (localTimerData.size());
437 for (timer_map_t::const_iterator it = localTimerData.begin();
438 it != localTimerData.end(); ++it) {
478 collectGlobalTimerData (timer_map_t& globalTimerData,
480 timer_map_t& localTimerData,
483 const bool alwaysWriteLocal,
512 const timer_map_t::size_type myNumGlobalNames = globalTimerNames.
size();
513 timer_map_t::size_type minNumGlobalNames = 0;
514 timer_map_t::size_type maxNumGlobalNames = 0;
516 outArg (minNumGlobalNames));
518 outArg (maxNumGlobalNames));
520 std::logic_error,
"Min # global timer names = " << minNumGlobalNames
521 <<
" != max # global timer names = " << maxNumGlobalNames
522 <<
". Please report this bug to the Teuchos developers.");
524 std::logic_error,
"My # global timer names = " << myNumGlobalNames
525 <<
" != min # global timer names = " << minNumGlobalNames
526 <<
". Please report this bug to the Teuchos developers.");
528 #endif // TEUCHOS_DEBUG 545 timer_map_t::iterator globalMapIter = globalTimerData.begin();
546 timer_map_t::iterator localMapIter;
548 it != globalTimerNames.
end(); ++it) {
549 const std::string& globalName = *it;
550 localMapIter = localTimerData.find (globalName);
552 if (localMapIter == localTimerData.end()) {
553 if (alwaysWriteLocal) {
569 localMapIter = localTimerData.insert (localMapIter, makeEmptyTimerDatum (globalName));
579 globalMapIter = globalTimerData.insert (globalMapIter, makeEmptyTimerDatum (globalName));
585 globalMapIter = globalTimerData.insert (globalMapIter, std::make_pair (globalName, localMapIter->second));
589 if (alwaysWriteLocal) {
592 std::sort (localTimerNames.
begin(), localTimerNames.
end());
599 const timer_map_t::size_type myNumGlobalTimers = globalTimerData.size();
600 timer_map_t::size_type minNumGlobalTimers = 0;
601 timer_map_t::size_type maxNumGlobalTimers = 0;
603 outArg (minNumGlobalTimers));
605 outArg (maxNumGlobalTimers));
607 std::logic_error,
"Min # global timers = " << minNumGlobalTimers
608 <<
" != max # global timers = " << maxNumGlobalTimers
609 <<
". Please report this bug to the Teuchos developers.");
611 std::logic_error,
"My # global timers = " << myNumGlobalTimers
612 <<
" != min # global timers = " << minNumGlobalTimers
613 <<
". Please report this bug to the Teuchos developers.");
615 #endif // TEUCHOS_DEBUG 666 std::vector<std::string>& statNames,
668 const timer_map_t& globalTimerData,
669 const bool ignoreZeroTimers)
673 const int numTimers =
static_cast<int> (globalTimerData.size());
674 const int numProcs = comm->getSize();
680 timingsAndCallCounts.
reserve (numTimers);
681 for (timer_map_t::const_iterator it = globalTimerData.begin();
682 it != globalTimerData.end(); ++it) {
683 timingsAndCallCounts.
push_back (it->second);
692 if (ignoreZeroTimers)
694 &timingsAndCallCounts[0], &minTimingsAndCallCounts[0]);
697 &timingsAndCallCounts[0], &minTimingsAndCallCounts[0]);
707 &timingsAndCallCounts[0], &maxTimingsAndCallCounts[0]);
725 Array<int> numProcsCallingEachTimer (numTimers);
728 if (ignoreZeroTimers) {
729 for (
int k = 0; k < numTimers; ++k) {
730 const double callCount =
static_cast<double> (timingsAndCallCounts[k].second);
731 if (callCount > 0) ICallThisTimer[k] = 1;
732 else ICallThisTimer[k] = 0;
736 &numProcsCallingEachTimer[0]);
745 const double P =
static_cast<double> (numProcs);
747 if (ignoreZeroTimers) {
748 for (
int k = 0; k < numTimers; ++k) {
749 const double timing = timingsAndCallCounts[k].first;
750 const double callCount =
static_cast<double> (timingsAndCallCounts[k].second);
752 scaledTimings[k] = timing / numProcsCallingEachTimer[k];
753 scaledCallCounts[k] = callCount / numProcsCallingEachTimer[k];
757 for (
int k = 0; k < numTimers; ++k) {
758 const double timing = timingsAndCallCounts[k].first;
759 const double callCount =
static_cast<double> (timingsAndCallCounts[k].second);
761 scaledTimings[k] = timing / P;
762 scaledCallCounts[k] = callCount / P;
768 &meanOverProcsTimings[0]);
774 for (
int k = 0; k < numTimers; ++k) {
776 meanOverCallCountsTimings[k] = meanOverProcsTimings[k] / meanCallCounts[k];
788 statNames.resize (4);
789 statNames[0] =
"MinOverProcs";
790 statNames[1] =
"MeanOverProcs";
791 statNames[2] =
"MaxOverProcs";
792 statNames[3] =
"MeanOverCallCounts";
794 stat_map_type::iterator statIter = statData.end();
795 timer_map_t::const_iterator it = globalTimerData.begin();
796 for (
int k = 0; it != globalTimerData.end(); ++k, ++it) {
797 std::vector<std::pair<double, double> > curData (4);
798 curData[0] = minTimingsAndCallCounts[k];
799 curData[1] = std::make_pair (meanOverProcsTimings[k], meanCallCounts[k]);
800 curData[2] = maxTimingsAndCallCounts[k];
801 curData[3] = std::make_pair (meanOverCallCountsTimings[k], meanCallCounts[k]);
806 statIter = statData.insert (statIter, std::make_pair (it->first, curData));
839 int mpiHasBeenStarted = 0;
840 MPI_Initialized (&mpiHasBeenStarted);
841 if (! mpiHasBeenStarted) {
855 std::vector<std::string>& statNames,
858 const std::string& filter)
864 timer_map_t localTimerData;
866 const bool writeZeroTimers =
false;
867 collectLocalTimerDataAndNames (localTimerData, localTimerNames,
868 counters(), writeZeroTimers, filter);
871 timer_map_t globalTimerData;
873 const bool alwaysWriteLocal =
false;
874 collectGlobalTimerData (globalTimerData, globalTimerNames,
875 localTimerData, localTimerNames,
876 comm, alwaysWriteLocal, setOp);
878 computeGlobalTimerStats (statData, statNames, comm, globalTimerData,
false);
885 const bool alwaysWriteLocal,
886 const bool writeGlobalStats,
887 const bool writeZeroTimers,
889 const std::string& filter,
890 const bool ignoreZeroTimers)
897 const int numProcs = comm->getSize();
898 const int myRank = comm->getRank();
904 timer_map_t localTimerData;
906 collectLocalTimerDataAndNames (localTimerData, localTimerNames,
907 counters(), writeZeroTimers, filter);
913 timer_map_t globalTimerData;
916 std::vector<std::string> statNames;
917 if (writeGlobalStats) {
918 collectGlobalTimerData (globalTimerData, globalTimerNames,
919 localTimerData, localTimerNames,
920 comm, alwaysWriteLocal, setOp);
925 computeGlobalTimerStats (statData, statNames, comm, globalTimerData, ignoreZeroTimers);
948 titles.
append (
"Timer Name");
951 TableColumn nameCol (writeGlobalStats ? globalTimerNames : localTimerNames);
952 tableColumns.
append (nameCol);
957 columnWidths.
append (
format().computeRequiredColumnWidth (titles.
back(), nameCol));
967 if (alwaysWriteLocal && numProcs > 1 && myRank == 0) {
968 titles.
append (
"Local time (num calls)");
974 for (timer_map_t::const_iterator it = localTimerData.begin();
975 it != localTimerData.end(); ++it) {
976 localTimings.
push_back (it->second.first);
977 localNumCalls.
push_back (static_cast<double> (it->second.second));
979 TableColumn timeAndCalls (localTimings, localNumCalls, precision,
true);
980 tableColumns.
append (timeAndCalls);
981 columnWidths.
append (
format().computeRequiredColumnWidth (titles.
back(), timeAndCalls));
984 if (writeGlobalStats) {
993 for (timer_map_t::const_iterator it = globalTimerData.begin();
994 it != globalTimerData.end(); ++it) {
995 globalTimings.
push_back (it->second.first);
996 globalNumCalls.
push_back (static_cast<double> (it->second.second));
999 titles.
append (
"Global time (num calls)");
1000 TableColumn timeAndCalls (globalTimings, globalNumCalls, precision,
true);
1001 tableColumns.
append (timeAndCalls);
1002 columnWidths.
append (
format().computeRequiredColumnWidth (titles.
back(), timeAndCalls));
1009 const timer_map_t::size_type numGlobalTimers = globalTimerData.
size();
1010 for (std::vector<std::string>::size_type statInd = 0; statInd < statNames.size(); ++statInd) {
1015 stat_map_type::const_iterator it = statData.begin();
1016 for (
int k = 0; it != statData.end(); ++it, ++k) {
1017 statTimings[k] = (it->second[statInd]).first;
1018 statCallCounts[k] = (it->second[statInd]).second;
1021 const std::string& statisticName = statNames[statInd];
1022 const std::string titleString = statisticName;
1023 titles.
append (titleString);
1024 TableColumn timeAndCalls (statTimings, statCallCounts, precision,
true);
1025 tableColumns.
append (timeAndCalls);
1026 columnWidths.
append (
format().computeRequiredColumnWidth (titles.
back(), timeAndCalls));
1034 std::ostringstream theTitle;
1035 theTitle <<
"TimeMonitor results over " << numProcs <<
" processor" 1036 << (numProcs > 1 ?
"s" :
"");
1043 const bool alwaysWriteLocal,
1044 const bool writeGlobalStats,
1045 const bool writeZeroTimers,
1047 const std::string& filter,
1048 const bool ignoreZeroTimers)
1056 writeGlobalStats, writeZeroTimers, setOp, filter, ignoreZeroTimers);
1061 std::vector<std::string>& statNames,
1063 const std::string& filter)
1099 quoteLabelForYaml (
const std::string& label)
1104 if (label.empty ()) {
1111 const bool alreadyQuoted = label.size () >= 2 &&
1112 label[0] ==
'"' && label[label.size() - 1] ==
'"';
1117 bool needToQuote =
false;
1120 out.reserve (label.size ());
1122 const size_t startPos = alreadyQuoted ? 1 : 0;
1123 const size_t endPos = alreadyQuoted ? label.size () - 1 : label.size ();
1124 for (
size_t i = startPos; i < endPos; ++i) {
1125 const char c = label[i];
1126 if (c ==
'"' || c ==
'\\') {
1127 out.push_back (
'\\');
1130 else if (c ==
':') {
1136 if (needToQuote || alreadyQuoted) {
1139 return "\"" + out +
"\"";
1152 const ETimeMonitorYamlFormat yamlStyle,
1153 const std::string& filter)
1156 using Teuchos::fancyOStream;
1157 using Teuchos::getFancyOStream;
1160 using Teuchos::rcpFromRef;
1162 typedef std::vector<std::string>::size_type size_type;
1164 const bool compact = (yamlStyle == YAML_FORMAT_COMPACT);
1172 std::vector<std::string> statNames;
1175 const int numProcs = comm->getSize();
1189 pfout->setTabIndentStr (
" ");
1192 fout <<
"# Teuchos::TimeMonitor report" << endl
1204 fout <<
"Output mode: " << (compact ?
"compact" :
"spacious") << endl
1205 <<
"Number of processes: " << numProcs << endl
1206 <<
"Time unit: s" << endl;
1210 fout <<
"Statistics collected: ";
1214 for (size_type i = 0; i < statNames.size (); ++i) {
1215 fout << quoteLabelForYaml (statNames[i]);
1216 if (i + 1 < statNames.size ()) {
1220 fout <<
"]" << endl;
1225 for (size_type i = 0; i < statNames.size (); ++i) {
1226 fout <<
"- " << quoteLabelForYaml (statNames[i]) << endl;
1235 fout <<
"Timer names: ";
1239 for (stat_map_type::const_iterator it = statData.begin();
1240 it != statData.end(); ++it, ++ind) {
1241 fout << quoteLabelForYaml (it->first);
1242 if (ind + 1 < statData.size ()) {
1246 fout <<
"]" << endl;
1251 for (stat_map_type::const_iterator it = statData.begin();
1252 it != statData.end(); ++it) {
1253 fout <<
"- " << quoteLabelForYaml (it->first) << endl;
1258 fout <<
"Total times: ";
1261 size_type outerInd = 0;
1262 for (stat_map_type::const_iterator outerIter = statData.begin();
1263 outerIter != statData.end(); ++outerIter, ++outerInd) {
1265 fout << quoteLabelForYaml (outerIter->first) <<
": ";
1267 const std::vector<std::pair<double, double> >& curData = outerIter->second;
1269 for (size_type innerInd = 0; innerInd < curData.size (); ++innerInd) {
1270 fout << quoteLabelForYaml (statNames[innerInd]) <<
": " 1271 << curData[innerInd].first;
1272 if (innerInd + 1 < curData.size ()) {
1277 if (outerInd + 1 < statData.size ()) {
1281 fout <<
"}" << endl;
1286 size_type outerInd = 0;
1287 for (stat_map_type::const_iterator outerIter = statData.begin();
1288 outerIter != statData.end(); ++outerIter, ++outerInd) {
1290 fout << quoteLabelForYaml (outerIter->first) <<
": " << endl;
1293 const std::vector<std::pair<double, double> >& curData = outerIter->second;
1294 for (size_type innerInd = 0; innerInd < curData.size (); ++innerInd) {
1295 fout << quoteLabelForYaml (statNames[innerInd]) <<
": " 1296 << curData[innerInd].first << endl;
1302 fout <<
"Call counts:";
1305 size_type outerInd = 0;
1306 for (stat_map_type::const_iterator outerIter = statData.begin();
1307 outerIter != statData.end(); ++outerIter, ++outerInd) {
1309 fout << quoteLabelForYaml (outerIter->first) <<
": ";
1311 const std::vector<std::pair<double, double> >& curData = outerIter->second;
1313 for (size_type innerInd = 0; innerInd < curData.size (); ++innerInd) {
1314 fout << quoteLabelForYaml (statNames[innerInd]) <<
": " 1315 << curData[innerInd].second;
1316 if (innerInd + 1 < curData.size ()) {
1321 if (outerInd + 1 < statData.size ()) {
1325 fout <<
"}" << endl;
1330 size_type outerInd = 0;
1331 for (stat_map_type::const_iterator outerIter = statData.begin();
1332 outerIter != statData.end(); ++outerIter, ++outerInd) {
1334 fout << quoteLabelForYaml (outerIter->first) <<
": " << endl;
1337 const std::vector<std::pair<double, double> >& curData = outerIter->second;
1338 for (size_type innerInd = 0; innerInd < curData.size (); ++innerInd) {
1339 fout << quoteLabelForYaml (statNames[innerInd]) <<
": " 1340 << curData[innerInd].second << endl;
1347 summarizeToYaml (std::ostream &out,
1348 const ETimeMonitorYamlFormat yamlStyle,
1349 const std::string& filter)
1356 summarizeToYaml (comm.
ptr (), out, yamlStyle, filter);
1361 bool TimeMonitor::setParams_ =
false;
1364 TimeMonitor::ETimeMonitorReportFormat TimeMonitor::reportFormat_ = TimeMonitor::REPORT_FORMAT_TABLE;
1365 TimeMonitor::ETimeMonitorYamlFormat TimeMonitor::yamlStyle_ = TimeMonitor::YAML_FORMAT_SPACIOUS;
1367 bool TimeMonitor::alwaysWriteLocal_ =
false;
1368 bool TimeMonitor::writeGlobalStats_ =
true;
1369 bool TimeMonitor::writeZeroTimers_ =
true;
1372 TimeMonitor::setReportFormatParameter (
ParameterList& plist)
1374 const std::string name (
"Report format");
1375 const std::string defaultValue (
"Table");
1376 const std::string docString (
"Output format for report of timer statistics");
1382 docs.
push_back (
"YAML (see yaml.org) format");
1385 docs.
push_back (
"Tabular format via Teuchos::TableFormat");
1388 setStringToIntegralParameter<ETimeMonitorReportFormat> (name, defaultValue,
1390 strings (), docs (),
1397 const std::string name (
"YAML style");
1398 const std::string defaultValue (
"spacious");
1399 const std::string docString (
"YAML-specific output format");
1405 docs.
push_back (
"Compact format: use \"flow style\" (see YAML 1.2 spec at " 1406 "yaml.org) for most sequences except the outermost sequence");
1410 docs.
push_back (
"Spacious format: avoid flow style");
1411 values.
push_back (YAML_FORMAT_SPACIOUS);
1413 setStringToIntegralParameter<ETimeMonitorYamlFormat> (name, defaultValue,
1415 strings (), docs (),
1422 const std::string name (
"How to merge timer sets");
1423 const std::string defaultValue (
"Intersection");
1424 const std::string docString (
"How to merge differing sets of timers " 1425 "across processes");
1431 docs.
push_back (
"Compute intersection of timer sets over processes");
1434 docs.
push_back (
"Compute union of timer sets over processes");
1437 setStringToIntegralParameter<ECounterSetOp> (name, defaultValue, docString,
1438 strings (), docs (), values (),
1450 const bool alwaysWriteLocal =
false;
1451 const bool writeGlobalStats =
true;
1452 const bool writeZeroTimers =
true;
1454 setReportFormatParameter (*plist);
1455 setYamlFormatParameter (*plist);
1456 setSetOpParameter (*plist);
1457 plist->set (
"alwaysWriteLocal", alwaysWriteLocal,
1458 "Always output local timers' values on Proc 0");
1459 plist->set (
"writeGlobalStats", writeGlobalStats,
"Always output global " 1460 "statistics, even if there is only one process in the " 1462 plist->set (
"writeZeroTimers", writeZeroTimers,
"Generate output for " 1463 "timers that have never been called");
1471 ETimeMonitorReportFormat reportFormat = REPORT_FORMAT_TABLE;
1472 ETimeMonitorYamlFormat yamlStyle = YAML_FORMAT_SPACIOUS;
1474 bool alwaysWriteLocal =
false;
1475 bool writeGlobalStats =
true;
1476 bool writeZeroTimers =
true;
1488 reportFormat = getIntegralValue<ETimeMonitorReportFormat> (*params,
"Report format");
1489 yamlStyle = getIntegralValue<ETimeMonitorYamlFormat> (*params,
"YAML style");
1490 setOp = getIntegralValue<ECounterSetOp> (*params,
"How to merge timer sets");
1491 alwaysWriteLocal = params->
get<
bool> (
"alwaysWriteLocal");
1492 writeGlobalStats = params->get<
bool> (
"writeGlobalStats");
1493 writeZeroTimers = params->get<
bool> (
"writeZeroTimers");
1498 reportFormat_ = reportFormat;
1499 yamlStyle_ = yamlStyle;
1501 alwaysWriteLocal_ = alwaysWriteLocal;
1502 writeGlobalStats_ = writeGlobalStats;
1503 writeZeroTimers_ = writeZeroTimers;
1511 const std::string& filter,
1514 setReportParameters (params);
1516 if (reportFormat_ == REPORT_FORMAT_YAML) {
1517 summarizeToYaml (comm, out, yamlStyle_, filter);
1519 else if (reportFormat_ == REPORT_FORMAT_TABLE) {
1520 summarize (comm, out, alwaysWriteLocal_, writeGlobalStats_,
1521 writeZeroTimers_, setOp_, filter);
1525 "Invalid report format. This should never happen; ParameterList " 1526 "validation should have caught this. Please report this bug to the " 1527 "Teuchos developers.");
1536 report (comm, out,
"", params);
1541 const std::string& filter,
1545 report (comm.
ptr (), out, filter, params);
void reserve(size_type n)
Array< T > & append(const T &x)
Add a new entry at the end of the array.
std::map< std::string, std::vector< std::pair< double, double > > > stat_map_type
Global statistics collected from timer data.
basic_OSTab< char > OSTab
TimeMonitor(Time &timer, bool reset=false)
Constructor: starts the timer.
~TimeMonitor()
Destructor: stops the timer.
basic_FancyOStream< char > FancyOStream
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
static void disableTimer(const std::string &name)
Disable the timer with the given name.
Teuchos version of MPI_MINLOC.
T * get() const
Get the raw C++ pointer to the underlying object.
Concrete serial communicator subclass.
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
Return the default global communicator.
Tabbing class for helping to create formated, indented output for a basic_FancyOStream object...
static RCP< const ParameterList > getValidReportParameters()
Default parameters (with validators) for report().
This structure defines some basic traits for a scalar field type.
Teuchos version of MPI_MAXLOC.
Base interface class for user-defined reduction operations for objects that use value semantics...
void reduce(const Ordinal count, const std::pair< ScalarType, IndexType > inBuffer[], std::pair< ScalarType, IndexType > inoutBuffer[]) const
void start(bool reset=false)
Start the timer, if the timer is enabled (see disable()).
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
A column of TableEntry objects.
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.
double stop()
Stop the timer, if the timer is enabled (see disable()).
std::ostream subclass that performs the magic of indenting data sent to an std::ostream object among ...
Ptr< T > ptr() const
Get a safer wrapper raw C++ pointer to the underlying object.
static void computeGlobalTimerStatistics(stat_map_type &statData, std::vector< std::string > &statNames, Ptr< const Comm< int > > comm, const ECounterSetOp setOp=Intersection, const std::string &filter="")
Compute global timer statistics for all timers on the given communicator.
TEUCHOS_DEPRECATED void reduceAll(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *globalReduct)
Deprecated .
void mergeCounterNames(const Comm< int > &comm, const Array< std::string > &localNames, Array< std::string > &globalNames, const ECounterSetOp setOp)
Merge counter names over all processors.
A list of parameters of arbitrary type.
std::vector< T >::const_iterator const_iterator
The type of a const forward iterator.
Abstract interface for distributed-memory communication.
void push_back(const value_type &x)
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos, as well as a number of utility routines.
Defines basic traits for the scalar field type.
static T zero()
Returns representation of zero for this scalar type.
Scope protection wrapper for Teuchos::Time, with timer reporting functionality.
Smart reference counting pointer class for automatic garbage collection.
ECounterSetOp
Set operation type for mergeCounterNames() to perform.
same as MinLoc, but don't allow zero
Simple wrapper class for raw pointers to single objects where no persisting relationship exists...
static void enableTimer(const std::string &name)
Enable the timer with the given name.
static void zeroOutTimers()
Reset all global timers to zero.
static void report(Ptr< const Comm< int > > comm, std::ostream &out, const std::string &filter, const RCP< ParameterList > ¶ms=null)
Report timer statistics to the given output stream.
bool is_null() const
Returns true if the underlying pointer is null.