|
Sierra Toolkit Version of the Day
|
00001 /*------------------------------------------------------------------------*/ 00002 /* Copyright 2010 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 { 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_ALL = 0x7FFF, 00045 00046 METRICS_FORCE = 0x8000 00047 }; 00048 00049 00050 struct LapCount {}; 00051 struct CPUTime {}; 00052 struct WallTime {}; 00053 struct MPICount {}; 00054 struct MPIByteCount {}; 00055 00056 template <class T> 00057 struct MetricTraits; 00058 00059 template<> 00060 struct MetricTraits<LapCount> 00061 { 00062 typedef unsigned Type; 00063 enum {METRIC = METRICS_LAP_COUNT}; 00064 static Type value_now(); 00065 static std::string table_header(); 00066 static std::string format(Type time); 00067 }; 00068 00069 template<> 00070 struct MetricTraits<CPUTime> 00071 { 00072 typedef double Type; 00073 enum {METRIC = METRICS_CPU_TIME}; 00074 static Type value_now(); 00075 static std::string table_header(); 00076 static std::string format(Type time); 00077 }; 00078 00079 template<> 00080 struct MetricTraits<WallTime> 00081 { 00082 typedef double Type; 00083 enum {METRIC = METRICS_WALL_TIME}; 00084 static Type value_now(); 00085 static std::string table_header(); 00086 static std::string format(Type time); 00087 }; 00088 00089 template<> 00090 struct MetricTraits<MPICount> 00091 { 00092 typedef double Type; 00093 enum {METRIC = METRICS_MPI_COUNT}; 00094 static Type value_now(); 00095 static std::string table_header(); 00096 static std::string format(Type count); 00097 }; 00098 00099 template<> 00100 struct MetricTraits<MPIByteCount> 00101 { 00102 typedef double Type; 00103 enum {METRIC = METRICS_MPI_BYTE_COUNT}; 00104 static Type value_now(); 00105 static std::string table_header(); 00106 static std::string format(Type count); 00107 }; 00108 00109 00110 template <class T> 00111 typename MetricTraits<T>::Type now() { 00112 return MetricTraits<T>::value_now(); 00113 } 00114 00115 } // namespace diag 00116 } // namespace stk 00117 00118 #endif // stk_util_diag_TimerMetricTraits_hpp