From 1eba0b806d09206fb336c25b68c9ebdd5e9b97a6 Mon Sep 17 00:00:00 2001 From: amete <serhanmete@gmail.com> Date: Fri, 10 May 2019 17:35:52 +0200 Subject: [PATCH] Starting groundwork for PerfMon MT migration --- .../PerfMonComps/PerfMonComps/PerfMonMTAlg.h | 37 ++++++++ .../PerfMonComps/PerfMonMTAuditor.h | 54 +++++++++++ .../PerfMonComps/PerfMonComps/PerfMonMTSvc.h | 42 +++++++++ .../share/PerfMonMTSvc_jobOptions.py | 25 +++++ .../PerfMonComps/src/PerfMonMTAlg.cxx | 55 +++++++++++ .../PerfMonComps/src/PerfMonMTAuditor.cxx | 51 ++++++++++ .../PerfMonComps/src/PerfMonMTSvc.cxx | 94 +++++++++++++++++++ .../PerfMonComps/src/PerfMonUtils.cxx | 5 + .../src/components/PerfMonComps_entries.cxx | 4 + .../PerfMonKernel/IPerfMonMTSvc.h | 43 +++++++++ 10 files changed, 410 insertions(+) create mode 100644 Control/PerformanceMonitoring/PerfMonComps/PerfMonComps/PerfMonMTAlg.h create mode 100644 Control/PerformanceMonitoring/PerfMonComps/PerfMonComps/PerfMonMTAuditor.h create mode 100644 Control/PerformanceMonitoring/PerfMonComps/PerfMonComps/PerfMonMTSvc.h create mode 100644 Control/PerformanceMonitoring/PerfMonComps/share/PerfMonMTSvc_jobOptions.py create mode 100644 Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTAlg.cxx create mode 100644 Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTAuditor.cxx create mode 100644 Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTSvc.cxx create mode 100644 Control/PerformanceMonitoring/PerfMonKernel/PerfMonKernel/IPerfMonMTSvc.h diff --git a/Control/PerformanceMonitoring/PerfMonComps/PerfMonComps/PerfMonMTAlg.h b/Control/PerformanceMonitoring/PerfMonComps/PerfMonComps/PerfMonMTAlg.h new file mode 100644 index 000000000000..386817f74d6c --- /dev/null +++ b/Control/PerformanceMonitoring/PerfMonComps/PerfMonComps/PerfMonMTAlg.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PERFMONCOMPS_PERFMONMTALG_H +#define PERFMONCOMPS_PERFMONMTALG_H + +// Framework includes +#include "AthenaBaseComps/AthReentrantAlgorithm.h" + +// Forward declaration +class IPerfMonMTSvc; + +class PerfMonMTAlg : public AthReentrantAlgorithm { + + public: + + /// Standard Algorithm constructor + PerfMonMTAlg( const std::string& name, ISvcLocator* pSvcLocator ); + + /// Standard initialization function + StatusCode initialize(); + + /// Standard execute function + StatusCode execute( const EventContext& ) const; + + /// Standard finalization function + StatusCode finalize(); + + private: + + /// Handle to PerfMonMTSvc + ServiceHandle< IPerfMonMTSvc > m_perfMonMTSvc; + +}; + +#endif // PERFMONCOMPS_PERFMONMTALG_H diff --git a/Control/PerformanceMonitoring/PerfMonComps/PerfMonComps/PerfMonMTAuditor.h b/Control/PerformanceMonitoring/PerfMonComps/PerfMonComps/PerfMonMTAuditor.h new file mode 100644 index 000000000000..f0f4dad2c777 --- /dev/null +++ b/Control/PerformanceMonitoring/PerfMonComps/PerfMonComps/PerfMonMTAuditor.h @@ -0,0 +1,54 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PERFMONCOMPS_PERFMONMTAUDITOR_H +#define PERFMONCOMPS_PERFMONMTAUDITOR_H + +// STL includes +#include <string> + +// Framework includes +#include "GaudiKernel/Auditor.h" +#include "GaudiKernel/ServiceHandle.h" + +// Forward declaration +//class INamedInterface; +class IPerfMonMTSvc; + +class PerfMonMTAuditor : public Auditor +{ + /* + using Auditor::before; + using Auditor::after; + */ + + public: + + /// Constructor + PerfMonMTAuditor(const std::string& name, ISvcLocator* pSvcLocator); + + /// Gaudi hooks + virtual StatusCode initialize() override; + + /// Implement inherited methods from Auditor + void before( StandardEventType, INamedInterface* ) override; + 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; + + private: + + /// Handle to PerfMonMTSvc + ServiceHandle< IPerfMonMTSvc > m_perfMonMTSvc; + +}; // end PerfMonMTAuditor + +#endif // PERFMONCOMPS_PERFMONMTAUDITOR_H diff --git a/Control/PerformanceMonitoring/PerfMonComps/PerfMonComps/PerfMonMTSvc.h b/Control/PerformanceMonitoring/PerfMonComps/PerfMonComps/PerfMonMTSvc.h new file mode 100644 index 000000000000..334584b6fed6 --- /dev/null +++ b/Control/PerformanceMonitoring/PerfMonComps/PerfMonComps/PerfMonMTSvc.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PERFMONCOMPS_PERFMONMTSVC_H +#define PERFMONCOMPS_PERFMONMTSVC_H + +#include "AthenaBaseComps/AthService.h" + +#include "PerfMonKernel/IPerfMonMTSvc.h" + + +class PerfMonMTSvc : virtual public IPerfMonMTSvc, + public AthService +{ + + public: + + /// Standard Gaudi Service constructor + PerfMonMTSvc( const std::string& name, ISvcLocator* pSvcLocator ); + + /// Function declaring the interface(s) implemented by the service + virtual StatusCode queryInterface( const InterfaceID& riid, + void** ppvInterface ) override; + + /// Standard Gaudi Service initialization + virtual StatusCode initialize() override; + + /// Standard Gaudi Service finalization + virtual StatusCode finalize() override; + + /// Start Auditing + virtual void startAud( const std::string& stepName, + const std::string& compName ) override; + + /// Stop Auditing + virtual void stopAud ( const std::string& stepName, + const std::string& compName ) override; + +}; // class PerfMonMTSvc + +#endif // PERFMONCOMPS_PERFMONMTSVC_H diff --git a/Control/PerformanceMonitoring/PerfMonComps/share/PerfMonMTSvc_jobOptions.py b/Control/PerformanceMonitoring/PerfMonComps/share/PerfMonMTSvc_jobOptions.py new file mode 100644 index 000000000000..819776e7d153 --- /dev/null +++ b/Control/PerformanceMonitoring/PerfMonComps/share/PerfMonMTSvc_jobOptions.py @@ -0,0 +1,25 @@ +############################### +# Load PerfMonMTSvc +############################### +from AthenaCommon.AppMgr import ServiceMgr as svcMgr +if not hasattr(svcMgr, "PerfMonMTSvc"): + from PerfMonComps.PerfMonCompsConf import PerfMonMTSvc + svcMgr += PerfMonMTSvc("PerfMonMTSvc") + pass + +############################### +# Load PerfMonMTAlg +############################### +from AthenaCommon.AlgSequence import AthSequencer +topSequence = AthSequencer("AthAlgSeq") +if not hasattr(topSequence, "PerfMonMTSvcAlg"): + from PerfMonComps.PerfMonCompsConf import PerfMonMTAlg + topSequence += PerfMonMTAlg("PerfMonMTAlg") + pass + +############################### +# Print what we did +############################### +from AthenaCommon.Logging import logging +log = logging.getLogger("PerfMonMTSvc_jobOptions.py") +log.info("Setting up PerfMonMT...") diff --git a/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTAlg.cxx b/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTAlg.cxx new file mode 100644 index 000000000000..81ac0b0e42e4 --- /dev/null +++ b/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTAlg.cxx @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +// PerfMonKernel includes +#include "PerfMonKernel/IPerfMonMTSvc.h" + +// PerfMonComps includes +#include "PerfMonComps/PerfMonMTAlg.h" + +/* + * Constructor + */ +PerfMonMTAlg::PerfMonMTAlg( const std::string& name, + ISvcLocator* pSvcLocator ) + : AthReentrantAlgorithm( name, pSvcLocator ), + m_perfMonMTSvc( "PerfMonMTSvc", name ) { + +} + +/* + * Initialize the algorithm + */ +StatusCode PerfMonMTAlg::initialize() { + + ATH_MSG_INFO("Initialize"); + + /// Retrieve the PerfMonMTSvc + CHECK( m_perfMonMTSvc.retrieve() ); + + return StatusCode::SUCCESS; + +} + +/* + * Finalize the algorithm + */ +StatusCode PerfMonMTAlg::finalize() { + + ATH_MSG_INFO("Finalize"); + + return StatusCode::SUCCESS; + +} + +/* + * Execute the algorithm + */ +StatusCode PerfMonMTAlg::execute( const EventContext& /*ctx*/ ) const { + + // Call startAud + m_perfMonMTSvc->startAud("",""); + + return StatusCode::SUCCESS; +} diff --git a/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTAuditor.cxx b/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTAuditor.cxx new file mode 100644 index 000000000000..27ea7599006a --- /dev/null +++ b/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTAuditor.cxx @@ -0,0 +1,51 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +// Framework includes +#include "GaudiKernel/INamedInterface.h" + +// PerfMonKernel includes +#include "PerfMonKernel/IPerfMonMTSvc.h" + +// PerfMonComps includes +#include "PerfMonComps/PerfMonMTAuditor.h" + +/* + * Constructor + */ +PerfMonMTAuditor::PerfMonMTAuditor( const std::string& name, + ISvcLocator* pSvcLocator ) : + Auditor ( name, pSvcLocator ), + m_perfMonMTSvc ( "PerfMonMTSvc", name ) +{ + +} + + +/* + * Initialize the Auditor + */ +StatusCode PerfMonMTAuditor::initialize() +{ + //ATH_MSG_INFO("Initialize"); + + if ( !m_perfMonMTSvc.retrieve().isSuccess() ) { + //ATH_MSG_ERROR("Could not retrieve PerfMonMTSvc!"); + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +/* + * Implementation of base class methods + */ +void PerfMonMTAuditor::before( StandardEventType, INamedInterface* ) { return; } +void PerfMonMTAuditor::before( StandardEventType, const std::string& ) { return; } +void PerfMonMTAuditor::before( CustomEventTypeRef, INamedInterface* ) { return; } +void PerfMonMTAuditor::before( CustomEventTypeRef, const std::string& ) { return; } +void PerfMonMTAuditor::after( StandardEventType, INamedInterface*, const StatusCode& ) { return; } +void PerfMonMTAuditor::after( StandardEventType, const std::string&, const StatusCode& ) { return; } +void PerfMonMTAuditor::after( CustomEventTypeRef, INamedInterface*, const StatusCode& ) { return; } +void PerfMonMTAuditor::after( CustomEventTypeRef, const std::string&, const StatusCode& ) { return; } diff --git a/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTSvc.cxx b/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTSvc.cxx new file mode 100644 index 000000000000..c7d1188db6d3 --- /dev/null +++ b/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTSvc.cxx @@ -0,0 +1,94 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +// STL includes +#include <pthread.h> +#include <time.h> + +// Framework includes +#include "GaudiKernel/ThreadLocalContext.h" + +// PerfMonComps includes +#include "PerfMonComps/PerfMonMTSvc.h" +#include "PerfMonUtils.h" // borrow from existing code + +/* + * Constructor + */ +PerfMonMTSvc::PerfMonMTSvc( const std::string& name, + ISvcLocator* pSvcLocator ) + : AthService( name, pSvcLocator ) { +} + +/* + * Query Interface + */ +StatusCode PerfMonMTSvc::queryInterface( const InterfaceID& riid, + void** ppvInterface ) { + + if( !ppvInterface ) { + return StatusCode::FAILURE; + } + + if ( riid == IPerfMonMTSvc::interfaceID() ) { + *ppvInterface = static_cast< IPerfMonMTSvc* >( this ); + return StatusCode::SUCCESS; + } + + return AthService::queryInterface( riid, ppvInterface ); +} + +/* + * Initialize the Service + */ +StatusCode PerfMonMTSvc::initialize() { + + ATH_MSG_INFO("Initialize"); + + /// Configure the auditor + if( !PerfMon::makeAuditor("PerfMonMTAuditor", auditorSvc(), msg()).isSuccess()) { + ATH_MSG_ERROR("Could not register auditor [PerfMonMTAuditor]!"); + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; + +} + +/* + * Finalize the Service + */ +StatusCode PerfMonMTSvc::finalize() { + + ATH_MSG_INFO("Finalize"); + + return StatusCode::SUCCESS; + +} + +/* + * Start Auditing + */ +void PerfMonMTSvc::startAud( const std::string& /*stepName*/, + const std::string& /*compName*/ ) { + ATH_MSG_INFO("Starting Auditing"); + const EventContext ctx = Gaudi::Hive::currentContext(); + if(ctx.valid()) { + ATH_MSG_INFO("Current event number is " << ctx.evt() << + " slot number is " << ctx.slot()); + } + + // Get thread's clock id + clockid_t thread_cid; + pthread_getcpuclockid(pthread_self(),&thread_cid); + ATH_MSG_INFO("Current threads' CPU clock id is " << thread_cid); +} + +/* + * Stop Auditing + */ +void PerfMonMTSvc::stopAud( const std::string& /*stepName*/, + const std::string& /*compName*/ ) { + ATH_MSG_INFO("Stopping Auditing"); +} diff --git a/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonUtils.cxx b/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonUtils.cxx index b90359deb794..ace6534f806f 100644 --- a/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonUtils.cxx +++ b/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonUtils.cxx @@ -32,6 +32,11 @@ StatusCode makeAuditor( const std::string& audName, IAuditorSvc* audSvc, MsgStream& msg ) { + msg << MSG::INFO << "SERHAN" << endmsg; + msg << MSG::INFO << "SERHAN" << endmsg; + msg << MSG::INFO << "SERHAN" << endmsg; + msg << MSG::INFO << "SERHAN" << endmsg; + if ( 0 == audSvc ) { msg << MSG::ERROR << "Null pointer to IAuditorSvc !!" << endmsg; return StatusCode::FAILURE; diff --git a/Control/PerformanceMonitoring/PerfMonComps/src/components/PerfMonComps_entries.cxx b/Control/PerformanceMonitoring/PerfMonComps/src/components/PerfMonComps_entries.cxx index 7cd8a61913be..b2928ce77dee 100644 --- a/Control/PerformanceMonitoring/PerfMonComps/src/components/PerfMonComps_entries.cxx +++ b/Control/PerformanceMonitoring/PerfMonComps/src/components/PerfMonComps_entries.cxx @@ -5,6 +5,8 @@ #include "../PerfMonAuditor.h" #include "../PerfMonStorePayloadMon.h" +#include "PerfMonComps/PerfMonMTSvc.h" +#include "PerfMonComps/PerfMonMTAlg.h" DECLARE_COMPONENT( PerfMonSvc ) DECLARE_COMPONENT( Athena::PerfMonAuditor ) @@ -14,3 +16,5 @@ DECLARE_COMPONENT( PerfMon::CallGraphBuilderSvc ) DECLARE_COMPONENT( PerfMon::CallGraphAuditor ) DECLARE_COMPONENT( PerfMon::StorePayloadMon ) +DECLARE_COMPONENT( PerfMonMTSvc ) +DECLARE_COMPONENT( PerfMonMTAlg ) diff --git a/Control/PerformanceMonitoring/PerfMonKernel/PerfMonKernel/IPerfMonMTSvc.h b/Control/PerformanceMonitoring/PerfMonKernel/PerfMonKernel/IPerfMonMTSvc.h new file mode 100644 index 000000000000..f454a02f16a8 --- /dev/null +++ b/Control/PerformanceMonitoring/PerfMonKernel/PerfMonKernel/IPerfMonMTSvc.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PERMONKERNEL_IPERFMONMTSV_H +#define PERMONKERNEL_IPERFMONMTSV_H + +/// STL includes +#include <string> + +/// Framework include +//#include "GaudiKernel/IMonitorSvc.h" +#include "GaudiKernel/IService.h" + +//class IPerfMonMTSvc : virtual public IMonitorSvc +class IPerfMonMTSvc : virtual public IService +{ + + public: + + /// Framework - Service InterfaceID + static const InterfaceID& interfaceID(); + + /// Start Auditing + virtual void startAud( const std::string& stepName, + const std::string& compName = "PerfMonMTSlice" ) = 0; + + /// Stop Auditing + virtual void stopAud( const std::string& stepName, + const std::string& compName = "PerfMonMTSlice" ) = 0; + +}; // class IPerfMonMTSvc + +/////////////////////////////////////////////////////////////////// +// Inline methods: +/////////////////////////////////////////////////////////////////// +inline const InterfaceID& IPerfMonMTSvc::interfaceID() +{ + static const InterfaceID IID_IPerfMonMTSvc("IPerfMonMTSvc", 1, 0); + return IID_IPerfMonMTSvc; +} + +#endif // PERMONKERNEL_IPERFMONMTSV_H -- GitLab