diff --git a/Control/AthenaCommon/python/AppMgr.py b/Control/AthenaCommon/python/AppMgr.py index 5731b7832b975f47519526c9d6e0702c9c76496a..4da48370440d726d6ea0d66c38d8011923565dbc 100755 --- a/Control/AthenaCommon/python/AppMgr.py +++ b/Control/AthenaCommon/python/AppMgr.py @@ -258,10 +258,10 @@ class AthAppMgr( AppMgr ): Logging.log.debug ("building master sequence...") athMasterSeq = _as.AthSequencer ("AthMasterSeq",Sequential = True) athFilterSeq = _as.AthSequencer ("AthFilterSeq"); - athBeginSeq = _as.AthSequencer ("AthBeginSeq") + athBeginSeq = _as.AthSequencer ("AthBeginSeq",Sequential=True) athCondSeq = _as.AthSequencer ("AthCondSeq") athAlgSeq = _as.AthSequencer ("AthAlgSeq") - athEndSeq = _as.AthSequencer ("AthEndSeq") + athEndSeq = _as.AthSequencer ("AthEndSeq",Sequential=True) athOutSeq = _as.AthSequencer ("AthOutSeq") athRegSeq = _as.AthSequencer ("AthRegSeq") athAllAlgSeq = _as.AthSequencer ("AthAllAlgSeq") diff --git a/Control/AthenaServices/src/CoreDumpSvc.cxx b/Control/AthenaServices/src/CoreDumpSvc.cxx index 29edf73e82e01172f2dfeb850b1593993aaef8a8..baef5ddaea7719a04f6fddcb3d1021d5890822fd 100644 --- a/Control/AthenaServices/src/CoreDumpSvc.cxx +++ b/Control/AthenaServices/src/CoreDumpSvc.cxx @@ -37,6 +37,7 @@ #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/System.h" #include "GaudiKernel/ThreadLocalContext.h" +#include "GaudiKernel/ConcurrencyFlags.h" // Athena includes #include "AthenaKernel/IAthenaSummarySvc.h" @@ -158,10 +159,9 @@ CoreDumpSvc::CoreDumpSvc( const std::string& name, ISvcLocator* pSvcLocator ) : sigs.push_back(SIGILL); sigs.push_back(SIGFPE); m_signals.setValue(sigs); - // Allocate for 200 slots. This should be increased if we foresee more than 200 slots. - // Memory overhead is negligable compared to dynamically allocate the entries - m_usrCoreDumps.resize(200); - m_sysCoreDumps.resize(200); + // Allocate for 2 slots just for now. + m_usrCoreDumps.resize(2); + m_sysCoreDumps.resize(2); } @@ -238,6 +238,20 @@ StatusCode CoreDumpSvc::initialize() return StatusCode::SUCCESS; } +StatusCode CoreDumpSvc::start(){ + auto numSlots=Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents(); + numSlots=(1>numSlots)?1:numSlots; + if(numSlots>1000){ + ATH_MSG_WARNING("Num Slots are greater than 1000. Is this correct? numSlots="<< + numSlots); + numSlots=1000; + ATH_MSG_WARNING("Setting numSlots to "<<numSlots); + } + m_usrCoreDumps.resize(numSlots); + m_sysCoreDumps.resize(numSlots); + +} + StatusCode CoreDumpSvc::finalize() { ATH_MSG_DEBUG ("Finalizing " << name()); @@ -272,7 +286,9 @@ StatusCode CoreDumpSvc::queryInterface(const InterfaceID& riid, void** ppvInterf //---------------------------------------------------------------------- void CoreDumpSvc::setCoreDumpInfo( const std::string& name, const std::string& value ) { - auto &m_usrCoreDump=m_usrCoreDumps.at(Gaudi::Hive::currentContext().slot()); + auto currSlot=Gaudi::Hive::currentContext().slot(); + if(currSlot==EventContext::INVALID_CONTEXT_ID)currSlot=0; + auto &m_usrCoreDump=m_usrCoreDumps.at(currSlot); m_usrCoreDump[name] = value; } @@ -440,7 +456,9 @@ void CoreDumpSvc::handle(const Incident& incident) { //handle is single threaded in context; const auto &currCtx=incident.context(); - auto &currRec=m_sysCoreDumps.at(currCtx.slot()); + auto currSlot=currCtx.slot(); + if(currSlot==EventContext::INVALID_CONTEXT_ID)currSlot=0; + auto &currRec=m_sysCoreDumps.at(currSlot); currRec.LastInc= incident.source() + ":" + incident.type(); //m_sysCoreDump["Last incident"] = incident.source() + ":" + incident.type(); diff --git a/Control/AthenaServices/src/CoreDumpSvc.h b/Control/AthenaServices/src/CoreDumpSvc.h index 0a52180f6db2e2b8680171aac7fddc10695986fa..23cece29dbc63fe0c5a61f543aaaa001de65108e 100644 --- a/Control/AthenaServices/src/CoreDumpSvc.h +++ b/Control/AthenaServices/src/CoreDumpSvc.h @@ -88,6 +88,7 @@ public: //@{ virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface ); virtual StatusCode initialize(); + virtual StatusCode start(); virtual StatusCode finalize(); /// Incident listener diff --git a/Control/StoreGate/StoreGate/StoreGateSvc.h b/Control/StoreGate/StoreGate/StoreGateSvc.h index 99e42a5e69a9b453787c70f2efa8ad4779716a56..0306d4fb33fcf9e4c0034b9f711f8f0c36cda14b 100644 --- a/Control/StoreGate/StoreGate/StoreGateSvc.h +++ b/Control/StoreGate/StoreGate/StoreGateSvc.h @@ -58,6 +58,7 @@ #include "StoreGate/SGObjectWithVersion.h" #include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/IIncidentListener.h" #ifdef SG_DEPRECATION_WARNINGS # define SG_DEPRECATED __attribute__((deprecated)) @@ -128,7 +129,8 @@ class StoreGateSvc : public Service, public IProxyDict, public IHiveStore, - public IHiveStoreMgr + public IHiveStoreMgr, + public IIncidentListener { public: @@ -855,6 +857,7 @@ public: ////////////////////////////////////////////////////////////////// /// \name Gaudi IIncidentListener implementation //@{ + virtual void handle(const Incident&) override final; /// load proxies at begin event StatusCode loadEventProxies(); //@} diff --git a/Control/StoreGate/src/SGHiveMgrSvc.cxx b/Control/StoreGate/src/SGHiveMgrSvc.cxx index 15818599011324b7b015cfb32e10b305bd387892..7d6ccdf3e9bd3b1733227cb981f84124d0aaf920 100644 --- a/Control/StoreGate/src/SGHiveMgrSvc.cxx +++ b/Control/StoreGate/src/SGHiveMgrSvc.cxx @@ -2,11 +2,13 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ +#include "GaudiKernel/IIncidentSvc.h" #include "AthenaKernel/CloneService.h" #include "AthenaKernel/errorcheck.h" #include "StoreGate/StoreGateSvc.h" #include "StoreGate/tools/SGImplSvc.h" #include "SGHiveMgrSvc.h" + using namespace SG; __thread HiveEventSlot* s_current(0); @@ -149,6 +151,14 @@ StatusCode HiveMgrSvc::initialize() { //use hiveStore default impl store as prototype Service* child(0); SGImplSvc* pSG(0); + ServiceHandle<IIncidentSvc> pincSvc("IncidentSvc",name()); + if(!(pincSvc.retrieve().isSuccess())){ + error()<<"Failed to retrieve incident Svc"<<endmsg; + return StatusCode::FAILURE; + } + const int PRIORITY=100; + pincSvc->addListener(this, "EndEvent",PRIORITY); + pincSvc->addListener(this, "BeginEvent", PRIORITY); for( size_t i = 0; i< m_nSlots; ++i) { std::ostringstream oss; @@ -164,8 +174,14 @@ StatusCode HiveMgrSvc::initialize() { return StatusCode::FAILURE; } } + return selectStore(0); } + +void HiveMgrSvc::handle(const Incident &inc) { + m_slots.at(inc.context().slot()).pEvtStore->handle(inc); +} + StatusCode HiveMgrSvc::finalize() { info() << "Finalizing " << name() << " - package version " << PACKAGE_VERSION << endmsg ; diff --git a/Control/StoreGate/src/SGHiveMgrSvc.h b/Control/StoreGate/src/SGHiveMgrSvc.h index d294f37e265eb60cd02f81b6cc5ac1a47cd09a5f..4af0b4604f89cad163a70e9340673ed6b160bf23 100644 --- a/Control/StoreGate/src/SGHiveMgrSvc.h +++ b/Control/StoreGate/src/SGHiveMgrSvc.h @@ -14,6 +14,8 @@ #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/StatusCode.h" #include "GaudiKernel/IHiveWhiteBoard.h" +#include "GaudiKernel/IIncidentListener.h" + #include "StoreGate/StoreGateSvc.h" #include "StoreGate/SGHiveEventSlot.h" @@ -29,7 +31,7 @@ template <class TYPE> class SvcFactory; * $Id: SGHiveMgrSvc.h 794852 2017-01-31 23:24:04Z leggett $ **/ namespace SG { -class HiveMgrSvc : virtual public IHiveWhiteBoard, public Service { + class HiveMgrSvc : virtual public IHiveWhiteBoard, public Service, public IIncidentListener { friend class SvcFactory<HiveMgrSvc>; friend class TestSGHiveMgrSvc; public: @@ -104,13 +106,14 @@ public: virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface ); //@} + //handle incidents + virtual void handle(const Incident&) override final; private: ServiceHandle<StoreGateSvc> m_hiveStore; size_t m_nSlots; //property settable also by setNumberOfStores std::vector<SG::HiveEventSlot> m_slots; //maybe ServiceHandle<ActiveStoreSvc> m_active; - protected: /// Standard Service Constructor. sets active store to default event store HiveMgrSvc(const std::string& name, ISvcLocator* svc); diff --git a/Control/StoreGate/src/SGImplSvc.cxx b/Control/StoreGate/src/SGImplSvc.cxx index 3f52b05705cb4d91319aba4ebf932f65115d359c..400784d87bd3f17ed90d4f89cfd5c6c817a43d37 100644 --- a/Control/StoreGate/src/SGImplSvc.cxx +++ b/Control/StoreGate/src/SGImplSvc.cxx @@ -88,16 +88,65 @@ StoreID::type findStoreID(const string& storeNamePrefix) { if (::isdigit(storeNamePrefix.at(0))) { ist = storeNamePrefix.find("_",0) +1; } + //slightly faster - auto i(BEG); - while (i != END) { - int comp = storeNamePrefix.compare(ist, (i->first).size(), (i->first)); - // std::cout << storeNamePrefix <<' '<< storeNamePrefix.size() <<' '<< i->first <<' '<< (i->first).size() <<' '<< comp << std::endl; - //NAMETOID is sorted so if we go past storeNamePrefix we are done - if (comp < 0) break; - else if (comp == 0) return i->second; - ++i; + auto c(storeNamePrefix.at(ist)); + switch(c){ + case 'C': + { + return StoreID::CONDITION_STORE; + break; + } + case 'D': + { + return StoreID::DETECTOR_STORE; + break; + } + case 'E': + { + return StoreID::EVENT_STORE; + break; + } + case 'I': + { + return StoreID::METADATA_STORE; + break; + } + case 'M': + { + return StoreID::SIMPLE_STORE; + break; + } + case 'S': + { + if (storeNamePrefix.at(ist+1)=='p'){ + return StoreID::SPARE_STORE; + }else{ + return StoreID::EVENT_STORE; + } + break; + } + case 'T': + { + return StoreID::METADATA_STORE; + break; + } + default: + { + return StoreID::UNKNOWN; + break; + } } + + // auto i(BEG); + // while (i != END) { + // int comp = storeNamePrefix.compare(ist, (i->first).size(), (i->first)); + // // std::cout << storeNamePrefix <<' '<< storeNamePrefix.size() <<' '<< i->first <<' '<< (i->first).size() <<' '<< comp << std::endl; + // //NAMETOID is sorted so if we go past storeNamePrefix we are done + // if (comp < 0) break; + // else if (comp == 0) return i->second; + // ++i; + // } return StoreID::UNKNOWN; } @@ -206,9 +255,10 @@ StatusCode SGImplSvc::initialize() { } //start listening to "EndEvent" - const int PRIORITY = 100; - m_pIncSvc->addListener(this, "EndEvent", PRIORITY); - m_pIncSvc->addListener(this, "BeginEvent", PRIORITY); + // const int PRIORITY = 100; + // Mother svc should register these incidents + // m_pIncSvc->addListener(this, "EndEvent", PRIORITY); + // m_pIncSvc->addListener(this, "BeginEvent", PRIORITY); const bool CREATEIF(true); // cache pointer to Persistency Service diff --git a/Control/StoreGate/src/StoreGateSvc.cxx b/Control/StoreGate/src/StoreGateSvc.cxx index e85648ae78c0936d04872e526faac4dee40eebec..77b087c458e28fa3f8477efe5572475e128bb69f 100644 --- a/Control/StoreGate/src/StoreGateSvc.cxx +++ b/Control/StoreGate/src/StoreGateSvc.cxx @@ -174,7 +174,7 @@ StatusCode StoreGateSvc::initialize() { std::string implStoreFullName = "SGImplSvc/" + implStoreName; debug() << "trying to create store " << implStoreFullName << endmsg; - + ISvcManager* pSM(dynamic_cast<ISvcManager*>(&*serviceLocator())); if (!pSM) std::abort(); m_defaultStore = dynamic_cast<SGImplSvc*>( (pSM->createService(implStoreFullName)).get() ); @@ -183,7 +183,7 @@ StatusCode StoreGateSvc::initialize() { error() << "Could not create store " << implStoreFullName << endmsg; return StatusCode::FAILURE; } - + if ( m_defaultStore->sysInitialize().isSuccess() ) { // createService returns to us a reference to the service; we shouldn't // increment it again. @@ -203,6 +203,9 @@ StatusCode StoreGateSvc::initialize() { error() << "Could not locate IncidentSvc" << endmsg; return StatusCode::FAILURE; } + const int PRIORITY=100; + m_incSvc->addListener(this, "EndEvent",PRIORITY); + m_incSvc->addListener(this, "BeginEvent", PRIORITY); return StatusCode::SUCCESS; } @@ -224,6 +227,10 @@ StatusCode StoreGateSvc::stop() { return StatusCode::SUCCESS; } +void StoreGateSvc::handle(const Incident &inc) { + m_defaultStore->handle(inc); +} + ////////////////////////////////////////////////////////////// IIOVSvc* StoreGateSvc::getIIOVSvc() { // Get hold of the IOVSvc