9 #include <stk_util/diag/PrintTimer.hpp> 10 #include <stk_util/diag/PrintTable.hpp> 20 #include <stk_util/diag/Writer.hpp> 21 #include <stk_util/diag/WriterManip.hpp> 22 #include <stk_util/diag/WriterExt.hpp> 23 #include <stk_util/util/string_case_compare.hpp> 24 #include <stk_util/util/Marshal.hpp> 33 Marshal &operator<<(Marshal &mout, const diag::Timer::Metric<T> &t);
35 Marshal &
operator<<(Marshal &mout,
const diag::Timer &t);
37 Marshal &operator>>(Marshal &min, diag::ParallelTimer &t);
53 Percent(
double numerator,
double denominator)
54 : m_numerator(numerator),
55 m_denominator(denominator)
68 std::ostream &operator()(std::ostream &os)
const;
78 std::ostream & os)
const 80 std::ostringstream strout;
82 if (m_numerator == 0.0)
84 else if (m_denominator == 0.0)
87 double ratio = m_numerator/m_denominator*100.0;
90 else if (ratio >= 100.0)
96 return os << strout.str();
109 inline std::ostream &
operator<<(std::ostream &os,
const Percent &p) {
115 template <
typename T>
121 m_min(
std::numeric_limits<double>::max()),
125 typename MetricTraits<T>::Type m_value;
126 typename MetricTraits<T>::Type m_checkpoint;
131 void accumulate(
const Metric<T> &metric,
bool checkpoint) {
132 double value =
static_cast<double>(metric.m_value);
134 value -=
static_cast<double>(metric.m_checkpoint);
137 m_min = std::min(m_min, value);
138 m_max = std::max(m_max, value);
141 Writer &
dump(Writer &dout)
const {
142 if (
dout.shouldPrint()) {
143 dout <<
"Metric<" <<
typeid(
typename MetricTraits<T>::Type) <<
">" << push <<
dendl;
145 dout <<
"m_checkpoint " << m_value <<
dendl;
158 m_subtimerLapCount(0),
168 ParallelTimer(
const ParallelTimer ¶llel_timer)
169 : m_name(parallel_timer.m_name),
170 m_timerMask(parallel_timer.m_timerMask),
171 m_subtimerLapCount(parallel_timer.m_subtimerLapCount),
172 m_lapCount(parallel_timer.m_lapCount),
173 m_cpuTime(parallel_timer.m_cpuTime),
174 m_wallTime(parallel_timer.m_wallTime),
175 m_MPICount(parallel_timer.m_MPICount),
176 m_MPIByteCount(parallel_timer.m_MPIByteCount),
177 m_heapAlloc(parallel_timer.m_heapAlloc),
178 m_subtimerList(parallel_timer.m_subtimerList)
181 ParallelTimer &operator=(
const ParallelTimer ¶llel_timer) {
182 m_name = parallel_timer.m_name;
183 m_timerMask = parallel_timer.m_timerMask;
184 m_subtimerLapCount = parallel_timer.m_subtimerLapCount;
185 m_lapCount = parallel_timer.m_lapCount;
186 m_cpuTime = parallel_timer.m_cpuTime;
187 m_wallTime = parallel_timer.m_wallTime;
188 m_MPICount = parallel_timer.m_MPICount;
189 m_heapAlloc = parallel_timer.m_heapAlloc;
190 m_subtimerList = parallel_timer.m_subtimerList;
196 const Metric<T> &getMetric()
const;
199 TimerMask m_timerMask;
200 double m_subtimerLapCount;
202 Metric<LapCount> m_lapCount;
203 Metric<CPUTime> m_cpuTime;
204 Metric<WallTime> m_wallTime;
205 Metric<MPICount> m_MPICount;
206 Metric<MPIByteCount> m_MPIByteCount;
207 Metric<HeapAlloc> m_heapAlloc;
209 std::list<ParallelTimer> m_subtimerList;
211 Writer &
dump(Writer &dout)
const;
215 const ParallelTimer::Metric<LapCount> &
216 ParallelTimer::getMetric<LapCount>()
const {
222 const ParallelTimer::Metric<CPUTime> &
223 ParallelTimer::getMetric<CPUTime>()
const {
229 const ParallelTimer::Metric<WallTime> &
230 ParallelTimer::getMetric<WallTime>()
const {
236 const ParallelTimer::Metric<MPICount> &
237 ParallelTimer::getMetric<MPICount>()
const {
243 const ParallelTimer::Metric<MPIByteCount> &
244 ParallelTimer::getMetric<MPIByteCount>()
const {
245 return m_MPIByteCount;
250 const ParallelTimer::Metric<HeapAlloc> &
251 ParallelTimer::getMetric<HeapAlloc>()
const {
256 template <
typename T>
257 Writer &operator<<(Writer &dout, const ParallelTimer::Metric<T> &t) {
261 Writer &
operator<<(Writer &dout,
const ParallelTimer ¶llel_timer) {
262 return parallel_timer.dump(dout);
267 if (
dout.shouldPrint()) {
268 dout <<
"ParallelTimer " << m_name << push <<
dendl;
270 dout <<
"m_timerMask " << hex << m_timerMask <<
dendl;
271 dout <<
"m_subtimerLapCount " << m_subtimerLapCount <<
dendl;
272 dout <<
"m_lapCount " << m_lapCount <<
dendl;
273 dout <<
"m_cpuTime " << m_cpuTime <<
dendl;
274 dout <<
"m_wallTime " << m_wallTime <<
dendl;
275 dout <<
"m_MPICount " << m_MPICount <<
dendl;
276 dout <<
"m_MPIByteCount " << m_MPIByteCount <<
dendl;
277 dout <<
"m_heapAlloc " << m_heapAlloc <<
dendl;
278 dout <<
"m_subtimerList " << m_subtimerList <<
dendl;
284 #ifdef __INTEL_COMPILER 285 #pragma warning(push) 286 #pragma warning(disable: 444) 288 class finder :
public std::unary_function<ParallelTimer, bool>
291 finder(
const std::string &name)
295 bool operator()(
const ParallelTimer ¶llel_timer)
const {
296 return equal_case(parallel_timer.m_name, m_name);
302 #ifdef __INTEL_COMPILER 308 merge_parallel_timer(
310 const ParallelTimer & p1,
313 p0.m_timerMask = p1.m_timerMask;
314 p0.m_subtimerLapCount += p1.m_subtimerLapCount;
315 p0.m_lapCount.accumulate(p1.m_lapCount, checkpoint);
316 p0.m_cpuTime.accumulate(p1.m_cpuTime, checkpoint);
317 p0.m_wallTime.accumulate(p1.m_wallTime, checkpoint);
318 p0.m_MPICount.accumulate(p1.m_MPICount, checkpoint);
319 p0.m_MPIByteCount.accumulate(p1.m_MPIByteCount, checkpoint);
320 p0.m_heapAlloc.accumulate(p1.m_heapAlloc, checkpoint);
323 for (std::list<ParallelTimer>::const_iterator p1_it = p1.m_subtimerList.begin(); p1_it != p1.m_subtimerList.end(); ++p1_it) {
324 std::list<ParallelTimer>::iterator p0_it = std::find_if(p0.m_subtimerList.begin(), p0.m_subtimerList.end(), finder((*p1_it).m_name));
325 if (p0_it == p0.m_subtimerList.end()) {
326 p0.m_subtimerList.push_back((*p1_it));
327 p0_it = --p0.m_subtimerList.end();
328 merge_parallel_timer(*p0_it, *p1_it, checkpoint);
331 merge_parallel_timer(*p0_it, *p1_it, checkpoint);
339 ParallelTimer & parallel_timer,
347 const int parallel_root = 0 ;
352 std::string send_string(mout.str());
354 ParallelTimer root_parallel_timer;
368 std::vector<char> buffer;
370 for(
int ii=0; ii<num_cycles; ++ii) {
372 int *
const recv_count_ptr = &recv_count[0] ;
375 int send_count = send_string.size();
382 int result = MPI_Gather(&send_count, 1, MPI_INT,
383 recv_count_ptr, 1, MPI_INT,
384 parallel_root, comm);
385 if (MPI_SUCCESS != result) {
386 std::ostringstream message ;
387 message <<
"stk_classic::diag::collect_timers FAILED: MPI_Gather = " << result ;
388 throw std::runtime_error(message.str());
395 recv_displ[i + 1] = recv_displ[i] + recv_count[i] ;
400 buffer.assign(recv_size, 0);
403 const char *
const send_ptr = send_string.data();
404 char *
const recv_ptr = recv_size ? & buffer[0] : 0;
405 int *
const recv_displ_ptr = & recv_displ[0] ;
407 result = MPI_Gatherv((
void *) send_ptr, send_count, MPI_CHAR,
408 recv_ptr, recv_count_ptr, recv_displ_ptr, MPI_CHAR,
409 parallel_root, comm);
410 if (MPI_SUCCESS != result) {
411 std::ostringstream message ;
412 message <<
"stk_classic::diag::collect_timers FAILED: MPI_Gatherv = " << result ;
413 throw std::runtime_error(message.str());
416 std::vector<ParallelTimer> parallel_timer_vector;
421 int received_count = recv_displ[j+1] - recv_displ[j];
422 if (received_count > 0) {
424 parallel_timer_vector.resize(parallel_timer_vector.size()+1);
425 Marshal min(std::string(recv_ptr + recv_displ[j], recv_ptr + recv_displ[j + 1]));
427 min >> parallel_timer_vector[parallel_timer_vector.size()-1];
431 if (
parallel_rank==parallel_root && send_count>0) root_parallel_timer = parallel_timer_vector[0];
433 for (
size_t j = 0; j < parallel_timer_vector.size(); ++j)
434 merge_parallel_timer(root_parallel_timer, parallel_timer_vector[j], checkpoint);
438 parallel_timer = root_parallel_timer;
447 const Timer & root_timer,
449 MetricsMask metrics_mask,
451 bool timer_checkpoint)
454 if (timer.shouldRecord()) {
455 if (timer.
getTimerMask() == 0 || timer.
getMetric<LapCount>().getAccumulatedLap(timer_checkpoint) > 0) {
456 table << justify(PrintTable::Cell::LEFT) << indent(depth) << timer.
getName() << end_col
457 << justify(PrintTable::Cell::RIGHT) << timer.
getMetric<LapCount>().getAccumulatedLap(timer_checkpoint) << end_col;
459 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<CPUTime>::METRIC)
460 table << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<CPUTime>::format(timer.
getMetric<CPUTime>().getAccumulatedLap(timer_checkpoint))
461 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<CPUTime>().getAccumulatedLap(timer_checkpoint), root_timer.getMetric<CPUTime>().getAccumulatedLap(timer_checkpoint)) << end_col;
462 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<WallTime>::METRIC)
463 table << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<WallTime>::format(timer.
getMetric<WallTime>().getAccumulatedLap(timer_checkpoint))
464 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<WallTime>().getAccumulatedLap(timer_checkpoint), root_timer.getMetric<WallTime>().getAccumulatedLap(timer_checkpoint)) << end_col;
465 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<MPICount>::METRIC)
466 table << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<MPICount>::format(timer.
getMetric<MPICount>().getAccumulatedLap(timer_checkpoint))
467 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<MPICount>().getAccumulatedLap(timer_checkpoint), root_timer.getMetric<MPICount>().getAccumulatedLap(timer_checkpoint)) << end_col;
468 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<MPIByteCount>::METRIC)
469 table << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<MPIByteCount>::format(timer.
getMetric<MPIByteCount>().getAccumulatedLap(timer_checkpoint))
470 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<MPIByteCount>().getAccumulatedLap(timer_checkpoint), root_timer.getMetric<MPIByteCount>().getAccumulatedLap(timer_checkpoint)) << end_col;
471 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<HeapAlloc>::METRIC)
472 table << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<HeapAlloc>::format(timer.
getMetric<HeapAlloc>().getAccumulatedLap(timer_checkpoint))
473 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<HeapAlloc>().getAccumulatedLap(timer_checkpoint), root_timer.getMetric<HeapAlloc>().getAccumulatedLap(timer_checkpoint)) << end_col;
476 table << justify(PrintTable::Cell::LEFT) << indent(depth) << span << timer.
getName() << end_col;
482 for (TimerList::const_iterator it = timer.begin(); it != timer.end(); ++it)
483 printSubtable(table, root_timer, *it, metrics_mask, depth, timer_checkpoint);
493 const ParallelTimer & root_timer,
494 const ParallelTimer & timer,
495 MetricsMask metrics_mask,
497 bool timer_checkpoint)
499 if (timer.m_subtimerLapCount != 0.0) {
500 if (timer.m_timerMask == 0 || timer.
getMetric<LapCount>().m_sum > 0) {
501 table << justify(PrintTable::Cell::LEFT) << indent(depth) << timer.m_name << end_col
502 << justify(PrintTable::Cell::RIGHT) << timer.
getMetric<LapCount>().m_sum << end_col;
504 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<CPUTime>::METRIC)
505 table << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<CPUTime>::format(timer.
getMetric<CPUTime>().m_sum)
506 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<CPUTime>().m_sum, root_timer.getMetric<CPUTime>().m_sum) << end_col
507 << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<CPUTime>::format(timer.
getMetric<CPUTime>().m_min)
508 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<CPUTime>().m_min, root_timer.getMetric<CPUTime>().m_sum) << end_col
509 << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<CPUTime>::format(timer.
getMetric<CPUTime>().m_max)
510 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<CPUTime>().m_max, root_timer.getMetric<CPUTime>().m_sum) << end_col;
511 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<WallTime>::METRIC)
512 table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits<WallTime>::format(timer.
getMetric<WallTime>().m_sum)
513 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<WallTime>().m_sum, root_timer.getMetric<WallTime>().m_sum) << end_col
514 << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<WallTime>::format(timer.
getMetric<WallTime>().m_min)
515 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<WallTime>().m_min, root_timer.getMetric<WallTime>().m_sum) << end_col
516 << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<WallTime>::format(timer.
getMetric<WallTime>().m_max)
517 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<WallTime>().m_max, root_timer.getMetric<WallTime>().m_sum) << end_col;
518 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<MPICount>::METRIC)
519 table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits<MPICount>::format(timer.
getMetric<MPICount>().m_sum)
520 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<MPICount>().m_sum, root_timer.getMetric<MPICount>().m_sum) << end_col
521 << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<MPICount>::format(timer.
getMetric<MPICount>().m_min)
522 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<MPICount>().m_min, root_timer.getMetric<MPICount>().m_sum) << end_col
523 << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<MPICount>::format(timer.
getMetric<MPICount>().m_max)
524 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<MPICount>().m_max, root_timer.getMetric<MPICount>().m_sum) << end_col;
525 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<MPIByteCount>::METRIC)
526 table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits<MPIByteCount>::format(timer.
getMetric<MPIByteCount>().m_sum)
527 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<MPIByteCount>().m_sum, root_timer.getMetric<MPIByteCount>().m_sum) << end_col
528 << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<MPIByteCount>::format(timer.
getMetric<MPIByteCount>().m_min)
529 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<MPIByteCount>().m_min, root_timer.getMetric<MPIByteCount>().m_sum) << end_col
530 << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<MPIByteCount>::format(timer.
getMetric<MPIByteCount>().m_max)
531 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<MPIByteCount>().m_max, root_timer.getMetric<MPIByteCount>().m_sum) << end_col;
532 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<HeapAlloc>::METRIC)
533 table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits<HeapAlloc>::format(timer.
getMetric<HeapAlloc>().m_sum)
534 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<HeapAlloc>().m_sum, root_timer.getMetric<HeapAlloc>().m_sum) << end_col
535 << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<HeapAlloc>::format(timer.
getMetric<HeapAlloc>().m_min)
536 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<HeapAlloc>().m_min, root_timer.getMetric<HeapAlloc>().m_sum) << end_col
537 << justify(PrintTable::Cell::RIGHT) <<
std::setw(12) << MetricTraits<HeapAlloc>::format(timer.
getMetric<HeapAlloc>().m_max)
538 <<
" " <<
std::setw(8) << Percent(timer.
getMetric<HeapAlloc>().m_max, root_timer.getMetric<HeapAlloc>().m_sum) << end_col;
541 table << justify(PrintTable::Cell::LEFT) << indent(depth) << span << timer.m_name << end_col;
547 for (std::list<ParallelTimer>::const_iterator it = timer.m_subtimerList.begin(); it != timer.m_subtimerList.end(); ++it)
548 printSubtable(table, root_timer, *it, metrics_mask, depth, timer_checkpoint);
558 MetricsMask metrics_mask,
560 bool timer_checkpoint)
562 updateRootTimer(root_timer);
564 root_timer.accumulateSubtimerLapCounts();
566 if (metrics_mask & getEnabledTimerMetricsMask()) {
567 table.setAutoEndCol(
false);
569 table << cell_width(name_width) << justify(PrintTable::Cell::CENTER) <<
"Timer" << (timer_checkpoint ?
" (delta time)" :
"") << end_col
570 << justify(PrintTable::Cell::CENTER) <<
"Count" << end_col;
572 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<CPUTime>::METRIC)
573 table << justify(PrintTable::Cell::CENTER) << MetricTraits<CPUTime>::table_header() << end_col;
574 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<WallTime>::METRIC)
575 table << justify(PrintTable::Cell::CENTER) << MetricTraits<WallTime>::table_header() << end_col;
576 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<MPICount>::METRIC)
577 table << justify(PrintTable::Cell::CENTER) << MetricTraits<MPICount>::table_header() << end_col;
578 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<MPIByteCount>::METRIC)
579 table << justify(PrintTable::Cell::CENTER) << MetricTraits<MPIByteCount>::table_header() << end_col;
580 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<HeapAlloc>::METRIC)
581 table << justify(PrintTable::Cell::CENTER) << MetricTraits<HeapAlloc>::table_header() << end_col;
585 printSubtable(table, root_timer, root_timer, metrics_mask, 0, timer_checkpoint);
587 if (timer_checkpoint)
588 root_timer.checkpoint();
599 MetricsMask metrics_mask,
601 bool timer_checkpoint,
604 updateRootTimer(root_timer);
606 root_timer.accumulateSubtimerLapCounts();
608 ParallelTimer parallel_timer;
610 stk_classic::diag::collect_timers(root_timer, parallel_timer, timer_checkpoint, parallel_machine);
614 if (metrics_mask & getEnabledTimerMetricsMask()) {
615 table.setAutoEndCol(
false);
617 table << end_col << end_col;
619 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<CPUTime>::METRIC)
620 table << justify(PrintTable::Cell::CENTER) << MetricTraits<CPUTime>::table_header() << end_col
621 << justify(PrintTable::Cell::CENTER) << MetricTraits<CPUTime>::table_header() << end_col
622 << justify(PrintTable::Cell::CENTER) << MetricTraits<CPUTime>::table_header() << end_col;
623 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<WallTime>::METRIC)
624 table << justify(PrintTable::Cell::CENTER) << MetricTraits<WallTime>::table_header() << end_col
625 << justify(PrintTable::Cell::CENTER) << MetricTraits<WallTime>::table_header() << end_col
626 << justify(PrintTable::Cell::CENTER) << MetricTraits<WallTime>::table_header() << end_col;
627 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<MPICount>::METRIC)
628 table << justify(PrintTable::Cell::CENTER) << MetricTraits<MPICount>::table_header() << end_col
629 << justify(PrintTable::Cell::CENTER) << MetricTraits<MPICount>::table_header() << end_col
630 << justify(PrintTable::Cell::CENTER) << MetricTraits<MPICount>::table_header() << end_col;
631 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<MPIByteCount>::METRIC)
632 table << justify(PrintTable::Cell::CENTER) << MetricTraits<MPIByteCount>::table_header() << end_col
633 << justify(PrintTable::Cell::CENTER) << MetricTraits<MPIByteCount>::table_header() << end_col
634 << justify(PrintTable::Cell::CENTER) << MetricTraits<MPIByteCount>::table_header() << end_col;
635 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<HeapAlloc>::METRIC)
636 table << justify(PrintTable::Cell::CENTER) << MetricTraits<HeapAlloc>::table_header() << end_col
637 << justify(PrintTable::Cell::CENTER) << MetricTraits<HeapAlloc>::table_header() << end_col
638 << justify(PrintTable::Cell::CENTER) << MetricTraits<HeapAlloc>::table_header() << end_col;
641 table << cell_width(name_width) << justify(PrintTable::Cell::CENTER) <<
"Timer" << (timer_checkpoint ?
" (delta time)" :
"") << end_col
642 << justify(PrintTable::Cell::CENTER) <<
"Count" << end_col;
644 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<CPUTime>::METRIC)
645 table << justify(PrintTable::Cell::CENTER) <<
"Sum (% of System)" << end_col
646 << justify(PrintTable::Cell::CENTER) <<
"Min (% of System)" << end_col
647 << justify(PrintTable::Cell::CENTER) <<
"Max (% of System)" << end_col;
648 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<WallTime>::METRIC)
649 table << justify(PrintTable::Cell::CENTER) <<
"Sum (% of System)" << end_col
650 << justify(PrintTable::Cell::CENTER) <<
"Min (% of System)" << end_col
651 << justify(PrintTable::Cell::CENTER) <<
"Max (% of System)" << end_col;
652 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<MPICount>::METRIC)
653 table << justify(PrintTable::Cell::CENTER) <<
"Sum (% of System)" << end_col
654 << justify(PrintTable::Cell::CENTER) <<
"Min (% of System)" << end_col
655 << justify(PrintTable::Cell::CENTER) <<
"Max (% of System)" << end_col;
656 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<MPIByteCount>::METRIC)
657 table << justify(PrintTable::Cell::CENTER) <<
"Sum (% of System)" << end_col
658 << justify(PrintTable::Cell::CENTER) <<
"Min (% of System)" << end_col
659 << justify(PrintTable::Cell::CENTER) <<
"Max (% of System)" << end_col;
660 if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits<HeapAlloc>::METRIC)
661 table << justify(PrintTable::Cell::CENTER) <<
"Sum (% of System)" << end_col
662 << justify(PrintTable::Cell::CENTER) <<
"Min (% of System)" << end_col
663 << justify(PrintTable::Cell::CENTER) <<
"Max (% of System)" << end_col;
667 printSubtable(table, parallel_timer, parallel_timer, metrics_mask, 0, timer_checkpoint);
670 if (timer_checkpoint)
671 root_timer.checkpoint();
680 std::ostream &printTimersTable(std::ostream& os, Timer root_timer, MetricsMask metrics_mask,
bool timer_checkpoint)
682 stk_classic::PrintTable print_table;
684 printTable(print_table, root_timer, metrics_mask, 40, timer_checkpoint);
692 std::ostream &printTimersTable(std::ostream& os, Timer root_timer, MetricsMask metrics_mask,
bool timer_checkpoint,
ParallelMachine parallel_machine)
694 stk_classic::PrintTable print_table;
698 printTable(print_table, root_timer, metrics_mask, 40, timer_checkpoint);
700 printTable(print_table, root_timer, metrics_mask, 40, timer_checkpoint, parallel_machine);
709 std::ostream &printXML(std::ostream &os, MetricsMask metrics_mask,
bool timer_checkpoint);
711 std::ostream &printSubXML(std::ostream &os, MetricsMask metrics_mask,
int depth,
bool timer_checkpoint);
718 Marshal &operator<<(Marshal &mout, const diag::Timer::Metric<T> &t) {
719 mout << t.getAccumulatedLap(
false) << t.getAccumulatedLap(
true);
724 Marshal &
operator<<(Marshal &mout,
const diag::Timer &t) {
725 mout << t.getName() << t.getTimerMask() << t.getSubtimerLapCount()
726 << t.getMetric<diag::LapCount>() << t.getMetric<diag::CPUTime>() << t.getMetric<diag::WallTime>()
727 << t.getMetric<diag::MPICount>() << t.getMetric<diag::MPIByteCount>() << t.getMetric<diag::HeapAlloc>();
729 mout << t.getTimerList();
734 Marshal &operator>>(Marshal &min, diag::ParallelTimer &t) {
735 min >> t.m_name >> t.m_timerMask >> t.m_subtimerLapCount
736 >> t.m_lapCount.m_value
737 >> t.m_lapCount.m_checkpoint
738 >> t.m_cpuTime.m_value
739 >> t.m_cpuTime.m_checkpoint
740 >> t.m_wallTime.m_value
741 >> t.m_wallTime.m_checkpoint
742 >> t.m_MPICount.m_value
743 >> t.m_MPICount.m_checkpoint
744 >> t.m_MPIByteCount.m_value
745 >> t.m_MPIByteCount.m_checkpoint
746 >> t.m_heapAlloc.m_value
747 >> t.m_heapAlloc.m_checkpoint;
749 min >> t.m_subtimerList;
std::ostream & dout()
Diagnostic output stream.
int parallel_rank()
function parallel_rank returns the rank of this processor in the current mpi communicator.
double getSubtimerLapCount() const
Struct Marshal is a data packer for sending and receiving parallel messages. The data put-to (<<) is ...
unsigned parallel_machine_rank(ParallelMachine parallel_machine)
Member function parallel_machine_rank ...
_setprecision setprecision(int precision)
Function setprecision sets the numeric precision as a manipulator.
std::ostream & operator<<(std::ostream &s, const Bucket &k)
Print the part names for which this bucket is a subset.
Writer & dendl(Writer &dout)
Writer function dendl calls the Writer::dendl manipulator.
unsigned parallel_machine_size(ParallelMachine parallel_machine)
Member function parallel_machine_size ...
Writer & dump(Writer &dout, const std::vector< T > &t)
Template dump prints the object contained within a std::vector object to the diagnostic writer...
TimerMask getTimerMask() const
_setw setw(int width)
Function setw sets the width for the next field as a manipulator.
bool equal_case(const char *lhs, const char *rhs)
Case-insensitive equality compare.
const std::string & getName() const
int parallel_size()
function parallel_size returns the number of processors in the current mpi communicator.
const Metric< T > & getMetric() const