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);
207 typedef std::map<std::string, std::pair<double, int> > timer_map_t;
224 timer == null, std::invalid_argument,
225 "TimeMonitor::disableTimer: Invalid timer \"" << name <<
"\"");
234 timer == null, std::invalid_argument,
235 "TimeMonitor::enableTimer: Invalid timer \"" << name <<
"\"");
242 typedef std::map<std::string, RCP<Time> > map_type;
243 typedef map_type::iterator iter_type;
251 for (iter_type it = ctrs.begin(); it != ctrs.end(); ++it) {
257 it->second->isRunning (), std::runtime_error,
258 "Timer \"" << it->second->name () <<
"\" is currently running. "
259 "You are not allowed to reset running timers.");
261 #endif // TEUCHOS_DEBUG
263 for (iter_type it = ctrs.begin(); it != ctrs.end(); ++it) {
264 it->second->reset ();
277 std::pair<std::string, std::pair<double, int> >
278 makeEmptyTimerDatum (
const std::string& name)
280 return std::make_pair (name, std::make_pair (
double(0),
int(0)));
301 collectLocalTimerData (timer_map_t& localData,
302 const std::map<std::string, RCP<Time> >& localCounters,
303 const std::string& filter=
"")
305 using std::make_pair;
306 typedef timer_map_t::iterator iter_t;
308 timer_map_t theLocalData;
309 for (std::map<std::string, RCP<Time> >::const_iterator it = localCounters.begin();
310 it != localCounters.end(); ++it) {
311 const std::string& name = it->second->name ();
315 const bool skipThisOne = (filter !=
"" && name.find (filter) != 0);
317 const double timing = it->second->totalElapsedTime ();
318 const int numCalls = it->second->numCalls ();
322 iter_t loc = theLocalData.find (name);
323 if (loc == theLocalData.end()) {
325 theLocalData.insert (loc, make_pair (name, make_pair (timing, numCalls)));
328 loc->second.first += timing;
329 loc->second.second += numCalls;
335 localData.swap (theLocalData);
342 filterZeroData (timer_map_t& timerData)
346 timer_map_t newTimerData;
347 for (timer_map_t::const_iterator it = timerData.begin();
348 it != timerData.end(); ++it) {
349 if (it->second.second > 0) {
350 newTimerData[it->first] = it->second;
353 timerData.swap (newTimerData);
378 collectLocalTimerDataAndNames (timer_map_t& localTimerData,
379 Array<std::string>& localTimerNames,
380 const std::map<std::string, RCP<Time> >& localTimers,
381 const bool writeZeroTimers,
382 const std::string& filter=
"")
385 collectLocalTimerData (localTimerData, localTimers, filter);
391 if (! writeZeroTimers) {
392 filterZeroData (localTimerData);
397 localTimerNames.reserve (localTimerData.size());
398 for (timer_map_t::const_iterator it = localTimerData.begin();
399 it != localTimerData.end(); ++it) {
400 localTimerNames.push_back (it->first);
439 collectGlobalTimerData (timer_map_t& globalTimerData,
440 Array<std::string>& globalTimerNames,
441 timer_map_t& localTimerData,
442 Array<std::string>& localTimerNames,
443 Ptr<
const Comm<int> > comm,
444 const bool alwaysWriteLocal,
473 const timer_map_t::size_type myNumGlobalNames = globalTimerNames.size();
474 timer_map_t::size_type minNumGlobalNames = 0;
475 timer_map_t::size_type maxNumGlobalNames = 0;
477 outArg (minNumGlobalNames));
479 outArg (maxNumGlobalNames));
481 std::logic_error,
"Min # global timer names = " << minNumGlobalNames
482 <<
" != max # global timer names = " << maxNumGlobalNames
483 <<
". Please report this bug to the Teuchos developers.");
485 std::logic_error,
"My # global timer names = " << myNumGlobalNames
486 <<
" != min # global timer names = " << minNumGlobalNames
487 <<
". Please report this bug to the Teuchos developers.");
489 #endif // TEUCHOS_DEBUG
506 timer_map_t::iterator globalMapIter = globalTimerData.begin();
507 timer_map_t::iterator localMapIter;
508 for (Array<string>::const_iterator it = globalTimerNames.begin();
509 it != globalTimerNames.end(); ++it) {
510 const std::string& globalName = *it;
511 localMapIter = localTimerData.find (globalName);
513 if (localMapIter == localTimerData.end()) {
514 if (alwaysWriteLocal) {
530 localMapIter = localTimerData.insert (localMapIter, makeEmptyTimerDatum (globalName));
535 localTimerNames.push_back (globalName);
540 globalMapIter = globalTimerData.insert (globalMapIter, makeEmptyTimerDatum (globalName));
546 globalMapIter = globalTimerData.insert (globalMapIter, std::make_pair (globalName, localMapIter->second));
550 if (alwaysWriteLocal) {
553 std::sort (localTimerNames.begin(), localTimerNames.end());
560 const timer_map_t::size_type myNumGlobalTimers = globalTimerData.size();
561 timer_map_t::size_type minNumGlobalTimers = 0;
562 timer_map_t::size_type maxNumGlobalTimers = 0;
564 outArg (minNumGlobalTimers));
566 outArg (maxNumGlobalTimers));
568 std::logic_error,
"Min # global timers = " << minNumGlobalTimers
569 <<
" != max # global timers = " << maxNumGlobalTimers
570 <<
". Please report this bug to the Teuchos developers.");
572 std::logic_error,
"My # global timers = " << myNumGlobalTimers
573 <<
" != min # global timers = " << minNumGlobalTimers
574 <<
". Please report this bug to the Teuchos developers.");
576 #endif // TEUCHOS_DEBUG
618 std::vector<std::string>& statNames,
619 Ptr<
const Comm<int> > comm,
620 const timer_map_t& globalTimerData)
624 const int numTimers =
static_cast<int> (globalTimerData.size());
625 const int numProcs = comm->getSize();
630 Array<std::pair<double, int> > timingsAndCallCounts;
631 timingsAndCallCounts.reserve (numTimers);
632 for (timer_map_t::const_iterator it = globalTimerData.begin();
633 it != globalTimerData.end(); ++it) {
634 timingsAndCallCounts.push_back (it->second);
641 Array<std::pair<double, int> > minTimingsAndCallCounts (numTimers);
643 reduceAll (*comm, MinLoc<int, double, int>(), numTimers,
644 &timingsAndCallCounts[0], &minTimingsAndCallCounts[0]);
651 Array<std::pair<double, int> > maxTimingsAndCallCounts (numTimers);
653 reduceAll (*comm, MaxLoc<int, double, int>(), numTimers,
654 &timingsAndCallCounts[0], &maxTimingsAndCallCounts[0]);
668 Array<double> meanOverCallCountsTimings (numTimers);
669 Array<double> meanOverProcsTimings (numTimers);
670 Array<double> meanCallCounts (numTimers);
675 Array<double> scaledTimings (numTimers);
676 Array<double> scaledCallCounts (numTimers);
677 const double P =
static_cast<double> (numProcs);
678 for (
int k = 0; k < numTimers; ++k) {
679 const double timing = timingsAndCallCounts[k].first;
680 const double callCount =
static_cast<double> (timingsAndCallCounts[k].second);
682 scaledTimings[k] = timing / P;
683 scaledCallCounts[k] = callCount / P;
687 &meanOverProcsTimings[0]);
693 for (
int k = 0; k < numTimers; ++k) {
694 if (meanCallCounts[k] > ScalarTraits<double>::zero ()) {
695 meanOverCallCountsTimings[k] = meanOverProcsTimings[k] / meanCallCounts[k];
707 statNames.resize (4);
708 statNames[0] =
"MinOverProcs";
709 statNames[1] =
"MeanOverProcs";
710 statNames[2] =
"MaxOverProcs";
711 statNames[3] =
"MeanOverCallCounts";
713 stat_map_type::iterator statIter = statData.end();
714 timer_map_t::const_iterator it = globalTimerData.begin();
715 for (
int k = 0; it != globalTimerData.end(); ++k, ++it) {
716 std::vector<std::pair<double, double> > curData (4);
717 curData[0] = minTimingsAndCallCounts[k];
718 curData[1] = std::make_pair (meanOverProcsTimings[k], meanCallCounts[k]);
719 curData[2] = maxTimingsAndCallCounts[k];
720 curData[3] = std::make_pair (meanOverCallCountsTimings[k], meanCallCounts[k]);
725 statIter = statData.insert (statIter, std::make_pair (it->first, curData));
746 RCP<const Comm<int> >
758 int mpiHasBeenStarted = 0;
759 MPI_Initialized (&mpiHasBeenStarted);
760 if (! mpiHasBeenStarted) {
762 comm = rcp_implicit_cast<
const Comm<int> > (
rcp (
new SerialComm<int> ()));
774 std::vector<std::string>& statNames,
777 const std::string& filter)
783 timer_map_t localTimerData;
785 const bool writeZeroTimers =
false;
786 collectLocalTimerDataAndNames (localTimerData, localTimerNames,
787 counters(), writeZeroTimers, filter);
790 timer_map_t globalTimerData;
792 const bool alwaysWriteLocal =
false;
793 collectGlobalTimerData (globalTimerData, globalTimerNames,
794 localTimerData, localTimerNames,
795 comm, alwaysWriteLocal, setOp);
797 computeGlobalTimerStats (statData, statNames, comm, globalTimerData);
804 const bool alwaysWriteLocal,
805 const bool writeGlobalStats,
806 const bool writeZeroTimers,
808 const std::string& filter)
815 const int numProcs = comm->getSize();
816 const int myRank = comm->getRank();
822 timer_map_t localTimerData;
824 collectLocalTimerDataAndNames (localTimerData, localTimerNames,
825 counters(), writeZeroTimers, filter);
831 timer_map_t globalTimerData;
834 std::vector<std::string> statNames;
835 if (writeGlobalStats) {
836 collectGlobalTimerData (globalTimerData, globalTimerNames,
837 localTimerData, localTimerNames,
838 comm, alwaysWriteLocal, setOp);
843 computeGlobalTimerStats (statData, statNames, comm, globalTimerData);
866 titles.
append (
"Timer Name");
869 TableColumn nameCol (writeGlobalStats ? globalTimerNames : localTimerNames);
870 tableColumns.
append (nameCol);
875 columnWidths.
append (
format().computeRequiredColumnWidth (titles.
back(), nameCol));
885 if (alwaysWriteLocal && numProcs > 1 && myRank == 0) {
886 titles.
append (
"Local time (num calls)");
892 for (timer_map_t::const_iterator it = localTimerData.begin();
893 it != localTimerData.end(); ++it) {
894 localTimings.
push_back (it->second.first);
895 localNumCalls.
push_back (static_cast<double> (it->second.second));
897 TableColumn timeAndCalls (localTimings, localNumCalls, precision,
true);
898 tableColumns.
append (timeAndCalls);
899 columnWidths.
append (
format().computeRequiredColumnWidth (titles.
back(), timeAndCalls));
902 if (writeGlobalStats) {
911 for (timer_map_t::const_iterator it = globalTimerData.begin();
912 it != globalTimerData.end(); ++it) {
913 globalTimings.
push_back (it->second.first);
914 globalNumCalls.
push_back (static_cast<double> (it->second.second));
917 titles.
append (
"Global time (num calls)");
918 TableColumn timeAndCalls (globalTimings, globalNumCalls, precision,
true);
919 tableColumns.
append (timeAndCalls);
920 columnWidths.
append (
format().computeRequiredColumnWidth (titles.
back(), timeAndCalls));
927 const timer_map_t::size_type numGlobalTimers = globalTimerData.
size();
928 for (std::vector<std::string>::size_type statInd = 0; statInd < statNames.size(); ++statInd) {
933 stat_map_type::const_iterator it = statData.begin();
934 for (
int k = 0; it != statData.end(); ++it, ++k) {
935 statTimings[k] = (it->second[statInd]).first;
936 statCallCounts[k] = (it->second[statInd]).second;
939 const std::string& statisticName = statNames[statInd];
940 const std::string titleString = statisticName;
941 titles.
append (titleString);
942 TableColumn timeAndCalls (statTimings, statCallCounts, precision,
true);
943 tableColumns.
append (timeAndCalls);
944 columnWidths.
append (
format().computeRequiredColumnWidth (titles.
back(), timeAndCalls));
952 std::ostringstream theTitle;
953 theTitle <<
"TimeMonitor results over " << numProcs <<
" processor"
954 << (numProcs > 1 ?
"s" :
"");
961 const bool alwaysWriteLocal,
962 const bool writeGlobalStats,
963 const bool writeZeroTimers,
965 const std::string& filter)
973 writeGlobalStats, writeZeroTimers, setOp, filter);
978 std::vector<std::string>& statNames,
980 const std::string& filter)
1016 quoteLabelForYaml (
const std::string& label)
1021 if (label.empty ()) {
1028 const bool alreadyQuoted = label.size () >= 2 &&
1029 label[0] ==
'"' && label[label.size() - 1] ==
'"';
1034 bool needToQuote =
false;
1037 out.reserve (label.size ());
1039 const size_t startPos = alreadyQuoted ? 1 : 0;
1040 const size_t endPos = alreadyQuoted ? label.size () - 1 : label.size ();
1041 for (
size_t i = startPos; i < endPos; ++i) {
1042 const char c = label[i];
1043 if (c ==
'"' || c ==
'\\') {
1044 out.push_back (
'\\');
1047 else if (c ==
':') {
1053 if (needToQuote || alreadyQuoted) {
1056 return "\"" + out +
"\"";
1067 summarizeToYaml (Ptr<
const Comm<int> > comm,
1069 const ETimeMonitorYamlFormat yamlStyle,
1070 const std::string& filter)
1073 using Teuchos::fancyOStream;
1074 using Teuchos::getFancyOStream;
1077 using Teuchos::rcpFromRef;
1079 typedef std::vector<std::string>::size_type size_type;
1081 const bool compact = (yamlStyle == YAML_FORMAT_COMPACT);
1089 std::vector<std::string> statNames;
1092 const int numProcs = comm->getSize();
1105 RCP<FancyOStream> pfout = getFancyOStream (rcpFromRef (out));
1106 pfout->setTabIndentStr (
" ");
1109 fout <<
"# Teuchos::TimeMonitor report" << endl
1121 fout <<
"Output mode: " << (compact ?
"compact" :
"spacious") << endl
1122 <<
"Number of processes: " << numProcs << endl
1123 <<
"Time unit: s" << endl;
1127 fout <<
"Statistics collected: ";
1131 for (size_type i = 0; i < statNames.size (); ++i) {
1132 fout << quoteLabelForYaml (statNames[i]);
1133 if (i + 1 < statNames.size ()) {
1137 fout <<
"]" << endl;
1142 for (size_type i = 0; i < statNames.size (); ++i) {
1143 fout <<
"- " << quoteLabelForYaml (statNames[i]) << endl;
1152 fout <<
"Timer names: ";
1156 for (stat_map_type::const_iterator it = statData.begin();
1157 it != statData.end(); ++it, ++ind) {
1158 fout << quoteLabelForYaml (it->first);
1159 if (ind + 1 < statData.size ()) {
1163 fout <<
"]" << endl;
1168 for (stat_map_type::const_iterator it = statData.begin();
1169 it != statData.end(); ++it) {
1170 fout <<
"- " << quoteLabelForYaml (it->first) << endl;
1175 fout <<
"Total times: ";
1178 size_type outerInd = 0;
1179 for (stat_map_type::const_iterator outerIter = statData.begin();
1180 outerIter != statData.end(); ++outerIter, ++outerInd) {
1182 fout << quoteLabelForYaml (outerIter->first) <<
": ";
1184 const std::vector<std::pair<double, double> >& curData = outerIter->second;
1186 for (size_type innerInd = 0; innerInd < curData.size (); ++innerInd) {
1187 fout << quoteLabelForYaml (statNames[innerInd]) <<
": "
1188 << curData[innerInd].first;
1189 if (innerInd + 1 < curData.size ()) {
1194 if (outerInd + 1 < statData.size ()) {
1198 fout <<
"}" << endl;
1203 size_type outerInd = 0;
1204 for (stat_map_type::const_iterator outerIter = statData.begin();
1205 outerIter != statData.end(); ++outerIter, ++outerInd) {
1207 fout << quoteLabelForYaml (outerIter->first) <<
": " << endl;
1210 const std::vector<std::pair<double, double> >& curData = outerIter->second;
1211 for (size_type innerInd = 0; innerInd < curData.size (); ++innerInd) {
1212 fout << quoteLabelForYaml (statNames[innerInd]) <<
": "
1213 << curData[innerInd].first << endl;
1219 fout <<
"Call counts:";
1222 size_type outerInd = 0;
1223 for (stat_map_type::const_iterator outerIter = statData.begin();
1224 outerIter != statData.end(); ++outerIter, ++outerInd) {
1226 fout << quoteLabelForYaml (outerIter->first) <<
": ";
1228 const std::vector<std::pair<double, double> >& curData = outerIter->second;
1230 for (size_type innerInd = 0; innerInd < curData.size (); ++innerInd) {
1231 fout << quoteLabelForYaml (statNames[innerInd]) <<
": "
1232 << curData[innerInd].second;
1233 if (innerInd + 1 < curData.size ()) {
1238 if (outerInd + 1 < statData.size ()) {
1242 fout <<
"}" << endl;
1247 size_type outerInd = 0;
1248 for (stat_map_type::const_iterator outerIter = statData.begin();
1249 outerIter != statData.end(); ++outerIter, ++outerInd) {
1251 fout << quoteLabelForYaml (outerIter->first) <<
": " << endl;
1254 const std::vector<std::pair<double, double> >& curData = outerIter->second;
1255 for (size_type innerInd = 0; innerInd < curData.size (); ++innerInd) {
1256 fout << quoteLabelForYaml (statNames[innerInd]) <<
": "
1257 << curData[innerInd].second << endl;
1264 summarizeToYaml (std::ostream &out,
1265 const ETimeMonitorYamlFormat yamlStyle,
1266 const std::string& filter)
1271 RCP<const Comm<int> > comm = getDefaultComm ();
1273 summarizeToYaml (comm.ptr (), out, yamlStyle, filter);
1278 bool TimeMonitor::setParams_ =
false;
1281 TimeMonitor::ETimeMonitorReportFormat TimeMonitor::reportFormat_ = TimeMonitor::REPORT_FORMAT_TABLE;
1282 TimeMonitor::ETimeMonitorYamlFormat TimeMonitor::yamlStyle_ = TimeMonitor::YAML_FORMAT_SPACIOUS;
1284 bool TimeMonitor::alwaysWriteLocal_ =
false;
1285 bool TimeMonitor::writeGlobalStats_ =
true;
1286 bool TimeMonitor::writeZeroTimers_ =
true;
1289 TimeMonitor::setReportFormatParameter (ParameterList& plist)
1291 const std::string name (
"Report format");
1292 const std::string defaultValue (
"Table");
1293 const std::string docString (
"Output format for report of timer statistics");
1294 Array<std::string> strings;
1295 Array<std::string> docs;
1296 Array<ETimeMonitorReportFormat> values;
1298 strings.push_back (
"YAML");
1299 docs.push_back (
"YAML (see yaml.org) format");
1300 values.push_back (REPORT_FORMAT_YAML);
1301 strings.push_back (
"Table");
1302 docs.push_back (
"Tabular format via Teuchos::TableFormat");
1303 values.push_back (REPORT_FORMAT_TABLE);
1305 setStringToIntegralParameter<ETimeMonitorReportFormat> (name, defaultValue,
1307 strings (), docs (),
1312 TimeMonitor::setYamlFormatParameter (ParameterList& plist)
1314 const std::string name (
"YAML style");
1315 const std::string defaultValue (
"spacious");
1316 const std::string docString (
"YAML-specific output format");
1317 Array<std::string> strings;
1318 Array<std::string> docs;
1319 Array<ETimeMonitorYamlFormat> values;
1321 strings.push_back (
"compact");
1322 docs.push_back (
"Compact format: use \"flow style\" (see YAML 1.2 spec at "
1323 "yaml.org) for most sequences except the outermost sequence");
1324 values.push_back (YAML_FORMAT_COMPACT);
1326 strings.push_back (
"spacious");
1327 docs.push_back (
"Spacious format: avoid flow style");
1328 values.push_back (YAML_FORMAT_SPACIOUS);
1330 setStringToIntegralParameter<ETimeMonitorYamlFormat> (name, defaultValue,
1332 strings (), docs (),
1337 TimeMonitor::setSetOpParameter (ParameterList& plist)
1339 const std::string name (
"How to merge timer sets");
1340 const std::string defaultValue (
"Intersection");
1341 const std::string docString (
"How to merge differing sets of timers "
1342 "across processes");
1343 Array<std::string> strings;
1344 Array<std::string> docs;
1345 Array<ECounterSetOp> values;
1347 strings.push_back (
"Intersection");
1348 docs.push_back (
"Compute intersection of timer sets over processes");
1349 values.push_back (Intersection);
1350 strings.push_back (
"Union");
1351 docs.push_back (
"Compute union of timer sets over processes");
1352 values.push_back (Union);
1354 setStringToIntegralParameter<ECounterSetOp> (name, defaultValue, docString,
1355 strings (), docs (), values (),
1359 RCP<const ParameterList>
1367 const bool alwaysWriteLocal =
false;
1368 const bool writeGlobalStats =
true;
1369 const bool writeZeroTimers =
true;
1371 setReportFormatParameter (*plist);
1372 setYamlFormatParameter (*plist);
1373 setSetOpParameter (*plist);
1374 plist->set (
"alwaysWriteLocal", alwaysWriteLocal,
1375 "Always output local timers' values on Proc 0");
1376 plist->set (
"writeGlobalStats", writeGlobalStats,
"Always output global "
1377 "statistics, even if there is only one process in the "
1379 plist->set (
"writeZeroTimers", writeZeroTimers,
"Generate output for "
1380 "timers that have never been called");
1388 ETimeMonitorReportFormat reportFormat = REPORT_FORMAT_TABLE;
1389 ETimeMonitorYamlFormat yamlStyle = YAML_FORMAT_SPACIOUS;
1391 bool alwaysWriteLocal =
false;
1392 bool writeGlobalStats =
true;
1393 bool writeZeroTimers =
true;
1405 reportFormat = getIntegralValue<ETimeMonitorReportFormat> (*params,
"Report format");
1406 yamlStyle = getIntegralValue<ETimeMonitorYamlFormat> (*params,
"YAML style");
1407 setOp = getIntegralValue<ECounterSetOp> (*params,
"How to merge timer sets");
1408 alwaysWriteLocal = params->
get<
bool> (
"alwaysWriteLocal");
1409 writeGlobalStats = params->get<
bool> (
"writeGlobalStats");
1410 writeZeroTimers = params->get<
bool> (
"writeZeroTimers");
1415 reportFormat_ = reportFormat;
1416 yamlStyle_ = yamlStyle;
1418 alwaysWriteLocal_ = alwaysWriteLocal;
1419 writeGlobalStats_ = writeGlobalStats;
1420 writeZeroTimers_ = writeZeroTimers;
1428 const std::string& filter,
1431 setReportParameters (params);
1433 if (reportFormat_ == REPORT_FORMAT_YAML) {
1434 summarizeToYaml (comm, out, yamlStyle_, filter);
1436 else if (reportFormat_ == REPORT_FORMAT_TABLE) {
1437 summarize (comm, out, alwaysWriteLocal_, writeGlobalStats_,
1438 writeZeroTimers_, setOp_, filter);
1442 "Invalid report format. This should never happen; ParameterList "
1443 "validation should have caught this. Please report this bug to the "
1444 "Teuchos developers.");
1453 report (comm, out,
"", params);
1458 const std::string& filter,
1462 report (comm.
ptr (), out, filter, params);
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.
void reduce(const Ordinal count, const std::pair< ScalarType, IndexType > inBuffer[], std::pair< ScalarType, IndexType > inoutBuffer[]) const
T * get() const
Get the raw C++ pointer to the underlying object.
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
Return the default global communicator.
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...
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="")
Print summary statistics for all timers on the given communicator.
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.
double stop()
Stop the timer, if the timer is enabled (see disable()).
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.
Abstract interface for distributed-memory communication.
void push_back(const value_type &x)
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.
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.