IntelProfilerAuditor Class Reference
Inheritance diagram for IntelProfilerAuditor:
Collaboration diagram for IntelProfilerAuditor:

Classes

struct  stack_entity
 

Public Member Functions

 IntelProfilerAuditor (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
void handle (const Incident &incident)
 Inform that a new incident has occurred. More...
 
void before (StandardEventType type, INamedInterface *i)
 
void after (StandardEventType type, INamedInterface *i, const StatusCode &sc)
 
- Public Member Functions inherited from Auditor
 Auditor (const std::string &name, ISvcLocator *svcloc)
 Constructor. More...
 
 ~Auditor () override=default
 Destructor. More...
 
StatusCode sysInitialize () override
 Initialization method invoked by the framework. More...
 
StatusCode sysFinalize () override
 Finalization method invoked by the framework. More...
 
void before (StandardEventType, INamedInterface *) override
 The following methods are meant to be implemented by the child class... More...
 
void before (StandardEventType, const std::string &) override
 
void before (CustomEventTypeRef, INamedInterface *) override
 
void before (CustomEventTypeRef, const std::string &) override
 
void after (StandardEventType, INamedInterface *, const StatusCode &) override
 
void after (StandardEventType, const std::string &, const StatusCode &) override
 
void after (CustomEventTypeRef, INamedInterface *, const StatusCode &) override
 
void after (CustomEventTypeRef, const std::string &, const StatusCode &) override
 
void beforeInitialize (INamedInterface *) override
 
void afterInitialize (INamedInterface *) override
 
void beforeReinitialize (INamedInterface *) override
 
void afterReinitialize (INamedInterface *) override
 
void beforeExecute (INamedInterface *) override
 
void afterExecute (INamedInterface *, const StatusCode &) override
 
void beforeFinalize (INamedInterface *) override
 
void afterFinalize (INamedInterface *) override
 
void beforeBeginRun (INamedInterface *) override
 
void afterBeginRun (INamedInterface *) override
 
void beforeEndRun (INamedInterface *) override
 
void afterEndRun (INamedInterface *) override
 
virtual StatusCode finalize ()
 
const std::string & name () const override
 
bool isEnabled () const override
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
int outputLevel () const
 Retrieve the output level of current auditor. More...
 
void setOutputLevel (int level)
 Set the output level for current auditor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 The standard service locator. More...
 
template<class T >
StatusCode service (const std::string &name, T *&svc, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T = IService>
SmartIF< T > service (const std::string &name, bool createIf=false) const
 
StatusCode setProperty (const Property &p) override
 Set a value of a property of an auditor. More...
 
StatusCode setProperty (const std::string &s) override
 Implementation of IProperty::setProperty. More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 Implementation of IProperty::setProperty. More...
 
StatusCode getProperty (Property *p) const override
 Get the value of a property. More...
 
const PropertygetProperty (const std::string &name) const override
 Get the property by name. More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 Implementation of IProperty::getProperty. More...
 
const std::vector< Property * > & getProperties () const override
 Get all properties. More...
 
bool hasProperty (const std::string &name) const override
 Implementation of IProperty::hasProperty. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setProperties ()
 Set the auditor's properties. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
 Auditor (const std::string &name, ISvcLocator *svcloc)
 Constructor. More...
 
 ~Auditor () override=default
 Destructor. More...
 
StatusCode sysInitialize () override
 Initialization method invoked by the framework. More...
 
StatusCode sysFinalize () override
 Finalization method invoked by the framework. More...
 
void before (StandardEventType, INamedInterface *) override
 The following methods are meant to be implemented by the child class... More...
 
void before (StandardEventType, const std::string &) override
 
void before (CustomEventTypeRef, INamedInterface *) override
 
void before (CustomEventTypeRef, const std::string &) override
 
void after (StandardEventType, INamedInterface *, const StatusCode &) override
 
void after (StandardEventType, const std::string &, const StatusCode &) override
 
void after (CustomEventTypeRef, INamedInterface *, const StatusCode &) override
 
void after (CustomEventTypeRef, const std::string &, const StatusCode &) override
 
void beforeInitialize (INamedInterface *) override
 
void afterInitialize (INamedInterface *) override
 
void beforeReinitialize (INamedInterface *) override
 
void afterReinitialize (INamedInterface *) override
 
void beforeExecute (INamedInterface *) override
 
void afterExecute (INamedInterface *, const StatusCode &) override
 
void beforeFinalize (INamedInterface *) override
 
void afterFinalize (INamedInterface *) override
 
void beforeBeginRun (INamedInterface *) override
 
void afterBeginRun (INamedInterface *) override
 
void beforeEndRun (INamedInterface *) override
 
void afterEndRun (INamedInterface *) override
 
virtual StatusCode finalize ()
 
const std::string & name () const override
 
bool isEnabled () const override
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
int outputLevel () const
 Retrieve the output level of current auditor. More...
 
void setOutputLevel (int level)
 Set the output level for current auditor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 The standard service locator. More...
 
template<class T >
StatusCode service (const std::string &name, T *&svc, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T = IService>
SmartIF< T > service (const std::string &name, bool createIf=false) const
 
StatusCode setProperty (const Property &p) override
 Set a value of a property of an auditor. More...
 
StatusCode setProperty (const std::string &s) override
 Implementation of IProperty::setProperty. More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 Implementation of IProperty::setProperty. More...
 
StatusCode getProperty (Property *p) const override
 Get the value of a property. More...
 
const PropertygetProperty (const std::string &name) const override
 Get the property by name. More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 Implementation of IProperty::getProperty. More...
 
const std::vector< Property * > & getProperties () const override
 Get all properties. More...
 
bool hasProperty (const std::string &name) const override
 Implementation of IProperty::hasProperty. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setProperties ()
 Set the auditor's properties. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
- Public Member Functions inherited from implements< Interfaces >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 implements ()=default
 Default constructor. More...
 
 implements (const implements &)
 Copy constructor (zero the reference count) More...
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count). More...
 
 ~implements () override=default
 Virtual destructor. More...
 
unsigned long addRef () override
 Reference Interface instance. More...
 
unsigned long release () override
 Release Interface instance. More...
 
unsigned long refCount () const override
 Current reference count. More...
 
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 implements ()=default
 Default constructor. More...
 
 implements (const implements &)
 Copy constructor (zero the reference count) More...
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count). More...
 
 ~implements () override=default
 Virtual destructor. More...
 
unsigned long addRef () override
 Reference Interface instance. More...
 
unsigned long release () override
 Release Interface instance. More...
 
unsigned long refCount () const override
 Current reference count. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from IIncidentListener
 DeclareInterfaceID (IIncidentListener, 2, 0)
 InterfaceID. More...
 
 DeclareInterfaceID (IIncidentListener, 2, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from IInterface
virtual void * i_cast (const InterfaceID &) const =0
 main cast function More...
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release ()=0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance. More...
 
virtual ~IInterface ()=default
 Virtual destructor. More...
 
virtual void * i_cast (const InterfaceID &) const =0
 main cast function More...
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release ()=0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance. More...
 
virtual ~IInterface ()=default
 Virtual destructor. More...
 

Private Member Functions

void start_profiling_component (const std::string &name)
 
void skip_profiling_component (const std::string &name)
 
void start ()
 
void pause ()
 
void resume ()
 
void stop ()
 
bool hasIncludes () const
 
bool isIncluded (const std::string &name) const
 
bool isExcluded (const std::string &name) const
 
bool isRunning () const
 
int stackLevel () const
 
std::string stackIndent (bool newLevel=false) const
 
std::string taskTypeName (const std::string &component_name) const
 

Private Attributes

int m_nStartFromEvent
 
int m_nStopAtEvent
 
std::vector< std::string > m_excluded
 
std::vector< std::string > m_included
 
std::vector< std::string > m_algs_for_tasktypes
 
std::string m_alg_delim
 
bool m_enable_frames
 
int m_frames_rate
 
MsgStream m_log
 
int m_nEvents
 
__itt_domain * domain
 
bool m_isStarted
 
std::vector< stack_entitym_stack
 
TaskTypes m_tasktypes
 

Additional Inherited Members

- Public Types inherited from Auditor
typedef Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
 
typedef Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from implements< Interfaces >
using base_class = implements< Interfaces...>
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
using base_class = implements< Interfaces...>
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
- Public Types inherited from IInterface
enum  Status {
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR,
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR
}
 Return status. More...
 
enum  Status {
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR,
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR
}
 Return status. More...
 
using iid = Gaudi::InterfaceId< IInterface, 0, 0 >
 Interface ID. More...
 
using ext_iids = Gaudi::interface_list< iid >
 Extra interfaces. More...
 
using iid = Gaudi::InterfaceId< IInterface, 0, 0 >
 Interface ID. More...
 
using ext_iids = Gaudi::interface_list< iid >
 Extra interfaces. More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Attributes inherited from implements< Interfaces >
std::atomic_ulong m_refCount = {0}
 Reference counter. More...
 

Detailed Description

Definition at line 31 of file IntelProfilerAuditor.cpp.

Constructor & Destructor Documentation

IntelProfilerAuditor::IntelProfilerAuditor ( const std::string &  name,
ISvcLocator pSvcLocator 
)

Definition at line 119 of file IntelProfilerAuditor.cpp.

120  : Auditor(name, pSvcLocator), m_log(msgSvc(), name)
121  ,m_nEvents(0), m_isStarted(false) {
122  // ## Properties
123  declareProperty("IncludeAlgorithms", m_included,
124  "Names of included algorithms."
125  );
126  declareProperty("ExcludeAlgorithms", m_excluded,
127  "Names of excluded algorithms."
128  );
129  declareProperty("StartFromEventN", m_nStartFromEvent = 1,
130  "After what event we stop profiling. "
131  "If 0 than we also profile finalization stage."
132  );
133  declareProperty("StopAtEventN", m_nStopAtEvent = 0,
134  "After what event we stop profiling. "
135  "If 0 than we also profile finalization stage. Default = 0."
136  );
137  declareProperty("ComponentsForTaskTypes", m_algs_for_tasktypes,
138  "Algorithm name, for which intel amplifier task type will be created."
139  "By default all algorithms have a corresponding task type.");
140  declareProperty("TaskTypeNameDelimeter", m_alg_delim = " ",
141  "The String delimiter between sequences/algorithms names in "
142  "\"Task Type\" grouping at Amplifier. Default=\" \"."
143  );
144  declareProperty("EnableFrames", m_enable_frames = false,
145  "Enable frames (needed for detecting slow events). Default=false."
146  );
147  declareProperty("FramesRate", m_frames_rate = 100,
148  "Frames rate. The recommended maximum rate for calling the Frame API is "
149  "1000 frames (events) per second. A higher rate may result in large product"
150  " memory consumption and slow finalization. "
151  "You need update \"slow-frames-threshold\" and \"fast-frames-threshold\" "
152  "parameters of amplxe-cl tool to separate slow, medium and fast events. "
153  "For use frames you need to switch on \"EnableFrames\". "
154  "Default=100"
155  );
156 }
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Auditor.cpp:220
std::vector< std::string > m_algs_for_tasktypes
std::vector< std::string > m_excluded
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Auditor.h:241
Auditor(const std::string &name, ISvcLocator *svcloc)
Constructor.
Definition: Auditor.cpp:12
const std::string & name() const override
Definition: Auditor.cpp:212
std::vector< std::string > m_included

Member Function Documentation

void IntelProfilerAuditor::after ( StandardEventType  type,
INamedInterface i,
const StatusCode sc 
)

Definition at line 389 of file IntelProfilerAuditor.cpp.

390  {
391  // Skip unnecessary event types
392  if (!((type == IAuditor::Execute) && m_isStarted)) return;
393 
394  if ((m_nEvents+1) % m_frames_rate == 0) {
395  __itt_frame_end_v3(domain, NULL);
396  }
397 
398  // Name of the current component
399  const std::string& name = i->name();
400  stack_entity state = m_stack.back();
401  // Remove component from stack.
402  m_stack.pop_back();
403 
404 
405  if (state.event != 0) {
406  m_log << MSG::DEBUG << stackIndent(true) << "End event for "
407  << name << endmsg;
408  __itt_event_end(state.event);
409 
410  if (state.parent_event != 0) {
411  m_log << MSG::DEBUG << stackIndent() << "Resume event for "
412  << state.parent_event << endmsg;
413  __itt_event_start(state.parent_event);
414  }
415  }
416 
417  if (m_stack.empty()) {
418  // Pause if there are no parent components (top algorithm).
419  pause();
420  } else if (state.status) {
421  // If the profiling is running and we have parent component that is
422  // paused then pause the profiling.
423  if (!m_stack.back().status) {
424  pause();
425  }
426  }else {
427  // If the profiling was stopped, but the parent component should be profiled
428  // then resume profiling.
429  if (m_stack.back().status) {
430  resume();
431  }
432  }
433 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual const std::string & name() const =0
Retrieve the name of the instance.
std::vector< stack_entity > m_stack
std::string stackIndent(bool newLevel=false) const
const std::string & name() const override
Definition: Auditor.cpp:212
string type
Definition: gaudirun.py:151
void IntelProfilerAuditor::before ( StandardEventType  type,
INamedInterface i 
)

Definition at line 342 of file IntelProfilerAuditor.cpp.

342  {
343  // Skip unnecessary event types.
344  if (!((type == IAuditor::Execute) && m_isStarted)) return;
345 
346  // Name of the current component.
347  const std::string& name = i->name();
348  //m_log << MSG::DEBUG << "Before: " << name << " " << type << endmsg;
349 
350  if (isRunning()) {
351  if (isExcluded(name)) {
352  // If profiling is running and component is explicitly excluded
353  // then skip component.
355  }else{
356  // If profiling is running and component is'not explicitly excluded
357  // then start profiling for component (add to stack).
359  }
360  }else {
361  if (hasIncludes()) {
362  // If the profiling is not running and "includes" is explicitly defined ...
363  if (isIncluded(name)) {
364  // and the current component is in the include's list then start the
365  // component profiling.
367  } else{
368  // and the current component is not in the includes list then skip
369  // a profiling of the component.
371  }
372  }else {
373  // If "Includes" property isn't present and the component is ...
374  if (isExcluded(name)) {
375  // in the excludes list then skip a profiling
377  }else{
378  // not in the exclude list then start a profiling
380  }
381  }
382  }
383  if (m_nEvents % m_frames_rate == 0) {
384  __itt_frame_begin_v3(domain, NULL);
385  }
386 
387 }
void start_profiling_component(const std::string &name)
void skip_profiling_component(const std::string &name)
bool isExcluded(const std::string &name) const
virtual const std::string & name() const =0
Retrieve the name of the instance.
const std::string & name() const override
Definition: Auditor.cpp:212
bool isIncluded(const std::string &name) const
string type
Definition: gaudirun.py:151
void IntelProfilerAuditor::handle ( const Incident )
virtual

Inform that a new incident has occurred.

Implements IIncidentListener.

Definition at line 324 of file IntelProfilerAuditor.cpp.

324  {
325  if (IncidentType::BeginEvent != incident.type()) return;
326  // Increment the event counter
327  ++m_nEvents;
328 
329  if (m_nStartFromEvent == m_nEvents) {
330  m_log << MSG::INFO << "Start profiling (event #" << m_nEvents << ")"
331  << endmsg;
332  start();
333  }
334 
335  if (m_nStopAtEvent == m_nEvents) {
336  m_log << MSG::INFO << "Stop profiling (event #" << m_nEvents << ")"
337  << endmsg;
338  stop();
339  }
340 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool IntelProfilerAuditor::hasIncludes ( ) const
private

Definition at line 234 of file IntelProfilerAuditor.cpp.

234  {
235  return !m_included.empty();
236 }
std::vector< std::string > m_included
StatusCode IntelProfilerAuditor::initialize ( )
virtual

Reimplemented from Auditor.

Definition at line 273 of file IntelProfilerAuditor.cpp.

273  {
275  m_log << MSG::INFO << "Initialised" << endmsg;
276 
277  IIncidentSvc * inSvc = NULL;
278  const StatusCode sc = serviceLocator()->service("IncidentSvc", inSvc);
279  if (sc.isFailure())
280  return sc;
281  // Useful to start profiling only after some event, we don't need profile
282  // initialization stage. For that we need to count events with BeginEvent
283  // listener.
284  inSvc->addListener(this, IncidentType::BeginEvent);
285  // If the end event number don't setup we finish profiling at the end
286  // of loop. We don't need profiling finalization stage.
287  inSvc->addListener(this, IncidentType::EndProcessing);
288 
289  std::string str_excluded, str_included, str_eventtypes;
290  for (const auto& name : m_excluded) {
291  str_excluded += " " + name;
292  }
293  for (const auto& name : m_included) {
294  str_included += " " + name;
295  }
296  for (const auto& name : m_algs_for_tasktypes) {
297  str_eventtypes += " " + name;
298  }
299 
300  if (!m_included.empty()) {
301  m_log << MSG::INFO << "Included algorithms (" << m_included.size()
302  << "): " << str_included << endmsg;
303  }
304 
305  if (!m_excluded.empty()){
306  m_log << MSG::INFO << "Excluded algorithms (" << m_excluded.size()
307  << "): " << str_excluded << endmsg;
308  }
309 
310  if (!m_algs_for_tasktypes.empty()){
311  m_log << MSG::INFO << "Event types (" << m_algs_for_tasktypes.size()
312  << "): " << str_eventtypes << endmsg;
313  }
314 
315  // Create a profiler domain for detection of slow events.
316  domain = __itt_domain_create("Event loop");
317  domain->flags = m_enable_frames;
318 
319  return StatusCode::SUCCESS;
320 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::vector< std::string > m_algs_for_tasktypes
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
std::vector< std::string > m_excluded
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< ISvcLocator > & serviceLocator() const
The standard service locator.
Definition: Auditor.cpp:228
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
void setLevel(int level)
Update outputlevel.
Definition: MsgStream.h:106
const std::string & name() const override
Definition: Auditor.cpp:212
int outputLevel() const
Retrieve the output level of current auditor.
Definition: Auditor.h:105
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:21
std::vector< std::string > m_included
bool IntelProfilerAuditor::isExcluded ( const std::string &  name) const
private

Definition at line 243 of file IntelProfilerAuditor.cpp.

243  {
244  return std::find(m_excluded.begin(), m_excluded.end(), name) !=
245  m_excluded.end();
246 }
std::vector< std::string > m_excluded
const std::string & name() const override
Definition: Auditor.cpp:212
bool IntelProfilerAuditor::isIncluded ( const std::string &  name) const
private

Definition at line 238 of file IntelProfilerAuditor.cpp.

238  {
239  return std::find(m_included.begin(), m_included.end(), name) !=
240  m_included.end();
241 }
const std::string & name() const override
Definition: Auditor.cpp:212
std::vector< std::string > m_included
bool IntelProfilerAuditor::isRunning ( ) const
private

Definition at line 248 of file IntelProfilerAuditor.cpp.

248  {
249  return !m_stack.empty() && m_stack.back().status;
250 }
std::vector< stack_entity > m_stack
void IntelProfilerAuditor::pause ( )
private

Definition at line 215 of file IntelProfilerAuditor.cpp.

215  {
216  if (!m_isStarted) return;
217  m_log << MSG::DEBUG << stackIndent() << "Pause" << endmsg;
218  __itt_pause();
219 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::string stackIndent(bool newLevel=false) const
void IntelProfilerAuditor::resume ( )
private

Definition at line 209 of file IntelProfilerAuditor.cpp.

209  {
210  if (!m_isStarted) return;
211  m_log << MSG::DEBUG << stackIndent() << "Resume" << endmsg;
212  __itt_resume();
213 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::string stackIndent(bool newLevel=false) const
void IntelProfilerAuditor::skip_profiling_component ( const std::string &  name)
private

Definition at line 221 of file IntelProfilerAuditor.cpp.

221  {
222  if (!m_isStarted) return;
223  m_stack.push_back(stack_entity(name, false));
224  m_log << MSG::DEBUG << stackIndent() << "Skip component "
225  << name << endmsg;
226 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::vector< stack_entity > m_stack
std::string stackIndent(bool newLevel=false) const
const std::string & name() const override
Definition: Auditor.cpp:212
std::string IntelProfilerAuditor::stackIndent ( bool  newLevel = false) const
private

Definition at line 256 of file IntelProfilerAuditor.cpp.

256  {
257  std::stringstream indent(std::stringstream::out);
258  indent << std::setw(stackLevel()*2+(newLevel?2:0)) << " ";
259  return indent.str();
260 }
int IntelProfilerAuditor::stackLevel ( ) const
private

Definition at line 252 of file IntelProfilerAuditor.cpp.

252  {
253  return m_stack.size();
254 }
std::vector< stack_entity > m_stack
void IntelProfilerAuditor::start ( )
private

Definition at line 158 of file IntelProfilerAuditor.cpp.

158  {
159  m_isStarted = true;
160  __itt_resume();
161 }
void IntelProfilerAuditor::start_profiling_component ( const std::string &  name)
private

Definition at line 163 of file IntelProfilerAuditor.cpp.

163  {
164  if (!m_isStarted) return;
165  std::string typeName = taskTypeName(name);
166  __itt_event taskId = 0;
167  TaskTypes::const_iterator iter = m_tasktypes.find(typeName);
168  if( iter != m_tasktypes.end()) {
169  taskId = iter->second;
170  }
171 
172  if(!taskId && m_algs_for_tasktypes.empty()) {
173  // Create event
174  taskId = __itt_event_create(typeName.c_str(), typeName.size());
175  m_tasktypes.insert(TaskTypes::value_type(typeName, taskId));
176  }
177 
178  stack_entity state = stack_entity(name, true, taskId);
179  stack_entity* parent = !m_stack.empty()?&m_stack.back():NULL;
180 
181  if (parent != NULL) {
182  if (parent->event) {
183  state.parent_event = parent->event;
184  } else {
185  state.parent_event = parent->parent_event;
186  }
187  }
188 
189  if (taskId && state.parent_event) {
190  m_log << MSG::DEBUG << stackIndent() << "Pause event " <<
191  state.parent_event << endmsg;
192  __itt_event_end(state.parent_event);
193  }
194  m_stack.push_back(state);
195 
196  m_log << MSG::DEBUG << stackIndent() << "Start profiling component "
197  << typeName << endmsg;
198 
199  if (taskId) {
200  // Start event
201  m_log << MSG::DEBUG << stackIndent() << "Start event type "
202  << state.event << " for " << typeName << endmsg;
203  __itt_event_start(state.event);
204  }
205 
206  __itt_resume();
207 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::vector< std::string > m_algs_for_tasktypes
std::vector< stack_entity > m_stack
std::string stackIndent(bool newLevel=false) const
std::string taskTypeName(const std::string &component_name) const
const std::string & name() const override
Definition: Auditor.cpp:212
std::string typeName(const std::type_info &typ)
Definition: Dictionary.cpp:21
void IntelProfilerAuditor::stop ( )
private

Definition at line 228 of file IntelProfilerAuditor.cpp.

228  {
229  if (!m_isStarted) return;
230  m_isStarted = false;
231  __itt_pause();
232 }
std::string IntelProfilerAuditor::taskTypeName ( const std::string &  component_name) const
private

Definition at line 263 of file IntelProfilerAuditor.cpp.

263  {
264  std::string result;
265  std::string delim = "";
266  for (const auto& value : m_stack) {
267  result += delim+value.name;
268  delim = m_alg_delim;
269  }
270  return result+m_alg_delim+component_name;
271 }
std::vector< stack_entity > m_stack

Member Data Documentation

__itt_domain* IntelProfilerAuditor::domain
private

Definition at line 91 of file IntelProfilerAuditor.cpp.

std::string IntelProfilerAuditor::m_alg_delim
private

Definition at line 76 of file IntelProfilerAuditor.cpp.

std::vector<std::string> IntelProfilerAuditor::m_algs_for_tasktypes
private

Definition at line 73 of file IntelProfilerAuditor.cpp.

bool IntelProfilerAuditor::m_enable_frames
private

Definition at line 78 of file IntelProfilerAuditor.cpp.

std::vector<std::string> IntelProfilerAuditor::m_excluded
private

Definition at line 69 of file IntelProfilerAuditor.cpp.

int IntelProfilerAuditor::m_frames_rate
private

Definition at line 84 of file IntelProfilerAuditor.cpp.

std::vector<std::string> IntelProfilerAuditor::m_included
private

Definition at line 71 of file IntelProfilerAuditor.cpp.

bool IntelProfilerAuditor::m_isStarted
private

Definition at line 93 of file IntelProfilerAuditor.cpp.

MsgStream IntelProfilerAuditor::m_log
private

Definition at line 87 of file IntelProfilerAuditor.cpp.

int IntelProfilerAuditor::m_nEvents
private

Definition at line 89 of file IntelProfilerAuditor.cpp.

int IntelProfilerAuditor::m_nStartFromEvent
private

Definition at line 64 of file IntelProfilerAuditor.cpp.

int IntelProfilerAuditor::m_nStopAtEvent
private

Definition at line 67 of file IntelProfilerAuditor.cpp.

std::vector<stack_entity> IntelProfilerAuditor::m_stack
private

Definition at line 95 of file IntelProfilerAuditor.cpp.

TaskTypes IntelProfilerAuditor::m_tasktypes
private

Definition at line 97 of file IntelProfilerAuditor.cpp.


The documentation for this class was generated from the following file: