ATLAS Offline Software
VTuneAuditor.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Framework include(s)
6 #include "GaudiKernel/INamedInterface.h"
7 
8 // Local include(s)
9 #include "VTuneAuditor.h"
10 
11 /*
12  * Constructor
13  */
14 VTuneAuditor::VTuneAuditor( const std::string& name,
15  ISvcLocator* pSvcLocator ):
16  Auditor( name, pSvcLocator ),
17  m_vtuneProfilerSvc( "VTuneProfilerService", name )
18 {
19 
20  declareProperty( "ProfiledAlgs", m_algs,
21  "List of profiled algorithms." );
22 
23 }
24 
25 /*
26  * Initialize the Auditor
27  */
29 {
30 
31  if( !m_vtuneProfilerSvc.retrieve().isSuccess() ) {
32  return StatusCode::FAILURE;
33  }
34 
35  // Copy algorithms from the service
36  const IProperty* vtuneProfSvcProp = dynamic_cast<const IProperty*>(&(*m_vtuneProfilerSvc));
37  if ( !vtuneProfSvcProp ) {
38  msgStream() << MSG::ERROR
39  << "Could not retrieve IProperty interface to VTuneProfilerService."
40  << endmsg;
41  return StatusCode::FAILURE;
42  }
43 
44  std::vector<std::string> props2Copy = { "ProfiledAlgs" };
45  for(auto& prop : props2Copy) {
46  if ( !setProperty(vtuneProfSvcProp->getProperty(prop)) ) {
47  msgStream() << MSG::ERROR
48  << "Cannot set " << prop << " property."
49  << endmsg;
50  return StatusCode::FAILURE;
51  }
52  }
53 
54  return StatusCode::SUCCESS;
55 
56 }
57 
58 /*
59  * Implementation of base class methods
60  */
61 void VTuneAuditor::before( StandardEventType etype, INamedInterface* component ) {
62 
63  for( auto& val : m_algs ) {
64  if ( etype == StandardEventType::Execute && component->name() == val ) {
65  if ( m_vtuneProfilerSvc->resumeProfiling().isFailure() ) {
66  msgStream() << MSG::ERROR
67  << "Could not resume the profiling from the auditor"
68  << endmsg;
69  }
70  break;
71  }
72  }
73  return;
74 
75 }
76 
77 void VTuneAuditor::after( StandardEventType etype, INamedInterface* component, const StatusCode& ) {
78 
79  for( auto& val : m_algs ) {
80  if ( etype == StandardEventType::Execute && component->name() == val ) {
81  if ( m_vtuneProfilerSvc->pauseProfiling().isFailure() ) {
82  msgStream() << MSG::ERROR
83  << "Could not pause the profiling from the auditor"
84  << endmsg;
85  }
86  break;
87  }
88  }
89  return;
90 
91 }
VTuneAuditor::m_algs
std::vector< std::string > m_algs
Property: List of algorithms to profile.
Definition: VTuneAuditor.h:47
VTuneAuditor.h
VTuneAuditor::before
void before(StandardEventType, INamedInterface *) override
Implement inherited methods from Auditor.
Definition: VTuneAuditor.cxx:61
VTuneAuditor::VTuneAuditor
VTuneAuditor(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: VTuneAuditor.cxx:14
LArPulseShapeRunConfig.Execute
Execute
Definition: LArPulseShapeRunConfig.py:62
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
VTuneAuditor::initialize
virtual StatusCode initialize() override
Gaudi hooks.
Definition: VTuneAuditor.cxx:28
VTuneAuditor::m_vtuneProfilerSvc
ServiceHandle< IVTuneProfilerSvc > m_vtuneProfilerSvc
Handle to VTuneProfilerSvc.
Definition: VTuneAuditor.h:44
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
VTuneAuditor::after
void after(StandardEventType, INamedInterface *, const StatusCode &) override
Definition: VTuneAuditor.cxx:77