|
Sierra Toolkit
Version of the Day
|
00001 /*------------------------------------------------------------------------*/ 00002 /* Copyright 2010, 2011 Sandia Corporation. */ 00003 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ 00004 /* license for use of this work by or on behalf of the U.S. Government. */ 00005 /* Export of this program may require a license from the */ 00006 /* United States Government. */ 00007 /*------------------------------------------------------------------------*/ 00008 00009 #ifndef stk_util_diag_TimerMetricTraits_hpp 00010 #define stk_util_diag_TimerMetricTraits_hpp 00011 00012 #include <string> 00013 00014 namespace stk_classic { 00015 namespace diag { 00016 00017 typedef unsigned long MetricsMask; 00018 00025 void setTimerTimeFormat(int time_format); 00026 00031 int getTimerTimeFormat(); 00032 00038 enum Metrics { 00039 METRICS_LAP_COUNT = 0x0001, 00040 METRICS_CPU_TIME = 0x0002, 00041 METRICS_WALL_TIME = 0x0004, 00042 METRICS_MPI_COUNT = 0x0008, 00043 METRICS_MPI_BYTE_COUNT = 0x0010, 00044 METRICS_HEAP_ALLOC = 0x0020, 00045 METRICS_ALL = 0x7FFF, 00046 00047 METRICS_FORCE = 0x8000 00048 }; 00049 00050 00051 struct LapCount {}; 00052 struct CPUTime {}; 00053 struct WallTime {}; 00054 struct MPICount {}; 00055 struct MPIByteCount {}; 00056 struct HeapAlloc {}; 00057 00058 template <class T> 00059 struct MetricTraits; 00060 00061 template<> 00062 struct MetricTraits<LapCount> 00063 { 00064 typedef unsigned Type; 00065 enum {METRIC = METRICS_LAP_COUNT}; 00066 static Type value_now(); 00067 static std::string table_header(); 00068 static std::string format(Type time); 00069 }; 00070 00071 template<> 00072 struct MetricTraits<CPUTime> 00073 { 00074 typedef double Type; 00075 enum {METRIC = METRICS_CPU_TIME}; 00076 static Type value_now(); 00077 static std::string table_header(); 00078 static std::string format(Type time); 00079 }; 00080 00081 template<> 00082 struct MetricTraits<WallTime> 00083 { 00084 typedef double Type; 00085 enum {METRIC = METRICS_WALL_TIME}; 00086 static Type value_now(); 00087 static std::string table_header(); 00088 static std::string format(Type time); 00089 }; 00090 00091 template<> 00092 struct MetricTraits<MPICount> 00093 { 00094 typedef double Type; 00095 enum {METRIC = METRICS_MPI_COUNT}; 00096 static Type value_now(); 00097 static std::string table_header(); 00098 static std::string format(Type count); 00099 }; 00100 00101 template<> 00102 struct MetricTraits<MPIByteCount> 00103 { 00104 typedef double Type; 00105 enum {METRIC = METRICS_MPI_BYTE_COUNT}; 00106 static Type value_now(); 00107 static std::string table_header(); 00108 static std::string format(Type count); 00109 }; 00110 00111 00112 template<> 00113 struct MetricTraits<HeapAlloc> 00114 { 00115 typedef double Type; 00116 enum {METRIC = METRICS_HEAP_ALLOC}; 00117 static Type value_now(); 00118 static std::string table_header(); 00119 static std::string format(Type count); 00120 }; 00121 00122 template <class T> 00123 typename MetricTraits<T>::Type now() { 00124 return MetricTraits<T>::value_now(); 00125 } 00126 00127 } // namespace diag 00128 } // namespace stk_classic 00129 00130 #endif // stk_util_diag_TimerMetricTraits_hpp