Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
14 #include "valgrind/valgrind.h"
15 #include "valgrind/memcheck.h"
16 #include "valgrind/callgrind.h"
19 #include "Gaudi/Property.h"
20 #include "GaudiKernel/IIncidentSvc.h"
21 #include "GaudiKernel/Incident.h"
22 #include "GaudiKernel/ServiceHandle.h"
23 #include "GaudiKernel/Memory.h"
36 ISvcLocator* pSvcLocator ) :
37 base_class(
name, pSvcLocator),
44 declareProperty(
"ProfiledAlgs",
m_algs,
45 "List of profiled algorithms" );
48 "Intervals to profile (e.g. 'MyAlg.initialize:MyAlg.finalize'" );
51 "Dump separate profile after each event" );
54 "Dump separate profile after each interval in ProfiledIntervals" );
57 "List of incidents on which to dump a profile");
60 "Do not profile the first N events");
74 ATH_MSG_INFO (
"My process ID is [" << System::procID() <<
"]");
76 const bool insideValgrind =
static_cast<bool>(RUNNING_ON_VALGRIND);
77 if ( insideValgrind ) {
78 ATH_MSG_INFO (
"=== Running from inside Valgrind ! Hi there! ===");
89 makeAuditor(
"ValgrindAuditor",auditorSvc()).ignore();
91 if ((auditorSvc()==0) || auditorSvc()->getAuditor(
"ValgrindAuditor")==0) {
93 return StatusCode::FAILURE;
103 incSvc->addListener(
this, IncidentType::BeginEvent );
104 incSvc->addListener(
this, IncidentType::EndEvent );
107 incSvc->addListener(
this, incident );
110 return StatusCode::SUCCESS;
117 return StatusCode::SUCCESS;
134 if ( inc.type() == IncidentType::BeginEvent ) {
137 ATH_MSG_DEBUG (
"[BeginEvent] Callgrind instrumentation ON.");
144 if ( useEventIncident ) {
161 <<
" after incident [" << inc.type() <<
"].");
181 CALLGRIND_START_INSTRUMENTATION;
186 CALLGRIND_STOP_INSTRUMENTATION;
191 CALLGRIND_TOGGLE_COLLECT;
196 CALLGRIND_DUMP_STATS;
202 VALGRIND_DO_LEAK_CHECK;
213 return StatusCode::FAILURE;
216 if ( 0 != audSvc->getAuditor( audName ) ) {
218 << audName <<
"]... good.");
219 return StatusCode::SUCCESS;
222 const std::string
propName =
"Auditors";
223 IProperty * audSvcProp =
dynamic_cast<IProperty*
>(audSvc);
225 if ( 0 == audSvcProp ) {
226 ATH_MSG_ERROR (
"Could not dyn-cast IAuditorSvc to an IProperty !!");
227 return StatusCode::FAILURE;
230 StringArrayProperty audNames;
231 audNames.assign( audSvcProp->getProperty(
propName) );
232 std::vector<std::string> updatedNames( audNames.value() );
233 updatedNames.push_back( audName );
234 audNames.set( updatedNames );
236 if ( !audSvcProp->setProperty( audNames ).isSuccess() ) {
238 (
"Could not add [" << audName
239 <<
"] to the list of auditors of [AuditorSvc] !!"
241 << audSvcProp->getProperty(
propName));
242 return StatusCode::FAILURE;
246 if ( 0 == audSvc->getAuditor( audName ) ) {
248 << audName <<
"] !!");
249 return StatusCode::FAILURE;
253 return StatusCode::SUCCESS;
std::vector< std::string > m_dumpAfterIncident
List of incidents on which to create a profile dump.
std::string find(const std::string &s)
return a remapped string
unsigned int m_eventCounter
Internal event counter for BeginEvent incident.
virtual void handle(const Incident &incident) override
incident service handle for Begin/EndEvent
virtual void callgrindToggleCollect() override
Toggle callgrind event collection.
#define ATH_MSG_VERBOSE(x)
std::vector< std::string > m_intervals
List of auditor intervals to profile Syntax: "MessageSvc.initialize:MessageSvc.finalize".
StatusCode makeAuditor(const std::string &audName, IAuditorSvc *audSvc)
helper method to create auditors
bool m_dumpAfterEachInterval
Dump separate profile after each interval.
::StatusCode StatusCode
StatusCode definition for legacy code.
unsigned int m_ignoreFirstNEvents
Don't profile on the first N events.
virtual void valgrindDoLeakCheck() override
Do a leak check now.
bool m_dumpAfterEachEvent
Dump separate profile after each event.
virtual void callgrindStartInstrumentation() override
Start callgrind instrumentation.
std::vector< std::string > m_algs
List of algorithms to profile If list is empty, profile between begin/end event.
unsigned int m_profileCounter
Counter of created profiles.
ValgrindSvc(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
#define ATH_MSG_WARNING(x)
virtual ~ValgrindSvc()
Destructor:
virtual StatusCode initialize() override
Gaudi Service Implementation.
virtual void callgrindStopInstrumentation() override
Stop callgrind instrumentation.
virtual StatusCode finalize() override
virtual void callgrindDumpStats(std::ostream &out) override
Dump callgrind profiling stats.
virtual unsigned int profileCount() override
Number of created callgrind profiles.