1 #ifndef DASH__UTIL__TRACE_H__ 2 #define DASH__UTIL__TRACE_H__ 5 #include <dash/util/Timer.h> 24 typedef typename timer_t::timestamp_t
31 typedef std::vector<state_timespan_t>
61 static void clear(
const std::string & context);
66 static void add_context(
const std::string & context);
71 static trace_events_t &
context_trace(
const std::string & context);
76 static void write(std::ostream & out,
bool printHeader =
true);
82 const std::string & filename,
83 const std::string & path =
"");
86 static std::map<std::string, trace_events_t> _traces;
87 static bool _trace_enabled;
93 typedef typename TraceStore::timestamp_t
95 typedef typename TraceStore::state_t
101 typedef typename TraceStore::trace_events_t
105 std::string _context;
106 timestamp_t _ts_start;
112 Trace(std::string context)
113 : _context(std::move(context))
119 timer_t::Calibrate(0);
121 _ts_start = timer_t::Now();
124 inline void enter_state(
const state_t & state)
129 state_timespan_t state_timespan;
130 timestamp_t ts_event = timer_t::Now() - _ts_start;
131 state_timespan.start = ts_event;
132 state_timespan.end = ts_event;
133 state_timespan.state = state;
137 inline void exit_state(
const state_t &)
142 timestamp_t ts_event = timer_t::Now() - _ts_start;
151 #endif // DASH__UTIL__TRACE_H__ constexpr auto end(RangeType &&range) -> decltype(std::forward< RangeType >(range).end())
This class is a simple memory pool which holds allocates elements of size ValueType.
static void off()
Disable trace storage.
static void add_context(const std::string &context)
Register a new trace context.
static bool enabled()
Whether trace storage is enabled.
static void write(std::ostream &out, bool printHeader=true)
Write trace data to given output stream.
static void clear()
Clear trace data.
static bool on()
Enable trace storage if environment variable DASH_ENABLE_TRACE is set to 'on'.
static trace_events_t & context_trace(const std::string &context)
Return reference to traces list for given context.
void barrier()
A global barrier involving all units.