ATLAS Offline Software
Loading...
Searching...
No Matches
VTuneAuditor.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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 */
14VTuneAuditor::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 */
61void VTuneAuditor::before( const std::string& event, const std::string& name, const EventContext& ) {
62
63 for( auto& val : m_algs ) {
64 if ( event == IAuditor::Execute && 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
77void VTuneAuditor::after( const std::string& event, const std::string& name, const EventContext&,
78 const StatusCode& ) {
79
80 for( auto& val : m_algs ) {
81 if ( event == IAuditor::Execute && name == val ) {
82 if ( m_vtuneProfilerSvc->pauseProfiling().isFailure() ) {
83 msgStream() << MSG::ERROR
84 << "Could not pause the profiling from the auditor"
85 << endmsg;
86 }
87 break;
88 }
89 }
90 return;
91
92}
#define endmsg
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
virtual void after(const std::string &event, const std::string &name, const EventContext &, const StatusCode &) override
virtual void before(const std::string &event, const std::string &name, const EventContext &) override
Implement inherited methods from Auditor.
virtual StatusCode initialize() override
Gaudi hooks.
std::vector< std::string > m_algs
Property: List of algorithms to profile.
VTuneAuditor(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
ServiceHandle< IVTuneProfilerSvc > m_vtuneProfilerSvc
Handle to VTuneProfilerSvc.