Sierra Toolkit  Version of the Day
TimerMetricTraits.hpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010, 2011 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #ifndef stk_util_diag_TimerMetricTraits_hpp
10 #define stk_util_diag_TimerMetricTraits_hpp
11 
12 #include <string>
13 
14 namespace stk_classic {
15 namespace diag {
16 
17 typedef unsigned long MetricsMask;
18 
25 void setTimerTimeFormat(int time_format);
26 
31 int getTimerTimeFormat();
32 
38 enum Metrics {
39  METRICS_LAP_COUNT = 0x0001,
40  METRICS_CPU_TIME = 0x0002,
41  METRICS_WALL_TIME = 0x0004,
42  METRICS_MPI_COUNT = 0x0008,
43  METRICS_MPI_BYTE_COUNT = 0x0010,
44  METRICS_HEAP_ALLOC = 0x0020,
45  METRICS_ALL = 0x7FFF,
46 
47  METRICS_FORCE = 0x8000
48 };
49 
50 
51 struct LapCount {};
52 struct CPUTime {};
53 struct WallTime {};
54 struct MPICount {};
55 struct MPIByteCount {};
56 struct HeapAlloc {};
57 
58 template <class T>
59 struct MetricTraits;
60 
61 template<>
62 struct MetricTraits<LapCount>
63 {
64  typedef unsigned Type;
65  enum {METRIC = METRICS_LAP_COUNT};
66  static Type value_now();
67  static std::string table_header();
68  static std::string format(Type time);
69 };
70 
71 template<>
72 struct MetricTraits<CPUTime>
73 {
74  typedef double Type;
75  enum {METRIC = METRICS_CPU_TIME};
76  static Type value_now();
77  static std::string table_header();
78  static std::string format(Type time);
79 };
80 
81 template<>
82 struct MetricTraits<WallTime>
83 {
84  typedef double Type;
85  enum {METRIC = METRICS_WALL_TIME};
86  static Type value_now();
87  static std::string table_header();
88  static std::string format(Type time);
89 };
90 
91 template<>
92 struct MetricTraits<MPICount>
93 {
94  typedef double Type;
95  enum {METRIC = METRICS_MPI_COUNT};
96  static Type value_now();
97  static std::string table_header();
98  static std::string format(Type count);
99 };
100 
101 template<>
102 struct MetricTraits<MPIByteCount>
103 {
104  typedef double Type;
105  enum {METRIC = METRICS_MPI_BYTE_COUNT};
106  static Type value_now();
107  static std::string table_header();
108  static std::string format(Type count);
109 };
110 
111 
112 template<>
113 struct MetricTraits<HeapAlloc>
114 {
115  typedef double Type;
116  enum {METRIC = METRICS_HEAP_ALLOC};
117  static Type value_now();
118  static std::string table_header();
119  static std::string format(Type count);
120 };
121 
122 template <class T>
123 typename MetricTraits<T>::Type now() {
124  return MetricTraits<T>::value_now();
125 }
126 
127 } // namespace diag
128 } // namespace stk_classic
129 
130 #endif // stk_util_diag_TimerMetricTraits_hpp
CPU runtime metric tag.
Lap counter metric tag.
MPI call count metric tag.
MPI byte count metric tag.
Heap allocation metric tag.
Sierra Toolkit.
Wall clock metric tag.