17 #include "atlas/parallel/omp/omp.h" 18 #include "atlas/runtime/trace/CallStack.h" 19 #include "atlas/runtime/trace/CodeLocation.h" 20 #include "atlas/runtime/trace/Nesting.h" 21 #include "atlas/runtime/trace/StopWatch.h" 22 #include "atlas/runtime/trace/Timings.h" 38 template <
typename TraceTraits>
44 using Labels = std::vector<std::string>;
47 static std::string report();
48 static std::string report(
const eckit::Configuration& config );
67 double elapsed()
const;
70 using Identifier = Timings::Identifier;
75 void updateTimings()
const;
79 static std::string formatTitle(
const std::string& );
94 template <
typename TraceTraits>
96 std::string title = _title;
97 +( Barriers::state() ?
" [b]" :
"" ) +
98 ( atlas_omp_get_num_threads() > 1 ?
" @thread[" + std::to_string( atlas_omp_get_thread_num() ) +
"]" :
"" );
102 template <
typename TraceTraits>
104 loc_( loc ), title_( formatTitle( title ) ) {
108 template <
typename TraceTraits>
113 template <
typename TraceTraits>
115 loc_( loc ), title_( title ), labels_( labels ) {
119 template <
typename TraceTraits>
124 template <
typename TraceTraits>
129 template <
typename TraceTraits>
132 title_ + ( Barriers::state() ?
" [b]" :
"" ) +
133 ( atlas_omp_get_num_threads() > 1 ?
" @thread[" + std::to_string( atlas_omp_get_thread_num() ) +
"]" :
"" );
134 id_ = Timings::add( loc_, callstack_, title, labels_ );
137 template <
typename TraceTraits>
139 Timings::update( id_, stopwatch_.elapsed() );
142 template <
typename TraceTraits>
147 template <
typename TraceTraits>
149 if ( Control::enabled() ) {
151 if ( not callstack_ ) {
152 callstack_ = CurrentCallStack::instance().push( loc_, title_ );
155 Tracing::start( title_ );
161 template <
typename TraceTraits>
166 CurrentCallStack::instance().pop();
168 Tracing::stop( title_, stopwatch_.elapsed() );
173 template <
typename TraceTraits>
178 CurrentCallStack::instance().pop();
182 template <
typename TraceTraits>
186 CurrentCallStack::instance().push( loc_, title_ );
191 template <
typename TraceTraits>
193 return stopwatch_.elapsed();
196 template <
typename TraceTraits>
198 return Timings::report() + Barriers::report();
201 template <
typename TraceTraits>
203 return Timings::report( config ) + Barriers::report();
Definition: Barriers.h:21
Instances of CallStack can keep track of nested CodeLocations.
Definition: CallStack.h:27
Definition: CodeLocation.h:19
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33
Definition: StopWatch.h:21