From 0833e7e8b4b5c98ea9d753138b99a9b1f5bd7cc9 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 30 Oct 2017 14:25:48 -0500 Subject: [PATCH 01/52] Use queues to ensure legacy module see only one Run or Lumi at a time Added SerialTaskQueues to allow processing of only one Run and LuminosityBlock at a time for legacy modules. --- FWCore/Framework/interface/EDAnalyzer.h | 6 ++++++ FWCore/Framework/interface/EDFilter.h | 4 ++++ FWCore/Framework/interface/EDProducer.h | 4 ++++ FWCore/Framework/interface/OutputModule.h | 5 +++++ 4 files changed, 19 insertions(+) diff --git a/FWCore/Framework/interface/EDAnalyzer.h b/FWCore/Framework/interface/EDAnalyzer.h index 35912fe92c73c..e7612daaf5b37 100644 --- a/FWCore/Framework/interface/EDAnalyzer.h +++ b/FWCore/Framework/interface/EDAnalyzer.h @@ -6,6 +6,7 @@ #include "FWCore/ParameterSet/interface/ParameterSetfwd.h" #include "FWCore/Framework/interface/EDConsumerBase.h" #include "FWCore/Framework/interface/SharedResourcesAcquirer.h" +#include "FWCore/Concurrency/interface/SerialTaskQueue.h" #include @@ -49,6 +50,8 @@ namespace edm { void callWhenNewProductsRegistered(std::function const& func); + SerialTaskQueue* globalRunsQueue() { return &runQueue_;} + SerialTaskQueue* globalLuminosityBlocksQueue() { return &luminosityBlockQueue_;} private: bool doEvent(EventPrincipal const& ep, EventSetup const& c, ActivityRegistry* act, @@ -96,6 +99,9 @@ namespace edm { ModuleDescription moduleDescription_; SharedResourcesAcquirer resourceAcquirer_; + SerialTaskQueue runQueue_; + SerialTaskQueue luminosityBlockQueue_; + std::function callWhenNewProductsRegistered_; }; } diff --git a/FWCore/Framework/interface/EDFilter.h b/FWCore/Framework/interface/EDFilter.h index 4227b2f385c50..ff140a7279e5a 100644 --- a/FWCore/Framework/interface/EDFilter.h +++ b/FWCore/Framework/interface/EDFilter.h @@ -57,6 +57,8 @@ namespace edm { static bool wantsStreamRuns() {return false;} static bool wantsStreamLuminosityBlocks() {return false;}; + SerialTaskQueue* globalRunsQueue() { return &runQueue_;} + SerialTaskQueue* globalLuminosityBlocksQueue() { return &luminosityBlockQueue_;} private: bool doEvent(EventPrincipal const& ep, EventSetup const& c, ActivityRegistry* act, @@ -109,6 +111,8 @@ namespace edm { ModuleDescription moduleDescription_; std::vector previousParentage_; SharedResourcesAcquirer resourceAcquirer_; + SerialTaskQueue runQueue_; + SerialTaskQueue luminosityBlockQueue_; ParentageID previousParentageId_; }; } diff --git a/FWCore/Framework/interface/EDProducer.h b/FWCore/Framework/interface/EDProducer.h index a7fa3d54f5495..a821b30c216f6 100644 --- a/FWCore/Framework/interface/EDProducer.h +++ b/FWCore/Framework/interface/EDProducer.h @@ -53,6 +53,8 @@ namespace edm { static bool wantsStreamRuns() {return false;} static bool wantsStreamLuminosityBlocks() {return false;}; + SerialTaskQueue* globalRunsQueue() { return &runQueue_;} + SerialTaskQueue* globalLuminosityBlocksQueue() { return &luminosityBlockQueue_;} private: bool doEvent(EventPrincipal const& ep, EventSetup const& c, ActivityRegistry* act, @@ -104,6 +106,8 @@ namespace edm { ModuleDescription moduleDescription_; std::vector previousParentage_; SharedResourcesAcquirer resourceAcquirer_; + SerialTaskQueue runQueue_; + SerialTaskQueue luminosityBlockQueue_; ParentageID previousParentageId_; }; } diff --git a/FWCore/Framework/interface/OutputModule.h b/FWCore/Framework/interface/OutputModule.h index 93f3c1ab154fe..68d6cd0f75d16 100644 --- a/FWCore/Framework/interface/OutputModule.h +++ b/FWCore/Framework/interface/OutputModule.h @@ -86,6 +86,9 @@ namespace edm { static bool wantsStreamRuns() {return false;} static bool wantsStreamLuminosityBlocks() {return false;}; + SerialTaskQueue* globalRunsQueue() { return &runQueue_;} + SerialTaskQueue* globalLuminosityBlocksQueue() { return &luminosityBlockQueue_;} + bool wantAllEvents() const {return wantAllEvents_;} BranchIDLists const* branchIDLists(); @@ -179,6 +182,8 @@ namespace edm { std::map keepAssociation_; SharedResourcesAcquirer resourceAcquirer_; + SerialTaskQueue runQueue_; + SerialTaskQueue luminosityBlockQueue_; //------------------------------------------------------------------ // private member functions From a99f3dd4886bf4dbe9a26e30d5e63af5f0e5aa14 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 2 Nov 2017 11:12:58 -0500 Subject: [PATCH 02/52] Enforce processing only one transition at a time Use a SerialTaskQueue to enforce processing of only one Run or LuminosityBlock transition at a time for module types which need the constraint. Begin transition items are placed in the proper queue and then that queue gets paused when the task runs. The Queue does not resume until the corresponding end transition runs. This then frees any waiting begin transitions to start. --- FWCore/Framework/src/Worker.h | 69 +++++++++++++++++++++++++++------ FWCore/Framework/src/WorkerT.cc | 42 ++++++++++++++++++++ FWCore/Framework/src/WorkerT.h | 3 ++ 3 files changed, 103 insertions(+), 11 deletions(-) diff --git a/FWCore/Framework/src/Worker.h b/FWCore/Framework/src/Worker.h index 0770afeed3b67..ca5c587398756 100644 --- a/FWCore/Framework/src/Worker.h +++ b/FWCore/Framework/src/Worker.h @@ -119,6 +119,9 @@ namespace edm { virtual bool wantsGlobalLuminosityBlocks() const = 0; virtual bool wantsStreamRuns() const = 0; virtual bool wantsStreamLuminosityBlocks() const = 0; + + virtual SerialTaskQueue* globalRunsQueue() = 0; + virtual SerialTaskQueue* globalLuminosityBlocksQueue() = 0; template bool doWork(typename T::MyPrincipal const&, EventSetup const& c, @@ -400,6 +403,16 @@ namespace edm { m_context(context), m_serviceToken(ServiceRegistry::instance().presentToken()) {} + struct EnableQueueGuard { + SerialTaskQueue* queue_; + EnableQueueGuard(SerialTaskQueue* iQueue): queue_{iQueue} {} + EnableQueueGuard(EnableQueueGuard const&) = delete; + EnableQueueGuard& operator=(EnableQueueGuard const&) = delete; + EnableQueueGuard& operator=(EnableQueueGuard&&) = delete; + EnableQueueGuard(EnableQueueGuard&& iGuard): queue_{iGuard.queue_} {iGuard.queue_ = nullptr;} + ~EnableQueueGuard() { if(queue_) {queue_->resume();} } + }; + tbb::task* execute() override { //Need to make the services available early so other services can see them ServiceRegistry::Operate guard(m_serviceToken); @@ -424,22 +437,35 @@ namespace edm { if(auto queue = m_worker->serializeRunModule()) { auto const & principal = m_principal; auto& es = m_es; - queue.push( [worker = m_worker, &principal, - &es, streamID = m_streamID, - parentContext = m_parentContext, - sContext = m_context, serviceToken = m_serviceToken]() + auto f = [worker = m_worker, &principal, + &es, streamID = m_streamID, + parentContext = m_parentContext, + sContext = m_context, serviceToken = m_serviceToken]() { //Need to make the services available ServiceRegistry::Operate guard(serviceToken); - + + //If needed, we pause the queue in begin transition and resume it + // at the end transition. This guarantees that the module + // only processes one transition at a time + EnableQueueGuard enableQueueGuard{ workerhelper::CallImpl::enableGlobalQueue(worker)}; std::exception_ptr* ptr = nullptr; worker->template runModuleAfterAsyncPrefetch(ptr, - principal, - es, - streamID, - parentContext, - sContext); - }); + principal, + es, + streamID, + parentContext, + sContext); + }; + //keep another global transition from running if necessary + auto gQueue = workerhelper::CallImpl::pauseGlobalQueue(worker); + if(gQueue) { + gQueue->push( [queue,gQueue, f]() mutable { + gQueue->pause(); + queue.push(std::move(f));} ); + } else { + queue.push( std::move(f) ); + } return nullptr; } } @@ -634,6 +660,9 @@ namespace edm { static bool needToRunSelection( Worker const* iWorker) { return iWorker->implNeedToRunSelection(); } + + static SerialTaskQueue* pauseGlobalQueue(Worker*) { return nullptr;} + static SerialTaskQueue* enableGlobalQueue(Worker*) { return nullptr;} }; template<> @@ -654,6 +683,9 @@ namespace edm { static bool needToRunSelection( Worker const* iWorker) { return false; } + static SerialTaskQueue* pauseGlobalQueue(Worker* iWorker) { return iWorker->globalRunsQueue();} + static SerialTaskQueue* enableGlobalQueue(Worker*) { return nullptr;} + }; template<> class CallImpl>{ @@ -673,6 +705,9 @@ namespace edm { static bool needToRunSelection( Worker const* iWorker) { return false; } + static SerialTaskQueue* pauseGlobalQueue(Worker* iWorker) { return nullptr;} + static SerialTaskQueue* enableGlobalQueue(Worker*) { return nullptr;} + }; template<> class CallImpl>{ @@ -692,6 +727,8 @@ namespace edm { static bool needToRunSelection( Worker const* iWorker) { return false; } + static SerialTaskQueue* pauseGlobalQueue(Worker* iWorker) { return nullptr;} + static SerialTaskQueue* enableGlobalQueue(Worker* iWorker) { return iWorker->globalRunsQueue();} }; template<> class CallImpl>{ @@ -711,6 +748,8 @@ namespace edm { static bool needToRunSelection( Worker const* iWorker) { return false; } + static SerialTaskQueue* pauseGlobalQueue(Worker* iWorker) { return nullptr;} + static SerialTaskQueue* enableGlobalQueue(Worker*) { return nullptr;} }; template<> @@ -731,6 +770,8 @@ namespace edm { static bool needToRunSelection( Worker const* iWorker) { return false; } + static SerialTaskQueue* pauseGlobalQueue(Worker* iWorker) { return iWorker->globalLuminosityBlocksQueue();} + static SerialTaskQueue* enableGlobalQueue(Worker*) { return nullptr;} }; template<> class CallImpl>{ @@ -750,6 +791,8 @@ namespace edm { static bool needToRunSelection( Worker const* iWorker) { return false; } + static SerialTaskQueue* pauseGlobalQueue(Worker* iWorker) { return nullptr;} + static SerialTaskQueue* enableGlobalQueue(Worker*) { return nullptr;} }; template<> @@ -770,6 +813,8 @@ namespace edm { static bool needToRunSelection( Worker const* iWorker) { return false; } + static SerialTaskQueue* pauseGlobalQueue(Worker* iWorker) { return nullptr;} + static SerialTaskQueue* enableGlobalQueue(Worker* iWorker) { return iWorker->globalLuminosityBlocksQueue();} }; template<> class CallImpl>{ @@ -789,6 +834,8 @@ namespace edm { static bool needToRunSelection( Worker const* iWorker) { return false; } + static SerialTaskQueue* pauseGlobalQueue(Worker* iWorker) { return nullptr;} + static SerialTaskQueue* enableGlobalQueue(Worker*) { return nullptr;} }; } diff --git a/FWCore/Framework/src/WorkerT.cc b/FWCore/Framework/src/WorkerT.cc index aa14ea361cc82..e2716b49bcc64 100644 --- a/FWCore/Framework/src/WorkerT.cc +++ b/FWCore/Framework/src/WorkerT.cc @@ -148,6 +148,48 @@ namespace edm{ return module_->wantsStreamLuminosityBlocks(); } + template + SerialTaskQueue* WorkerT::globalRunsQueue() { + return nullptr; + } + template + SerialTaskQueue* WorkerT::globalLuminosityBlocksQueue() { + return nullptr; + } + template<> + SerialTaskQueue* WorkerT::globalRunsQueue() { + return module_->globalRunsQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalLuminosityBlocksQueue() { + return module_->globalLuminosityBlocksQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalRunsQueue() { + return module_->globalRunsQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalLuminosityBlocksQueue() { + return module_->globalLuminosityBlocksQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalRunsQueue() { + return module_->globalRunsQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalLuminosityBlocksQueue() { + return module_->globalLuminosityBlocksQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalRunsQueue() { + return module_->globalRunsQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalLuminosityBlocksQueue() { + return module_->globalLuminosityBlocksQueue(); + } + + template inline bool diff --git a/FWCore/Framework/src/WorkerT.h b/FWCore/Framework/src/WorkerT.h index 2c360d5566257..3c600da3021f0 100644 --- a/FWCore/Framework/src/WorkerT.h +++ b/FWCore/Framework/src/WorkerT.h @@ -50,6 +50,9 @@ namespace edm { bool wantsStreamRuns() const final; bool wantsStreamLuminosityBlocks() const final; + SerialTaskQueue* globalRunsQueue() final; + SerialTaskQueue* globalLuminosityBlocksQueue() final; + void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&) override; From fae6b5ce53d2c087547978bc4d557859c62ff842 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 3 Nov 2017 13:42:53 -0500 Subject: [PATCH 03/52] Enforce processing one Run/Lumi for ::one modules Use a SerialTaskQueue for the cases where we must restrict a ::one module to processing one Run or LuminosityBlock at a time. [Modules which do not care about those transitions to do require the restriction.] --- FWCore/Framework/interface/one/EDAnalyzer.h | 8 +++-- .../Framework/interface/one/EDAnalyzerBase.h | 2 ++ FWCore/Framework/interface/one/EDFilter.h | 8 +++-- FWCore/Framework/interface/one/EDFilterBase.h | 3 ++ FWCore/Framework/interface/one/EDProducer.h | 6 +++- .../Framework/interface/one/EDProducerBase.h | 3 ++ .../interface/one/OutputModuleBase.h | 5 +++ FWCore/Framework/interface/one/implementors.h | 14 ++++++++ FWCore/Framework/src/WorkerT.cc | 33 +++++++++++++++++++ FWCore/Framework/src/one/EDAnalyzerBase.cc | 5 ++- FWCore/Framework/src/one/EDFilterBase.cc | 3 ++ FWCore/Framework/src/one/EDProducerBase.cc | 3 ++ 12 files changed, 87 insertions(+), 6 deletions(-) diff --git a/FWCore/Framework/interface/one/EDAnalyzer.h b/FWCore/Framework/interface/one/EDAnalyzer.h index e9b097f97997e..f829d2afcdca2 100644 --- a/FWCore/Framework/interface/one/EDAnalyzer.h +++ b/FWCore/Framework/interface/one/EDAnalyzer.h @@ -46,13 +46,17 @@ namespace edm { // ---------- static member functions -------------------- // ---------- member functions --------------------------- - + SerialTaskQueue* globalRunsQueue() final { return globalRunsQueue_.queue();} + SerialTaskQueue* globalLuminosityBlocksQueue() final { return globalLuminosityBlocksQueue_.queue();} + private: EDAnalyzer(const EDAnalyzer&) = delete; const EDAnalyzer& operator=(const EDAnalyzer&) = delete; // ---------- member data -------------------------------- - + impl::OptionalSerialTaskQueueHolder::value> globalRunsQueue_; + impl::OptionalSerialTaskQueueHolder::value> globalLuminosityBlocksQueue_; + }; } diff --git a/FWCore/Framework/interface/one/EDAnalyzerBase.h b/FWCore/Framework/interface/one/EDAnalyzerBase.h index 9539cef952275..98d14ec8c7eb5 100644 --- a/FWCore/Framework/interface/one/EDAnalyzerBase.h +++ b/FWCore/Framework/interface/one/EDAnalyzerBase.h @@ -68,6 +68,8 @@ namespace edm { bool wantsStreamRuns() const {return false;} bool wantsStreamLuminosityBlocks() const {return false;}; + virtual SerialTaskQueue* globalRunsQueue(); + virtual SerialTaskQueue* globalLuminosityBlocksQueue(); void callWhenNewProductsRegistered(std::function const& func); private: diff --git a/FWCore/Framework/interface/one/EDFilter.h b/FWCore/Framework/interface/one/EDFilter.h index 64e3d33053c19..cb98151ad46b1 100644 --- a/FWCore/Framework/interface/one/EDFilter.h +++ b/FWCore/Framework/interface/one/EDFilter.h @@ -45,13 +45,17 @@ namespace edm { // ---------- static member functions -------------------- // ---------- member functions --------------------------- - + SerialTaskQueue* globalRunsQueue() final { return globalRunsQueue_.queue();} + SerialTaskQueue* globalLuminosityBlocksQueue() final { return globalLuminosityBlocksQueue_.queue();} + private: EDFilter(const EDFilter&) = delete; const EDFilter& operator=(const EDFilter&) = delete; // ---------- member data -------------------------------- - + impl::OptionalSerialTaskQueueHolder::value> globalRunsQueue_; + impl::OptionalSerialTaskQueueHolder::value> globalLuminosityBlocksQueue_; + }; } diff --git a/FWCore/Framework/interface/one/EDFilterBase.h b/FWCore/Framework/interface/one/EDFilterBase.h index 682eca6be596f..be25db7d4fd97 100644 --- a/FWCore/Framework/interface/one/EDFilterBase.h +++ b/FWCore/Framework/interface/one/EDFilterBase.h @@ -68,6 +68,9 @@ namespace edm { bool wantsStreamRuns() const {return false;} bool wantsStreamLuminosityBlocks() const {return false;}; + virtual SerialTaskQueue* globalRunsQueue(); + virtual SerialTaskQueue* globalLuminosityBlocksQueue(); + private: bool doEvent(EventPrincipal const& ep, EventSetup const& c, ActivityRegistry*, diff --git a/FWCore/Framework/interface/one/EDProducer.h b/FWCore/Framework/interface/one/EDProducer.h index dde567a0f0445..01556d35f6733 100644 --- a/FWCore/Framework/interface/one/EDProducer.h +++ b/FWCore/Framework/interface/one/EDProducer.h @@ -44,6 +44,9 @@ namespace edm { return WantsGlobalLuminosityBlockTransitions::value; } + SerialTaskQueue* globalRunsQueue() final { return globalRunsQueue_.queue();} + SerialTaskQueue* globalLuminosityBlocksQueue() final { return globalLuminosityBlocksQueue_.queue();} + // ---------- static member functions -------------------- // ---------- member functions --------------------------- @@ -53,7 +56,8 @@ namespace edm { const EDProducer& operator=(const EDProducer&) = delete; // ---------- member data -------------------------------- - + impl::OptionalSerialTaskQueueHolder::value> globalRunsQueue_; + impl::OptionalSerialTaskQueueHolder::value> globalLuminosityBlocksQueue_; }; } diff --git a/FWCore/Framework/interface/one/EDProducerBase.h b/FWCore/Framework/interface/one/EDProducerBase.h index e083ba423929b..23f79a6d8c6e7 100644 --- a/FWCore/Framework/interface/one/EDProducerBase.h +++ b/FWCore/Framework/interface/one/EDProducerBase.h @@ -68,6 +68,9 @@ namespace edm { bool wantsStreamRuns() const {return false;} bool wantsStreamLuminosityBlocks() const {return false;}; + virtual SerialTaskQueue* globalRunsQueue(); + virtual SerialTaskQueue* globalLuminosityBlocksQueue(); + private: bool doEvent(EventPrincipal const& ep, EventSetup const& c, ActivityRegistry*, diff --git a/FWCore/Framework/interface/one/OutputModuleBase.h b/FWCore/Framework/interface/one/OutputModuleBase.h index d5103f6506cca..ec42e44e522c3 100644 --- a/FWCore/Framework/interface/one/OutputModuleBase.h +++ b/FWCore/Framework/interface/one/OutputModuleBase.h @@ -100,6 +100,9 @@ namespace edm { bool wantsStreamRuns() const {return false;} bool wantsStreamLuminosityBlocks() const {return false;}; + SerialTaskQueue* globalRunsQueue() { return &runQueue_;} + SerialTaskQueue* globalLuminosityBlocksQueue() { return &luminosityBlockQueue_;} + bool wantAllEvents() const {return wantAllEvents_;} BranchIDLists const* branchIDLists(); @@ -191,6 +194,8 @@ namespace edm { std::map keepAssociation_; SharedResourcesAcquirer resourcesAcquirer_; + SerialTaskQueue runQueue_; + SerialTaskQueue luminosityBlockQueue_; //------------------------------------------------------------------ // private member functions diff --git a/FWCore/Framework/interface/one/implementors.h b/FWCore/Framework/interface/one/implementors.h index 7b32386fa9bac..dd66d03ae6f82 100644 --- a/FWCore/Framework/interface/one/implementors.h +++ b/FWCore/Framework/interface/one/implementors.h @@ -24,6 +24,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Concurrency/interface/SerialTaskQueue.h" // forward declarations @@ -32,7 +33,20 @@ namespace edm { namespace one { namespace impl { + template + struct OptionalSerialTaskQueueHolder; + template<> + struct OptionalSerialTaskQueueHolder { + edm::SerialTaskQueue* queue() { return &queue_;} + edm::SerialTaskQueue queue_; + }; + + template<> + struct OptionalSerialTaskQueueHolder { + edm::SerialTaskQueue* queue() { return nullptr;} + }; + template class SharedResourcesUser : public virtual T { public: diff --git a/FWCore/Framework/src/WorkerT.cc b/FWCore/Framework/src/WorkerT.cc index e2716b49bcc64..66ddd6ebfff42 100644 --- a/FWCore/Framework/src/WorkerT.cc +++ b/FWCore/Framework/src/WorkerT.cc @@ -188,6 +188,39 @@ namespace edm{ SerialTaskQueue* WorkerT::globalLuminosityBlocksQueue() { return module_->globalLuminosityBlocksQueue(); } + //one + template<> + SerialTaskQueue* WorkerT::globalRunsQueue() { + return module_->globalRunsQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalLuminosityBlocksQueue() { + return module_->globalLuminosityBlocksQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalRunsQueue() { + return module_->globalRunsQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalLuminosityBlocksQueue() { + return module_->globalLuminosityBlocksQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalRunsQueue() { + return module_->globalRunsQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalLuminosityBlocksQueue() { + return module_->globalLuminosityBlocksQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalRunsQueue() { + return module_->globalRunsQueue(); + } + template<> + SerialTaskQueue* WorkerT::globalLuminosityBlocksQueue() { + return module_->globalLuminosityBlocksQueue(); + } template diff --git a/FWCore/Framework/src/one/EDAnalyzerBase.cc b/FWCore/Framework/src/one/EDAnalyzerBase.cc index 173193542b171..540edde4b2214 100644 --- a/FWCore/Framework/src/one/EDAnalyzerBase.cc +++ b/FWCore/Framework/src/one/EDAnalyzerBase.cc @@ -67,7 +67,10 @@ namespace edm { return SharedResourcesAcquirer{ std::vector>(1, std::make_shared())}; } - + + SerialTaskQueue* EDAnalyzerBase::globalRunsQueue() {return nullptr;} + SerialTaskQueue* EDAnalyzerBase::globalLuminosityBlocksQueue() {return nullptr;}; + void EDAnalyzerBase::doBeginJob() { resourcesAcquirer_ = createAcquirer(); diff --git a/FWCore/Framework/src/one/EDFilterBase.cc b/FWCore/Framework/src/one/EDFilterBase.cc index 2dd918610c5f5..703e52863e523 100644 --- a/FWCore/Framework/src/one/EDFilterBase.cc +++ b/FWCore/Framework/src/one/EDFilterBase.cc @@ -69,6 +69,9 @@ namespace edm { std::vector>(1, std::make_shared())}; } + SerialTaskQueue* EDFilterBase::globalRunsQueue() {return nullptr;} + SerialTaskQueue* EDFilterBase::globalLuminosityBlocksQueue() {return nullptr;}; + void EDFilterBase::doBeginJob() { resourcesAcquirer_ = createAcquirer(); diff --git a/FWCore/Framework/src/one/EDProducerBase.cc b/FWCore/Framework/src/one/EDProducerBase.cc index 38f53934523fe..330dfb62e3c44 100644 --- a/FWCore/Framework/src/one/EDProducerBase.cc +++ b/FWCore/Framework/src/one/EDProducerBase.cc @@ -67,6 +67,9 @@ namespace edm { std::vector>(1, std::make_shared())}; } + SerialTaskQueue* EDProducerBase::globalRunsQueue() {return nullptr;} + SerialTaskQueue* EDProducerBase::globalLuminosityBlocksQueue() {return nullptr;}; + void EDProducerBase::doBeginJob() { resourcesAcquirer_ = createAcquirer(); From 5c3f2a9defed273909dd5b806c38137dd8a31bed Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 6 Nov 2017 11:17:28 -0600 Subject: [PATCH 04/52] Added isWithinValidityInterval method Added the method isWithinValidityInterval to be able to determine if we need to go to a new IOV. This will be used to determine if we need to do a synchronization across a LuminosityBlock boundary. --- FWCore/Framework/interface/EventSetupProvider.h | 3 ++- FWCore/Framework/src/EventSetupProvider.cc | 9 +++++++++ FWCore/Framework/src/EventSetupsController.cc | 10 ++++++++++ FWCore/Framework/src/EventSetupsController.h | 2 ++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/FWCore/Framework/interface/EventSetupProvider.h b/FWCore/Framework/interface/EventSetupProvider.h index b472c8ea29f6b..5dd7a83843508 100644 --- a/FWCore/Framework/interface/EventSetupProvider.h +++ b/FWCore/Framework/interface/EventSetupProvider.h @@ -62,7 +62,8 @@ class EventSetupProvider { // ---------- const member functions --------------------- std::set proxyProviderDescriptions() const; - + bool isWithinValidityInterval(IOVSyncValue const& ) const; + // ---------- static member functions -------------------- // ---------- member functions --------------------------- diff --git a/FWCore/Framework/src/EventSetupProvider.cc b/FWCore/Framework/src/EventSetupProvider.cc index 65a440ef350f1..39cc4c93c4e8d 100644 --- a/FWCore/Framework/src/EventSetupProvider.cc +++ b/FWCore/Framework/src/EventSetupProvider.cc @@ -779,6 +779,15 @@ EventSetupProvider::proxyProviderDescriptions() const return descriptions; } +bool +EventSetupProvider::isWithinValidityInterval(IOVSyncValue const& iSync) const { + for( auto const& provider: providers_) { + if(not provider.second->validityInterval().validFor(iSync)) { + return false; + } + } + return true; +} // // static member functions // diff --git a/FWCore/Framework/src/EventSetupsController.cc b/FWCore/Framework/src/EventSetupsController.cc index 0a78286417f36..e71eb16760f7e 100644 --- a/FWCore/Framework/src/EventSetupsController.cc +++ b/FWCore/Framework/src/EventSetupsController.cc @@ -76,6 +76,16 @@ namespace edm { }); } + bool + EventSetupsController::isWithinValidityInterval(IOVSyncValue const& syncValue) const { + for(auto const& provider: providers_) { + if( not provider->isWithinValidityInterval(syncValue)) { + return false; + } + } + return true; + } + std::shared_ptr EventSetupsController::getESProducerAndRegisterProcess(ParameterSet const& pset, unsigned subProcessIndex) { // Try to find a DataProxyProvider with a matching ParameterSet diff --git a/FWCore/Framework/src/EventSetupsController.h b/FWCore/Framework/src/EventSetupsController.h index 8943910a96a53..75ffe72794ba8 100644 --- a/FWCore/Framework/src/EventSetupsController.h +++ b/FWCore/Framework/src/EventSetupsController.h @@ -78,6 +78,8 @@ namespace edm { void eventSetupForInstance(IOVSyncValue const& syncValue); + bool isWithinValidityInterval(IOVSyncValue const& syncValue) const; + void forceCacheClear() const; std::shared_ptr getESProducerAndRegisterProcess(ParameterSet const& pset, unsigned subProcessIndex); From 2feaebbfd26c69b5ed8c363c2da6df7774b7c304 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 18 Dec 2017 14:50:24 -0600 Subject: [PATCH 05/52] Fix rebase change mistake --- FWCore/Framework/src/Worker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FWCore/Framework/src/Worker.h b/FWCore/Framework/src/Worker.h index ca5c587398756..c9955d4a057f0 100644 --- a/FWCore/Framework/src/Worker.h +++ b/FWCore/Framework/src/Worker.h @@ -458,7 +458,7 @@ namespace edm { sContext); }; //keep another global transition from running if necessary - auto gQueue = workerhelper::CallImpl::pauseGlobalQueue(worker); + auto gQueue = workerhelper::CallImpl::pauseGlobalQueue(m_worker); if(gQueue) { gQueue->push( [queue,gQueue, f]() mutable { gQueue->pause(); From 6c9d77c6f55d3e21d5441148a4087f1b68832df6 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 21 Dec 2017 12:18:18 -0600 Subject: [PATCH 06/52] Allow ReusableObjectHolder to be move constructed --- FWCore/Utilities/interface/ReusableObjectHolder.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/FWCore/Utilities/interface/ReusableObjectHolder.h b/FWCore/Utilities/interface/ReusableObjectHolder.h index 78a11767a013d..203354ca89fcf 100644 --- a/FWCore/Utilities/interface/ReusableObjectHolder.h +++ b/FWCore/Utilities/interface/ReusableObjectHolder.h @@ -77,7 +77,11 @@ namespace edm { class ReusableObjectHolder { public: ReusableObjectHolder():m_outstandingObjects(0){} - + ReusableObjectHolder(ReusableObjectHolder&& iOther): + m_availableQueue(std::move(iOther.m_availableQueue)), + m_outstandingObjects(0) { + assert(0== iOther.m_outstandingObjects); + } ~ReusableObjectHolder() { assert(0==m_outstandingObjects); T* item = 0; From 877b0adecf3805119cbffc982be8af603943c948 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 21 Dec 2017 12:30:45 -0600 Subject: [PATCH 07/52] Added LuminosityBlockAuxiliary::sameIdentity function Move checking identity between two instances to the class itself. --- DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h b/DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h index fbe84fb92f86b..722dc3434ac8d 100644 --- a/DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h +++ b/DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h @@ -53,6 +53,10 @@ namespace edm { } void mergeAuxiliary(LuminosityBlockAuxiliary const& newAux); + bool sameIdentity(LuminosityBlockAuxiliary const& iRHS) const { + return iRHS.processHistoryID_ == processHistoryID_ && + iRHS.id_ == id_; + } private: // This is the ID of the full process history (not the reduced process history). // In cases where LuminosityBlock's are merged, the ID of the first process history encountered From 67ac9457582324b3dfb905d47feb05950716fd49 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 21 Dec 2017 12:35:53 -0600 Subject: [PATCH 08/52] Fix bug when dealing with missing ProcessHistory For old format files, there can be cases where the ProcessHistory is unknown for a Run or Lumi. --- FWCore/Framework/src/Principal.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FWCore/Framework/src/Principal.cc b/FWCore/Framework/src/Principal.cc index 79f4a7872854e..ec00c7fac603d 100644 --- a/FWCore/Framework/src/Principal.cc +++ b/FWCore/Framework/src/Principal.cc @@ -380,6 +380,8 @@ namespace edm { } else { //Since this is static we don't want it deleted inputProcessHistory = std::shared_ptr(&s_emptyProcessHistory,[](void const*){}); + //no need to do any ordering since it is empty + orderProcessHistoryID_ = hist; } processHistoryID_ = hist; processHistoryPtr_ = inputProcessHistory; From 11cedfe3368a67637456e08245284551edf28491 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 21 Dec 2017 13:08:51 -0600 Subject: [PATCH 09/52] Allow cmsRun to have multiple LuminosityBlockPrincipals Restructured the system to allow multiple LuminosityBlockPrincipals to be used by the EventProcessor. This required moving state information about the transition out of EventProcessor and instead pass the state info as arguments to the member functions. In addition, the LuminosityBlockPrincipals are reused for different actual LuminosityBlock transitions. This is accomplished via the use of a ReusableObjectHolder. --- FWCore/Framework/interface/EventPrincipal.h | 4 +- FWCore/Framework/interface/EventProcessor.h | 13 +- .../interface/LuminosityBlockPrincipal.h | 10 +- FWCore/Framework/interface/SubProcess.h | 6 +- FWCore/Framework/src/EventPrincipal.cc | 7 +- FWCore/Framework/src/EventProcessor.cc | 78 ++++++----- .../Framework/src/LuminosityBlockPrincipal.cc | 4 +- FWCore/Framework/src/PrincipalCache.cc | 132 ++---------------- FWCore/Framework/src/PrincipalCache.h | 15 +- FWCore/Framework/src/StreamSchedule.cc | 13 ++ FWCore/Framework/src/StreamSchedule.h | 11 ++ FWCore/Framework/src/SubProcess.cc | 51 ++++--- FWCore/Framework/src/TransitionProcessors.icc | 13 +- FWCore/Framework/test/Event_t.cpp | 4 +- FWCore/Framework/test/MockEventProcessor.cc | 36 +++-- FWCore/Framework/test/MockEventProcessor.h | 15 +- .../test/event_getrefbeforeput_t.cppunit.cc | 10 +- .../test/eventprincipal_t.cppunit.cc | 5 +- .../Framework/test/generichandle_t.cppunit.cc | 8 +- .../Framework/test/global_module_t.cppunit.cc | 3 +- .../test/global_outputmodule_t.cppunit.cc | 5 +- .../test/limited_module_t.cppunit.cc | 5 +- .../test/limited_outputmodule_t.cppunit.cc | 4 +- .../test/one_outputmodule_t.cppunit.cc | 5 +- .../Framework/test/stream_module_t.cppunit.cc | 3 +- .../src/TFWLiteSelectorBasic.cc | 4 +- IOPool/Input/src/PoolSource.cc | 3 +- 27 files changed, 209 insertions(+), 258 deletions(-) diff --git a/FWCore/Framework/interface/EventPrincipal.h b/FWCore/Framework/interface/EventPrincipal.h index 91b75ee2036a9..d7b71811b344d 100644 --- a/FWCore/Framework/interface/EventPrincipal.h +++ b/FWCore/Framework/interface/EventPrincipal.h @@ -89,7 +89,7 @@ namespace edm { } bool luminosityBlockPrincipalPtrValid() const { - return (luminosityBlockPrincipal_) ? true : false; + return luminosityBlockPrincipal_ != nullptr; } void setLuminosityBlockPrincipal(std::shared_ptr const& lbp); @@ -191,7 +191,7 @@ namespace edm { EventAuxiliary aux_; - edm::propagate_const> luminosityBlockPrincipal_; + edm::propagate_const luminosityBlockPrincipal_; // Pointer to the 'retriever' that will get provenance information from the persistent store. edm::propagate_const> provRetrieverPtr_; diff --git a/FWCore/Framework/interface/EventProcessor.h b/FWCore/Framework/interface/EventProcessor.h index 8f18888da1aa9..f9f7a039775b2 100644 --- a/FWCore/Framework/interface/EventProcessor.h +++ b/FWCore/Framework/interface/EventProcessor.h @@ -47,6 +47,7 @@ namespace edm { class ProcessDesc; class SubProcess; class WaitingTaskHolder; + class LuminosityBlockProcessingStatus; namespace eventsetup { class EventSetupProvider; @@ -203,17 +204,17 @@ namespace edm { void beginRun(ProcessHistoryID const& phid, RunNumber_t run, bool& globalBeginSucceeded); void endRun(ProcessHistoryID const& phid, RunNumber_t run, bool globalBeginSucceeded, bool cleaningUpAfterException); - void beginLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi, bool& globalBeginSucceeded); - void endLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi, bool globalBeginSucceeded, bool cleaningUpAfterException); + void beginLumi(std::shared_ptr& status, bool& globalBeginSucceeded); + void endLumi(std::shared_ptr status, bool globalBeginSucceeded, bool cleaningUpAfterException); std::pair readRun(); std::pair readAndMergeRun(); - int readLuminosityBlock(); - int readAndMergeLumi(); + void readLuminosityBlock(LuminosityBlockProcessingStatus&); + int readAndMergeLumi(LuminosityBlockProcessingStatus&); void writeRun(ProcessHistoryID const& phid, RunNumber_t run); void deleteRunFromCache(ProcessHistoryID const& phid, RunNumber_t run); - void writeLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi); - void deleteLumiFromCache(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi); + void writeLumi(LuminosityBlockProcessingStatus& ); + void deleteLumiFromCache(LuminosityBlockProcessingStatus&); bool shouldWeStop() const; diff --git a/FWCore/Framework/interface/LuminosityBlockPrincipal.h b/FWCore/Framework/interface/LuminosityBlockPrincipal.h index 762ac4e331c83..f7cc32b437816 100644 --- a/FWCore/Framework/interface/LuminosityBlockPrincipal.h +++ b/FWCore/Framework/interface/LuminosityBlockPrincipal.h @@ -35,7 +35,6 @@ namespace edm { typedef LuminosityBlockAuxiliary Auxiliary; typedef Principal Base; LuminosityBlockPrincipal( - std::shared_ptr aux, std::shared_ptr reg, ProcessConfiguration const& pc, HistoryAppender* historyAppender, @@ -75,15 +74,16 @@ namespace edm { } void setEndTime(Timestamp const& time) { - aux_->setEndTime(time); + aux_.setEndTime(time); } LuminosityBlockNumber_t luminosityBlock() const { return aux().luminosityBlock(); } + void setAux( LuminosityBlockAuxiliary iAux) { aux_ = std::move(iAux);} LuminosityBlockAuxiliary const& aux() const { - return *aux_; + return aux_; } RunNumber_t run() const { @@ -91,7 +91,7 @@ namespace edm { } void mergeAuxiliary(LuminosityBlockAuxiliary const& aux) { - return aux_->mergeAuxiliary(aux); + return aux_.mergeAuxiliary(aux); } void put( @@ -113,7 +113,7 @@ namespace edm { edm::propagate_const> runPrincipal_; - edm::propagate_const> aux_; + LuminosityBlockAuxiliary aux_; LuminosityBlockIndex index_; diff --git a/FWCore/Framework/interface/SubProcess.h b/FWCore/Framework/interface/SubProcess.h index d22fe253e8287..10ca2dc47d792 100644 --- a/FWCore/Framework/interface/SubProcess.h +++ b/FWCore/Framework/interface/SubProcess.h @@ -109,9 +109,9 @@ namespace edm { // Write the luminosity block - void writeLumi(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber); + void writeLumi(LuminosityBlockPrincipal&); - void deleteLumiFromCache(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber); + void deleteLumiFromCache(LuminosityBlockPrincipal&); // Write the run void writeRun(ProcessHistoryID const& parentPhID, int runNumber); @@ -270,6 +270,8 @@ namespace edm { std::vector processHistoryRegistries_; std::vector historyAppenders_; PrincipalCache principalCache_; + //vector index is principal lumi's index value + std::vector> inUseLumiPrincipals_; edm::propagate_const> esp_; edm::propagate_const> schedule_; std::map parentToChildPhID_; diff --git a/FWCore/Framework/src/EventPrincipal.cc b/FWCore/Framework/src/EventPrincipal.cc index 9761f880d235f..b912c4ca7eb47 100644 --- a/FWCore/Framework/src/EventPrincipal.cc +++ b/FWCore/Framework/src/EventPrincipal.cc @@ -37,7 +37,7 @@ namespace edm { bool isForPrimaryProcess) : Base(reg, reg->productLookup(InEvent), pc, InEvent, historyAppender,isForPrimaryProcess), aux_(), - luminosityBlockPrincipal_(), + luminosityBlockPrincipal_(nullptr), provRetrieverPtr_(new ProductProvenanceRetriever(streamIndex)), eventSelectionIDs_(), branchIDListHelper_(branchIDListHelper), @@ -52,7 +52,8 @@ namespace edm { EventPrincipal::clearEventPrincipal() { clearPrincipal(); aux_ = EventAuxiliary(); - luminosityBlockPrincipal_ = nullptr; // propagate_const has no reset() function + //do not clear luminosityBlockPrincipal_ since + // it is only connected at beginLumi transition provRetrieverPtr_->reset(); branchListIndexToProcessIndex_.clear(); } @@ -136,7 +137,7 @@ namespace edm { void EventPrincipal::setLuminosityBlockPrincipal(std::shared_ptr const& lbp) { - luminosityBlockPrincipal_ = lbp; + luminosityBlockPrincipal_ = lbp.get(); } void diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 6bcde74d51459..37abc64104d4a 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -65,6 +65,7 @@ #include "MessageForSource.h" #include "MessageForParent.h" +#include "LuminosityBlockProcessingStatus.h" #include "boost/range/adaptor/reversed.hpp" @@ -523,7 +524,13 @@ namespace edm { // Reusable event principal auto ep = std::make_shared(preg(), branchIDListHelper(), thinnedAssociationsHelper(), *processConfiguration_, historyAppender_.get(), index); - principalCache_.insert(ep); + principalCache_.insert(std::move(ep)); + } + + for(unsigned int index =0; index < preallocations_.numberOfLuminosityBlocks(); ++index) { + auto lp = std::make_unique(preg(), *processConfiguration_, + historyAppender_.get(), index); + principalCache_.insert(std::move(lp)); } // fill the subprocesses, if there are any @@ -1076,9 +1083,13 @@ namespace edm { } } - void EventProcessor::beginLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi, bool& globalBeginSucceeded) { + void + EventProcessor::beginLumi(std::shared_ptr& status, bool& globalBeginSucceeded) { + status= std::make_shared(this, preallocations_.numberOfStreams()) ; + readLuminosityBlock(*status); + globalBeginSucceeded = false; - LuminosityBlockPrincipal& lumiPrincipal = principalCache_.lumiPrincipal(phid, run, lumi); + LuminosityBlockPrincipal& lumiPrincipal = *status->lumiPrincipal(); { SendSourceTerminationSignalIfException sentry(actReg_.get()); @@ -1117,7 +1128,6 @@ namespace edm { } } globalBeginSucceeded=true; - FDEBUG(1) << "\tbeginLumi " << run << "/" << lumi << "\n"; if(looper_) { looper_->doBeginLuminosityBlock(lumiPrincipal, es, &processContext_); } @@ -1141,14 +1151,19 @@ namespace edm { } } - FDEBUG(1) << "\tstreamBeginLumi " << run << "/" << lumi << "\n"; + //attach this lumi to the event principals + for(unsigned int i= 0; i< preallocations_.numberOfStreams(); ++i) { + auto& event = principalCache_.eventPrincipal(i); + event.setLuminosityBlockPrincipal(status->lumiPrincipal()); + } + if(looper_) { //looper_->doStreamBeginLuminosityBlock(schedule_->streamID(),lumiPrincipal, es); } } - void EventProcessor::endLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi, bool globalBeginSucceeded, bool cleaningUpAfterException) { - LuminosityBlockPrincipal& lumiPrincipal = principalCache_.lumiPrincipal(phid, run, lumi); + void EventProcessor::endLumi(std::shared_ptr status, bool globalBeginSucceeded, bool cleaningUpAfterException) { + LuminosityBlockPrincipal& lumiPrincipal = *status-> lumiPrincipal(); lumiPrincipal.setAtEndTransition(true); //We need to reset failed items since they might // be set this time around @@ -1192,7 +1207,6 @@ namespace edm { std::rethrow_exception(* (streamLoopWaitTask->exceptionPtr()) ); } } - FDEBUG(1) << "\tendLumi " << run << "/" << lumi << "\n"; if(looper_) { //looper_->doStreamEndLuminosityBlock(schedule_->streamID(),lumiPrincipal, es); } @@ -1213,7 +1227,6 @@ namespace edm { std::rethrow_exception(* (globalWaitTask->exceptionPtr()) ); } } - FDEBUG(1) << "\tendLumi " << run << "/" << lumi << "\n"; if(looper_) { looper_->doEndLuminosityBlock(lumiPrincipal, es, &processContext_); } @@ -1249,36 +1262,35 @@ namespace edm { return std::make_pair(runPrincipal->reducedProcessHistoryID(), input_->run()); } - int EventProcessor::readLuminosityBlock() { - if (principalCache_.hasLumiPrincipal()) { - throw edm::Exception(edm::errors::LogicError) - << "EventProcessor::readRun\n" - << "Illegal attempt to insert lumi into cache\n" - << "Contact a Framework Developer\n"; - } + void EventProcessor::readLuminosityBlock(LuminosityBlockProcessingStatus& iStatus) { if (!principalCache_.hasRunPrincipal()) { throw edm::Exception(edm::errors::LogicError) - << "EventProcessor::readRun\n" + << "EventProcessor::readLuminosityBlock\n" << "Illegal attempt to insert lumi into cache\n" << "Run is invalid\n" << "Contact a Framework Developer\n"; } - auto lbp = std::make_shared(input_->luminosityBlockAuxiliary(), preg(), *processConfiguration_, historyAppender_.get(), 0); + auto lbp = principalCache_.getAvailableLumiPrincipalPtr(); + lbp->setAux(*input_->luminosityBlockAuxiliary()); { SendSourceTerminationSignalIfException sentry(actReg_.get()); input_->readLuminosityBlock(*lbp, *historyAppender_); sentry.completedSuccessfully(); } lbp->setRunPrincipal(principalCache_.runPrincipalPtr()); - principalCache_.insert(lbp); - return input_->luminosityBlock(); + iStatus.lumiPrincipal() = std::move(lbp); } - int EventProcessor::readAndMergeLumi() { - principalCache_.merge(input_->luminosityBlockAuxiliary(), preg()); + int EventProcessor::readAndMergeLumi(LuminosityBlockProcessingStatus& iStatus) { + auto& lumiPrincipal = *iStatus.lumiPrincipal(); + assert(lumiPrincipal.aux().sameIdentity(*input_->luminosityBlockAuxiliary()) or + input_->processHistoryRegistry().reducedProcessHistoryID(lumiPrincipal.aux().processHistoryID()) == input_->processHistoryRegistry().reducedProcessHistoryID(input_->luminosityBlockAuxiliary()->processHistoryID())); + bool lumiOK = lumiPrincipal.adjustToNewProductRegistry(*preg()); + assert(lumiOK); + lumiPrincipal.mergeAuxiliary(*input_->luminosityBlockAuxiliary()); { SendSourceTerminationSignalIfException sentry(actReg_.get()); - input_->readAndMergeLumi(*principalCache_.lumiPrincipalPtr()); + input_->readAndMergeLumi(*iStatus.lumiPrincipal()); sentry.completedSuccessfully(); } return input_->luminosityBlock(); @@ -1296,16 +1308,16 @@ namespace edm { FDEBUG(1) << "\tdeleteRunFromCache " << run << "\n"; } - void EventProcessor::writeLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) { - schedule_->writeLumi(principalCache_.lumiPrincipal(phid, run, lumi), &processContext_); - for_all(subProcesses_, [&phid, run, lumi](auto& subProcess){ subProcess.writeLumi(phid, run, lumi); }); - FDEBUG(1) << "\twriteLumi " << run << "/" << lumi << "\n"; + void EventProcessor::writeLumi(LuminosityBlockProcessingStatus& iStatus) { + schedule_->writeLumi(*iStatus.lumiPrincipal(), &processContext_); + for_all(subProcesses_, [&iStatus](auto& subProcess){ subProcess.writeLumi(*iStatus.lumiPrincipal()); }); + //FDEBUG(1) << "\twriteLumi " << run << "/" << lumi << "\n"; } - void EventProcessor::deleteLumiFromCache(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) { - principalCache_.deleteLumi(phid, run, lumi); - for_all(subProcesses_, [&phid, run, lumi](auto& subProcess){ subProcess.deleteLumiFromCache(phid, run, lumi); }); - FDEBUG(1) << "\tdeleteLumiFromCache " << run << "/" << lumi << "\n"; + void EventProcessor::deleteLumiFromCache(LuminosityBlockProcessingStatus& iStatus) { + for(auto& s: subProcesses_) { s.deleteLumiFromCache(*iStatus.lumiPrincipal());} + iStatus.lumiPrincipal()->clearPrincipal(); + //FDEBUG(1) << "\tdeleteLumiFromCache " << run << "/" << lumi << "\n"; } bool EventProcessor::readNextEventForStream(unsigned int iStreamIndex, @@ -1457,7 +1469,6 @@ namespace edm { void EventProcessor::processEventAsyncImpl(WaitingTaskHolder iHolder, unsigned int iStreamIndex) { auto pep = &(principalCache_.eventPrincipal(iStreamIndex)); - pep->setLuminosityBlockPrincipal(principalCache_.lumiPrincipalPtr()); ServiceRegistry::Operate operate(serviceToken_); Service rng; @@ -1465,9 +1476,6 @@ namespace edm { Event ev(*pep, ModuleDescription(), nullptr); rng->postEventRead(ev); } - assert(pep->luminosityBlockPrincipalPtrValid()); - assert(principalCache_.lumiPrincipalPtr()->run() == pep->run()); - assert(principalCache_.lumiPrincipalPtr()->luminosityBlock() == pep->luminosityBlock()); WaitingTaskHolder finalizeEventTask( make_waiting_task( tbb::task::allocate_root(), diff --git a/FWCore/Framework/src/LuminosityBlockPrincipal.cc b/FWCore/Framework/src/LuminosityBlockPrincipal.cc index 0cfa3d4dabe66..c91dd220d9730 100644 --- a/FWCore/Framework/src/LuminosityBlockPrincipal.cc +++ b/FWCore/Framework/src/LuminosityBlockPrincipal.cc @@ -5,7 +5,6 @@ namespace edm { LuminosityBlockPrincipal::LuminosityBlockPrincipal( - std::shared_ptr aux, std::shared_ptr reg, ProcessConfiguration const& pc, HistoryAppender* historyAppender, @@ -13,7 +12,6 @@ namespace edm { bool isForPrimaryProcess) : Base(reg, reg->productLookup(InLumi), pc, InLumi, historyAppender, isForPrimaryProcess), runPrincipal_(), - aux_(aux), index_(index), complete_(false) { } @@ -25,7 +23,7 @@ namespace edm { complete_ = false; - fillPrincipal(aux_->processHistoryID(), processHistoryRegistry, reader); + fillPrincipal(aux_.processHistoryID(), processHistoryRegistry, reader); for(auto& prod : *this) { prod->setProcessHistory(processHistory()); diff --git a/FWCore/Framework/src/PrincipalCache.cc b/FWCore/Framework/src/PrincipalCache.cc index 30ba09e11a5fb..7feb84b61e32d 100644 --- a/FWCore/Framework/src/PrincipalCache.cc +++ b/FWCore/Framework/src/PrincipalCache.cc @@ -58,43 +58,8 @@ namespace edm { return runPrincipal_; } - LuminosityBlockPrincipal& - PrincipalCache::lumiPrincipal(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) const { - if (phid != reducedInputProcessHistoryID_ || - run != run_ || - lumi != lumi_ || - lumiPrincipal_.get() == nullptr) { - throwLumiMissing(); - } - return *lumiPrincipal_.get(); - } - - std::shared_ptr const& - PrincipalCache::lumiPrincipalPtr(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) const { - if (phid != reducedInputProcessHistoryID_ || - run != run_ || - lumi != lumi_ || - lumiPrincipal_.get() == nullptr) { - throwLumiMissing(); - } - return lumiPrincipal_; - } - - LuminosityBlockPrincipal& - PrincipalCache::lumiPrincipal() const { - if (lumiPrincipal_.get() == nullptr) { - throwLumiMissing(); - } - return *lumiPrincipal_.get(); - } - - std::shared_ptr const& - PrincipalCache::lumiPrincipalPtr() const { - if (lumiPrincipal_.get() == nullptr) { - throwLumiMissing(); - } - return lumiPrincipal_; - } + std::shared_ptr + PrincipalCache::getAvailableLumiPrincipalPtr() { return lumiHolder_.tryToGet();} void PrincipalCache::merge(std::shared_ptr aux, std::shared_ptr reg) { if (runPrincipal_.get() == nullptr) { @@ -126,37 +91,6 @@ namespace edm { runPrincipal_->mergeAuxiliary(*aux); } - void PrincipalCache::merge(std::shared_ptr aux, std::shared_ptr reg) { - if (lumiPrincipal_.get() == nullptr) { - throw edm::Exception(edm::errors::LogicError) - << "PrincipalCache::merge\n" - << "Illegal attempt to merge luminosity block into cache\n" - << "There is no luminosity block in the cache to merge with\n" - << "Contact a Framework Developer\n"; - } - if (inputProcessHistoryID_ != aux->processHistoryID()) { - if (reducedInputProcessHistoryID_ != processHistoryRegistry_->reducedProcessHistoryID(aux->processHistoryID())) { - throw edm::Exception(edm::errors::LogicError) - << "PrincipalCache::merge\n" - << "Illegal attempt to merge run into cache\n" - << "Reduced ProcessHistoryID inconsistent with the one already in cache\n" - << "Contact a Framework Developer\n"; - } - inputProcessHistoryID_ = aux->processHistoryID(); - } - if (aux->run() != run_ || - aux->luminosityBlock() != lumi_) { - throw edm::Exception(edm::errors::LogicError) - << "PrincipalCache::merge\n" - << "Illegal attempt to merge lumi into cache\n" - << "Run and lumi numbers are inconsistent with the ones already in the cache\n" - << "Contact a Framework Developer\n"; - } - bool lumiOK = lumiPrincipal_->adjustToNewProductRegistry(*reg); - assert(lumiOK); - lumiPrincipal_->mergeAuxiliary(*aux); - } - void PrincipalCache::insert(std::shared_ptr rp) { if (runPrincipal_.get() != nullptr) { throw edm::Exception(edm::errors::LogicError) @@ -172,39 +106,8 @@ namespace edm { runPrincipal_ = rp; } - void PrincipalCache::insert(std::shared_ptr lbp) { - if (lumiPrincipal_.get() != nullptr) { - throw edm::Exception(edm::errors::LogicError) - << "PrincipalCache::insert\n" - << "Illegal attempt to insert lumi into cache\n" - << "Contact a Framework Developer\n"; - } - if (runPrincipal_.get() == nullptr) { - throw edm::Exception(edm::errors::LogicError) - << "PrincipalCache::insert\n" - << "Illegal attempt to insert lumi into cache\n" - << "Run is invalid\n" - << "Contact a Framework Developer\n"; - } - if (inputProcessHistoryID_ != lbp->aux().processHistoryID()) { - if (reducedInputProcessHistoryID_ != processHistoryRegistry_->reducedProcessHistoryID(lbp->aux().processHistoryID())) { - throw edm::Exception(edm::errors::LogicError) - << "PrincipalCache::insert\n" - << "Illegal attempt to insert lumi into cache\n" - << "luminosity block has ProcessHistoryID inconsistent with run\n" - << "Contact a Framework Developer\n"; - } - inputProcessHistoryID_ = lbp->aux().processHistoryID(); - } - if (lbp->run() != run_) { - throw edm::Exception(edm::errors::LogicError) - << "PrincipalCache::insert\n" - << "Illegal attempt to insert lumi into cache\n" - << "luminosity block inconsistent with run number of run in cache\n" - << "Contact a Framework Developer\n"; - } - lumi_ = lbp->luminosityBlock(); - lumiPrincipal_ = lbp; + void PrincipalCache::insert(std::unique_ptr lbp) { + lumiHolder_.add(std::move(lbp)); } void PrincipalCache::insert(std::shared_ptr ep) { @@ -232,26 +135,6 @@ namespace edm { runPrincipal_.reset(); } - void PrincipalCache::deleteLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) { - if (lumiPrincipal_.get() == nullptr) { - throw edm::Exception(edm::errors::LogicError) - << "PrincipalCache::deleteLumi\n" - << "Illegal attempt to delete luminosity block from cache\n" - << "There is no luminosity block in the cache to delete\n" - << "Contact a Framework Developer\n"; - } - if (reducedInputProcessHistoryID_ != phid || - run != run_ || - lumi != lumi_) { - throw edm::Exception(edm::errors::LogicError) - << "PrincipalCache::deleteLumi\n" - << "Illegal attempt to delete luminosity block from cache\n" - << "Run number, lumi numbers, or reduced ProcessHistoryID inconsistent with those in cache\n" - << "Contact a Framework Developer\n"; - } - lumiPrincipal_.reset(); - } - void PrincipalCache::adjustEventsToNewProductRegistry(std::shared_ptr reg) { for(auto &eventPrincipal : eventPrincipals_) { if (eventPrincipal) { @@ -266,8 +149,11 @@ namespace edm { if (runPrincipal_) { runPrincipal_->adjustIndexesAfterProductRegistryAddition(); } - if (lumiPrincipal_) { - lumiPrincipal_->adjustIndexesAfterProductRegistryAddition(); + //Need to temporarily hold all the lumis to clear out the lumiHolder_ + std::vector> temp; + while(auto p = lumiHolder_.tryToGet()) { + p->adjustIndexesAfterProductRegistryAddition(); + temp.emplace_back(std::move(p)); } } diff --git a/FWCore/Framework/src/PrincipalCache.h b/FWCore/Framework/src/PrincipalCache.h index e5c78ddf29639..f92f8b42dc481 100644 --- a/FWCore/Framework/src/PrincipalCache.h +++ b/FWCore/Framework/src/PrincipalCache.h @@ -28,6 +28,8 @@ Original Author: W. David Dagenhart #include "DataFormats/Provenance/interface/RunID.h" #include "DataFormats/Provenance/interface/LuminosityBlockID.h" +#include "FWCore/Utilities/interface/ReusableObjectHolder.h" + #include #include #include @@ -47,6 +49,7 @@ namespace edm { PrincipalCache(); ~PrincipalCache(); + PrincipalCache(PrincipalCache&&) = default; RunPrincipal& runPrincipal(ProcessHistoryID const& phid, RunNumber_t run) const; std::shared_ptr const& runPrincipalPtr(ProcessHistoryID const& phid, RunNumber_t run) const; @@ -54,24 +57,18 @@ namespace edm { std::shared_ptr const& runPrincipalPtr() const; bool hasRunPrincipal() const {return bool(runPrincipal_);} - LuminosityBlockPrincipal& lumiPrincipal(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) const; - std::shared_ptr const& lumiPrincipalPtr(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) const; - LuminosityBlockPrincipal& lumiPrincipal() const; - std::shared_ptr const& lumiPrincipalPtr() const; - bool hasLumiPrincipal() const {return bool(lumiPrincipal_);} + std::shared_ptr getAvailableLumiPrincipalPtr(); EventPrincipal& eventPrincipal(unsigned int iStreamIndex) const { return *(eventPrincipals_[iStreamIndex]); } void merge(std::shared_ptr aux, std::shared_ptr reg); - void merge(std::shared_ptr aux, std::shared_ptr reg); void setNumberOfConcurrentPrincipals(PreallocationConfiguration const&); void insert(std::shared_ptr rp); - void insert(std::shared_ptr lbp); + void insert(std::unique_ptr lbp); void insert(std::shared_ptr ep); void deleteRun(ProcessHistoryID const& phid, RunNumber_t run); - void deleteLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi); void adjustEventsToNewProductRegistry(std::shared_ptr reg); @@ -87,7 +84,7 @@ namespace edm { // These are explicitly cleared when finished with the run, // lumi, or event std::shared_ptr runPrincipal_; - std::shared_ptr lumiPrincipal_; + edm::ReusableObjectHolder lumiHolder_; std::vector> eventPrincipals_; // This is just an accessor to the registry owned by the input source. diff --git a/FWCore/Framework/src/StreamSchedule.cc b/FWCore/Framework/src/StreamSchedule.cc index 6fb2245fe8325..9a7ed43701ac3 100644 --- a/FWCore/Framework/src/StreamSchedule.cc +++ b/FWCore/Framework/src/StreamSchedule.cc @@ -26,6 +26,8 @@ #include "FWCore/Utilities/interface/ExceptionCollector.h" #include "FWCore/Concurrency/interface/WaitingTaskHolder.h" +#include "LuminosityBlockProcessingStatus.h" + #include #include #include @@ -712,6 +714,17 @@ namespace edm { return iExcept; } + void + StreamSchedule::processOneBeginLumiAsync(WaitingTaskHolder iTask, + std::shared_ptr iLumiStatus, + EventSetup const& eventSetup) { + lumiStatus_ = std::move(iLumiStatus); + using Traits = OccurrenceTraits; + processOneStreamAsync(std::move(iTask), *(lumiStatus_->lumiPrincipal()), eventSetup); + } + void + StreamSchedule::processOneEndLumiAsync(WaitingTaskHolder iTask, bool cleaningUpAfterException) {} + void StreamSchedule::availablePaths(std::vector& oLabelsToFill) const { diff --git a/FWCore/Framework/src/StreamSchedule.h b/FWCore/Framework/src/StreamSchedule.h index 4cf4810caf946..48d20efe26231 100644 --- a/FWCore/Framework/src/StreamSchedule.h +++ b/FWCore/Framework/src/StreamSchedule.h @@ -111,6 +111,7 @@ namespace edm { class EndPathStatusInserter; class PreallocationConfiguration; class WaitingTaskHolder; + class LuminosityBlockProcessingStatus; namespace service { class TriggerNamesService; @@ -187,6 +188,14 @@ namespace edm { EventSetup const& eventSetup, bool cleaningUpAfterException = false); + //Handle LuminosityBlocks + void processOneBeginLumiAsync(WaitingTaskHolder iTask, + std::shared_ptr, + EventSetup const& eventSetup); + void processOneEndLumiAsync(WaitingTaskHolder iTask, bool cleaningUpAfterException); + + std::shared_ptr activeLuminosityBlockProcessingStatus() { return lumiStatus_;} + void beginStream(); void endStream(); @@ -336,6 +345,8 @@ namespace edm { WorkerManager workerManager_; std::shared_ptr actReg_; // We do not use propagate_const because the registry itself is mutable. + + std::shared_ptr lumiStatus_; edm::propagate_const results_; diff --git a/FWCore/Framework/src/SubProcess.cc b/FWCore/Framework/src/SubProcess.cc index 83dbd5941f56b..b19bc0b1c675d 100644 --- a/FWCore/Framework/src/SubProcess.cc +++ b/FWCore/Framework/src/SubProcess.cc @@ -184,6 +184,12 @@ namespace edm { false /*not primary process*/); principalCache_.insert(ep); } + for(unsigned int index = 0; index < preallocConfig.numberOfLuminosityBlocks(); ++ index) { + auto lbpp = std::make_unique(preg_, *processConfiguration_, &(historyAppenders_[historyLumiOffset_+index]),index,false); + principalCache_.insert(std::move(lbpp)); + } + + inUseLumiPrincipals_.resize(preallocConfig.numberOfLuminosityBlocks()); subProcesses_.reserve(subProcessVParameterSet.size()); for(auto& subProcessPSet : subProcessVParameterSet) { @@ -370,7 +376,7 @@ namespace edm { *(principal.productProvenanceRetrieverPtr()),//NOTE: this transfers the per product provenance principal.reader(), deepCopyRetriever); - ep.setLuminosityBlockPrincipal(principalCache_.lumiPrincipalPtr()); + ep.setLuminosityBlockPrincipal(inUseLumiPrincipals_[principal.luminosityBlockPrincipal().index()]); propagateProducts(InEvent, principal, ep); WaitingTaskHolder finalizeEventTask( make_waiting_task(tbb::task::allocate_root(), @@ -478,15 +484,16 @@ namespace edm { SubProcess::doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts) { ServiceRegistry::Operate operate(serviceToken_); - auto aux = std::make_shared(principal.aux()); - aux->setProcessHistoryID(principal.processHistoryID()); - auto lbpp = std::make_shared(aux, preg_, *processConfiguration_, &(historyAppenders_[historyLumiOffset_+principal.index()]),principal.index(),false); - auto & processHistoryRegistry = processHistoryRegistries_[historyLumiOffset_+principal.index()]; + auto aux = principal.aux(); + aux.setProcessHistoryID(principal.processHistoryID()); + auto lbpp = principalCache_.getAvailableLumiPrincipalPtr(); + lbpp->setAux(aux); + auto & processHistoryRegistry = processHistoryRegistries_[historyLumiOffset_+lbpp->index()]; + inUseLumiPrincipals_[principal.index()] = lbpp; processHistoryRegistry.registerProcessHistory(principal.processHistory()); lbpp->fillLuminosityBlockPrincipal(processHistoryRegistry, principal.reader()); lbpp->setRunPrincipal(principalCache_.runPrincipalPtr()); - principalCache_.insert(lbpp); - LuminosityBlockPrincipal& lbp = *principalCache_.lumiPrincipalPtr(); + LuminosityBlockPrincipal& lbp = *lbpp; propagateProducts(InLumi, principal, lbp); typedef OccurrenceTraits Traits; beginGlobalTransitionAsync(std::move(iHolder), @@ -499,7 +506,8 @@ namespace edm { void SubProcess::doEndLuminosityBlockAsync(WaitingTaskHolder iHolder,LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException) { - LuminosityBlockPrincipal& lbp = *principalCache_.lumiPrincipalPtr(); + + LuminosityBlockPrincipal& lbp = *inUseLumiPrincipals_[principal.index()]; lbp.setComplete(); propagateProducts(InLumi, principal, lbp); typedef OccurrenceTraits Traits; @@ -515,22 +523,21 @@ namespace edm { void - SubProcess::writeLumi(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber) { + SubProcess::writeLumi(LuminosityBlockPrincipal& principal) { ServiceRegistry::Operate operate(serviceToken_); - std::map::const_iterator it = parentToChildPhID_.find(parentPhID); - assert(it != parentToChildPhID_.end()); - auto const& childPhID = it->second; - schedule_->writeLumi(principalCache_.lumiPrincipal(childPhID, runNumber, lumiNumber), &processContext_); - for_all(subProcesses_, [&childPhID, runNumber, lumiNumber](auto& subProcess){ subProcess.writeLumi(childPhID, runNumber, lumiNumber); }); + auto l =inUseLumiPrincipals_[principal.index()]; + schedule_->writeLumi(*l, &processContext_); + for_all(subProcesses_, [l](auto& subProcess){ subProcess.writeLumi(*l); }); } void - SubProcess::deleteLumiFromCache(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber) { - std::map::const_iterator it = parentToChildPhID_.find(parentPhID); - assert(it != parentToChildPhID_.end()); - auto const& childPhID = it->second; - principalCache_.deleteLumi(childPhID, runNumber, lumiNumber); - for_all(subProcesses_, [&childPhID, runNumber, lumiNumber](auto& subProcess){ subProcess.deleteLumiFromCache(childPhID, runNumber, lumiNumber); }); + SubProcess::deleteLumiFromCache(LuminosityBlockPrincipal& principal) { + //release from list but stay around till end of routine + auto lb = std::move(inUseLumiPrincipals_[principal.index()]); + for(auto& s: subProcesses_) { + s.deleteLumiFromCache(*lb); + } + lb->clearPrincipal(); } void @@ -591,7 +598,7 @@ namespace edm { typedef OccurrenceTraits Traits; - LuminosityBlockPrincipal& lbp = *principalCache_.lumiPrincipalPtr(); + LuminosityBlockPrincipal& lbp = *inUseLumiPrincipals_[principal.index()]; beginStreamTransitionAsync(std::move(iHolder), *schedule_, @@ -609,7 +616,7 @@ namespace edm { unsigned int id, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException) { ServiceRegistry::Operate operate(serviceToken_); - LuminosityBlockPrincipal& lbp = *principalCache_.lumiPrincipalPtr(); + LuminosityBlockPrincipal& lbp = *inUseLumiPrincipals_[principal.index()]; typedef OccurrenceTraits Traits; endStreamTransitionAsync(std::move(iHolder), *schedule_, diff --git a/FWCore/Framework/src/TransitionProcessors.icc b/FWCore/Framework/src/TransitionProcessors.icc index b59abd0cbc6a8..f40f401690911 100644 --- a/FWCore/Framework/src/TransitionProcessors.icc +++ b/FWCore/Framework/src/TransitionProcessors.icc @@ -91,13 +91,13 @@ struct LumiResources { ~LumiResources() noexcept { try { //If we skip empty lumis, this would be called conditionally - run_->ep_.endLumi(processHistoryID(), run(), lumi(), globalTransitionSucceeded_, cleaningUpAfterException_); + run_->ep_.endLumi(status_, globalTransitionSucceeded_, cleaningUpAfterException_); if (success_) { - run_->ep_.writeLumi(processHistoryID(), run(), lumi()); + run_->ep_.writeLumi(*status_); } - run_->ep_.deleteLumiFromCache(processHistoryID(), run(), lumi()); + run_->ep_.deleteLumiFromCache(*status_); } catch(...) { if(cleaningUpAfterException_ or not run_->ep_.setDeferredException(std::current_exception())) { @@ -127,6 +127,7 @@ struct LumiResources { } std::shared_ptr run_; + std::shared_ptr status_; edm::LuminosityBlockNumber_t lumi_; bool cleaningUpAfterException_ = true; bool success_ = false; @@ -205,14 +206,12 @@ private: currentLumi_->normalEnd(); } currentLumi_ = std::make_shared(iRun,lumiID); - auto id = iEP.readLuminosityBlock(); - assert((id >= 0) and (static_cast(id) == lumiID)); - iEP.beginLumi(currentLumi_->processHistoryID(), currentLumi_->run(), currentLumi_->lumi(), currentLumi_->globalTransitionSucceeded_); + iEP.beginLumi(currentLumi_->status_, currentLumi_->globalTransitionSucceeded_); //only if we succeed at beginLumi should we run writeLumi currentLumi_->succeeded(); } else { //merge - auto id = iEP.readAndMergeLumi(); + auto id = iEP.readAndMergeLumi(*currentLumi_->status_); assert((id >= 0) and (static_cast(id) == lumiID) ); } } diff --git a/FWCore/Framework/test/Event_t.cpp b/FWCore/Framework/test/Event_t.cpp index a91d33c10fd46..c8d97648b94db 100644 --- a/FWCore/Framework/test/Event_t.cpp +++ b/FWCore/Framework/test/Event_t.cpp @@ -426,8 +426,8 @@ void testEvent::setUp() { ProcessConfiguration const& pc = currentModuleDescription_->processConfiguration(); auto runAux = std::make_shared(id.run(), time, time); auto rp = std::make_shared(runAux, preg, pc, &historyAppender_,0); - auto lumiAux = std::make_shared(rp->run(), 1, time, time); - auto lbp = std::make_shared(lumiAux, preg, pc, &historyAppender_,0); + auto lbp = std::make_shared(preg, pc, &historyAppender_,0); + lbp->setAux(LuminosityBlockAuxiliary(rp->run(), 1, time, time)); lbp->setRunPrincipal(rp); EventAuxiliary eventAux(id, uuid, time, true); const_cast(eventAux.processHistoryID()) = processHistoryID; diff --git a/FWCore/Framework/test/MockEventProcessor.cc b/FWCore/Framework/test/MockEventProcessor.cc index 641bf9f0e7e86..e410275c5ca68 100644 --- a/FWCore/Framework/test/MockEventProcessor.cc +++ b/FWCore/Framework/test/MockEventProcessor.cc @@ -26,8 +26,21 @@ namespace { using EventProcessor = edm::MockEventProcessor; + class WaitingTaskHolder; #include "FWCore/Framework/src/TransitionProcessors.icc" } + +namespace edm { +struct LuminosityBlockPrincipal { + LuminosityBlockPrincipal(int iRun,int iLumi): run_(iRun),lumi_(iLumi){} + int run_; + int lumi_; +}; +} + +#define TEST_NO_FWD_DECL +#include "FWCore/Framework/src/LuminosityBlockProcessingStatus.h" + namespace edm { MockEventProcessor::MockEventProcessor(std::string const& mockData, @@ -216,15 +229,17 @@ namespace edm { output_ << "\tendRun " << run << postfix; } - void MockEventProcessor::beginLumi(ProcessHistoryID const&, RunNumber_t run, LuminosityBlockNumber_t lumi, bool& globalTransitionSucceeded) { - output_ << "\tbeginLumi " << run << "/" << lumi << "\n"; + void MockEventProcessor::beginLumi(std::shared_ptr& status, bool& globalTransitionSucceeded) { + status = std::make_shared(this,1); + auto lumi = readLuminosityBlock(*status); + output_ << "\tbeginLumi " << run_ << "/" << lumi << "\n"; throwIfNeeded(); globalTransitionSucceeded = true; } - void MockEventProcessor::endLumi(ProcessHistoryID const&, RunNumber_t run, LuminosityBlockNumber_t lumi, bool globalTransitionSucceeded , bool /*cleaningUpAfterException*/) { + void MockEventProcessor::endLumi(std::shared_ptr status, bool globalTransitionSucceeded , bool /*cleaningUpAfterException*/) { auto postfix = globalTransitionSucceeded? "\n" : " global failed\n"; - output_ << "\tendLumi " << run << "/" << lumi << postfix; + output_ << "\tendLumi " << status->lumiPrincipal()->run_ << "/" << status->lumiPrincipal()->lumi_ << postfix; } std::pair MockEventProcessor::readRun() { @@ -237,12 +252,13 @@ namespace edm { return std::make_pair(ProcessHistoryID(), run_); } - int MockEventProcessor::readLuminosityBlock() { + int MockEventProcessor::readLuminosityBlock(LuminosityBlockProcessingStatus& iStatus) { output_ << "\treadLuminosityBlock " << lumi_ << "\n"; + iStatus.lumiPrincipal() = std::make_shared(run_,lumi_); return lumi_; } - int MockEventProcessor::readAndMergeLumi() { + int MockEventProcessor::readAndMergeLumi(LuminosityBlockProcessingStatus& iStatus) { output_ << "\treadAndMergeLumi " << lumi_ << "\n"; return lumi_; } @@ -255,12 +271,12 @@ namespace edm { output_ << "\tdeleteRunFromCache " << run << "\n"; } - void MockEventProcessor::writeLumi(ProcessHistoryID const&, RunNumber_t run, LuminosityBlockNumber_t lumi) { - output_ << "\twriteLumi " << run << "/" << lumi << "\n"; + void MockEventProcessor::writeLumi(LuminosityBlockProcessingStatus& iStatus) { + output_ << "\twriteLumi " << iStatus.lumiPrincipal()->run_ << "/" << iStatus.lumiPrincipal()->lumi_ << "\n"; } - void MockEventProcessor::deleteLumiFromCache(ProcessHistoryID const&, RunNumber_t run, LuminosityBlockNumber_t lumi) { - output_ << "\tdeleteLumiFromCache " << run << "/" << lumi << "\n"; + void MockEventProcessor::deleteLumiFromCache(LuminosityBlockProcessingStatus& iStatus) { + output_ << "\tdeleteLumiFromCache " << iStatus.lumiPrincipal()->run_ << "/" << iStatus.lumiPrincipal()->lumi_ << "\n"; } void MockEventProcessor::readAndProcessEvent() { diff --git a/FWCore/Framework/test/MockEventProcessor.h b/FWCore/Framework/test/MockEventProcessor.h index d3e9a6b0f7512..34cb1aa67d02a 100644 --- a/FWCore/Framework/test/MockEventProcessor.h +++ b/FWCore/Framework/test/MockEventProcessor.h @@ -17,6 +17,8 @@ Original Authors: W. David Dagenhart, Marc Paterno #include namespace edm { + class LuminosityBlockProcessingStatus; + class MockEventProcessor { public: class TestException : public std::exception { @@ -54,17 +56,18 @@ namespace edm { void beginRun(ProcessHistoryID const& phid, RunNumber_t run, bool& globalTransitionSucceeded); void endRun(ProcessHistoryID const& phid, RunNumber_t run, bool globalTranstitionSucceeded, bool cleaningUpAfterException); - void beginLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi, bool& globalTransitionSucceeded); - void endLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi, bool globalTransitionSucceeded, bool cleaningUpAfterException); + void beginLumi(std::shared_ptr& status, + bool& globalTransitionSucceeded); + void endLumi(std::shared_ptr, bool globalTransitionSucceeded, bool cleaningUpAfterException); std::pair readRun(); std::pair readAndMergeRun(); - int readLuminosityBlock(); - int readAndMergeLumi(); + int readLuminosityBlock(LuminosityBlockProcessingStatus& ); + int readAndMergeLumi(LuminosityBlockProcessingStatus&); void writeRun(ProcessHistoryID const& phid, RunNumber_t run); void deleteRunFromCache(ProcessHistoryID const& phid, RunNumber_t run); - void writeLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi); - void deleteLumiFromCache(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi); + void writeLumi(LuminosityBlockProcessingStatus&); + void deleteLumiFromCache(LuminosityBlockProcessingStatus&); bool shouldWeStop() const; diff --git a/FWCore/Framework/test/event_getrefbeforeput_t.cppunit.cc b/FWCore/Framework/test/event_getrefbeforeput_t.cppunit.cc index a9d02ec06308e..f9d641c6390ca 100644 --- a/FWCore/Framework/test/event_getrefbeforeput_t.cppunit.cc +++ b/FWCore/Framework/test/event_getrefbeforeput_t.cppunit.cc @@ -71,8 +71,9 @@ void testEventGetRefBeforePut::failGetProductNotRegisteredTest() { std::shared_ptr pregc(preg.release()); auto runAux = std::make_shared(col.run(), fakeTime, fakeTime); auto rp = std::make_shared(runAux, pregc, pc, &historyAppender_,0); - auto lumiAux = std::make_shared(rp->run(), 1, fakeTime, fakeTime); - auto lbp = std::make_shared(lumiAux, pregc, pc, &historyAppender_,0); + edm::LuminosityBlockAuxiliary lumiAux(rp->run(), 1, fakeTime, fakeTime); + auto lbp = std::make_shared(pregc, pc, &historyAppender_,0); + lbp->setAux(lumiAux); lbp->setRunPrincipal(rp); edm::EventAuxiliary eventAux(col, uuid, fakeTime, true); edm::EventPrincipal ep(pregc, branchIDListHelper, thinnedAssociationsHelper, pc, &historyAppender_,edm::StreamID::invalidStreamID()); @@ -166,8 +167,9 @@ void testEventGetRefBeforePut::getRefTest() { std::shared_ptr pregc(preg.release()); auto runAux = std::make_shared(col.run(), fakeTime, fakeTime); auto rp = std::make_shared(runAux, pregc, pc, &historyAppender_,0); - auto lumiAux = std::make_shared(rp->run(), 1, fakeTime, fakeTime); - auto lbp = std::make_shared(lumiAux, pregc, pc, &historyAppender_,0); + edm::LuminosityBlockAuxiliary lumiAux(rp->run(), 1, fakeTime, fakeTime); + auto lbp = std::make_shared(pregc, pc, &historyAppender_,0); + lbp->setAux(lumiAux); lbp->setRunPrincipal(rp); edm::EventAuxiliary eventAux(col, uuid, fakeTime, true); edm::EventPrincipal ep(pregc, branchIDListHelper, thinnedAssociationsHelper, pc, &historyAppender_,edm::StreamID::invalidStreamID()); diff --git a/FWCore/Framework/test/eventprincipal_t.cppunit.cc b/FWCore/Framework/test/eventprincipal_t.cppunit.cc index ebed445bd3000..40030ac37dd87 100644 --- a/FWCore/Framework/test/eventprincipal_t.cppunit.cc +++ b/FWCore/Framework/test/eventprincipal_t.cppunit.cc @@ -183,8 +183,9 @@ void test_ep::setUp() { edm::Timestamp now(1234567UL); auto runAux = std::make_shared(eventID_.run(), now, now); auto rp = std::make_shared(runAux, pProductRegistry_, *process, &historyAppender_,0); - auto lumiAux = std::make_shared(rp->run(), 1, now, now); - auto lbp = std::make_shared(lumiAux, pProductRegistry_, *process, &historyAppender_,0); + edm::LuminosityBlockAuxiliary lumiAux(rp->run(), 1, now, now); + auto lbp = std::make_shared(pProductRegistry_, *process, &historyAppender_,0); + lbp->setAux(lumiAux); lbp->setRunPrincipal(rp); edm::EventAuxiliary eventAux(eventID_, uuid, now, true); pEvent_.reset(new edm::EventPrincipal(pProductRegistry_, branchIDListHelper, thinnedAssociationsHelper, *process, &historyAppender_,edm::StreamID::invalidStreamID())); diff --git a/FWCore/Framework/test/generichandle_t.cppunit.cc b/FWCore/Framework/test/generichandle_t.cppunit.cc index d27293619b3be..b4e43f37d84de 100644 --- a/FWCore/Framework/test/generichandle_t.cppunit.cc +++ b/FWCore/Framework/test/generichandle_t.cppunit.cc @@ -84,8 +84,8 @@ void testGenericHandle::failgetbyLabelTest() { preg->setFrozen(); auto runAux = std::make_shared(id.run(), time, time); auto rp = std::make_shared(runAux, preg, pc, &historyAppender_,0); - auto lumiAux = std::make_shared(rp->run(), 1, time, time); - auto lbp = std::make_shared(lumiAux, preg, pc, &historyAppender_,0); + auto lbp = std::make_shared(preg, pc, &historyAppender_,0); + lbp->setAux(edm::LuminosityBlockAuxiliary(rp->run(), 1, time, time)); lbp->setRunPrincipal(rp); auto branchIDListHelper = std::make_shared(); branchIDListHelper->updateFromRegistry(*preg); @@ -177,8 +177,8 @@ void testGenericHandle::getbyLabelTest() { std::shared_ptr pregc(preg.release()); auto runAux = std::make_shared(col.run(), fakeTime, fakeTime); auto rp = std::make_shared(runAux, pregc, pc, &historyAppender_,0); - auto lumiAux = std::make_shared(rp->run(), 1, fakeTime, fakeTime); - auto lbp = std::make_shared(lumiAux, pregc, pc, &historyAppender_,0); + auto lbp = std::make_shared(pregc, pc, &historyAppender_,0); + lbp->setAux(edm::LuminosityBlockAuxiliary(rp->run(), 1, fakeTime, fakeTime)); lbp->setRunPrincipal(rp); edm::EventAuxiliary eventAux(col, uuid, fakeTime, true); edm::EventPrincipal ep(pregc, branchIDListHelper, thinnedAssociationsHelper, pc, &historyAppender_,edm::StreamID::invalidStreamID()); diff --git a/FWCore/Framework/test/global_module_t.cppunit.cc b/FWCore/Framework/test/global_module_t.cppunit.cc index 4ba1a111707f7..e904b207efc73 100644 --- a/FWCore/Framework/test/global_module_t.cppunit.cc +++ b/FWCore/Framework/test/global_module_t.cppunit.cc @@ -358,7 +358,8 @@ m_ep() auto runAux = std::make_shared(eventID.run(), now, now); m_rp.reset(new edm::RunPrincipal(runAux, m_prodReg, m_procConfig, &historyAppender_,0)); auto lumiAux = std::make_shared(m_rp->run(), 1, now, now); - m_lbp.reset(new edm::LuminosityBlockPrincipal(lumiAux, m_prodReg, m_procConfig, &historyAppender_,0)); + m_lbp.reset(new edm::LuminosityBlockPrincipal(m_prodReg, m_procConfig, &historyAppender_,0)); + m_lbp->setAux(*lumiAux); m_lbp->setRunPrincipal(m_rp); edm::EventAuxiliary eventAux(eventID, uuid, now, true); diff --git a/FWCore/Framework/test/global_outputmodule_t.cppunit.cc b/FWCore/Framework/test/global_outputmodule_t.cppunit.cc index 4c992238dc700..1fbfa4ddd944b 100644 --- a/FWCore/Framework/test/global_outputmodule_t.cppunit.cc +++ b/FWCore/Framework/test/global_outputmodule_t.cppunit.cc @@ -173,8 +173,9 @@ m_ep() edm::Timestamp now(1234567UL); auto runAux = std::make_shared(eventID.run(), now, now); m_rp.reset(new edm::RunPrincipal(runAux, m_prodReg, m_procConfig, &historyAppender_,0)); - auto lumiAux = std::make_shared(m_rp->run(), 1, now, now); - m_lbp.reset(new edm::LuminosityBlockPrincipal(lumiAux, m_prodReg, m_procConfig, &historyAppender_,0)); + edm::LuminosityBlockAuxiliary lumiAux(m_rp->run(), 1, now, now); + m_lbp.reset(new edm::LuminosityBlockPrincipal(m_prodReg, m_procConfig, &historyAppender_,0)); + m_lbp->setAux(lumiAux); m_lbp->setRunPrincipal(m_rp); edm::EventAuxiliary eventAux(eventID, uuid, now, true); diff --git a/FWCore/Framework/test/limited_module_t.cppunit.cc b/FWCore/Framework/test/limited_module_t.cppunit.cc index 9c3e0fc0e3cdf..a7fc81fdc5311 100644 --- a/FWCore/Framework/test/limited_module_t.cppunit.cc +++ b/FWCore/Framework/test/limited_module_t.cppunit.cc @@ -384,8 +384,9 @@ m_ep() edm::Timestamp now(1234567UL); auto runAux = std::make_shared(eventID.run(), now, now); m_rp.reset(new edm::RunPrincipal(runAux, m_prodReg, m_procConfig, &historyAppender_,0)); - auto lumiAux = std::make_shared(m_rp->run(), 1, now, now); - m_lbp.reset(new edm::LuminosityBlockPrincipal(lumiAux, m_prodReg, m_procConfig, &historyAppender_,0)); + edm::LuminosityBlockAuxiliary lumiAux(m_rp->run(), 1, now, now); + m_lbp.reset(new edm::LuminosityBlockPrincipal(m_prodReg, m_procConfig, &historyAppender_,0)); + m_lbp->setAux(lumiAux); m_lbp->setRunPrincipal(m_rp); edm::EventAuxiliary eventAux(eventID, uuid, now, true); diff --git a/FWCore/Framework/test/limited_outputmodule_t.cppunit.cc b/FWCore/Framework/test/limited_outputmodule_t.cppunit.cc index fbb8df7778e8e..164d968ddc45a 100644 --- a/FWCore/Framework/test/limited_outputmodule_t.cppunit.cc +++ b/FWCore/Framework/test/limited_outputmodule_t.cppunit.cc @@ -173,8 +173,8 @@ m_ep() edm::Timestamp now(1234567UL); auto runAux = std::make_shared(eventID.run(), now, now); m_rp.reset(new edm::RunPrincipal(runAux, m_prodReg, m_procConfig, &historyAppender_,0)); - auto lumiAux = std::make_shared(m_rp->run(), 1, now, now); - m_lbp.reset(new edm::LuminosityBlockPrincipal(lumiAux, m_prodReg, m_procConfig, &historyAppender_,0)); + m_lbp.reset(new edm::LuminosityBlockPrincipal(m_prodReg, m_procConfig, &historyAppender_,0)); + m_lbp->setAux(edm::LuminosityBlockAuxiliary(m_rp->run(), 1, now, now)); m_lbp->setRunPrincipal(m_rp); edm::EventAuxiliary eventAux(eventID, uuid, now, true); diff --git a/FWCore/Framework/test/one_outputmodule_t.cppunit.cc b/FWCore/Framework/test/one_outputmodule_t.cppunit.cc index 901ccfadc8cb7..961e6b17354c6 100644 --- a/FWCore/Framework/test/one_outputmodule_t.cppunit.cc +++ b/FWCore/Framework/test/one_outputmodule_t.cppunit.cc @@ -251,8 +251,9 @@ m_ep() edm::Timestamp now(1234567UL); auto runAux = std::make_shared(eventID.run(), now, now); m_rp.reset(new edm::RunPrincipal(runAux, m_prodReg, m_procConfig, &historyAppender_,0)); - auto lumiAux = std::make_shared(m_rp->run(), 1, now, now); - m_lbp.reset(new edm::LuminosityBlockPrincipal(lumiAux, m_prodReg, m_procConfig, &historyAppender_,0)); + edm::LuminosityBlockAuxiliary lumiAux(m_rp->run(), 1, now, now); + m_lbp.reset(new edm::LuminosityBlockPrincipal(m_prodReg, m_procConfig, &historyAppender_,0)); + m_lbp->setAux(lumiAux); m_lbp->setRunPrincipal(m_rp); edm::EventAuxiliary eventAux(eventID, uuid, now, true); diff --git a/FWCore/Framework/test/stream_module_t.cppunit.cc b/FWCore/Framework/test/stream_module_t.cppunit.cc index 47ecc7ed02617..480666919ba7a 100644 --- a/FWCore/Framework/test/stream_module_t.cppunit.cc +++ b/FWCore/Framework/test/stream_module_t.cppunit.cc @@ -381,7 +381,8 @@ m_ep() auto runAux = std::make_shared(eventID.run(), now, now); m_rp.reset(new edm::RunPrincipal(runAux, m_prodReg, m_procConfig, &historyAppender_,0)); auto lumiAux = std::make_shared(m_rp->run(), 1, now, now); - m_lbp.reset(new edm::LuminosityBlockPrincipal(lumiAux, m_prodReg, m_procConfig, &historyAppender_,0)); + m_lbp.reset(new edm::LuminosityBlockPrincipal(m_prodReg, m_procConfig, &historyAppender_,0)); + m_lbp->setAux(*lumiAux); m_lbp->setRunPrincipal(m_rp); edm::EventAuxiliary eventAux(eventID, uuid, now, true); diff --git a/FWCore/TFWLiteSelector/src/TFWLiteSelectorBasic.cc b/FWCore/TFWLiteSelector/src/TFWLiteSelectorBasic.cc index 77ac350281e32..173c46d8c9008 100644 --- a/FWCore/TFWLiteSelector/src/TFWLiteSelectorBasic.cc +++ b/FWCore/TFWLiteSelector/src/TFWLiteSelectorBasic.cc @@ -329,8 +329,8 @@ TFWLiteSelectorBasic::Process(Long64_t iEntry) { m_->reader_->setEntry(iEntry); auto runAux = std::make_shared(aux.run(), aux.time(), aux.time()); auto rp = std::make_shared(runAux, m_->reg(), m_->pc_, nullptr, 0); - auto lumiAux = std::make_shared(rp->run(), 1, aux.time(), aux.time()); - auto lbp = std::make_shared(lumiAux, m_->reg(), m_->pc_, nullptr, 0); + auto lbp = std::make_shared(m_->reg(), m_->pc_, nullptr, 0); + lbp->setAux(edm::LuminosityBlockAuxiliary(rp->run(), 1, aux.time(), aux.time())); m_->ep_->fillEventPrincipal(*eaux, *m_->phreg_, std::move(eventSelectionIDs), diff --git a/IOPool/Input/src/PoolSource.cc b/IOPool/Input/src/PoolSource.cc index 79062225d0f04..a95d4c516f5f5 100644 --- a/IOPool/Input/src/PoolSource.cc +++ b/IOPool/Input/src/PoolSource.cc @@ -209,11 +209,12 @@ namespace edm { if(found) { std::shared_ptr secondaryAuxiliary = secondaryFileSequence_->readLuminosityBlockAuxiliary_(); checkConsistency(lumiPrincipal.aux(), *secondaryAuxiliary); - secondaryLumiPrincipal_ = std::make_shared(secondaryAuxiliary, + secondaryLumiPrincipal_ = std::make_shared( secondaryFileSequence_->fileProductRegistry(), processConfiguration(), nullptr, lumiPrincipal.index()); + secondaryLumiPrincipal_->setAux(*secondaryAuxiliary); secondaryFileSequence_->readLuminosityBlock_(*secondaryLumiPrincipal_); checkHistoryConsistency(lumiPrincipal, *secondaryLumiPrincipal_); lumiPrincipal.recombine(*secondaryLumiPrincipal_, branchIDsToReplace_[InLumi]); From 3b8fff90c2f9dcf910c0d5c4dcfa958e02a35cf7 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 21 Dec 2017 14:32:38 -0600 Subject: [PATCH 10/52] Add additional transition tests --- FWCore/Framework/test/transition_test.sh | 7 + FWCore/Framework/test/transition_test_cfg.py | 145 +++++++++++++++++-- 2 files changed, 140 insertions(+), 12 deletions(-) diff --git a/FWCore/Framework/test/transition_test.sh b/FWCore/Framework/test/transition_test.sh index 0ccf155ab8273..0304853d08c31 100755 --- a/FWCore/Framework/test/transition_test.sh +++ b/FWCore/Framework/test/transition_test.sh @@ -13,3 +13,10 @@ function die { echo $1: status $2 ; exit $2; } (cmsRun ${LOCAL_TEST_DIR}/transition_test_cfg.py 7 ) || die 'Failure running cmsRun transition_test_cfg.py 7' $? (cmsRun ${LOCAL_TEST_DIR}/transition_test_cfg.py 8 ) || die 'Failure running cmsRun transition_test_cfg.py 8' $? (cmsRun ${LOCAL_TEST_DIR}/transition_test_cfg.py 9 ) || die 'Failure running cmsRun transition_test_cfg.py 9' $? +(cmsRun ${LOCAL_TEST_DIR}/transition_test_cfg.py 10 ) || die 'Failure running cmsRun transition_test_cfg.py 10' $? +(cmsRun ${LOCAL_TEST_DIR}/transition_test_cfg.py 11 ) || die 'Failure running cmsRun transition_test_cfg.py 11' $? +(cmsRun ${LOCAL_TEST_DIR}/transition_test_cfg.py 12 ) || die 'Failure running cmsRun transition_test_cfg.py 12' $? +(cmsRun ${LOCAL_TEST_DIR}/transition_test_cfg.py 13 ) || die 'Failure running cmsRun transition_test_cfg.py 13' $? +(cmsRun ${LOCAL_TEST_DIR}/transition_test_cfg.py 14 ) || die 'Failure running cmsRun transition_test_cfg.py 14' $? +(cmsRun ${LOCAL_TEST_DIR}/transition_test_cfg.py 15 ) || die 'Failure running cmsRun transition_test_cfg.py 15' $? +(cmsRun ${LOCAL_TEST_DIR}/transition_test_cfg.py 16 ) || die 'Failure running cmsRun transition_test_cfg.py 16' $? diff --git a/FWCore/Framework/test/transition_test_cfg.py b/FWCore/Framework/test/transition_test_cfg.py index a5d4e872a1bdd..681f5ce8e07e3 100644 --- a/FWCore/Framework/test/transition_test_cfg.py +++ b/FWCore/Framework/test/transition_test_cfg.py @@ -2,8 +2,8 @@ import sys def chooseTrans(index): - d = { -0: ["Simple", + d = ( + ["Simple", cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -24,7 +24,20 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], -1: ["Multiple different Lumis", + ["Less events than streams", + cms.untracked.VPSet( + cms.PSet(type = cms.untracked.string("IsFile"), + id = cms.untracked.EventID(0,0,0)), + cms.PSet(type = cms.untracked.string("IsRun"), + id = cms.untracked.EventID(1,0,0)), + cms.PSet(type = cms.untracked.string("IsLumi"), + id = cms.untracked.EventID(1,1,0)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,1)), + cms.PSet(type = cms.untracked.string("IsStop"), + id = cms.untracked.EventID(0,0,0)) + ) ], + ["Multiple different Lumis", cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -45,7 +58,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], -2: ["Empty Lumi", + ["Empty Lumi", cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -62,7 +75,24 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], -3: ["Multiple different runs", + ["Empty Lumi at end", + cms.untracked.VPSet( + cms.PSet(type = cms.untracked.string("IsFile"), + id = cms.untracked.EventID(0,0,0)), + cms.PSet(type = cms.untracked.string("IsRun"), + id = cms.untracked.EventID(1,0,0)), + cms.PSet(type = cms.untracked.string("IsLumi"), + id = cms.untracked.EventID(1,1,0)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,3)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,4)), + cms.PSet(type = cms.untracked.string("IsLumi"), + id = cms.untracked.EventID(1,2,0)), + cms.PSet(type = cms.untracked.string("IsStop"), + id = cms.untracked.EventID(0,0,0)) + ) ], + ["Multiple different runs", cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -85,7 +115,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], -4: ["Empty run", + ["Empty run", cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -102,7 +132,50 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], -5: ["Empty file", + ["Empty run at end", + cms.untracked.VPSet( + cms.PSet(type = cms.untracked.string("IsFile"), + id = cms.untracked.EventID(0,0,0)), + cms.PSet(type = cms.untracked.string("IsRun"), + id = cms.untracked.EventID(1,0,0)), + cms.PSet(type = cms.untracked.string("IsLumi"), + id = cms.untracked.EventID(1,1,0)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,1)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,2)), + cms.PSet(type = cms.untracked.string("IsRun"), + id = cms.untracked.EventID(2,0,0)), + cms.PSet(type = cms.untracked.string("IsStop"), + id = cms.untracked.EventID(0,0,0)) + ) ], + ["Empty run no lumi", + cms.untracked.VPSet( + cms.PSet(type = cms.untracked.string("IsFile"), + id = cms.untracked.EventID(0,0,0)), + cms.PSet(type = cms.untracked.string("IsRun"), + id = cms.untracked.EventID(1,0,0)), + cms.PSet(type = cms.untracked.string("IsStop"), + id = cms.untracked.EventID(0,0,0)) + ) ], + ["Empty file at end", + cms.untracked.VPSet( + cms.PSet(type = cms.untracked.string("IsFile"), + id = cms.untracked.EventID(0,0,0)), + cms.PSet(type = cms.untracked.string("IsRun"), + id = cms.untracked.EventID(1,0,0)), + cms.PSet(type = cms.untracked.string("IsLumi"), + id = cms.untracked.EventID(1,1,0)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,1)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,2)), + cms.PSet(type = cms.untracked.string("IsFile"), + id = cms.untracked.EventID(0,0,0)), + cms.PSet(type = cms.untracked.string("IsStop"), + id = cms.untracked.EventID(0,0,0)) + ) ], + ["Empty file", cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -119,7 +192,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], -6: ["Merge run across files", + ["Merge run across files", cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -144,7 +217,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], -7: ["Merge run & lumi across files", + ["Merge run & lumi across files", cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -169,7 +242,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], -8: ["Delayed lumi merge", + ["Delayed lumi merge", cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -177,6 +250,27 @@ def chooseTrans(index): id = cms.untracked.EventID(1,0,0)), cms.PSet(type = cms.untracked.string("IsLumi"), id = cms.untracked.EventID(1,1,0)), + cms.PSet(type = cms.untracked.string("IsLumi"), #to merge + id = cms.untracked.EventID(1,1,0)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,1)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,2)), + cms.PSet(type = cms.untracked.string("IsLumi"), + id = cms.untracked.EventID(1,2,0)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,2,3)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,2,4)), + cms.PSet(type = cms.untracked.string("IsStop"), + id = cms.untracked.EventID(0,0,0)) + ) ], + ["Delayed lumi merge 2", + cms.untracked.VPSet( + cms.PSet(type = cms.untracked.string("IsFile"), + id = cms.untracked.EventID(0,0,0)), + cms.PSet(type = cms.untracked.string("IsRun"), + id = cms.untracked.EventID(1,0,0)), cms.PSet(type = cms.untracked.string("IsLumi"), id = cms.untracked.EventID(1,1,0)), cms.PSet(type = cms.untracked.string("IsEvent"), @@ -185,6 +279,8 @@ def chooseTrans(index): id = cms.untracked.EventID(1,1,2)), cms.PSet(type = cms.untracked.string("IsLumi"), id = cms.untracked.EventID(1,2,0)), + cms.PSet(type = cms.untracked.string("IsLumi"), + id = cms.untracked.EventID(1,2,0)), # to merge cms.PSet(type = cms.untracked.string("IsEvent"), id = cms.untracked.EventID(1,2,3)), cms.PSet(type = cms.untracked.string("IsEvent"), @@ -192,12 +288,35 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], -9: ["Delayed run merge", + ["Delayed run merge", cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), cms.PSet(type = cms.untracked.string("IsRun"), id = cms.untracked.EventID(1,0,0)), + cms.PSet(type = cms.untracked.string("IsRun"), # to merge + id = cms.untracked.EventID(1,0,0)), + cms.PSet(type = cms.untracked.string("IsLumi"), + id = cms.untracked.EventID(1,1,0)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,1)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,2)), + cms.PSet(type = cms.untracked.string("IsRun"), + id = cms.untracked.EventID(2,0,0)), + cms.PSet(type = cms.untracked.string("IsLumi"), + id = cms.untracked.EventID(2,1,0)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(2,1,1)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(2,1,2)), + cms.PSet(type = cms.untracked.string("IsStop"), + id = cms.untracked.EventID(0,0,0)) + ) ], + ["Delayed run merge 2", + cms.untracked.VPSet( + cms.PSet(type = cms.untracked.string("IsFile"), + id = cms.untracked.EventID(0,0,0)), cms.PSet(type = cms.untracked.string("IsRun"), id = cms.untracked.EventID(1,0,0)), cms.PSet(type = cms.untracked.string("IsLumi"), @@ -208,6 +327,8 @@ def chooseTrans(index): id = cms.untracked.EventID(1,1,2)), cms.PSet(type = cms.untracked.string("IsRun"), id = cms.untracked.EventID(2,0,0)), + cms.PSet(type = cms.untracked.string("IsRun"), # to merge + id = cms.untracked.EventID(2,0,0)), cms.PSet(type = cms.untracked.string("IsLumi"), id = cms.untracked.EventID(2,1,0)), cms.PSet(type = cms.untracked.string("IsEvent"), @@ -217,7 +338,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - } + ) print '****************************************' print 'Test:', d[index][0] print '****************************************' From e54d5f1e578d72e70badaa8da3bf69c865f32baa Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 22 Dec 2017 09:45:56 -0600 Subject: [PATCH 11/52] Move globalBegin status info to LuminosityBlockProcessingStatus Instead of passing globalBeginSucceeded to beginLumi and endLumi calls as arguments, consolidated the status into LuminosityBlockProcessingStatus. --- FWCore/Framework/interface/EventProcessor.h | 4 +- FWCore/Framework/src/EventProcessor.cc | 9 +- .../src/LuminosityBlockProcessingStatus.h | 90 +++++++++++++++++++ FWCore/Framework/src/TransitionProcessors.icc | 5 +- FWCore/Framework/test/MockEventProcessor.cc | 8 +- FWCore/Framework/test/MockEventProcessor.h | 5 +- 6 files changed, 104 insertions(+), 17 deletions(-) create mode 100644 FWCore/Framework/src/LuminosityBlockProcessingStatus.h diff --git a/FWCore/Framework/interface/EventProcessor.h b/FWCore/Framework/interface/EventProcessor.h index f9f7a039775b2..e15b19073c50c 100644 --- a/FWCore/Framework/interface/EventProcessor.h +++ b/FWCore/Framework/interface/EventProcessor.h @@ -204,8 +204,8 @@ namespace edm { void beginRun(ProcessHistoryID const& phid, RunNumber_t run, bool& globalBeginSucceeded); void endRun(ProcessHistoryID const& phid, RunNumber_t run, bool globalBeginSucceeded, bool cleaningUpAfterException); - void beginLumi(std::shared_ptr& status, bool& globalBeginSucceeded); - void endLumi(std::shared_ptr status, bool globalBeginSucceeded, bool cleaningUpAfterException); + void beginLumi(std::shared_ptr& status); + void endLumi(std::shared_ptr status, bool cleaningUpAfterException); std::pair readRun(); std::pair readAndMergeRun(); diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 37abc64104d4a..e37461b017072 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1084,11 +1084,10 @@ namespace edm { } void - EventProcessor::beginLumi(std::shared_ptr& status, bool& globalBeginSucceeded) { + EventProcessor::beginLumi(std::shared_ptr& status) { status= std::make_shared(this, preallocations_.numberOfStreams()) ; readLuminosityBlock(*status); - globalBeginSucceeded = false; LuminosityBlockPrincipal& lumiPrincipal = *status->lumiPrincipal(); { SendSourceTerminationSignalIfException sentry(actReg_.get()); @@ -1127,7 +1126,7 @@ namespace edm { std::rethrow_exception(* (globalWaitTask->exceptionPtr()) ); } } - globalBeginSucceeded=true; + status->globalBeginDidSucceed(); if(looper_) { looper_->doBeginLuminosityBlock(lumiPrincipal, es, &processContext_); } @@ -1162,7 +1161,7 @@ namespace edm { } } - void EventProcessor::endLumi(std::shared_ptr status, bool globalBeginSucceeded, bool cleaningUpAfterException) { + void EventProcessor::endLumi(std::shared_ptr status, bool cleaningUpAfterException) { LuminosityBlockPrincipal& lumiPrincipal = *status-> lumiPrincipal(); lumiPrincipal.setAtEndTransition(true); //We need to reset failed items since they might @@ -1187,7 +1186,7 @@ namespace edm { sentry.completedSuccessfully(); } EventSetup const& es = esp_->eventSetup(); - if(globalBeginSucceeded){ + if(status->didGlobalBeginSucceed()){ //To wait, the ref count has to b 1+#streams auto streamLoopWaitTask = make_empty_waiting_task(); streamLoopWaitTask->increment_ref_count(); diff --git a/FWCore/Framework/src/LuminosityBlockProcessingStatus.h b/FWCore/Framework/src/LuminosityBlockProcessingStatus.h new file mode 100644 index 0000000000000..e66d332b2fb7e --- /dev/null +++ b/FWCore/Framework/src/LuminosityBlockProcessingStatus.h @@ -0,0 +1,90 @@ +#ifndef FWCore_Framework_LuminosityBlockProcessingStatus_h +#define FWCore_Framework_LuminosityBlockProcessingStatus_h +// -*- C++ -*- +// +// Package: FWCore/Framework +// Class : LuminosityBlockProcessingStatus +// +/**\class LuminosityBlockProcessingStatus LuminosityBlockProcessingStatus.h "LuminosityBlockProcessingStatus.h" + + Description: Keep status information about one LuminosityBlock transition + + Usage: + + +*/ +// +// Original Author: root +// Created: Tue, 19 Dec 2017 14:24:57 GMT +// + +// system include files +#include +#include + +// user include files +#include "FWCore/Concurrency/interface/LimitedTaskQueue.h" + +// forward declarations +namespace edm { +#if !defined(TEST_NO_FWD_DECL) + class EventProcessor; + class LuminosityBlockPrincipal; + class WaitingTaskHolder; + class LuminosityBlockProcessingStatus; + void globalEndLumiAsync(edm::WaitingTaskHolder iTask, std::shared_ptr iLumiStatus); +#endif + +class LuminosityBlockProcessingStatus +{ + + public: + friend void globalEndLumiAsync(WaitingTaskHolder iTask, std::shared_ptr iLumiStatus); + + + LuminosityBlockProcessingStatus(EventProcessor* iEP, unsigned int iNStreams): + eventProcessor_(iEP), nStreamsStillProcessingLumi_(iNStreams) {} + + std::shared_ptr& lumiPrincipal() { return lumiPrincipal_;} + + void setResumer( LimitedTaskQueue::Resumer iResumer ) { + globalLumiQueueResumer_ = std::move(iResumer); + } + void resumeGlobalLumiQueue() { + globalLumiQueueResumer_.resume(); + } + + bool streamFinishedLumi() { + return 0 == (--nStreamsStillProcessingLumi_); + } + + bool wasEventProcessingStopped() const { return stopProcessingEvents_;} + void stopProcessingEvents() { stopProcessingEvents_ = true;} + void startProcessingEvents() { stopProcessingEvents_ = false;} + + bool isLumiEnding() const {return lumiEnding_;} + void endLumi() { lumiEnding_ = true;} + + bool continuingLumi() const { return continuingLumi_;} + void haveContinuedLumi() { continuingLumi_ = false; } + void needToContinueLumi() { continuingLumi_ = true;} + + bool haveStartedNextLumi() const { return startedNextLumi_;} + void startNextLumi() { startedNextLumi_ = true;} + + private: + // ---------- member data -------------------------------- + std::shared_ptr lumiPrincipal_; + LimitedTaskQueue::Resumer globalLumiQueueResumer_; + EventProcessor* eventProcessor_ = nullptr; + std::atomic nStreamsStillProcessingLumi_{0}; //read/write as streams finish lumi so must be atomic + bool stopProcessingEvents_{false}; //read/write in m_sourceQueue OR from main thread when no tasks running + bool lumiEnding_{false}; //read/write in m_sourceQueue NOTE: This is a useful cache instead of recalculating each call + bool continuingLumi_{false}; //read/write in m_sourceQueue OR from main thread when no tasks running + bool startedNextLumi_{false}; //read/write in m_sourceQueue + + +}; +} + +#endif diff --git a/FWCore/Framework/src/TransitionProcessors.icc b/FWCore/Framework/src/TransitionProcessors.icc index f40f401690911..bb3c51c692c89 100644 --- a/FWCore/Framework/src/TransitionProcessors.icc +++ b/FWCore/Framework/src/TransitionProcessors.icc @@ -91,7 +91,7 @@ struct LumiResources { ~LumiResources() noexcept { try { //If we skip empty lumis, this would be called conditionally - run_->ep_.endLumi(status_, globalTransitionSucceeded_, cleaningUpAfterException_); + run_->ep_.endLumi(status_, cleaningUpAfterException_); if (success_) { run_->ep_.writeLumi(*status_); @@ -131,7 +131,6 @@ struct LumiResources { edm::LuminosityBlockNumber_t lumi_; bool cleaningUpAfterException_ = true; bool success_ = false; - bool globalTransitionSucceeded_ = false; }; struct EventResources { @@ -206,7 +205,7 @@ private: currentLumi_->normalEnd(); } currentLumi_ = std::make_shared(iRun,lumiID); - iEP.beginLumi(currentLumi_->status_, currentLumi_->globalTransitionSucceeded_); + iEP.beginLumi(currentLumi_->status_); //only if we succeed at beginLumi should we run writeLumi currentLumi_->succeeded(); } else { diff --git a/FWCore/Framework/test/MockEventProcessor.cc b/FWCore/Framework/test/MockEventProcessor.cc index e410275c5ca68..13b4378cb1efe 100644 --- a/FWCore/Framework/test/MockEventProcessor.cc +++ b/FWCore/Framework/test/MockEventProcessor.cc @@ -229,16 +229,16 @@ namespace edm { output_ << "\tendRun " << run << postfix; } - void MockEventProcessor::beginLumi(std::shared_ptr& status, bool& globalTransitionSucceeded) { + void MockEventProcessor::beginLumi(std::shared_ptr& status) { status = std::make_shared(this,1); auto lumi = readLuminosityBlock(*status); output_ << "\tbeginLumi " << run_ << "/" << lumi << "\n"; throwIfNeeded(); - globalTransitionSucceeded = true; + status->globalBeginDidSucceed(); } - void MockEventProcessor::endLumi(std::shared_ptr status, bool globalTransitionSucceeded , bool /*cleaningUpAfterException*/) { - auto postfix = globalTransitionSucceeded? "\n" : " global failed\n"; + void MockEventProcessor::endLumi(std::shared_ptr status, bool /*cleaningUpAfterException*/) { + auto postfix = status->didGlobalBeginSucceed()? "\n" : " global failed\n"; output_ << "\tendLumi " << status->lumiPrincipal()->run_ << "/" << status->lumiPrincipal()->lumi_ << postfix; } diff --git a/FWCore/Framework/test/MockEventProcessor.h b/FWCore/Framework/test/MockEventProcessor.h index 34cb1aa67d02a..d001fa3072a19 100644 --- a/FWCore/Framework/test/MockEventProcessor.h +++ b/FWCore/Framework/test/MockEventProcessor.h @@ -56,9 +56,8 @@ namespace edm { void beginRun(ProcessHistoryID const& phid, RunNumber_t run, bool& globalTransitionSucceeded); void endRun(ProcessHistoryID const& phid, RunNumber_t run, bool globalTranstitionSucceeded, bool cleaningUpAfterException); - void beginLumi(std::shared_ptr& status, - bool& globalTransitionSucceeded); - void endLumi(std::shared_ptr, bool globalTransitionSucceeded, bool cleaningUpAfterException); + void beginLumi(std::shared_ptr& status); + void endLumi(std::shared_ptr, bool cleaningUpAfterException); std::pair readRun(); std::pair readAndMergeRun(); From 0e5d4a8fdf248f3159b1884c6ad3f962018a9779 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 27 Dec 2017 15:54:06 -0600 Subject: [PATCH 12/52] Added EventProcessor::beginLumiAsync Added method EventProcessor::beginLumiAsync and the queue's needed for global Lumi access, IOVs and each Stream. --- FWCore/Framework/interface/EventProcessor.h | 8 + FWCore/Framework/src/EventProcessor.cc | 180 ++++++++++++-------- 2 files changed, 119 insertions(+), 69 deletions(-) diff --git a/FWCore/Framework/interface/EventProcessor.h b/FWCore/Framework/interface/EventProcessor.h index e15b19073c50c..373354de59729 100644 --- a/FWCore/Framework/interface/EventProcessor.h +++ b/FWCore/Framework/interface/EventProcessor.h @@ -27,6 +27,9 @@ configured in the user's main() function, and is set running. #include "FWCore/ServiceRegistry/interface/ServiceLegacy.h" #include "FWCore/ServiceRegistry/interface/ServiceToken.h" +#include "FWCore/Concurrency/interface/SerialTaskQueue.h" +#include "FWCore/Concurrency/interface/LimitedTaskQueue.h" + #include "FWCore/Utilities/interface/get_underlying_safe.h" #include @@ -205,6 +208,7 @@ namespace edm { void endRun(ProcessHistoryID const& phid, RunNumber_t run, bool globalBeginSucceeded, bool cleaningUpAfterException); void beginLumi(std::shared_ptr& status); + void beginLumiAsync(edm::WaitingTaskHolder iHolder, std::shared_ptr& oStatus); void endLumi(std::shared_ptr status, bool cleaningUpAfterException); std::pair readRun(); @@ -281,11 +285,15 @@ namespace edm { edm::propagate_const> input_; edm::propagate_const> espController_; edm::propagate_const> esp_; + edm::SerialTaskQueue iovQueue_; std::unique_ptr act_table_; std::shared_ptr processConfiguration_; ProcessContext processContext_; PathsAndConsumesOfModules pathsAndConsumesOfModules_; edm::propagate_const> schedule_; + std::vector streamQueues_; + std::unique_ptr lumiQueue_; + std::vector subProcesses_; edm::propagate_const> historyAppender_; diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index e37461b017072..e0afbc9532f85 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -494,6 +494,9 @@ namespace edm { preallocations_ = PreallocationConfiguration{nThreads,nStreams,nConcurrentLumis,nConcurrentRuns}; + lumiQueue_ = std::make_unique(nConcurrentLumis); + streamQueues_.resize(nStreams); + // initialize the input source input_ = makeInput(*parameterSet, *common, @@ -1082,88 +1085,127 @@ namespace edm { looper_->doEndRun(runPrincipal, es, &processContext_); } } - + + void + EventProcessor::beginLumi(std::shared_ptr& oStatus) { + auto waitTask = make_empty_waiting_task(); + waitTask->increment_ref_count(); + + beginLumiAsync(WaitingTaskHolder{waitTask.get()},oStatus); + waitTask->wait_for_all(); + + if(waitTask->exceptionPtr() != nullptr) { + std::rethrow_exception(* (waitTask->exceptionPtr()) ); + } + } + void - EventProcessor::beginLumi(std::shared_ptr& status) { - status= std::make_shared(this, preallocations_.numberOfStreams()) ; - readLuminosityBlock(*status); + EventProcessor::beginLumiAsync(edm::WaitingTaskHolder iHolder, std::shared_ptr& oStatus) { + oStatus= std::make_shared(this, preallocations_.numberOfStreams()) ; - LuminosityBlockPrincipal& lumiPrincipal = *status->lumiPrincipal(); - { - SendSourceTerminationSignalIfException sentry(actReg_.get()); + sourceResourcesAcquirer_.serialQueueChain().push([this,iHolder,oStatus]() mutable { + //make the services available + ServiceRegistry::Operate operate(serviceToken_); - input_->doBeginLumi(lumiPrincipal, &processContext_); - sentry.completedSuccessfully(); - } + try { + readLuminosityBlock(*oStatus); - Service rng; - if(rng.isAvailable()) { - LuminosityBlock lb(lumiPrincipal, ModuleDescription(), nullptr); - rng->preBeginLumi(lb); - } + LuminosityBlockPrincipal& lumiPrincipal = *oStatus->lumiPrincipal(); + { + SendSourceTerminationSignalIfException sentry(actReg_.get()); - // NOTE: Using 0 as the event number for the begin of a lumi block is a bad idea - // lumi blocks know their start and end times why not also start and end events? - IOVSyncValue ts(EventID(lumiPrincipal.run(), lumiPrincipal.luminosityBlock(), 0), lumiPrincipal.beginTime()); - { - SendSourceTerminationSignalIfException sentry(actReg_.get()); - espController_->eventSetupForInstance(ts); - sentry.completedSuccessfully(); - } - EventSetup const& es = esp_->eventSetup(); - { - typedef OccurrenceTraits Traits; - auto globalWaitTask = make_empty_waiting_task(); - globalWaitTask->increment_ref_count(); - beginGlobalTransitionAsync(WaitingTaskHolder(globalWaitTask.get()), - *schedule_, - lumiPrincipal, - ts, - es, - subProcesses_); - globalWaitTask->wait_for_all(); - if(globalWaitTask->exceptionPtr() != nullptr) { - std::rethrow_exception(* (globalWaitTask->exceptionPtr()) ); - } - } - status->globalBeginDidSucceed(); - if(looper_) { - looper_->doBeginLuminosityBlock(lumiPrincipal, es, &processContext_); - } - { - //To wait, the ref count has to b 1+#streams - auto streamLoopWaitTask = make_empty_waiting_task(); - streamLoopWaitTask->increment_ref_count(); + input_->doBeginLumi(lumiPrincipal, &processContext_); + sentry.completedSuccessfully(); + } - typedef OccurrenceTraits Traits; + Service rng; + if(rng.isAvailable()) { + LuminosityBlock lb(lumiPrincipal, ModuleDescription(), nullptr); + rng->preBeginLumi(lb); + } + + IOVSyncValue ts(EventID(lumiPrincipal.run(), lumiPrincipal.luminosityBlock(), 0), lumiPrincipal.beginTime()); + + //Task to start the stream beginLumis + auto beginStreamsTask= make_waiting_task(tbb::task::allocate_root() + ,[this, holder = iHolder, oStatus, ts] (std::exception_ptr const* iPtr) mutable { + if (iPtr) { + holder.doneWaiting(*iPtr); + } else { + oStatus->globalBeginDidSucceed(); + EventSetup const& es = esp_->eventSetup(); + if(looper_) { + try { + looper_->doBeginLuminosityBlock(*(oStatus->lumiPrincipal()), es, &processContext_); + }catch(...) { + holder.doneWaiting(std::current_exception()); + return; + } + } + typedef OccurrenceTraits Traits; + + for(unsigned int i=0; ilumiPrincipal(); + event.setLuminosityBlockPrincipal(lp); + beginStreamTransitionAsync(holder, *schedule_,i,*lp,ts,es,subProcesses_); + }); + } + } + }); + + //task to start the global begin lumi + WaitingTaskHolder beginStreamsHolder{beginStreamsTask}; + auto lumiAction =[this,beginStreamsHolder , oStatus, ts](LimitedTaskQueue::Resumer iResumer) mutable { + oStatus->setResumer(std::move(iResumer)); + EventSetup const& es = esp_->eventSetup(); + { + typedef OccurrenceTraits Traits; + beginGlobalTransitionAsync(beginStreamsHolder, + *schedule_, + *(oStatus->lumiPrincipal()), + ts, + es, + subProcesses_); + } + }; - beginStreamsTransitionAsync(streamLoopWaitTask.get(), - *schedule_, - preallocations_.numberOfStreams(), - lumiPrincipal, - ts, - es, - subProcesses_); - streamLoopWaitTask->wait_for_all(); - if(streamLoopWaitTask->exceptionPtr() != nullptr) { - std::rethrow_exception(* (streamLoopWaitTask->exceptionPtr()) ); + + //Safe to do check now since can not have multiple beginLumis at same time in this part of the code + // because we do not attempt to read from the source again until we try to get the first event in a lumi + if(espController_->isWithinValidityInterval(ts)) { + iovQueue_.pause(); + lumiQueue_->pushAndPause(std::move(lumiAction)); + } else { + //If EventSetup fails, need beginStreamsHolder in order to pass back exception + iovQueue_.push([this,lumiAction,beginStreamsHolder,ts]() mutable { + try { + SendSourceTerminationSignalIfException sentry(actReg_.get()); + espController_->eventSetupForInstance(ts); + sentry.completedSuccessfully(); + } catch(...) { + beginStreamsHolder.doneWaiting(std::current_exception()); + return; + } + iovQueue_.pause(); + lumiQueue_->pushAndPause(std::move(lumiAction)); + }); + } + } catch(...) { + iHolder.doneWaiting(std::current_exception()); } - } - - //attach this lumi to the event principals - for(unsigned int i= 0; i< preallocations_.numberOfStreams(); ++i) { - auto& event = principalCache_.eventPrincipal(i); - event.setLuminosityBlockPrincipal(status->lumiPrincipal()); - } - - if(looper_) { - //looper_->doStreamBeginLuminosityBlock(schedule_->streamID(),lumiPrincipal, es); - } + }); } void EventProcessor::endLumi(std::shared_ptr status, bool cleaningUpAfterException) { LuminosityBlockPrincipal& lumiPrincipal = *status-> lumiPrincipal(); lumiPrincipal.setAtEndTransition(true); + + //need to release the IOV + auto dtr = [](SerialTaskQueue* iQueue) { iQueue->resume();}; + std::unique_ptr guard(&iovQueue_, dtr); + //We need to reset failed items since they might // be set this time around lumiPrincipal.resetFailedFromThisProcess(); From 4000bfa1d08710d24d98edc6e739414e671d693c Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sun, 31 Dec 2017 09:55:25 -0600 Subject: [PATCH 13/52] Moved cleaningUpAfterException to status Moved cleaningUpAfterException information to LuminosityBlockProcessingStatus --- FWCore/Framework/interface/EventProcessor.h | 4 ++-- FWCore/Framework/src/EventProcessor.cc | 3 ++- FWCore/Framework/src/LuminosityBlockProcessingStatus.h | 4 ++++ FWCore/Framework/src/TransitionProcessors.icc | 7 +++---- FWCore/Framework/test/MockEventProcessor.cc | 7 +++++-- FWCore/Framework/test/MockEventProcessor.h | 2 +- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/FWCore/Framework/interface/EventProcessor.h b/FWCore/Framework/interface/EventProcessor.h index 373354de59729..49dfcb657bac1 100644 --- a/FWCore/Framework/interface/EventProcessor.h +++ b/FWCore/Framework/interface/EventProcessor.h @@ -209,8 +209,8 @@ namespace edm { void beginLumi(std::shared_ptr& status); void beginLumiAsync(edm::WaitingTaskHolder iHolder, std::shared_ptr& oStatus); - void endLumi(std::shared_ptr status, bool cleaningUpAfterException); - + void endLumi(std::shared_ptr status); + std::pair readRun(); std::pair readAndMergeRun(); void readLuminosityBlock(LuminosityBlockProcessingStatus&); diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index e0afbc9532f85..9d41b1a71b7ce 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1198,7 +1198,8 @@ namespace edm { }); } - void EventProcessor::endLumi(std::shared_ptr status, bool cleaningUpAfterException) { + void EventProcessor::endLumi(std::shared_ptr status) { + bool cleaningUpAfterException = status->cleaningUpAfterException(); LuminosityBlockPrincipal& lumiPrincipal = *status-> lumiPrincipal(); lumiPrincipal.setAtEndTransition(true); diff --git a/FWCore/Framework/src/LuminosityBlockProcessingStatus.h b/FWCore/Framework/src/LuminosityBlockProcessingStatus.h index e66d332b2fb7e..3b4ee41ddd279 100644 --- a/FWCore/Framework/src/LuminosityBlockProcessingStatus.h +++ b/FWCore/Framework/src/LuminosityBlockProcessingStatus.h @@ -72,6 +72,8 @@ class LuminosityBlockProcessingStatus bool haveStartedNextLumi() const { return startedNextLumi_;} void startNextLumi() { startedNextLumi_ = true;} + void noExceptionHappened() { cleaningUpAfterException_ = false; } + bool cleaningUpAfterException() const { return cleaningUpAfterException_;} private: // ---------- member data -------------------------------- std::shared_ptr lumiPrincipal_; @@ -82,6 +84,8 @@ class LuminosityBlockProcessingStatus bool lumiEnding_{false}; //read/write in m_sourceQueue NOTE: This is a useful cache instead of recalculating each call bool continuingLumi_{false}; //read/write in m_sourceQueue OR from main thread when no tasks running bool startedNextLumi_{false}; //read/write in m_sourceQueue + bool globalBeginSucceeded_{false}; + bool cleaningUpAfterException_{true}; }; diff --git a/FWCore/Framework/src/TransitionProcessors.icc b/FWCore/Framework/src/TransitionProcessors.icc index bb3c51c692c89..0fad14ea35f1b 100644 --- a/FWCore/Framework/src/TransitionProcessors.icc +++ b/FWCore/Framework/src/TransitionProcessors.icc @@ -91,7 +91,7 @@ struct LumiResources { ~LumiResources() noexcept { try { //If we skip empty lumis, this would be called conditionally - run_->ep_.endLumi(status_, cleaningUpAfterException_); + run_->ep_.endLumi(status_); if (success_) { run_->ep_.writeLumi(*status_); @@ -100,7 +100,7 @@ struct LumiResources { run_->ep_.deleteLumiFromCache(*status_); } catch(...) { - if(cleaningUpAfterException_ or not run_->ep_.setDeferredException(std::current_exception())) { + if(status_->cleaningUpAfterException() or not run_->ep_.setDeferredException(std::current_exception())) { std::string message("Another exception was caught while trying to clean up lumis after the primary fatal exception."); run_->ep_.setExceptionMessageLumis(message); } @@ -119,7 +119,7 @@ struct LumiResources { } void normalEnd() { - cleaningUpAfterException_ = false; + status_->noExceptionHappened(); } void succeeded() { @@ -129,7 +129,6 @@ struct LumiResources { std::shared_ptr run_; std::shared_ptr status_; edm::LuminosityBlockNumber_t lumi_; - bool cleaningUpAfterException_ = true; bool success_ = false; }; diff --git a/FWCore/Framework/test/MockEventProcessor.cc b/FWCore/Framework/test/MockEventProcessor.cc index 13b4378cb1efe..d0e3f14ed9a07 100644 --- a/FWCore/Framework/test/MockEventProcessor.cc +++ b/FWCore/Framework/test/MockEventProcessor.cc @@ -27,7 +27,6 @@ namespace { class WaitingTaskHolder; -#include "FWCore/Framework/src/TransitionProcessors.icc" } namespace edm { @@ -41,6 +40,10 @@ struct LuminosityBlockPrincipal { #define TEST_NO_FWD_DECL #include "FWCore/Framework/src/LuminosityBlockProcessingStatus.h" +namespace { +#include "FWCore/Framework/src/TransitionProcessors.icc" +} + namespace edm { MockEventProcessor::MockEventProcessor(std::string const& mockData, @@ -237,7 +240,7 @@ namespace edm { status->globalBeginDidSucceed(); } - void MockEventProcessor::endLumi(std::shared_ptr status, bool /*cleaningUpAfterException*/) { + void MockEventProcessor::endLumi(std::shared_ptr status) { auto postfix = status->didGlobalBeginSucceed()? "\n" : " global failed\n"; output_ << "\tendLumi " << status->lumiPrincipal()->run_ << "/" << status->lumiPrincipal()->lumi_ << postfix; } diff --git a/FWCore/Framework/test/MockEventProcessor.h b/FWCore/Framework/test/MockEventProcessor.h index d001fa3072a19..3641d7c84764e 100644 --- a/FWCore/Framework/test/MockEventProcessor.h +++ b/FWCore/Framework/test/MockEventProcessor.h @@ -57,7 +57,7 @@ namespace edm { void endRun(ProcessHistoryID const& phid, RunNumber_t run, bool globalTranstitionSucceeded, bool cleaningUpAfterException); void beginLumi(std::shared_ptr& status); - void endLumi(std::shared_ptr, bool cleaningUpAfterException); + void endLumi(std::shared_ptr); std::pair readRun(); std::pair readAndMergeRun(); From cd5c6ef67862ad30aa88a13186dc030de25a6f0a Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 1 Jan 2018 14:43:00 -0600 Subject: [PATCH 14/52] Removed isComplete from Principal Since a Principal needs to be used across transitions the 'isComplete' can not be a property of the Principal. Instead, the PrincipalGetterAdapter is used to know if we are at an end transition or not. --- FWCore/Framework/interface/LuminosityBlock.h | 2 +- .../interface/LuminosityBlockForOutput.h | 2 +- .../interface/LuminosityBlockPrincipal.h | 8 -------- FWCore/Framework/interface/OccurrenceForOutput.h | 2 +- FWCore/Framework/interface/Principal.h | 4 ---- FWCore/Framework/interface/PrincipalGetAdapter.h | 5 +++-- FWCore/Framework/interface/Run.h | 2 +- FWCore/Framework/interface/RunForOutput.h | 2 +- FWCore/Framework/interface/RunPrincipal.h | 8 -------- .../interface/stream/EDAnalyzerAdaptor.h | 8 ++++---- .../interface/stream/ProducingModuleAdaptor.h | 8 ++++---- FWCore/Framework/src/EDAnalyzer.cc | 8 ++++---- FWCore/Framework/src/EDFilter.cc | 8 ++++---- FWCore/Framework/src/EDLooperBase.cc | 8 ++++---- FWCore/Framework/src/EDProducer.cc | 8 ++++---- FWCore/Framework/src/Event.cc | 4 ++-- FWCore/Framework/src/EventForOutput.cc | 4 ++-- FWCore/Framework/src/EventProcessor.cc | 4 +--- FWCore/Framework/src/LuminosityBlock.cc | 6 +++--- FWCore/Framework/src/LuminosityBlockForOutput.cc | 6 +++--- FWCore/Framework/src/LuminosityBlockPrincipal.cc | 6 +----- FWCore/Framework/src/OccurrenceForOutput.cc | 4 ++-- FWCore/Framework/src/OutputModule.cc | 12 ++++++------ FWCore/Framework/src/PrincipalGetAdapter.cc | 10 +++------- FWCore/Framework/src/Run.cc | 4 ++-- FWCore/Framework/src/RunForOutput.cc | 4 ++-- FWCore/Framework/src/RunPrincipal.cc | 4 +--- FWCore/Framework/src/SubProcess.cc | 2 -- FWCore/Framework/src/global/EDAnalyzerBase.cc | 16 ++++++++-------- FWCore/Framework/src/global/EDFilterBase.cc | 16 ++++++++-------- FWCore/Framework/src/global/EDProducerBase.cc | 16 ++++++++-------- FWCore/Framework/src/global/OutputModuleBase.cc | 12 ++++++------ FWCore/Framework/src/limited/EDAnalyzerBase.cc | 16 ++++++++-------- FWCore/Framework/src/limited/EDFilterBase.cc | 16 ++++++++-------- FWCore/Framework/src/limited/EDProducerBase.cc | 16 ++++++++-------- FWCore/Framework/src/limited/OutputModuleBase.cc | 12 ++++++------ FWCore/Framework/src/one/EDAnalyzerBase.cc | 8 ++++---- FWCore/Framework/src/one/EDFilterBase.cc | 8 ++++---- FWCore/Framework/src/one/EDProducerBase.cc | 8 ++++---- FWCore/Framework/src/one/OutputModuleBase.cc | 12 ++++++------ .../src/stream/EDAnalyzerAdaptorBase.cc | 8 ++++---- .../src/stream/ProducingModuleAdaptorBase.cc | 8 ++++---- FWCore/Sources/src/PuttableSourceBase.cc | 8 ++++---- 43 files changed, 150 insertions(+), 183 deletions(-) diff --git a/FWCore/Framework/interface/LuminosityBlock.h b/FWCore/Framework/interface/LuminosityBlock.h index ec17412349049..9333efcd55089 100644 --- a/FWCore/Framework/interface/LuminosityBlock.h +++ b/FWCore/Framework/interface/LuminosityBlock.h @@ -46,7 +46,7 @@ namespace edm { class LuminosityBlock : public LuminosityBlockBase { public: LuminosityBlock(LuminosityBlockPrincipal const& lbp, ModuleDescription const& md, - ModuleCallingContext const*); + ModuleCallingContext const*, bool isAtEnd); ~LuminosityBlock() override; // AUX functions are defined in LuminosityBlockBase diff --git a/FWCore/Framework/interface/LuminosityBlockForOutput.h b/FWCore/Framework/interface/LuminosityBlockForOutput.h index 78aa8c768f5f9..58e87ca262227 100644 --- a/FWCore/Framework/interface/LuminosityBlockForOutput.h +++ b/FWCore/Framework/interface/LuminosityBlockForOutput.h @@ -39,7 +39,7 @@ namespace edm { class LuminosityBlockForOutput : public OccurrenceForOutput { public: LuminosityBlockForOutput(LuminosityBlockPrincipal const& lbp, ModuleDescription const& md, - ModuleCallingContext const*); + ModuleCallingContext const*, bool isAtEnd); ~LuminosityBlockForOutput() override; LuminosityBlockAuxiliary const& luminosityBlockAuxiliary() const {return aux_;} diff --git a/FWCore/Framework/interface/LuminosityBlockPrincipal.h b/FWCore/Framework/interface/LuminosityBlockPrincipal.h index f7cc32b437816..9764be35319d7 100644 --- a/FWCore/Framework/interface/LuminosityBlockPrincipal.h +++ b/FWCore/Framework/interface/LuminosityBlockPrincipal.h @@ -101,14 +101,8 @@ namespace edm { void put(ProductResolverIndex index, std::unique_ptr edp) const; - void setComplete() { - complete_ = true; - } - private: - bool isComplete_() const override {return complete_;} - unsigned int transitionIndex_() const override; edm::propagate_const> runPrincipal_; @@ -116,8 +110,6 @@ namespace edm { LuminosityBlockAuxiliary aux_; LuminosityBlockIndex index_; - - bool complete_; }; } #endif diff --git a/FWCore/Framework/interface/OccurrenceForOutput.h b/FWCore/Framework/interface/OccurrenceForOutput.h index 17f5b3511aeed..d699587264203 100644 --- a/FWCore/Framework/interface/OccurrenceForOutput.h +++ b/FWCore/Framework/interface/OccurrenceForOutput.h @@ -45,7 +45,7 @@ namespace edm { class OccurrenceForOutput { public: OccurrenceForOutput(Principal const& ep, ModuleDescription const& md, - ModuleCallingContext const*); + ModuleCallingContext const*, bool isAtEnd); virtual ~OccurrenceForOutput(); //Used in conjunction with EDGetToken diff --git a/FWCore/Framework/interface/Principal.h b/FWCore/Framework/interface/Principal.h index 0db8f9b77f4a7..c64365b0eea3d 100644 --- a/FWCore/Framework/interface/Principal.h +++ b/FWCore/Framework/interface/Principal.h @@ -197,8 +197,6 @@ namespace edm { ConstProductResolverPtr getProductResolverByIndex(ProductResolverIndex const& oid) const; - bool isComplete() const {return isComplete_();} - protected: // ----- Add a new ProductResolver @@ -258,8 +256,6 @@ namespace edm { SharedResourcesAcquirer* sra, ModuleCallingContext const* mcc) const; - virtual bool isComplete_() const {return true;} - void putOrMerge(std::unique_ptr prod, ProductResolverBase const* productResolver) const; std::shared_ptr processHistoryPtr_; diff --git a/FWCore/Framework/interface/PrincipalGetAdapter.h b/FWCore/Framework/interface/PrincipalGetAdapter.h index 6ac9ad0c41135..cac56183d15f7 100644 --- a/FWCore/Framework/interface/PrincipalGetAdapter.h +++ b/FWCore/Framework/interface/PrincipalGetAdapter.h @@ -134,7 +134,7 @@ namespace edm { class PrincipalGetAdapter { public: PrincipalGetAdapter(Principal const& pcpl, - ModuleDescription const& md); + ModuleDescription const& md, bool isComplete); ~PrincipalGetAdapter(); @@ -157,7 +157,7 @@ namespace edm { size_t numberOfProductsConsumed() const ; - bool isComplete() const; + bool isComplete() const { return isComplete_;} template bool @@ -267,6 +267,7 @@ namespace edm { EDConsumerBase const* consumer_; SharedResourcesAcquirer* resourcesAcquirer_; // We do not use propagate_const because the acquirer is itself mutable. ProducerBase const* prodBase_ = nullptr; + bool isComplete_; }; template diff --git a/FWCore/Framework/interface/Run.h b/FWCore/Framework/interface/Run.h index 3402dbde9efaa..5a4cdbae4d626 100644 --- a/FWCore/Framework/interface/Run.h +++ b/FWCore/Framework/interface/Run.h @@ -43,7 +43,7 @@ namespace edm { class Run : public RunBase { public: Run(RunPrincipal const& rp, ModuleDescription const& md, - ModuleCallingContext const*); + ModuleCallingContext const*, bool isAtEnd); ~Run() override; //Used in conjunction with EDGetToken diff --git a/FWCore/Framework/interface/RunForOutput.h b/FWCore/Framework/interface/RunForOutput.h index 7d346f50fc78f..71c38e15c8a2f 100644 --- a/FWCore/Framework/interface/RunForOutput.h +++ b/FWCore/Framework/interface/RunForOutput.h @@ -38,7 +38,7 @@ namespace edm { class RunForOutput : public OccurrenceForOutput { public: RunForOutput(RunPrincipal const& rp, ModuleDescription const& md, - ModuleCallingContext const*); + ModuleCallingContext const*, bool isAtEnd); ~RunForOutput() override; RunAuxiliary const& runAuxiliary() const {return aux_;} diff --git a/FWCore/Framework/interface/RunPrincipal.h b/FWCore/Framework/interface/RunPrincipal.h index 3594a2ac46574..9b0ed80ec55c2 100644 --- a/FWCore/Framework/interface/RunPrincipal.h +++ b/FWCore/Framework/interface/RunPrincipal.h @@ -93,21 +93,13 @@ namespace edm { void put(ProductResolverIndex index, std::unique_ptr edp) const; - void setComplete() { - complete_ = true; - } - private: - bool isComplete_() const override {return complete_;} - unsigned int transitionIndex_() const override; edm::propagate_const> aux_; ProcessHistoryID m_reducedHistoryID; RunIndex index_; - - bool complete_; }; } #endif diff --git a/FWCore/Framework/interface/stream/EDAnalyzerAdaptor.h b/FWCore/Framework/interface/stream/EDAnalyzerAdaptor.h index 0df0253e743d5..6f5b0e67325e0 100644 --- a/FWCore/Framework/interface/stream/EDAnalyzerAdaptor.h +++ b/FWCore/Framework/interface/stream/EDAnalyzerAdaptor.h @@ -118,7 +118,7 @@ namespace edm { EventSetup const& c, ModuleCallingContext const* mcc) final { if(T::HasAbility::kRunCache or T::HasAbility::kRunSummaryCache) { - Run r(rp, moduleDescription(), mcc); + Run r(rp, moduleDescription(), mcc, false); r.setConsumer(consumer()); Run const& cnstR = r; RunIndex ri = rp.index(); @@ -133,7 +133,7 @@ namespace edm { { if(T::HasAbility::kRunCache or T::HasAbility::kRunSummaryCache) { - Run r(rp, moduleDescription(), mcc); + Run r(rp, moduleDescription(), mcc, true); r.setConsumer(consumer()); RunIndex ri = rp.index(); @@ -148,7 +148,7 @@ namespace edm { ModuleCallingContext const* mcc) final { if(T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache) { - LuminosityBlock lb(lbp, moduleDescription(), mcc); + LuminosityBlock lb(lbp, moduleDescription(), mcc, false); lb.setConsumer(consumer()); LuminosityBlock const& cnstLb = lb; LuminosityBlockIndex li = lbp.index(); @@ -165,7 +165,7 @@ namespace edm { ModuleCallingContext const* mcc) final { if(T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache) { - LuminosityBlock lb(lbp, moduleDescription(), mcc); + LuminosityBlock lb(lbp, moduleDescription(), mcc, true); lb.setConsumer(consumer()); LuminosityBlockIndex li = lbp.index(); diff --git a/FWCore/Framework/interface/stream/ProducingModuleAdaptor.h b/FWCore/Framework/interface/stream/ProducingModuleAdaptor.h index 40b06accd3960..2eef6648599ae 100644 --- a/FWCore/Framework/interface/stream/ProducingModuleAdaptor.h +++ b/FWCore/Framework/interface/stream/ProducingModuleAdaptor.h @@ -123,7 +123,7 @@ namespace edm { EventSetup const& c, ModuleCallingContext const* mcc) final { if(T::HasAbility::kRunCache or T::HasAbility::kRunSummaryCache or T::HasAbility::kBeginRunProducer) { - Run r(rp, this->moduleDescription(), mcc); + Run r(rp, this->moduleDescription(), mcc, false); r.setConsumer(this->consumer()); r.setProducer(this->producer()); Run const& cnstR = r; @@ -143,7 +143,7 @@ namespace edm { { if(T::HasAbility::kRunCache or T::HasAbility::kRunSummaryCache or T::HasAbility::kEndRunProducer) { - Run r(rp, this->moduleDescription(), mcc); + Run r(rp, this->moduleDescription(), mcc, true); r.setConsumer(this->consumer()); r.setProducer(this->producer()); @@ -162,7 +162,7 @@ namespace edm { ModuleCallingContext const* mcc) final { if(T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache or T::HasAbility::kBeginLuminosityBlockProducer) { - LuminosityBlock lb(lbp, this->moduleDescription(), mcc); + LuminosityBlock lb(lbp, this->moduleDescription(), mcc, false); lb.setConsumer(this->consumer()); lb.setProducer(this->producer()); LuminosityBlock const& cnstLb = lb; @@ -184,7 +184,7 @@ namespace edm { ModuleCallingContext const* mcc) final { if(T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache or T::HasAbility::kEndLuminosityBlockProducer) { - LuminosityBlock lb(lbp, this->moduleDescription(), mcc); + LuminosityBlock lb(lbp, this->moduleDescription(), mcc, true); lb.setConsumer(this->consumer()); lb.setProducer(this->producer()); diff --git a/FWCore/Framework/src/EDAnalyzer.cc b/FWCore/Framework/src/EDAnalyzer.cc index 133b63ec65697..cfefa521f29bb 100644 --- a/FWCore/Framework/src/EDAnalyzer.cc +++ b/FWCore/Framework/src/EDAnalyzer.cc @@ -57,7 +57,7 @@ namespace edm { bool EDAnalyzer::doBeginRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc,false); r.setConsumer(this); this->beginRun(r, c); return true; @@ -66,7 +66,7 @@ namespace edm { bool EDAnalyzer::doEndRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc,true); r.setConsumer(this); this->endRun(r, c); return true; @@ -75,7 +75,7 @@ namespace edm { bool EDAnalyzer::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc,false); lb.setConsumer(this); this->beginLuminosityBlock(lb, c); return true; @@ -84,7 +84,7 @@ namespace edm { bool EDAnalyzer::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc,true); lb.setConsumer(this); this->endLuminosityBlock(lb, c); return true; diff --git a/FWCore/Framework/src/EDFilter.cc b/FWCore/Framework/src/EDFilter.cc index 38abb69797e98..e6be31c692e82 100644 --- a/FWCore/Framework/src/EDFilter.cc +++ b/FWCore/Framework/src/EDFilter.cc @@ -56,7 +56,7 @@ namespace edm { void EDFilter::doBeginRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc,false); r.setConsumer(this); Run const& cnstR=r; this->beginRun(cnstR, c); @@ -67,7 +67,7 @@ namespace edm { void EDFilter::doEndRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc,true); r.setConsumer(this); Run const& cnstR=r; this->endRun(cnstR, c); @@ -78,7 +78,7 @@ namespace edm { void EDFilter::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc,false); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->beginLuminosityBlock(cnstLb, c); @@ -88,7 +88,7 @@ namespace edm { void EDFilter::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc,true); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->endLuminosityBlock(cnstLb, c); diff --git a/FWCore/Framework/src/EDLooperBase.cc b/FWCore/Framework/src/EDLooperBase.cc index 1e34e8d2ac014..1573bf598ebfb 100644 --- a/FWCore/Framework/src/EDLooperBase.cc +++ b/FWCore/Framework/src/EDLooperBase.cc @@ -98,7 +98,7 @@ namespace edm { processContext); ParentContext parentContext(&globalContext); ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext); - Run run(iRP, moduleDescription_, &moduleCallingContext_); + Run run(iRP, moduleDescription_, &moduleCallingContext_, false); beginRun(run,iES); } @@ -111,7 +111,7 @@ namespace edm { processContext); ParentContext parentContext(&globalContext); ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext); - Run run(iRP, moduleDescription_, &moduleCallingContext_); + Run run(iRP, moduleDescription_, &moduleCallingContext_,true); endRun(run,iES); } void EDLooperBase::doBeginLuminosityBlock(LuminosityBlockPrincipal& iLB, EventSetup const& iES, ProcessContext* processContext){ @@ -123,7 +123,7 @@ namespace edm { processContext); ParentContext parentContext(&globalContext); ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext); - LuminosityBlock luminosityBlock(iLB, moduleDescription_, &moduleCallingContext_); + LuminosityBlock luminosityBlock(iLB, moduleDescription_, &moduleCallingContext_, false); beginLuminosityBlock(luminosityBlock,iES); } void EDLooperBase::doEndLuminosityBlock(LuminosityBlockPrincipal& iLB, EventSetup const& iES, ProcessContext* processContext){ @@ -135,7 +135,7 @@ namespace edm { processContext); ParentContext parentContext(&globalContext); ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext); - LuminosityBlock luminosityBlock(iLB, moduleDescription_, &moduleCallingContext_); + LuminosityBlock luminosityBlock(iLB, moduleDescription_, &moduleCallingContext_, true); endLuminosityBlock(luminosityBlock,iES); } diff --git a/FWCore/Framework/src/EDProducer.cc b/FWCore/Framework/src/EDProducer.cc index 07f89a1c3fcd0..e1531b8a9e1c7 100644 --- a/FWCore/Framework/src/EDProducer.cc +++ b/FWCore/Framework/src/EDProducer.cc @@ -56,7 +56,7 @@ namespace edm { void EDProducer::doBeginRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); Run const& cnstR = r; this->beginRun(cnstR, c); @@ -66,7 +66,7 @@ namespace edm { void EDProducer::doEndRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc,true); r.setConsumer(this); Run const& cnstR = r; this->endRun(cnstR, c); @@ -76,7 +76,7 @@ namespace edm { void EDProducer::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc,false); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->beginLuminosityBlock(cnstLb, c); @@ -86,7 +86,7 @@ namespace edm { void EDProducer::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc,true); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->endLuminosityBlock(cnstLb, c); diff --git a/FWCore/Framework/src/Event.cc b/FWCore/Framework/src/Event.cc index b5387a39f83a9..76b0a4d4790f6 100644 --- a/FWCore/Framework/src/Event.cc +++ b/FWCore/Framework/src/Event.cc @@ -20,9 +20,9 @@ namespace edm { std::string const Event::emptyString_; Event::Event(EventPrincipal const& ep, ModuleDescription const& md, ModuleCallingContext const* moduleCallingContext) : - provRecorder_(ep, md), + provRecorder_(ep, md, true /*always at end*/), aux_(ep.aux()), - luminosityBlock_(ep.luminosityBlockPrincipalPtrValid() ? new LuminosityBlock(ep.luminosityBlockPrincipal(), md, moduleCallingContext) : nullptr), + luminosityBlock_(ep.luminosityBlockPrincipalPtrValid() ? new LuminosityBlock(ep.luminosityBlockPrincipal(), md, moduleCallingContext,false) : nullptr), gotBranchIDs_(), gotViews_(), streamID_(ep.streamID()), diff --git a/FWCore/Framework/src/EventForOutput.cc b/FWCore/Framework/src/EventForOutput.cc index 6449431c5a54a..42b5bcac78a96 100644 --- a/FWCore/Framework/src/EventForOutput.cc +++ b/FWCore/Framework/src/EventForOutput.cc @@ -12,9 +12,9 @@ namespace edm { EventForOutput::EventForOutput(EventPrincipal const& ep, ModuleDescription const& md, ModuleCallingContext const* moduleCallingContext) : - OccurrenceForOutput(ep, md, moduleCallingContext), + OccurrenceForOutput(ep, md, moduleCallingContext, true /*always at end*/), aux_(ep.aux()), - luminosityBlock_(ep.luminosityBlockPrincipalPtrValid() ? new LuminosityBlockForOutput(ep.luminosityBlockPrincipal(), md, moduleCallingContext) : nullptr), + luminosityBlock_(ep.luminosityBlockPrincipalPtrValid() ? new LuminosityBlockForOutput(ep.luminosityBlockPrincipal(), md, moduleCallingContext,false /*not at end*/) : nullptr), streamID_(ep.streamID()) { } diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 9d41b1a71b7ce..8e93670f2ac00 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1025,7 +1025,6 @@ namespace edm { SendSourceTerminationSignalIfException sentry(actReg_.get()); runPrincipal.setEndTime(input_->timestamp()); - runPrincipal.setComplete(); input_->doEndRun(runPrincipal, cleaningUpAfterException, &processContext_); sentry.completedSuccessfully(); } @@ -1120,7 +1119,7 @@ namespace edm { Service rng; if(rng.isAvailable()) { - LuminosityBlock lb(lumiPrincipal, ModuleDescription(), nullptr); + LuminosityBlock lb(lumiPrincipal, ModuleDescription(), nullptr, false); rng->preBeginLumi(lb); } @@ -1215,7 +1214,6 @@ namespace edm { SendSourceTerminationSignalIfException sentry(actReg_.get()); lumiPrincipal.setEndTime(input_->timestamp()); - lumiPrincipal.setComplete(); input_->doEndLumi(lumiPrincipal, cleaningUpAfterException, &processContext_); sentry.completedSuccessfully(); } diff --git a/FWCore/Framework/src/LuminosityBlock.cc b/FWCore/Framework/src/LuminosityBlock.cc index 537a978273d9c..b2ab07026a26f 100644 --- a/FWCore/Framework/src/LuminosityBlock.cc +++ b/FWCore/Framework/src/LuminosityBlock.cc @@ -10,10 +10,10 @@ namespace edm { std::string const LuminosityBlock::emptyString_; LuminosityBlock::LuminosityBlock(LuminosityBlockPrincipal const& lbp, ModuleDescription const& md, - ModuleCallingContext const* moduleCallingContext) : - provRecorder_(lbp, md), + ModuleCallingContext const* moduleCallingContext, bool isAtEnd) : + provRecorder_(lbp, md,isAtEnd), aux_(lbp.aux()), - run_(new Run(lbp.runPrincipal(), md, moduleCallingContext)), + run_(new Run(lbp.runPrincipal(), md, moduleCallingContext,false)), moduleCallingContext_(moduleCallingContext) { } diff --git a/FWCore/Framework/src/LuminosityBlockForOutput.cc b/FWCore/Framework/src/LuminosityBlockForOutput.cc index 022aa4d14414c..937319e4d06bc 100644 --- a/FWCore/Framework/src/LuminosityBlockForOutput.cc +++ b/FWCore/Framework/src/LuminosityBlockForOutput.cc @@ -8,10 +8,10 @@ namespace edm { LuminosityBlockForOutput::LuminosityBlockForOutput(LuminosityBlockPrincipal const& lbp, ModuleDescription const& md, - ModuleCallingContext const* moduleCallingContext) : - OccurrenceForOutput(lbp, md, moduleCallingContext), + ModuleCallingContext const* moduleCallingContext, bool isAtEnd) : + OccurrenceForOutput(lbp, md, moduleCallingContext, isAtEnd), aux_(lbp.aux()), - run_(new RunForOutput(lbp.runPrincipal(), md, moduleCallingContext)) { + run_(new RunForOutput(lbp.runPrincipal(), md, moduleCallingContext, false)) { } LuminosityBlockForOutput::~LuminosityBlockForOutput() { diff --git a/FWCore/Framework/src/LuminosityBlockPrincipal.cc b/FWCore/Framework/src/LuminosityBlockPrincipal.cc index c91dd220d9730..589954cdcbe53 100644 --- a/FWCore/Framework/src/LuminosityBlockPrincipal.cc +++ b/FWCore/Framework/src/LuminosityBlockPrincipal.cc @@ -12,17 +12,13 @@ namespace edm { bool isForPrimaryProcess) : Base(reg, reg->productLookup(InLumi), pc, InLumi, historyAppender, isForPrimaryProcess), runPrincipal_(), - index_(index), - complete_(false) { + index_(index) { } void LuminosityBlockPrincipal::fillLuminosityBlockPrincipal( ProcessHistoryRegistry const& processHistoryRegistry, DelayedReader* reader) { - - complete_ = false; - fillPrincipal(aux_.processHistoryID(), processHistoryRegistry, reader); for(auto& prod : *this) { diff --git a/FWCore/Framework/src/OccurrenceForOutput.cc b/FWCore/Framework/src/OccurrenceForOutput.cc index da6e95717569d..52e105275cfca 100644 --- a/FWCore/Framework/src/OccurrenceForOutput.cc +++ b/FWCore/Framework/src/OccurrenceForOutput.cc @@ -12,8 +12,8 @@ namespace edm { - OccurrenceForOutput::OccurrenceForOutput(Principal const& p, ModuleDescription const& md, ModuleCallingContext const* moduleCallingContext) : - provRecorder_(p, md), + OccurrenceForOutput::OccurrenceForOutput(Principal const& p, ModuleDescription const& md, ModuleCallingContext const* moduleCallingContext, bool isAtEnd) : + provRecorder_(p, md, isAtEnd), moduleCallingContext_(moduleCallingContext) { } diff --git a/FWCore/Framework/src/OutputModule.cc b/FWCore/Framework/src/OutputModule.cc index 87344b48cd137..5e8ce1d712790 100644 --- a/FWCore/Framework/src/OutputModule.cc +++ b/FWCore/Framework/src/OutputModule.cc @@ -290,7 +290,7 @@ namespace edm { EventSetup const&, ModuleCallingContext const* mcc) { FDEBUG(2) << "beginRun called\n"; - RunForOutput r(rp, moduleDescription_, mcc); + RunForOutput r(rp, moduleDescription_, mcc,false); r.setConsumer(this); beginRun(r); return true; @@ -301,7 +301,7 @@ namespace edm { EventSetup const&, ModuleCallingContext const* mcc) { FDEBUG(2) << "endRun called\n"; - RunForOutput r(rp, moduleDescription_, mcc); + RunForOutput r(rp, moduleDescription_, mcc,true); r.setConsumer(this); endRun(r); return true; @@ -311,7 +311,7 @@ namespace edm { OutputModule::doWriteRun(RunPrincipal const& rp, ModuleCallingContext const* mcc) { FDEBUG(2) << "writeRun called\n"; - RunForOutput r(rp, moduleDescription_, mcc); + RunForOutput r(rp, moduleDescription_, mcc,true); r.setConsumer(this); writeRun(r); } @@ -321,7 +321,7 @@ namespace edm { EventSetup const&, ModuleCallingContext const* mcc) { FDEBUG(2) << "beginLuminosityBlock called\n"; - LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc); + LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc,false); lb.setConsumer(this); beginLuminosityBlock(lb); return true; @@ -332,7 +332,7 @@ namespace edm { EventSetup const&, ModuleCallingContext const* mcc) { FDEBUG(2) << "endLuminosityBlock called\n"; - LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc); + LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc,true); lb.setConsumer(this); endLuminosityBlock(lb); return true; @@ -341,7 +341,7 @@ namespace edm { void OutputModule::doWriteLuminosityBlock(LuminosityBlockPrincipal const& lbp, ModuleCallingContext const* mcc) { FDEBUG(2) << "writeLuminosityBlock called\n"; - LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc); + LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc,true); lb.setConsumer(this); writeLuminosityBlock(lb); } diff --git a/FWCore/Framework/src/PrincipalGetAdapter.cc b/FWCore/Framework/src/PrincipalGetAdapter.cc index ba55b75654239..e5bba5fafaf3e 100644 --- a/FWCore/Framework/src/PrincipalGetAdapter.cc +++ b/FWCore/Framework/src/PrincipalGetAdapter.cc @@ -19,12 +19,13 @@ namespace edm { PrincipalGetAdapter::PrincipalGetAdapter(Principal const& pcpl, - ModuleDescription const& md) : + ModuleDescription const& md, bool isComplete) : //putProducts_(), principal_(pcpl), md_(md), consumer_(nullptr), - resourcesAcquirer_(nullptr) + resourcesAcquirer_(nullptr), + isComplete_(isComplete) { } @@ -365,9 +366,4 @@ namespace edm { PrincipalGetAdapter::prodGetter() const{ return principal_.prodGetter(); } - - bool - PrincipalGetAdapter::isComplete() const { - return principal_.isComplete(); - } } diff --git a/FWCore/Framework/src/Run.cc b/FWCore/Framework/src/Run.cc index b05762a3d16d1..491433c6ed449 100644 --- a/FWCore/Framework/src/Run.cc +++ b/FWCore/Framework/src/Run.cc @@ -9,8 +9,8 @@ namespace edm { std::string const Run::emptyString_; Run::Run(RunPrincipal const& rp, ModuleDescription const& md, - ModuleCallingContext const* moduleCallingContext) : - provRecorder_(rp, md), + ModuleCallingContext const* moduleCallingContext, bool isAtEnd) : + provRecorder_(rp, md, isAtEnd), aux_(rp.aux()), moduleCallingContext_(moduleCallingContext) { } diff --git a/FWCore/Framework/src/RunForOutput.cc b/FWCore/Framework/src/RunForOutput.cc index 17ecc9a5035b7..f0876a8b36d7c 100644 --- a/FWCore/Framework/src/RunForOutput.cc +++ b/FWCore/Framework/src/RunForOutput.cc @@ -7,8 +7,8 @@ namespace edm { RunForOutput::RunForOutput(RunPrincipal const& rp, ModuleDescription const& md, - ModuleCallingContext const* moduleCallingContext) : - OccurrenceForOutput(rp, md, moduleCallingContext), + ModuleCallingContext const* moduleCallingContext, bool isAtEnd) : + OccurrenceForOutput(rp, md, moduleCallingContext, isAtEnd), aux_(rp.aux()) { } diff --git a/FWCore/Framework/src/RunPrincipal.cc b/FWCore/Framework/src/RunPrincipal.cc index aa1352c425540..6b03d2dfd88c7 100644 --- a/FWCore/Framework/src/RunPrincipal.cc +++ b/FWCore/Framework/src/RunPrincipal.cc @@ -13,13 +13,11 @@ namespace edm { unsigned int iRunIndex, bool isForPrimaryProcess) : Base(reg, reg->productLookup(InRun), pc, InRun, historyAppender, isForPrimaryProcess), - aux_(aux), index_(iRunIndex), complete_(false) { + aux_(aux), index_(iRunIndex) { } void RunPrincipal::fillRunPrincipal(ProcessHistoryRegistry const& processHistoryRegistry, DelayedReader* reader) { - complete_ = false; - m_reducedHistoryID = processHistoryRegistry.reducedProcessHistoryID(aux_->processHistoryID()); fillPrincipal(aux_->processHistoryID(), processHistoryRegistry, reader); diff --git a/FWCore/Framework/src/SubProcess.cc b/FWCore/Framework/src/SubProcess.cc index b19bc0b1c675d..37a6c13048732 100644 --- a/FWCore/Framework/src/SubProcess.cc +++ b/FWCore/Framework/src/SubProcess.cc @@ -448,7 +448,6 @@ namespace edm { IOVSyncValue const& ts, bool cleaningUpAfterException) { RunPrincipal& rp = *principalCache_.runPrincipalPtr(); - rp.setComplete(); propagateProducts(InRun, principal, rp); typedef OccurrenceTraits Traits; rp.setAtEndTransition(true); @@ -508,7 +507,6 @@ namespace edm { SubProcess::doEndLuminosityBlockAsync(WaitingTaskHolder iHolder,LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException) { LuminosityBlockPrincipal& lbp = *inUseLumiPrincipals_[principal.index()]; - lbp.setComplete(); propagateProducts(InLumi, principal, lbp); typedef OccurrenceTraits Traits; lbp.setAtEndTransition(true); diff --git a/FWCore/Framework/src/global/EDAnalyzerBase.cc b/FWCore/Framework/src/global/EDAnalyzerBase.cc index 1b2114fa8aac2..03766c89f3b7b 100644 --- a/FWCore/Framework/src/global/EDAnalyzerBase.cc +++ b/FWCore/Framework/src/global/EDAnalyzerBase.cc @@ -81,7 +81,7 @@ namespace edm { EDAnalyzerBase::doBeginRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); Run const& cnstR = r; this->doBeginRun_(cnstR, c); @@ -91,7 +91,7 @@ namespace edm { void EDAnalyzerBase::doEndRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); Run const& cnstR = r; this->doEndRunSummary_(r,c); @@ -101,7 +101,7 @@ namespace edm { void EDAnalyzerBase::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doBeginLuminosityBlock_(cnstLb, c); @@ -111,7 +111,7 @@ namespace edm { void EDAnalyzerBase::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doEndLuminosityBlockSummary_(cnstLb,c); @@ -132,7 +132,7 @@ namespace edm { EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); this->doStreamBeginRun_(id, r, c); } @@ -141,7 +141,7 @@ namespace edm { RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); this->doStreamEndRun_(id, r, c); this->doStreamEndRunSummary_(id, r, c); @@ -151,7 +151,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); this->doStreamBeginLuminosityBlock_(id,lb, c); } @@ -161,7 +161,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); this->doStreamEndLuminosityBlock_(id,lb, c); this->doStreamEndLuminosityBlockSummary_(id,lb, c); diff --git a/FWCore/Framework/src/global/EDFilterBase.cc b/FWCore/Framework/src/global/EDFilterBase.cc index abe20015d7a94..eb18ca6effae1 100644 --- a/FWCore/Framework/src/global/EDFilterBase.cc +++ b/FWCore/Framework/src/global/EDFilterBase.cc @@ -107,7 +107,7 @@ namespace edm { void EDFilterBase::doBeginRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); Run const& cnstR = r; this->doBeginRun_(cnstR, c); @@ -120,7 +120,7 @@ namespace edm { void EDFilterBase::doEndRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); r.setProducer(this); Run const& cnstR = r; @@ -133,7 +133,7 @@ namespace edm { void EDFilterBase::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doBeginLuminosityBlock_(cnstLb, c); @@ -146,7 +146,7 @@ namespace edm { void EDFilterBase::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); lb.setProducer(this); LuminosityBlock const& cnstLb = lb; @@ -170,7 +170,7 @@ namespace edm { EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); this->doStreamBeginRun_(id, r, c); } @@ -179,7 +179,7 @@ namespace edm { RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); this->doStreamEndRun_(id, r, c); this->doStreamEndRunSummary_(id, r, c); @@ -189,7 +189,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false ); lb.setConsumer(this); this->doStreamBeginLuminosityBlock_(id,lb, c); } @@ -199,7 +199,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); this->doStreamEndLuminosityBlock_(id,lb, c); this->doStreamEndLuminosityBlockSummary_(id,lb, c); diff --git a/FWCore/Framework/src/global/EDProducerBase.cc b/FWCore/Framework/src/global/EDProducerBase.cc index d945d9aeafce2..f7ed179e2e6b0 100644 --- a/FWCore/Framework/src/global/EDProducerBase.cc +++ b/FWCore/Framework/src/global/EDProducerBase.cc @@ -108,7 +108,7 @@ namespace edm { void EDProducerBase::doBeginRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); Run const& cnstR = r; this->doBeginRun_(cnstR, c); @@ -121,7 +121,7 @@ namespace edm { void EDProducerBase::doEndRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); r.setProducer(this); Run const& cnstR = r; @@ -134,7 +134,7 @@ namespace edm { void EDProducerBase::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doBeginLuminosityBlock_(cnstLb, c); @@ -147,7 +147,7 @@ namespace edm { void EDProducerBase::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); lb.setProducer(this); LuminosityBlock const& cnstLb = lb; @@ -171,7 +171,7 @@ namespace edm { EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); this->doStreamBeginRun_(id, r, c); } @@ -180,7 +180,7 @@ namespace edm { RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); this->doStreamEndRun_(id, r, c); this->doStreamEndRunSummary_(id, r, c); @@ -190,7 +190,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc,f alse); lb.setConsumer(this); this->doStreamBeginLuminosityBlock_(id,lb, c); } @@ -200,7 +200,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); this->doStreamEndLuminosityBlock_(id,lb, c); this->doStreamEndLuminosityBlockSummary_(id,lb, c); diff --git a/FWCore/Framework/src/global/OutputModuleBase.cc b/FWCore/Framework/src/global/OutputModuleBase.cc index 8f33d8156d03f..164784233a43e 100644 --- a/FWCore/Framework/src/global/OutputModuleBase.cc +++ b/FWCore/Framework/src/global/OutputModuleBase.cc @@ -283,7 +283,7 @@ namespace edm { OutputModuleBase::doBeginRun(RunPrincipal const& rp, EventSetup const&, ModuleCallingContext const* mcc) { - RunForOutput r(rp, moduleDescription_, mcc); + RunForOutput r(rp, moduleDescription_, mcc, false); r.setConsumer(this); doBeginRun_(r); return true; @@ -293,7 +293,7 @@ namespace edm { OutputModuleBase::doEndRun(RunPrincipal const& rp, EventSetup const&, ModuleCallingContext const* mcc) { - RunForOutput r(rp, moduleDescription_, mcc); + RunForOutput r(rp, moduleDescription_, mcc, true); r.setConsumer(this); doEndRun_(r); return true; @@ -302,7 +302,7 @@ namespace edm { void OutputModuleBase::doWriteRun(RunPrincipal const& rp, ModuleCallingContext const* mcc) { - RunForOutput r(rp, moduleDescription_, mcc); + RunForOutput r(rp, moduleDescription_, mcc, true); r.setConsumer(this); writeRun(r); } @@ -311,7 +311,7 @@ namespace edm { OutputModuleBase::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const&, ModuleCallingContext const* mcc) { - LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc); + LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); doBeginLuminosityBlock_(lb); return true; @@ -321,7 +321,7 @@ namespace edm { OutputModuleBase::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const&, ModuleCallingContext const* mcc) { - LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc); + LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); doEndLuminosityBlock_(lb); return true; @@ -329,7 +329,7 @@ namespace edm { void OutputModuleBase::doWriteLuminosityBlock(LuminosityBlockPrincipal const& lbp, ModuleCallingContext const* mcc) { - LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc); + LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); writeLuminosityBlock(lb); } diff --git a/FWCore/Framework/src/limited/EDAnalyzerBase.cc b/FWCore/Framework/src/limited/EDAnalyzerBase.cc index ef5b16804a608..0f4d9ab601649 100644 --- a/FWCore/Framework/src/limited/EDAnalyzerBase.cc +++ b/FWCore/Framework/src/limited/EDAnalyzerBase.cc @@ -82,7 +82,7 @@ namespace edm { EDAnalyzerBase::doBeginRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); Run const& cnstR = r; this->doBeginRun_(cnstR, c); @@ -92,7 +92,7 @@ namespace edm { void EDAnalyzerBase::doEndRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); Run const& cnstR = r; this->doEndRunSummary_(r,c); @@ -102,7 +102,7 @@ namespace edm { void EDAnalyzerBase::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doBeginLuminosityBlock_(cnstLb, c); @@ -112,7 +112,7 @@ namespace edm { void EDAnalyzerBase::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doEndLuminosityBlockSummary_(cnstLb,c); @@ -133,7 +133,7 @@ namespace edm { EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); this->doStreamBeginRun_(id, r, c); } @@ -142,7 +142,7 @@ namespace edm { RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); this->doStreamEndRun_(id, r, c); this->doStreamEndRunSummary_(id, r, c); @@ -152,7 +152,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); this->doStreamBeginLuminosityBlock_(id,lb, c); } @@ -162,7 +162,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); this->doStreamEndLuminosityBlock_(id,lb, c); this->doStreamEndLuminosityBlockSummary_(id,lb, c); diff --git a/FWCore/Framework/src/limited/EDFilterBase.cc b/FWCore/Framework/src/limited/EDFilterBase.cc index 98ddf148e5152..ed9e79843ef10 100644 --- a/FWCore/Framework/src/limited/EDFilterBase.cc +++ b/FWCore/Framework/src/limited/EDFilterBase.cc @@ -84,7 +84,7 @@ namespace edm { void EDFilterBase::doBeginRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); Run const& cnstR = r; this->doBeginRun_(cnstR, c); @@ -97,7 +97,7 @@ namespace edm { void EDFilterBase::doEndRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); r.setProducer(this); Run const& cnstR = r; @@ -110,7 +110,7 @@ namespace edm { void EDFilterBase::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doBeginLuminosityBlock_(cnstLb, c); @@ -123,7 +123,7 @@ namespace edm { void EDFilterBase::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); lb.setProducer(this); LuminosityBlock const& cnstLb = lb; @@ -147,7 +147,7 @@ namespace edm { EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); this->doStreamBeginRun_(id, r, c); } @@ -156,7 +156,7 @@ namespace edm { RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); this->doStreamEndRun_(id, r, c); this->doStreamEndRunSummary_(id, r, c); @@ -166,7 +166,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); this->doStreamBeginLuminosityBlock_(id,lb, c); } @@ -176,7 +176,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); this->doStreamEndLuminosityBlock_(id,lb, c); this->doStreamEndLuminosityBlockSummary_(id,lb, c); diff --git a/FWCore/Framework/src/limited/EDProducerBase.cc b/FWCore/Framework/src/limited/EDProducerBase.cc index 9edf1142adfc3..efe6b39a67fa1 100644 --- a/FWCore/Framework/src/limited/EDProducerBase.cc +++ b/FWCore/Framework/src/limited/EDProducerBase.cc @@ -84,7 +84,7 @@ namespace edm { void EDProducerBase::doBeginRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); Run const& cnstR = r; this->doBeginRun_(cnstR, c); @@ -97,7 +97,7 @@ namespace edm { void EDProducerBase::doEndRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); r.setProducer(this); Run const& cnstR = r; @@ -110,7 +110,7 @@ namespace edm { void EDProducerBase::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doBeginLuminosityBlock_(cnstLb, c); @@ -123,7 +123,7 @@ namespace edm { void EDProducerBase::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); lb.setProducer(this); LuminosityBlock const& cnstLb = lb; @@ -147,7 +147,7 @@ namespace edm { EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); this->doStreamBeginRun_(id, r, c); } @@ -156,7 +156,7 @@ namespace edm { RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); this->doStreamEndRun_(id, r, c); this->doStreamEndRunSummary_(id, r, c); @@ -166,7 +166,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); this->doStreamBeginLuminosityBlock_(id,lb, c); } @@ -176,7 +176,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); this->doStreamEndLuminosityBlock_(id,lb, c); this->doStreamEndLuminosityBlockSummary_(id,lb, c); diff --git a/FWCore/Framework/src/limited/OutputModuleBase.cc b/FWCore/Framework/src/limited/OutputModuleBase.cc index ed06c4eb1ad85..c90ecf3d8033a 100644 --- a/FWCore/Framework/src/limited/OutputModuleBase.cc +++ b/FWCore/Framework/src/limited/OutputModuleBase.cc @@ -284,7 +284,7 @@ namespace edm { OutputModuleBase::doBeginRun(RunPrincipal const& rp, EventSetup const&, ModuleCallingContext const* mcc) { - RunForOutput r(rp, moduleDescription_, mcc); + RunForOutput r(rp, moduleDescription_, mcc, false); r.setConsumer(this); doBeginRun_(r); return true; @@ -294,7 +294,7 @@ namespace edm { OutputModuleBase::doEndRun(RunPrincipal const& rp, EventSetup const&, ModuleCallingContext const* mcc) { - RunForOutput r(rp, moduleDescription_, mcc); + RunForOutput r(rp, moduleDescription_, mcc, true); r.setConsumer(this); doEndRun_(r); return true; @@ -303,7 +303,7 @@ namespace edm { void OutputModuleBase::doWriteRun(RunPrincipal const& rp, ModuleCallingContext const* mcc) { - RunForOutput r(rp, moduleDescription_, mcc); + RunForOutput r(rp, moduleDescription_, mcc, true); r.setConsumer(this); writeRun(r); } @@ -312,7 +312,7 @@ namespace edm { OutputModuleBase::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const&, ModuleCallingContext const* mcc) { - LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc); + LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); doBeginLuminosityBlock_(lb); return true; @@ -322,7 +322,7 @@ namespace edm { OutputModuleBase::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const&, ModuleCallingContext const* mcc) { - LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc); + LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); doEndLuminosityBlock_(lb); return true; @@ -330,7 +330,7 @@ namespace edm { void OutputModuleBase::doWriteLuminosityBlock(LuminosityBlockPrincipal const& lbp, ModuleCallingContext const* mcc) { - LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc); + LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); writeLuminosityBlock(lb); } diff --git a/FWCore/Framework/src/one/EDAnalyzerBase.cc b/FWCore/Framework/src/one/EDAnalyzerBase.cc index 540edde4b2214..4ea217c17b673 100644 --- a/FWCore/Framework/src/one/EDAnalyzerBase.cc +++ b/FWCore/Framework/src/one/EDAnalyzerBase.cc @@ -86,7 +86,7 @@ namespace edm { void EDAnalyzerBase::doBeginRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); Run const& cnstR = r; this->doBeginRun_(cnstR, c); @@ -95,7 +95,7 @@ namespace edm { void EDAnalyzerBase::doEndRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); Run const& cnstR = r; this->doEndRun_(cnstR, c); @@ -104,7 +104,7 @@ namespace edm { void EDAnalyzerBase::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doBeginLuminosityBlock_(cnstLb, c); @@ -113,7 +113,7 @@ namespace edm { void EDAnalyzerBase::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doEndLuminosityBlock_(cnstLb, c); diff --git a/FWCore/Framework/src/one/EDFilterBase.cc b/FWCore/Framework/src/one/EDFilterBase.cc index 703e52863e523..922b55b3eff95 100644 --- a/FWCore/Framework/src/one/EDFilterBase.cc +++ b/FWCore/Framework/src/one/EDFilterBase.cc @@ -93,7 +93,7 @@ namespace edm { void EDFilterBase::doBeginRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); Run const& cnstR = r; this->doBeginRun_(cnstR, c); @@ -105,7 +105,7 @@ namespace edm { void EDFilterBase::doEndRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); Run const& cnstR = r; this->doEndRun_(cnstR, c); @@ -117,7 +117,7 @@ namespace edm { void EDFilterBase::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doBeginLuminosityBlock_(cnstLb, c); @@ -129,7 +129,7 @@ namespace edm { void EDFilterBase::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doEndLuminosityBlock_(cnstLb, c); diff --git a/FWCore/Framework/src/one/EDProducerBase.cc b/FWCore/Framework/src/one/EDProducerBase.cc index 330dfb62e3c44..7060ee6fde68f 100644 --- a/FWCore/Framework/src/one/EDProducerBase.cc +++ b/FWCore/Framework/src/one/EDProducerBase.cc @@ -91,7 +91,7 @@ namespace edm { void EDProducerBase::doBeginRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(this); Run const& cnstR = r; this->doBeginRun_(cnstR, c); @@ -103,7 +103,7 @@ namespace edm { void EDProducerBase::doEndRun(RunPrincipal const& rp, EventSetup const& c, ModuleCallingContext const* mcc) { - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(this); Run const& cnstR = r; this->doEndRun_(cnstR, c); @@ -115,7 +115,7 @@ namespace edm { void EDProducerBase::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doBeginLuminosityBlock_(cnstLb, c); @@ -127,7 +127,7 @@ namespace edm { void EDProducerBase::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); LuminosityBlock const& cnstLb = lb; this->doEndLuminosityBlock_(cnstLb, c); diff --git a/FWCore/Framework/src/one/OutputModuleBase.cc b/FWCore/Framework/src/one/OutputModuleBase.cc index 6548dbca807ab..8461f452117d4 100644 --- a/FWCore/Framework/src/one/OutputModuleBase.cc +++ b/FWCore/Framework/src/one/OutputModuleBase.cc @@ -270,7 +270,7 @@ namespace edm { OutputModuleBase::doBeginRun(RunPrincipal const& rp, EventSetup const&, ModuleCallingContext const* mcc) { - RunForOutput r(rp, moduleDescription_, mcc); + RunForOutput r(rp, moduleDescription_, mcc, false); r.setConsumer(this); doBeginRun_(r); return true; @@ -280,7 +280,7 @@ namespace edm { OutputModuleBase::doEndRun(RunPrincipal const& rp, EventSetup const&, ModuleCallingContext const* mcc) { - RunForOutput r(rp, moduleDescription_, mcc); + RunForOutput r(rp, moduleDescription_, mcc, true); r.setConsumer(this); doEndRun_(r); return true; @@ -289,7 +289,7 @@ namespace edm { void OutputModuleBase::doWriteRun(RunPrincipal const& rp, ModuleCallingContext const* mcc) { - RunForOutput r(rp, moduleDescription_, mcc); + RunForOutput r(rp, moduleDescription_, mcc, true); r.setConsumer(this); writeRun(r); } @@ -298,7 +298,7 @@ namespace edm { OutputModuleBase::doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const&, ModuleCallingContext const* mcc) { - LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc); + LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); doBeginLuminosityBlock_(lb); return true; @@ -308,7 +308,7 @@ namespace edm { OutputModuleBase::doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const&, ModuleCallingContext const* mcc) { - LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc); + LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); doEndLuminosityBlock_(lb); @@ -317,7 +317,7 @@ namespace edm { void OutputModuleBase::doWriteLuminosityBlock(LuminosityBlockPrincipal const& lbp, ModuleCallingContext const* mcc) { - LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc); + LuminosityBlockForOutput lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(this); writeLuminosityBlock(lb); } diff --git a/FWCore/Framework/src/stream/EDAnalyzerAdaptorBase.cc b/FWCore/Framework/src/stream/EDAnalyzerAdaptorBase.cc index 3cba511977e71..347a702c7fc2c 100644 --- a/FWCore/Framework/src/stream/EDAnalyzerAdaptorBase.cc +++ b/FWCore/Framework/src/stream/EDAnalyzerAdaptorBase.cc @@ -171,7 +171,7 @@ EDAnalyzerAdaptorBase::doStreamBeginRun(StreamID id, auto mod = m_streamModules[id]; setupRun(mod, rp.index()); - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(mod); mod->beginRun(r, c); @@ -184,7 +184,7 @@ EDAnalyzerAdaptorBase::doStreamEndRun(StreamID id, ModuleCallingContext const* mcc) { auto mod = m_streamModules[id]; - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(mod); mod->endRun(r, c); streamEndRunSummary(mod,r,c); @@ -198,7 +198,7 @@ EDAnalyzerAdaptorBase::doStreamBeginLuminosityBlock(StreamID id, auto mod = m_streamModules[id]; setupLuminosityBlock(mod,lbp.index()); - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(mod); mod->beginLuminosityBlock(lb, c); } @@ -209,7 +209,7 @@ EDAnalyzerAdaptorBase::doStreamEndLuminosityBlock(StreamID id, ModuleCallingContext const* mcc) { auto mod = m_streamModules[id]; - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(mod); mod->endLuminosityBlock(lb, c); streamEndLuminosityBlockSummary(mod,lb, c); diff --git a/FWCore/Framework/src/stream/ProducingModuleAdaptorBase.cc b/FWCore/Framework/src/stream/ProducingModuleAdaptorBase.cc index bded63d4e8404..a42c1d7ddd4e3 100644 --- a/FWCore/Framework/src/stream/ProducingModuleAdaptorBase.cc +++ b/FWCore/Framework/src/stream/ProducingModuleAdaptorBase.cc @@ -183,7 +183,7 @@ namespace edm { auto mod = m_streamModules[id]; setupRun(mod, rp.index()); - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, false); r.setConsumer(mod); mod->beginRun(r, c); @@ -196,7 +196,7 @@ namespace edm { ModuleCallingContext const* mcc) { auto mod = m_streamModules[id]; - Run r(rp, moduleDescription_, mcc); + Run r(rp, moduleDescription_, mcc, true); r.setConsumer(mod); mod->endRun(r, c); streamEndRunSummary(mod,r,c); @@ -211,7 +211,7 @@ namespace edm { auto mod = m_streamModules[id]; setupLuminosityBlock(mod,lbp.index()); - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(mod); mod->beginLuminosityBlock(lb, c); } @@ -224,7 +224,7 @@ namespace edm { ModuleCallingContext const* mcc) { auto mod = m_streamModules[id]; - LuminosityBlock lb(lbp, moduleDescription_, mcc); + LuminosityBlock lb(lbp, moduleDescription_, mcc, true); lb.setConsumer(mod); mod->endLuminosityBlock(lb, c); streamEndLuminosityBlockSummary(mod,lb, c); diff --git a/FWCore/Sources/src/PuttableSourceBase.cc b/FWCore/Sources/src/PuttableSourceBase.cc index 16f18958c16a9..a783a757163ee 100644 --- a/FWCore/Sources/src/PuttableSourceBase.cc +++ b/FWCore/Sources/src/PuttableSourceBase.cc @@ -64,7 +64,7 @@ PuttableSourceBase::beginJob() { void PuttableSourceBase::doBeginRun(RunPrincipal& rp, ProcessContext const* ) { - Run run(rp, moduleDescription(), nullptr); + Run run(rp, moduleDescription(), nullptr, false); run.setProducer(this); callWithTryCatchAndPrint( [this,&run](){ beginRun(run); }, "Calling Source::beginRun" ); commit_(run); @@ -72,7 +72,7 @@ PuttableSourceBase::doBeginRun(RunPrincipal& rp, ProcessContext const* ) { void PuttableSourceBase::doEndRun(RunPrincipal& rp, bool cleaningUpAfterException, ProcessContext const* ) { - Run run(rp, moduleDescription(), nullptr); + Run run(rp, moduleDescription(), nullptr, true); run.setProducer(this); callWithTryCatchAndPrint( [this,&run](){ endRun(run); }, "Calling Source::endRun", cleaningUpAfterException ); commit_(run); @@ -80,7 +80,7 @@ PuttableSourceBase::doEndRun(RunPrincipal& rp, bool cleaningUpAfterException, Pr void PuttableSourceBase::doBeginLumi(LuminosityBlockPrincipal& lbp, ProcessContext const* ) { - LuminosityBlock lb(lbp, moduleDescription(), nullptr); + LuminosityBlock lb(lbp, moduleDescription(), nullptr, false); lb.setProducer(this); callWithTryCatchAndPrint( [this,&lb](){ beginLuminosityBlock(lb); }, "Calling Source::beginLuminosityBlock" ); commit_(lb); @@ -88,7 +88,7 @@ PuttableSourceBase::doBeginLumi(LuminosityBlockPrincipal& lbp, ProcessContext co void PuttableSourceBase::doEndLumi(LuminosityBlockPrincipal& lbp, bool cleaningUpAfterException, ProcessContext const* ) { - LuminosityBlock lb(lbp, moduleDescription(), nullptr); + LuminosityBlock lb(lbp, moduleDescription(), nullptr, false); lb.setProducer(this); callWithTryCatchAndPrint( [this,&lb](){ endLuminosityBlock(lb); }, "Calling Source::endLuminosityBlock", cleaningUpAfterException ); commit_(lb); From d1bb9c283836303b2174c80aad23464ea41e38a8 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 2 Jan 2018 13:09:04 -0600 Subject: [PATCH 15/52] Fix typo --- FWCore/Framework/src/global/EDProducerBase.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FWCore/Framework/src/global/EDProducerBase.cc b/FWCore/Framework/src/global/EDProducerBase.cc index f7ed179e2e6b0..fb6f857d7bed1 100644 --- a/FWCore/Framework/src/global/EDProducerBase.cc +++ b/FWCore/Framework/src/global/EDProducerBase.cc @@ -190,7 +190,7 @@ namespace edm { LuminosityBlockPrincipal const& lbp, EventSetup const& c, ModuleCallingContext const* mcc) { - LuminosityBlock lb(lbp, moduleDescription_, mcc,f alse); + LuminosityBlock lb(lbp, moduleDescription_, mcc, false); lb.setConsumer(this); this->doStreamBeginLuminosityBlock_(id,lb, c); } From bb8c6589298362508d68c6ba609ae8aa5dc35a66 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 2 Jan 2018 16:56:06 -0600 Subject: [PATCH 16/52] Added isAtEndTransition() method Added isAtEndTransition() method to Context system to allow determination in ProductResolvers. --- .../ServiceRegistry/interface/GlobalContext.h | 5 ++++ .../ServiceRegistry/interface/ParentContext.h | 2 ++ .../ServiceRegistry/interface/StreamContext.h | 4 +++ FWCore/ServiceRegistry/src/ParentContext.cc | 26 +++++++++++++++++++ 4 files changed, 37 insertions(+) diff --git a/FWCore/ServiceRegistry/interface/GlobalContext.h b/FWCore/ServiceRegistry/interface/GlobalContext.h index 716c0287dbc75..3bd74a2b04e17 100644 --- a/FWCore/ServiceRegistry/interface/GlobalContext.h +++ b/FWCore/ServiceRegistry/interface/GlobalContext.h @@ -49,6 +49,11 @@ namespace edm { ProcessContext const* processContext); Transition transition() const { return transition_; } + bool isAtEndTransition() const { return transition() == Transition::kEndLuminosityBlock or + transition() == Transition::kEndRun or + transition() == Transition::kWriteRun or + transition() == Transition::kWriteLuminosityBlock;} + LuminosityBlockID const& luminosityBlockID() const { return luminosityBlockID_; } RunIndex const& runIndex() const { return runIndex_; } LuminosityBlockIndex const& luminosityBlockIndex() const { return luminosityBlockIndex_; } diff --git a/FWCore/ServiceRegistry/interface/ParentContext.h b/FWCore/ServiceRegistry/interface/ParentContext.h index 4b38c252f42e7..e51407ab7911c 100644 --- a/FWCore/ServiceRegistry/interface/ParentContext.h +++ b/FWCore/ServiceRegistry/interface/ParentContext.h @@ -45,6 +45,8 @@ namespace edm { Type type() const { return type_; } + bool isAtEndTransition() const; + GlobalContext const* globalContext() const; InternalContext const* internalContext() const; ModuleCallingContext const* moduleCallingContext() const; diff --git a/FWCore/ServiceRegistry/interface/StreamContext.h b/FWCore/ServiceRegistry/interface/StreamContext.h index 43acfdb8323ee..72b5610a4b095 100644 --- a/FWCore/ServiceRegistry/interface/StreamContext.h +++ b/FWCore/ServiceRegistry/interface/StreamContext.h @@ -56,6 +56,10 @@ namespace edm { StreamID const& streamID() const { return streamID_; } Transition transition() const { return transition_; } + bool isAtEndTransition() const { + return transition() ==Transition::kEndLuminosityBlock or + transition() ==Transition::kEndRun; + } EventID const& eventID() const { return eventID_; } // event#==0 is a lumi, event#==0&lumi#==0 is a run RunIndex const& runIndex() const { return runIndex_; } LuminosityBlockIndex const& luminosityBlockIndex() const { return luminosityBlockIndex_; } diff --git a/FWCore/ServiceRegistry/src/ParentContext.cc b/FWCore/ServiceRegistry/src/ParentContext.cc index d4670f861e653..59244a88e1c5e 100644 --- a/FWCore/ServiceRegistry/src/ParentContext.cc +++ b/FWCore/ServiceRegistry/src/ParentContext.cc @@ -3,6 +3,7 @@ #include "FWCore/ServiceRegistry/interface/InternalContext.h" #include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h" #include "FWCore/ServiceRegistry/interface/PlaceInPathContext.h" +#include "FWCore/ServiceRegistry/interface/PathContext.h" #include "FWCore/ServiceRegistry/interface/StreamContext.h" #include "FWCore/Utilities/interface/EDMException.h" @@ -86,6 +87,31 @@ namespace edm { return parent_.internal; } + bool + ParentContext::isAtEndTransition() const { + switch(type_) { + case Type::kGlobal: + { + return parent_.global->isAtEndTransition(); + } + case Type::kModule: + { + return parent_.module->parent().isAtEndTransition(); + } + case Type::kStream: + { + return parent_.stream->isAtEndTransition(); + } + case Type::kPlaceInPath: + { + return parent_.placeInPath->pathContext()->streamContext()->isAtEndTransition(); + } + default: + break; + } + return false; + } + std::ostream& operator<<(std::ostream& os, ParentContext const& pc) { if(pc.type() == ParentContext::Type::kGlobal && pc.globalContext()) { os << *pc.globalContext(); From 3c09d58529372b14e50ba205bc49df65f3217ba2 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 2 Jan 2018 16:57:20 -0600 Subject: [PATCH 17/52] Fixed at end bug in doEndLumi The at end bit was improperly set for the LuminosityBlock made in doEndLumi. --- FWCore/Sources/src/PuttableSourceBase.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FWCore/Sources/src/PuttableSourceBase.cc b/FWCore/Sources/src/PuttableSourceBase.cc index a783a757163ee..9d9110800f7f5 100644 --- a/FWCore/Sources/src/PuttableSourceBase.cc +++ b/FWCore/Sources/src/PuttableSourceBase.cc @@ -88,7 +88,7 @@ PuttableSourceBase::doBeginLumi(LuminosityBlockPrincipal& lbp, ProcessContext co void PuttableSourceBase::doEndLumi(LuminosityBlockPrincipal& lbp, bool cleaningUpAfterException, ProcessContext const* ) { - LuminosityBlock lb(lbp, moduleDescription(), nullptr, false); + LuminosityBlock lb(lbp, moduleDescription(), nullptr, true); lb.setProducer(this); callWithTryCatchAndPrint( [this,&lb](){ endLuminosityBlock(lb); }, "Calling Source::endLuminosityBlock", cleaningUpAfterException ); commit_(lb); From 46ac2a4b5f2cbc7c682d34d1f38e25efaffd035d Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 3 Jan 2018 09:19:08 -0600 Subject: [PATCH 18/52] Removed atEndTransition state from Principal No longer change Principal at end transition since a Principal can now be used simultaneously on a begin and end transition. The state information is now obtained from the Context system. --- FWCore/Framework/interface/Principal.h | 5 ----- FWCore/Framework/src/EventProcessor.cc | 2 -- FWCore/Framework/src/Principal.cc | 9 +-------- FWCore/Framework/src/PrincipalGetAdapter.cc | 4 ++-- FWCore/Framework/src/ProductResolvers.cc | 8 +++++--- FWCore/Framework/src/SubProcess.cc | 2 -- 6 files changed, 8 insertions(+), 22 deletions(-) diff --git a/FWCore/Framework/interface/Principal.h b/FWCore/Framework/interface/Principal.h index c64365b0eea3d..cfea59a43234c 100644 --- a/FWCore/Framework/interface/Principal.h +++ b/FWCore/Framework/interface/Principal.h @@ -86,9 +86,6 @@ namespace edm { void setupUnscheduled(UnscheduledConfigurator const&); - void setAtEndTransition(bool iAtEnd); - bool atEndTransition() const {return atEndTransition_;} - void deleteProduct(BranchID const& id) const; EDProductGetter const* prodGetter() const {return this;} @@ -288,8 +285,6 @@ namespace edm { edm::propagate_const historyAppender_; CacheIdentifier_t cacheIdentifier_; - - bool atEndTransition_; }; template diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 8e93670f2ac00..57740380f3f06 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1016,7 +1016,6 @@ namespace edm { void EventProcessor::endRun(ProcessHistoryID const& phid, RunNumber_t run, bool globalBeginSucceeded, bool cleaningUpAfterException) { RunPrincipal& runPrincipal = principalCache_.runPrincipal(phid, run); - runPrincipal.setAtEndTransition(true); //We need to reset failed items since they might // be set this time around runPrincipal.resetFailedFromThisProcess(); @@ -1200,7 +1199,6 @@ namespace edm { void EventProcessor::endLumi(std::shared_ptr status) { bool cleaningUpAfterException = status->cleaningUpAfterException(); LuminosityBlockPrincipal& lumiPrincipal = *status-> lumiPrincipal(); - lumiPrincipal.setAtEndTransition(true); //need to release the IOV auto dtr = [](SerialTaskQueue* iQueue) { iQueue->resume();}; diff --git a/FWCore/Framework/src/Principal.cc b/FWCore/Framework/src/Principal.cc index ec00c7fac603d..f1be4f7102384 100644 --- a/FWCore/Framework/src/Principal.cc +++ b/FWCore/Framework/src/Principal.cc @@ -128,8 +128,7 @@ namespace edm { reader_(), branchType_(bt), historyAppender_(historyAppender), - cacheIdentifier_(nextIdentifier()), - atEndTransition_(false) + cacheIdentifier_(nextIdentifier()) { productResolvers_.resize(reg->getNextIndexValue(bt)); //Now that these have been set, we can create the list of Branches we need. @@ -321,11 +320,6 @@ namespace edm { } } - void - Principal::setAtEndTransition(bool iAtEnd) { - atEndTransition_ = iAtEnd; - } - void Principal::deleteProduct(BranchID const& id) const { auto phb = getExistingProduct(id); @@ -348,7 +342,6 @@ namespace edm { DelayedReader* reader) { //increment identifier here since clearPrincipal isn't called for Run/Lumi cacheIdentifier_=nextIdentifier(); - atEndTransition_=false; if(reader) { reader_ = reader; } diff --git a/FWCore/Framework/src/PrincipalGetAdapter.cc b/FWCore/Framework/src/PrincipalGetAdapter.cc index e5bba5fafaf3e..0de007b23452c 100644 --- a/FWCore/Framework/src/PrincipalGetAdapter.cc +++ b/FWCore/Framework/src/PrincipalGetAdapter.cc @@ -311,13 +311,13 @@ namespace edm { return Transition::Event; } if(principal().branchType() == InRun) { - if(principal().atEndTransition()) { + if(isComplete()) { return Transition::EndRun; } else { return Transition::BeginRun; } } - if(principal().atEndTransition()) { + if(isComplete()) { return Transition::EndLuminosityBlock; } return Transition::BeginLuminosityBlock; diff --git a/FWCore/Framework/src/ProductResolvers.cc b/FWCore/Framework/src/ProductResolvers.cc index d14367ce7492c..e3a4c1a8fe88c 100644 --- a/FWCore/Framework/src/ProductResolvers.cc +++ b/FWCore/Framework/src/ProductResolvers.cc @@ -15,6 +15,7 @@ #include "FWCore/Concurrency/interface/FunctorTask.h" #include "FWCore/Utilities/interface/TypeID.h" #include "FWCore/Utilities/interface/make_sentry.h" +#include "FWCore/Utilities/interface/Transition.h" #include #include @@ -258,9 +259,10 @@ namespace edm { SharedResourcesAcquirer* sra, ModuleCallingContext const* mcc) const { if(not skipCurrentProcess) { - if(branchDescription().availableOnlyAtEndTransition() and - not principal.atEndTransition()) { - return; + if(branchDescription().availableOnlyAtEndTransition() and mcc ) { + if( not mcc->parent().isAtEndTransition() ) { + return; + } } m_waitingTasks.add(waitTask); diff --git a/FWCore/Framework/src/SubProcess.cc b/FWCore/Framework/src/SubProcess.cc index 37a6c13048732..2b4e886e2d92c 100644 --- a/FWCore/Framework/src/SubProcess.cc +++ b/FWCore/Framework/src/SubProcess.cc @@ -450,7 +450,6 @@ namespace edm { RunPrincipal& rp = *principalCache_.runPrincipalPtr(); propagateProducts(InRun, principal, rp); typedef OccurrenceTraits Traits; - rp.setAtEndTransition(true); endGlobalTransitionAsync(std::move(iHolder), *schedule_, rp, @@ -509,7 +508,6 @@ namespace edm { LuminosityBlockPrincipal& lbp = *inUseLumiPrincipals_[principal.index()]; propagateProducts(InLumi, principal, lbp); typedef OccurrenceTraits Traits; - lbp.setAtEndTransition(true); endGlobalTransitionAsync(std::move(iHolder), *schedule_, lbp, From 28403471225aac728146dc4cbb65ad883abeef41 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 3 Jan 2018 09:32:02 -0600 Subject: [PATCH 19/52] Better handling of at end transition data products Data products which are made at the end Run/LuminosityBlock transition no longer require a 'reset' to work. Now if those data products are requested outside of that transition, no waiting is required and the ProductResolver is never set to the ResolveFailed state. This allows these data products to work properly if we are concurrently processing events and an end transition. Only modules on the end transition can retrieve the end transition data products. --- FWCore/Framework/interface/Principal.h | 4 -- .../Framework/interface/ProductResolverBase.h | 2 - FWCore/Framework/src/EventProcessor.cc | 8 --- FWCore/Framework/src/GlobalSchedule.h | 7 -- FWCore/Framework/src/LuminosityBlock.cc | 3 +- FWCore/Framework/src/Principal.cc | 31 +++++--- FWCore/Framework/src/ProductResolverBase.cc | 2 - FWCore/Framework/src/ProductResolvers.cc | 72 ++++++++----------- FWCore/Framework/src/ProductResolvers.h | 6 +- FWCore/Framework/src/Run.cc | 3 +- 10 files changed, 56 insertions(+), 82 deletions(-) diff --git a/FWCore/Framework/interface/Principal.h b/FWCore/Framework/interface/Principal.h index cfea59a43234c..0b880fb3390bb 100644 --- a/FWCore/Framework/interface/Principal.h +++ b/FWCore/Framework/interface/Principal.h @@ -185,10 +185,6 @@ namespace edm { ProductData const* findProductByTag(TypeID const& typeID, InputTag const& tag, ModuleCallingContext const* mcc) const; void readAllFromSourceAndMergeImmediately(); - //For end Run/Lumi we need to reset products failed in the begin - // transition since they may be put into the Principal at the - // end transition - void resetFailedFromThisProcess(); std::vector const& lookupProcessOrder() const { return lookupProcessOrder_; } diff --git a/FWCore/Framework/interface/ProductResolverBase.h b/FWCore/Framework/interface/ProductResolverBase.h index 3d2fadc2b52b1..94090b1c7b504 100644 --- a/FWCore/Framework/interface/ProductResolverBase.h +++ b/FWCore/Framework/interface/ProductResolverBase.h @@ -76,8 +76,6 @@ namespace edm { } void resetProductData() { resetProductData_(false); } - virtual void resetFailedFromThisProcess(); - void unsafe_deleteProduct() const { const_cast(this)->resetProductData_(true); } diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 57740380f3f06..fdab5f82d4fc2 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1016,10 +1016,6 @@ namespace edm { void EventProcessor::endRun(ProcessHistoryID const& phid, RunNumber_t run, bool globalBeginSucceeded, bool cleaningUpAfterException) { RunPrincipal& runPrincipal = principalCache_.runPrincipal(phid, run); - //We need to reset failed items since they might - // be set this time around - runPrincipal.resetFailedFromThisProcess(); - { SendSourceTerminationSignalIfException sentry(actReg_.get()); @@ -1204,10 +1200,6 @@ namespace edm { auto dtr = [](SerialTaskQueue* iQueue) { iQueue->resume();}; std::unique_ptr guard(&iovQueue_, dtr); - //We need to reset failed items since they might - // be set this time around - lumiPrincipal.resetFailedFromThisProcess(); - { SendSourceTerminationSignalIfException sentry(actReg_.get()); diff --git a/FWCore/Framework/src/GlobalSchedule.h b/FWCore/Framework/src/GlobalSchedule.h index 496b7f2ad847a..969a7cb755195 100644 --- a/FWCore/Framework/src/GlobalSchedule.h +++ b/FWCore/Framework/src/GlobalSchedule.h @@ -180,13 +180,6 @@ namespace edm { T::preScheduleSignal(actReg_.get(), globalContext.get()); } - - //If we are in an end transition, we need to reset failed items since they might - // be set this time around - if( not T::begin_) { - ep.resetFailedFromThisProcess(); - } - auto doneTask = make_waiting_task(tbb::task::allocate_root(), [this,iHolder, cleaningUpAfterException, globalContext, token](std::exception_ptr const* iPtr) mutable { diff --git a/FWCore/Framework/src/LuminosityBlock.cc b/FWCore/Framework/src/LuminosityBlock.cc index b2ab07026a26f..0b8f8cd32658e 100644 --- a/FWCore/Framework/src/LuminosityBlock.cc +++ b/FWCore/Framework/src/LuminosityBlock.cc @@ -85,7 +85,8 @@ namespace edm { auto& p = provRecorder_.principal(); for(auto index: iShouldPut){ auto resolver = p.getProductResolverByIndex(index); - if(not resolver->productResolved()) { + if(not resolver->productResolved() and + isEndTransition(provRecorder_.transition()) == resolver->branchDescription().availableOnlyAtEndTransition()) { resolver->putProduct(std::unique_ptr()); } } diff --git a/FWCore/Framework/src/Principal.cc b/FWCore/Framework/src/Principal.cc index f1be4f7102384..0de43676eff8c 100644 --- a/FWCore/Framework/src/Principal.cc +++ b/FWCore/Framework/src/Principal.cc @@ -204,7 +204,17 @@ namespace edm { //only one choice so use a special resolver productResolvers_.at(productResolverIndex) = std::make_shared(lastMatchIndex); } else { - std::shared_ptr newHolder = std::make_shared(matchingHolders, ambiguous); + bool productMadeAtEnd = false; + //Need to know if the product from this processes is added at end of transition + for(unsigned int i=0; i< matchingHolders.size();++i) { + if( (not ambiguous[i]) and + ProductResolverIndexInvalid != matchingHolders[i] and + productResolvers_[matchingHolders[i]]->branchDescription().availableOnlyAtEndTransition()) { + productMadeAtEnd = true; + break; + } + } + std::shared_ptr newHolder = std::make_shared(matchingHolders, ambiguous, productMadeAtEnd); productResolvers_.at(productResolverIndex) = newHolder; } matchingHolders.assign(lookupProcessNames.size(), ProductResolverIndexInvalid); @@ -230,7 +240,17 @@ namespace edm { } } } - std::shared_ptr newHolder = std::make_shared(matchingHolders, ambiguous); + //Need to know if the product from this processes is added at end of transition + bool productMadeAtEnd = false; + for(unsigned int i=0; i< matchingHolders.size();++i) { + if( (not ambiguous[i]) and + ProductResolverIndexInvalid != matchingHolders[i] and + productResolvers_[matchingHolders[i]]->branchDescription().availableOnlyAtEndTransition()) { + productMadeAtEnd = true; + break; + } + } + std::shared_ptr newHolder = std::make_shared(matchingHolders, ambiguous, productMadeAtEnd); productResolvers_.at(productResolverIndex) = newHolder; } } @@ -892,11 +912,4 @@ namespace edm { prod->retrieveAndMerge(*this); } } - - void - Principal::resetFailedFromThisProcess() { - for( auto & prod : *this) { - prod->resetFailedFromThisProcess(); - } - } } diff --git a/FWCore/Framework/src/ProductResolverBase.cc b/FWCore/Framework/src/ProductResolverBase.cc index d14c8a86bd01a..d81f3a949eebb 100644 --- a/FWCore/Framework/src/ProductResolverBase.cc +++ b/FWCore/Framework/src/ProductResolverBase.cc @@ -53,6 +53,4 @@ namespace edm { void ProductResolverBase::setupUnscheduled(UnscheduledConfigurator const&) {} - void ProductResolverBase::resetFailedFromThisProcess() {} - } diff --git a/FWCore/Framework/src/ProductResolvers.cc b/FWCore/Framework/src/ProductResolvers.cc index e3a4c1a8fe88c..0bf96997afe32 100644 --- a/FWCore/Framework/src/ProductResolvers.cc +++ b/FWCore/Framework/src/ProductResolvers.cc @@ -435,14 +435,6 @@ namespace edm { return true; } - void - ProducedProductResolver::resetFailedFromThisProcess() { - if(ProductStatus::ResolveFailed == status()) { - resetProductData_(false); - } - } - - void DataManagingProductResolver::connectTo(ProductResolverBase const& iOther, Principal const*) { assert(false); @@ -638,14 +630,16 @@ namespace edm { NoProcessProductResolver:: NoProcessProductResolver(std::vector const& matchingHolders, - std::vector const& ambiguous) : + std::vector const& ambiguous, + bool madeAtEnd) : matchingHolders_(matchingHolders), ambiguous_(ambiguous), lastCheckIndex_(ambiguous_.size() + kUnsetOffset), lastSkipCurrentCheckIndex_(lastCheckIndex_.load()), prefetchRequested_(false), skippingPrefetchRequested_(false), - recheckedAtEnd_(false) { + madeAtEnd_{madeAtEnd} + { assert(ambiguous_.size() == matchingHolders_.size()); } @@ -668,29 +662,25 @@ namespace edm { //See if we've already cached which Resolver we should call or if // we know it is ambiguous const unsigned int choiceSize = ambiguous_.size(); - { - if( (not principal.atEndTransition()) or - recheckedAtEnd_) { - unsigned int checkCacheIndex = skipCurrentProcess? lastSkipCurrentCheckIndex_.load() : lastCheckIndex_.load(); - if( checkCacheIndex != choiceSize +kUnsetOffset) { - if (checkCacheIndex == choiceSize+kAmbiguousOffset) { - return ProductResolverBase::Resolution::makeAmbiguous(); - } else if(checkCacheIndex == choiceSize+kMissingOffset) { - return Resolution(nullptr); - } - return tryResolver(checkCacheIndex, principal, skipCurrentProcess, - sra,mcc); - } + + //madeAtEnd_==true and not at end transition is the same as skipping the current process + if( (not skipCurrentProcess) and (madeAtEnd_ and mcc)) { + skipCurrentProcess = not mcc->parent().isAtEndTransition(); + } + + unsigned int checkCacheIndex = skipCurrentProcess? lastSkipCurrentCheckIndex_.load() : lastCheckIndex_.load(); + if( checkCacheIndex != choiceSize +kUnsetOffset) { + if (checkCacheIndex == choiceSize+kAmbiguousOffset) { + return ProductResolverBase::Resolution::makeAmbiguous(); + } else if(checkCacheIndex == choiceSize+kMissingOffset) { + return Resolution(nullptr); } + return tryResolver(checkCacheIndex, principal, skipCurrentProcess, + sra,mcc); } std::atomic& updateCacheIndex = skipCurrentProcess? lastSkipCurrentCheckIndex_ : lastCheckIndex_; - //make sure recheckedAtEnd_ set to true if needed - auto setTrue = [](std::atomic* iBool) { *iBool = true; }; - using TrueGuard = std::unique_ptr, decltype(setTrue)>; - TrueGuard guard( principal.atEndTransition()?&recheckedAtEnd_:nullptr,setTrue); - std::vector const& lookupProcessOrder = principal.lookupProcessOrder(); for(unsigned int k : lookupProcessOrder) { assert(k < ambiguous_.size()); @@ -718,31 +708,26 @@ namespace edm { bool skipCurrentProcess, SharedResourcesAcquirer* sra, ModuleCallingContext const* mcc) const { - if(not skipCurrentProcess) { + bool timeToMakeAtEnd = true; + if(madeAtEnd_ and mcc) { + timeToMakeAtEnd = mcc->parent().isAtEndTransition(); + } + + //If timeToMakeAtEnd is false, then it is equivalent to skipping the current process + if(not skipCurrentProcess and timeToMakeAtEnd) { waitingTasks_.add(waitTask); - //It is possible that a new product was added at then end transition - // so we need to recheck what to return - bool needToRecheckAtEnd = false; - if(principal.atEndTransition()) { - bool expected = false; - needToRecheckAtEnd = recheckedAtEnd_.compare_exchange_strong(expected,true); - if(needToRecheckAtEnd) { - prefetchRequested_=true; - } - } - bool expected = false; - if( needToRecheckAtEnd or prefetchRequested_.compare_exchange_strong(expected,true)) { + if( prefetchRequested_.compare_exchange_strong(expected,true)) { //we are the first thread to request - tryPrefetchResolverAsync(0, principal, skipCurrentProcess, sra, mcc, ServiceRegistry::instance().presentToken()); + tryPrefetchResolverAsync(0, principal, false, sra, mcc, ServiceRegistry::instance().presentToken()); } } else { skippingWaitingTasks_.add(waitTask); bool expected = false; if( skippingPrefetchRequested_.compare_exchange_strong(expected,true)) { //we are the first thread to request - tryPrefetchResolverAsync(0, principal, skipCurrentProcess, sra, mcc, ServiceRegistry::instance().presentToken()); + tryPrefetchResolverAsync(0, principal, true, sra, mcc, ServiceRegistry::instance().presentToken()); } } } @@ -908,7 +893,6 @@ namespace edm { lastSkipCurrentCheckIndex_ = resetValue; prefetchRequested_ = false; skippingPrefetchRequested_ = false; - recheckedAtEnd_ = false; waitingTasks_.reset(); skippingWaitingTasks_.reset(); } diff --git a/FWCore/Framework/src/ProductResolvers.h b/FWCore/Framework/src/ProductResolvers.h index 2375de46aa05f..618acfaa60a0b 100644 --- a/FWCore/Framework/src/ProductResolvers.h +++ b/FWCore/Framework/src/ProductResolvers.h @@ -134,8 +134,6 @@ namespace edm { public: ProducedProductResolver(std::shared_ptr bd, ProductStatus iDefaultStatus) : DataManagingProductResolver(bd, iDefaultStatus) {assert(bd->produced());} - void resetFailedFromThisProcess() override; - protected: void putProduct_(std::unique_ptr edp) const override; private: @@ -310,7 +308,7 @@ namespace edm { public: typedef ProducedProductResolver::ProductStatus ProductStatus; NoProcessProductResolver(std::vector const& matchingHolders, - std::vector const& ambiguous); + std::vector const& ambiguous, bool madeAtEnd); void connectTo(ProductResolverBase const& iOther, Principal const*) final ; @@ -375,7 +373,7 @@ namespace edm { mutable std::atomic lastSkipCurrentCheckIndex_; mutable std::atomic prefetchRequested_; mutable std::atomic skippingPrefetchRequested_; - mutable std::atomic recheckedAtEnd_; + const bool madeAtEnd_; }; class SingleChoiceNoProcessProductResolver : public ProductResolverBase { diff --git a/FWCore/Framework/src/Run.cc b/FWCore/Framework/src/Run.cc index 491433c6ed449..5c4b0dcd41105 100644 --- a/FWCore/Framework/src/Run.cc +++ b/FWCore/Framework/src/Run.cc @@ -101,7 +101,8 @@ namespace edm { auto& p = provRecorder_.principal(); for(auto index: iShouldPut){ auto resolver = p.getProductResolverByIndex(index); - if(not resolver->productResolved()) { + if(not resolver->productResolved() and + isEndTransition(provRecorder_.transition()) == resolver->branchDescription().availableOnlyAtEndTransition()) { resolver->putProduct(std::unique_ptr()); } } From a0bbcd3eebefb62265c14f6cbcc1ea5b532d49ef Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 3 Jan 2018 12:24:00 -0600 Subject: [PATCH 20/52] Removed unnecessary lines --- FWCore/Framework/src/globalTransitionAsync.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/FWCore/Framework/src/globalTransitionAsync.h b/FWCore/Framework/src/globalTransitionAsync.h index 87474051d006e..ed326aecb9231 100644 --- a/FWCore/Framework/src/globalTransitionAsync.h +++ b/FWCore/Framework/src/globalTransitionAsync.h @@ -114,8 +114,6 @@ namespace edm { WaitingTaskHolder h(subs); iSchedule.processOneGlobalAsync(std::move(h),iPrincipal, iES,cleaningUpAfterException); - - } }; From dfd30f991da136f89d6e951691c2692a91957ad8 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 3 Jan 2018 12:26:05 -0600 Subject: [PATCH 21/52] Updated unit test to match processing order change Not resetting the InputProductResolver means that at endLumi the data products from the source are already available for 'testmerge'. So when 'thingWithMergeProducer' completes 'testmerge' will immediately start before 'test' runs. --- .../testSubProcess.grep2.txt | 96 +++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/FWCore/Integration/test/unit_test_outputs/testSubProcess.grep2.txt b/FWCore/Integration/test/unit_test_outputs/testSubProcess.grep2.txt index e4a65cb99a5d5..2c6758ca00eed 100644 --- a/FWCore/Integration/test/unit_test_outputs/testSubProcess.grep2.txt +++ b/FWCore/Integration/test/unit_test_outputs/testSubProcess.grep2.txt @@ -1056,10 +1056,10 @@ ++++ starting: global end lumi: run = 1 lumi = 1 time = 1 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 31 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 31 -++++++ starting: global end lumi for module: label = 'test' id = 32 -++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'testmerge' id = 33 ++++++ finished: global end lumi for module: label = 'testmerge' id = 33 +++++++ starting: global end lumi for module: label = 'test' id = 32 +++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'getInt' id = 35 ++++++ finished: global end lumi for module: label = 'getInt' id = 35 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 36 @@ -1069,10 +1069,10 @@ ++++ finished: global end lumi: run = 1 lumi = 1 time = 1 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 18 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 18 -++++++ starting: global end lumi for module: label = 'test' id = 19 -++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'testmerge' id = 20 ++++++ finished: global end lumi for module: label = 'testmerge' id = 20 +++++++ starting: global end lumi for module: label = 'test' id = 19 +++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'getInt' id = 22 ++++++ finished: global end lumi for module: label = 'getInt' id = 22 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 23 @@ -1838,10 +1838,10 @@ ++++ starting: global end lumi: run = 1 lumi = 2 time = 25000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 31 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 31 -++++++ starting: global end lumi for module: label = 'test' id = 32 -++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'testmerge' id = 33 ++++++ finished: global end lumi for module: label = 'testmerge' id = 33 +++++++ starting: global end lumi for module: label = 'test' id = 32 +++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'getInt' id = 35 ++++++ finished: global end lumi for module: label = 'getInt' id = 35 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 36 @@ -1851,10 +1851,10 @@ ++++ finished: global end lumi: run = 1 lumi = 2 time = 25000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 18 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 18 -++++++ starting: global end lumi for module: label = 'test' id = 19 -++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'testmerge' id = 20 ++++++ finished: global end lumi for module: label = 'testmerge' id = 20 +++++++ starting: global end lumi for module: label = 'test' id = 19 +++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'getInt' id = 22 ++++++ finished: global end lumi for module: label = 'getInt' id = 22 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 23 @@ -2296,10 +2296,10 @@ ++++ starting: global end lumi: run = 1 lumi = 3 time = 45000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 31 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 31 -++++++ starting: global end lumi for module: label = 'test' id = 32 -++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'testmerge' id = 33 ++++++ finished: global end lumi for module: label = 'testmerge' id = 33 +++++++ starting: global end lumi for module: label = 'test' id = 32 +++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'getInt' id = 35 ++++++ finished: global end lumi for module: label = 'getInt' id = 35 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 36 @@ -2309,10 +2309,10 @@ ++++ finished: global end lumi: run = 1 lumi = 3 time = 45000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 18 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 18 -++++++ starting: global end lumi for module: label = 'test' id = 19 -++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'testmerge' id = 20 ++++++ finished: global end lumi for module: label = 'testmerge' id = 20 +++++++ starting: global end lumi for module: label = 'test' id = 19 +++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'getInt' id = 22 ++++++ finished: global end lumi for module: label = 'getInt' id = 22 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 23 @@ -2362,10 +2362,10 @@ ++++ starting: global end run 1 : time = 0 ++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 31 ++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 31 -++++++ starting: global end run for module: label = 'test' id = 32 -++++++ finished: global end run for module: label = 'test' id = 32 ++++++ starting: global end run for module: label = 'testmerge' id = 33 ++++++ finished: global end run for module: label = 'testmerge' id = 33 +++++++ starting: global end run for module: label = 'test' id = 32 +++++++ finished: global end run for module: label = 'test' id = 32 ++++++ starting: global end run for module: label = 'getInt' id = 35 ++++++ finished: global end run for module: label = 'getInt' id = 35 ++++++ starting: global end run for module: label = 'dependsOnNoPut' id = 36 @@ -2375,10 +2375,10 @@ ++++ finished: global end run 1 : time = 0 ++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 18 ++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 18 -++++++ starting: global end run for module: label = 'test' id = 19 -++++++ finished: global end run for module: label = 'test' id = 19 ++++++ starting: global end run for module: label = 'testmerge' id = 20 ++++++ finished: global end run for module: label = 'testmerge' id = 20 +++++++ starting: global end run for module: label = 'test' id = 19 +++++++ finished: global end run for module: label = 'test' id = 19 ++++++ starting: global end run for module: label = 'getInt' id = 22 ++++++ finished: global end run for module: label = 'getInt' id = 22 ++++++ starting: global end run for module: label = 'dependsOnNoPut' id = 23 @@ -3212,10 +3212,10 @@ ++++ starting: global end lumi: run = 2 lumi = 1 time = 55000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 31 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 31 -++++++ starting: global end lumi for module: label = 'test' id = 32 -++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'testmerge' id = 33 ++++++ finished: global end lumi for module: label = 'testmerge' id = 33 +++++++ starting: global end lumi for module: label = 'test' id = 32 +++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'getInt' id = 35 ++++++ finished: global end lumi for module: label = 'getInt' id = 35 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 36 @@ -3225,10 +3225,10 @@ ++++ finished: global end lumi: run = 2 lumi = 1 time = 55000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 18 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 18 -++++++ starting: global end lumi for module: label = 'test' id = 19 -++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'testmerge' id = 20 ++++++ finished: global end lumi for module: label = 'testmerge' id = 20 +++++++ starting: global end lumi for module: label = 'test' id = 19 +++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'getInt' id = 22 ++++++ finished: global end lumi for module: label = 'getInt' id = 22 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 23 @@ -3994,10 +3994,10 @@ ++++ starting: global end lumi: run = 2 lumi = 2 time = 75000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 31 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 31 -++++++ starting: global end lumi for module: label = 'test' id = 32 -++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'testmerge' id = 33 ++++++ finished: global end lumi for module: label = 'testmerge' id = 33 +++++++ starting: global end lumi for module: label = 'test' id = 32 +++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'getInt' id = 35 ++++++ finished: global end lumi for module: label = 'getInt' id = 35 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 36 @@ -4007,10 +4007,10 @@ ++++ finished: global end lumi: run = 2 lumi = 2 time = 75000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 18 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 18 -++++++ starting: global end lumi for module: label = 'test' id = 19 -++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'testmerge' id = 20 ++++++ finished: global end lumi for module: label = 'testmerge' id = 20 +++++++ starting: global end lumi for module: label = 'test' id = 19 +++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'getInt' id = 22 ++++++ finished: global end lumi for module: label = 'getInt' id = 22 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 23 @@ -4452,10 +4452,10 @@ ++++ starting: global end lumi: run = 2 lumi = 3 time = 95000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 31 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 31 -++++++ starting: global end lumi for module: label = 'test' id = 32 -++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'testmerge' id = 33 ++++++ finished: global end lumi for module: label = 'testmerge' id = 33 +++++++ starting: global end lumi for module: label = 'test' id = 32 +++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'getInt' id = 35 ++++++ finished: global end lumi for module: label = 'getInt' id = 35 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 36 @@ -4465,10 +4465,10 @@ ++++ finished: global end lumi: run = 2 lumi = 3 time = 95000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 18 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 18 -++++++ starting: global end lumi for module: label = 'test' id = 19 -++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'testmerge' id = 20 ++++++ finished: global end lumi for module: label = 'testmerge' id = 20 +++++++ starting: global end lumi for module: label = 'test' id = 19 +++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'getInt' id = 22 ++++++ finished: global end lumi for module: label = 'getInt' id = 22 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 23 @@ -4518,10 +4518,10 @@ ++++ starting: global end run 2 : time = 0 ++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 31 ++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 31 -++++++ starting: global end run for module: label = 'test' id = 32 -++++++ finished: global end run for module: label = 'test' id = 32 ++++++ starting: global end run for module: label = 'testmerge' id = 33 ++++++ finished: global end run for module: label = 'testmerge' id = 33 +++++++ starting: global end run for module: label = 'test' id = 32 +++++++ finished: global end run for module: label = 'test' id = 32 ++++++ starting: global end run for module: label = 'getInt' id = 35 ++++++ finished: global end run for module: label = 'getInt' id = 35 ++++++ starting: global end run for module: label = 'dependsOnNoPut' id = 36 @@ -4531,10 +4531,10 @@ ++++ finished: global end run 2 : time = 0 ++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 18 ++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 18 -++++++ starting: global end run for module: label = 'test' id = 19 -++++++ finished: global end run for module: label = 'test' id = 19 ++++++ starting: global end run for module: label = 'testmerge' id = 20 ++++++ finished: global end run for module: label = 'testmerge' id = 20 +++++++ starting: global end run for module: label = 'test' id = 19 +++++++ finished: global end run for module: label = 'test' id = 19 ++++++ starting: global end run for module: label = 'getInt' id = 22 ++++++ finished: global end run for module: label = 'getInt' id = 22 ++++++ starting: global end run for module: label = 'dependsOnNoPut' id = 23 @@ -5368,10 +5368,10 @@ ++++ starting: global end lumi: run = 3 lumi = 1 time = 105000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 31 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 31 -++++++ starting: global end lumi for module: label = 'test' id = 32 -++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'testmerge' id = 33 ++++++ finished: global end lumi for module: label = 'testmerge' id = 33 +++++++ starting: global end lumi for module: label = 'test' id = 32 +++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'getInt' id = 35 ++++++ finished: global end lumi for module: label = 'getInt' id = 35 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 36 @@ -5381,10 +5381,10 @@ ++++ finished: global end lumi: run = 3 lumi = 1 time = 105000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 18 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 18 -++++++ starting: global end lumi for module: label = 'test' id = 19 -++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'testmerge' id = 20 ++++++ finished: global end lumi for module: label = 'testmerge' id = 20 +++++++ starting: global end lumi for module: label = 'test' id = 19 +++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'getInt' id = 22 ++++++ finished: global end lumi for module: label = 'getInt' id = 22 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 23 @@ -6150,10 +6150,10 @@ ++++ starting: global end lumi: run = 3 lumi = 2 time = 125000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 31 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 31 -++++++ starting: global end lumi for module: label = 'test' id = 32 -++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'testmerge' id = 33 ++++++ finished: global end lumi for module: label = 'testmerge' id = 33 +++++++ starting: global end lumi for module: label = 'test' id = 32 +++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'getInt' id = 35 ++++++ finished: global end lumi for module: label = 'getInt' id = 35 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 36 @@ -6163,10 +6163,10 @@ ++++ finished: global end lumi: run = 3 lumi = 2 time = 125000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 18 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 18 -++++++ starting: global end lumi for module: label = 'test' id = 19 -++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'testmerge' id = 20 ++++++ finished: global end lumi for module: label = 'testmerge' id = 20 +++++++ starting: global end lumi for module: label = 'test' id = 19 +++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'getInt' id = 22 ++++++ finished: global end lumi for module: label = 'getInt' id = 22 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 23 @@ -6608,10 +6608,10 @@ ++++ starting: global end lumi: run = 3 lumi = 3 time = 145000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 31 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 31 -++++++ starting: global end lumi for module: label = 'test' id = 32 -++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'testmerge' id = 33 ++++++ finished: global end lumi for module: label = 'testmerge' id = 33 +++++++ starting: global end lumi for module: label = 'test' id = 32 +++++++ finished: global end lumi for module: label = 'test' id = 32 ++++++ starting: global end lumi for module: label = 'getInt' id = 35 ++++++ finished: global end lumi for module: label = 'getInt' id = 35 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 36 @@ -6621,10 +6621,10 @@ ++++ finished: global end lumi: run = 3 lumi = 3 time = 145000001 ++++++ starting: global end lumi for module: label = 'thingWithMergeProducer' id = 18 ++++++ finished: global end lumi for module: label = 'thingWithMergeProducer' id = 18 -++++++ starting: global end lumi for module: label = 'test' id = 19 -++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'testmerge' id = 20 ++++++ finished: global end lumi for module: label = 'testmerge' id = 20 +++++++ starting: global end lumi for module: label = 'test' id = 19 +++++++ finished: global end lumi for module: label = 'test' id = 19 ++++++ starting: global end lumi for module: label = 'getInt' id = 22 ++++++ finished: global end lumi for module: label = 'getInt' id = 22 ++++++ starting: global end lumi for module: label = 'dependsOnNoPut' id = 23 @@ -6674,10 +6674,10 @@ ++++ starting: global end run 3 : time = 0 ++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 31 ++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 31 -++++++ starting: global end run for module: label = 'test' id = 32 -++++++ finished: global end run for module: label = 'test' id = 32 ++++++ starting: global end run for module: label = 'testmerge' id = 33 ++++++ finished: global end run for module: label = 'testmerge' id = 33 +++++++ starting: global end run for module: label = 'test' id = 32 +++++++ finished: global end run for module: label = 'test' id = 32 ++++++ starting: global end run for module: label = 'getInt' id = 35 ++++++ finished: global end run for module: label = 'getInt' id = 35 ++++++ starting: global end run for module: label = 'dependsOnNoPut' id = 36 @@ -6687,10 +6687,10 @@ ++++ finished: global end run 3 : time = 0 ++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 18 ++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 18 -++++++ starting: global end run for module: label = 'test' id = 19 -++++++ finished: global end run for module: label = 'test' id = 19 ++++++ starting: global end run for module: label = 'testmerge' id = 20 ++++++ finished: global end run for module: label = 'testmerge' id = 20 +++++++ starting: global end run for module: label = 'test' id = 19 +++++++ finished: global end run for module: label = 'test' id = 19 ++++++ starting: global end run for module: label = 'getInt' id = 22 ++++++ finished: global end run for module: label = 'getInt' id = 22 ++++++ starting: global end run for module: label = 'dependsOnNoPut' id = 23 From 6b2fca2cae3bed294a8962f282a95b83fbf7905e Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 3 Jan 2018 14:11:52 -0600 Subject: [PATCH 22/52] Added default move constructor --- FWCore/Framework/interface/WorkerManager.h | 1 + FWCore/Framework/src/WorkerRegistry.h | 3 ++- FWCore/Utilities/interface/Signal.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/FWCore/Framework/interface/WorkerManager.h b/FWCore/Framework/interface/WorkerManager.h index 5eb02a116e1ba..dd9adbb7b887f 100644 --- a/FWCore/Framework/interface/WorkerManager.h +++ b/FWCore/Framework/interface/WorkerManager.h @@ -32,6 +32,7 @@ namespace edm { typedef std::vector AllWorkers; WorkerManager(std::shared_ptr actReg, ExceptionToActionTable const& actions); + WorkerManager(WorkerManager&&) = default; WorkerManager(std::shared_ptr modReg, std::shared_ptr actReg, diff --git a/FWCore/Framework/src/WorkerRegistry.h b/FWCore/Framework/src/WorkerRegistry.h index dc17ffbf3c78e..de50ad05bb5e6 100644 --- a/FWCore/Framework/src/WorkerRegistry.h +++ b/FWCore/Framework/src/WorkerRegistry.h @@ -43,7 +43,8 @@ namespace edm { WorkerRegistry(std::shared_ptr areg, std::shared_ptr iModReg); ~WorkerRegistry(); - + + WorkerRegistry(WorkerRegistry&&) = default; WorkerRegistry(WorkerRegistry const&) = delete; // Disallow copying and moving WorkerRegistry& operator=(WorkerRegistry const&) = delete; // Disallow copying and moving diff --git a/FWCore/Utilities/interface/Signal.h b/FWCore/Utilities/interface/Signal.h index 3a0ae92cf7ddf..eff125cbe43c6 100644 --- a/FWCore/Utilities/interface/Signal.h +++ b/FWCore/Utilities/interface/Signal.h @@ -41,6 +41,7 @@ namespace edm { Signal() = default; ~Signal() = default; + Signal(Signal&&) = default; // ---------- const member functions --------------------- template From 533ffea5637001cdebb2c53a85196ff78729da04 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 3 Jan 2018 14:21:17 -0600 Subject: [PATCH 23/52] Use a WorkerManager per concurrent Lumi Each concurrent LuminosityBlock needs its own WorkerManager. For now, the Run uses WorkerManger 0. --- FWCore/Framework/src/GlobalSchedule.cc | 81 +++++++++++++++----------- FWCore/Framework/src/GlobalSchedule.h | 20 +++---- 2 files changed, 54 insertions(+), 47 deletions(-) diff --git a/FWCore/Framework/src/GlobalSchedule.cc b/FWCore/Framework/src/GlobalSchedule.cc index c922ef2e394bc..21a48403f2bc0 100644 --- a/FWCore/Framework/src/GlobalSchedule.cc +++ b/FWCore/Framework/src/GlobalSchedule.cc @@ -3,6 +3,7 @@ #include "FWCore/Framework/src/TriggerResultInserter.h" #include "FWCore/Framework/src/PathStatusInserter.h" #include "FWCore/Framework/src/EndPathStatusInserter.h" +#include "FWCore/Framework/src/PreallocationConfiguration.h" #include "DataFormats/Provenance/interface/ProcessConfiguration.h" #include "DataFormats/Provenance/interface/ProductRegistry.h" @@ -11,6 +12,7 @@ #include "FWCore/Utilities/interface/Algorithms.h" #include "FWCore/Utilities/interface/Exception.h" + #include #include #include @@ -30,10 +32,13 @@ namespace edm { std::shared_ptr areg, std::shared_ptr processConfiguration, ProcessContext const* processContext) : - workerManager_(modReg,areg,actions), actReg_(areg), processContext_(processContext) { + workerManagers_.reserve(prealloc.numberOfLuminosityBlocks()); + for(unsigned int i = 0; i(inserter, inserter->moduleDescription(), &actions)); // propagate_const has no reset() function inserter->doPreallocate(prealloc); - results_inserter_->setActivityRegistry(actReg_); - addToAllWorkers(results_inserter_.get()); + for(auto& wm: workerManagers_) { + auto results_inserter = WorkerPtr(new edm::WorkerT(inserter, inserter->moduleDescription(), &actions)); // propagate_const has no reset() function + results_inserter->setActivityRegistry(actReg_); + wm.addToAllWorkers(results_inserter.get()); + extraWorkers_.emplace_back(std::move(results_inserter)); + } } for(auto & pathStatusInserter : pathStatusInserters) { std::shared_ptr inserterPtr = get_underlying(pathStatusInserter); - WorkerPtr workerPtr(new edm::WorkerT(inserterPtr, - inserterPtr->moduleDescription(), - &actions)); - pathStatusInserterWorkers_.emplace_back(workerPtr); inserterPtr->doPreallocate(prealloc); - workerPtr->setActivityRegistry(actReg_); - addToAllWorkers(workerPtr.get()); + + for(auto& wm: workerManagers_) { + WorkerPtr workerPtr(new edm::WorkerT(inserterPtr, + inserterPtr->moduleDescription(), + &actions)); + workerPtr->setActivityRegistry(actReg_); + wm.addToAllWorkers(workerPtr.get()); + extraWorkers_.emplace_back(std::move(workerPtr)); + } } for(auto & endPathStatusInserter : endPathStatusInserters) { std::shared_ptr inserterPtr = get_underlying(endPathStatusInserter); - WorkerPtr workerPtr(new edm::WorkerT(inserterPtr, - inserterPtr->moduleDescription(), - &actions)); - endPathStatusInserterWorkers_.emplace_back(workerPtr); inserterPtr->doPreallocate(prealloc); - workerPtr->setActivityRegistry(actReg_); - addToAllWorkers(workerPtr.get()); + for(auto& wm: workerManagers_) { + WorkerPtr workerPtr(new edm::WorkerT(inserterPtr, + inserterPtr->moduleDescription(), + &actions)); + workerPtr->setActivityRegistry(actReg_); + wm.addToAllWorkers(workerPtr.get()); + extraWorkers_.emplace_back(std::move(workerPtr)); + } } } // GlobalSchedule::GlobalSchedule void GlobalSchedule::endJob(ExceptionCollector & collector) { - workerManager_.endJob(collector); + workerManagers_[0].endJob(collector); } void GlobalSchedule::beginJob(ProductRegistry const& iRegistry) { - workerManager_.beginJob(iRegistry); + workerManagers_[0].beginJob(iRegistry); } void GlobalSchedule::replaceModule(maker::ModuleHolder* iMod, std::string const& iLabel) { Worker* found = nullptr; - for (auto const& worker : allWorkers()) { - if (worker->description().moduleLabel() == iLabel) { - found = worker; - break; + for(auto& wm: workerManagers_) { + for (auto const& worker : wm.allWorkers()) { + if (worker->description().moduleLabel() == iLabel) { + found = worker; + break; + } } + if (nullptr == found) { + return; + } + + iMod->replaceModuleFor(found); + found->beginJob(); } - if (nullptr == found) { - return; - } - - iMod->replaceModuleFor(found); - found->beginJob(); } std::vector @@ -112,10 +129,4 @@ namespace edm { } return result; } - - void - GlobalSchedule::addToAllWorkers(Worker* w) { - workerManager_.addToAllWorkers(w); - } - } diff --git a/FWCore/Framework/src/GlobalSchedule.h b/FWCore/Framework/src/GlobalSchedule.h index 969a7cb755195..3c90fd9366b5c 100644 --- a/FWCore/Framework/src/GlobalSchedule.h +++ b/FWCore/Framework/src/GlobalSchedule.h @@ -122,7 +122,7 @@ namespace edm { /// returns the collection of pointers to workers AllWorkers const& allWorkers() const { - return workerManager_.allWorkers(); + return workerManagers_[0].allWorkers(); } private: @@ -150,17 +150,12 @@ namespace edm { /// returns the action table ExceptionToActionTable const& actionTable() const { - return workerManager_.actionTable(); + return workerManagers_[0].actionTable(); } - void addToAllWorkers(Worker* w); - - WorkerManager workerManager_; + std::vector workerManagers_; std::shared_ptr actReg_; // We do not use propagate_const because the registry itself is mutable. - edm::propagate_const results_inserter_; - std::vector> pathStatusInserterWorkers_; - std::vector> endPathStatusInserterWorkers_; - + std::vector> extraWorkers_; ProcessContext const* processContext_; }; @@ -217,16 +212,17 @@ namespace edm { iHolder.doneWaiting(excpt); }); - workerManager_.resetAll(); + workerManagers_[ep.index()].resetAll(); ParentContext parentContext(globalContext.get()); //make sure the ProductResolvers know about their // workers to allow proper data dependency handling - workerManager_.setupOnDemandSystem(ep,es); + workerManagers_[ep.index()].setupOnDemandSystem(ep,es); //make sure the task doesn't get run until all workers have beens started WaitingTaskHolder holdForLoop(doneTask); - for(auto& worker: boost::adaptors::reverse((allWorkers()))) { + auto& aw = workerManagers_[ep.index()].allWorkers(); + for(Worker* worker: boost::adaptors::reverse(aw) ) { worker->doWorkAsync(doneTask,ep,es,StreamID::invalidStreamID(),parentContext,globalContext.get()); } From 0eee573f63cdf3ed332a98e0b59d8c3465bd5b51 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 9 Jan 2018 16:42:30 -0600 Subject: [PATCH 24/52] Removed end transitions from InputSource API Removed endRun and endLumi callbacks from InputSource to avoid unwanted synchronization at those boundaries. --- FWCore/Framework/interface/InputSource.h | 6 ---- FWCore/Framework/src/EventProcessor.cc | 12 +------ FWCore/Framework/src/InputSource.cc | 8 ----- FWCore/Integration/test/ThingExtSource.cc | 8 +++-- FWCore/Integration/test/ThingExtSource.h | 17 +++++----- FWCore/Integration/test/ThingSource.cc | 8 +++-- FWCore/Integration/test/ThingSource.h | 17 +++++----- FWCore/Integration/test/ThrowingSource.cc | 34 ++++++------------- FWCore/Sources/interface/PuttableSourceBase.h | 4 --- FWCore/Sources/src/PuttableSourceBase.cc | 24 ------------- 10 files changed, 42 insertions(+), 96 deletions(-) diff --git a/FWCore/Framework/interface/InputSource.h b/FWCore/Framework/interface/InputSource.h index 64796be6a0326..c14c4f8594652 100644 --- a/FWCore/Framework/interface/InputSource.h +++ b/FWCore/Framework/interface/InputSource.h @@ -217,15 +217,9 @@ namespace edm { /// Called by framework at beginning of lumi block virtual void doBeginLumi(LuminosityBlockPrincipal& lbp, ProcessContext const*); - /// Called by framework at end of lumi block - virtual void doEndLumi(LuminosityBlockPrincipal& lbp, bool cleaningUpAfterException, ProcessContext const*); - /// Called by framework at beginning of run virtual void doBeginRun(RunPrincipal& rp, ProcessContext const*); - /// Called by framework at end of run - virtual void doEndRun(RunPrincipal& rp, bool cleaningUpAfterException, ProcessContext const*); - /// Accessor for the current time, as seen by the input source Timestamp const& timestamp() const {return time_;} diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index fdab5f82d4fc2..6bc2422efa476 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1016,13 +1016,7 @@ namespace edm { void EventProcessor::endRun(ProcessHistoryID const& phid, RunNumber_t run, bool globalBeginSucceeded, bool cleaningUpAfterException) { RunPrincipal& runPrincipal = principalCache_.runPrincipal(phid, run); - { - SendSourceTerminationSignalIfException sentry(actReg_.get()); - - runPrincipal.setEndTime(input_->timestamp()); - input_->doEndRun(runPrincipal, cleaningUpAfterException, &processContext_); - sentry.completedSuccessfully(); - } + runPrincipal.setEndTime(input_->timestamp()); IOVSyncValue ts(EventID(runPrincipal.run(), LuminosityBlockID::maxLuminosityBlockNumber(), EventID::maxEventNumber()), runPrincipal.endTime()); @@ -1201,11 +1195,7 @@ namespace edm { std::unique_ptr guard(&iovQueue_, dtr); { - SendSourceTerminationSignalIfException sentry(actReg_.get()); - lumiPrincipal.setEndTime(input_->timestamp()); - input_->doEndLumi(lumiPrincipal, cleaningUpAfterException, &processContext_); - sentry.completedSuccessfully(); } //NOTE: Using the max event number for the end of a lumi block is a bad idea // lumi blocks know their start and end times why not also start and end events? diff --git a/FWCore/Framework/src/InputSource.cc b/FWCore/Framework/src/InputSource.cc index e680f77f25188..7f3271aee5734 100644 --- a/FWCore/Framework/src/InputSource.cc +++ b/FWCore/Framework/src/InputSource.cc @@ -443,18 +443,10 @@ namespace edm { InputSource::doBeginRun(RunPrincipal& rp, ProcessContext const* ) { } - void - InputSource::doEndRun(RunPrincipal& rp, bool cleaningUpAfterException, ProcessContext const* ) { - } - void InputSource::doBeginLumi(LuminosityBlockPrincipal& lbp, ProcessContext const* ) { } - void - InputSource::doEndLumi(LuminosityBlockPrincipal& lbp, bool cleaningUpAfterException, ProcessContext const* ) { - } - bool InputSource::randomAccess() const { return callWithTryCatchAndPrint( [this](){ return randomAccess_(); }, diff --git a/FWCore/Integration/test/ThingExtSource.cc b/FWCore/Integration/test/ThingExtSource.cc index 3adfe292e768c..7f7f3e3c35f72 100644 --- a/FWCore/Integration/test/ThingExtSource.cc +++ b/FWCore/Integration/test/ThingExtSource.cc @@ -10,9 +10,9 @@ namespace edmtest { ProducerSourceFromFiles(pset, desc, true), alg_() { produces(); produces("beginLumi"); - produces("endLumi"); + produces("endLumi"); produces("beginRun"); - produces("endRun"); + produces("endRun"); } // Virtual destructor needed. @@ -51,6 +51,8 @@ namespace edmtest { // Step D: Put outputs into lumi block lb.put(std::move(result), "beginLumi"); + + endLuminosityBlock(lb); } void ThingExtSource::endLuminosityBlock(edm::LuminosityBlock& lb) { @@ -78,6 +80,8 @@ namespace edmtest { // Step D: Put outputs into event r.put(std::move(result), "beginRun"); + + endRun(r); } void ThingExtSource::endRun(edm::Run& r) { diff --git a/FWCore/Integration/test/ThingExtSource.h b/FWCore/Integration/test/ThingExtSource.h index 895e9adcfcd50..f44cbb79db64b 100644 --- a/FWCore/Integration/test/ThingExtSource.h +++ b/FWCore/Integration/test/ThingExtSource.h @@ -21,21 +21,22 @@ namespace edmtest { // explicit ThingExtSource(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc); - virtual ~ThingExtSource(); + ~ThingExtSource() override; - virtual bool setRunAndEventInfo(edm::EventID&, edm::TimeValue_t&, edm::EventAuxiliary::ExperimentType&); + bool setRunAndEventInfo(edm::EventID&, edm::TimeValue_t&, edm::EventAuxiliary::ExperimentType&) override; - virtual void produce(edm::Event& e); + void produce(edm::Event& e) override; - virtual void beginRun(edm::Run& r); + void beginRun(edm::Run& r) override; - virtual void endRun(edm::Run& r); + void beginLuminosityBlock(edm::LuminosityBlock& lb) override; - virtual void beginLuminosityBlock(edm::LuminosityBlock& lb); - - virtual void endLuminosityBlock(edm::LuminosityBlock& lb); private: + //Not called by the framework, only used internally + void endRun(edm::Run& r); + void endLuminosityBlock(edm::LuminosityBlock& lb); + ThingAlgorithm alg_; }; } diff --git a/FWCore/Integration/test/ThingSource.cc b/FWCore/Integration/test/ThingSource.cc index 9d0cba957fbd9..51fbe017e4a74 100644 --- a/FWCore/Integration/test/ThingSource.cc +++ b/FWCore/Integration/test/ThingSource.cc @@ -10,9 +10,9 @@ namespace edmtest { ProducerSourceBase(pset, desc, false), alg_() { produces(); produces("beginLumi"); - produces("endLumi"); + produces("endLumi"); produces("beginRun"); - produces("endRun"); + produces("endRun"); } // Virtual destructor needed. @@ -44,6 +44,8 @@ namespace edmtest { // Step D: Put outputs into lumi block lb.put(std::move(result), "beginLumi"); + + endLuminosityBlock(lb); } void ThingSource::endLuminosityBlock(edm::LuminosityBlock& lb) { @@ -71,6 +73,8 @@ namespace edmtest { // Step D: Put outputs into event r.put(std::move(result), "beginRun"); + + endRun(r); } void ThingSource::endRun(edm::Run& r) { diff --git a/FWCore/Integration/test/ThingSource.h b/FWCore/Integration/test/ThingSource.h index fcbc4317cbd73..b34aa1a55572a 100644 --- a/FWCore/Integration/test/ThingSource.h +++ b/FWCore/Integration/test/ThingSource.h @@ -21,21 +21,22 @@ namespace edmtest { // explicit ThingSource(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc); - virtual ~ThingSource(); + ~ThingSource() override; - virtual bool setRunAndEventInfo(edm::EventID&, edm::TimeValue_t&, edm::EventAuxiliary::ExperimentType&) {return true;} + bool setRunAndEventInfo(edm::EventID&, edm::TimeValue_t&, edm::EventAuxiliary::ExperimentType&) override {return true;} - virtual void produce(edm::Event& e); + void produce(edm::Event& e) override; - virtual void beginRun(edm::Run& r); + void beginRun(edm::Run& r) override; - virtual void endRun(edm::Run& r); + void beginLuminosityBlock(edm::LuminosityBlock& lb) override; - virtual void beginLuminosityBlock(edm::LuminosityBlock& lb); - - virtual void endLuminosityBlock(edm::LuminosityBlock& lb); private: + //called internally, not by the framework + void endRun(edm::Run& r); + void endLuminosityBlock(edm::LuminosityBlock& lb); + ThingAlgorithm alg_; }; } diff --git a/FWCore/Integration/test/ThrowingSource.cc b/FWCore/Integration/test/ThrowingSource.cc index 6da4a2c890528..ec6ff28a399a6 100644 --- a/FWCore/Integration/test/ThrowingSource.cc +++ b/FWCore/Integration/test/ThrowingSource.cc @@ -12,17 +12,15 @@ namespace edm { explicit ThrowingSource(ParameterSet const&, InputSourceDescription const&); ~ThrowingSource() noexcept(false) ; - virtual void beginJob(); - virtual void endJob(); - virtual void beginLuminosityBlock(edm::LuminosityBlock&); - virtual void endLuminosityBlock(edm::LuminosityBlock&); - virtual void beginRun(edm::Run&); - virtual void endRun(edm::Run&); - virtual std::unique_ptr readFile_(); - virtual void closeFile_(); - virtual std::shared_ptr readRunAuxiliary_(); - virtual std::shared_ptr readLuminosityBlockAuxiliary_(); - virtual void readEvent_(edm::EventPrincipal&); + void beginJob() override; + void endJob() override; + void beginLuminosityBlock(edm::LuminosityBlock&) override; + void beginRun(edm::Run&) override; + std::unique_ptr readFile_() override; + void closeFile_() override; + std::shared_ptr readRunAuxiliary_() override; + std::shared_ptr readLuminosityBlockAuxiliary_() override; + void readEvent_(edm::EventPrincipal&) override; private: enum { kDoNotThrow = 0, @@ -41,8 +39,8 @@ namespace edm { kCloseFile = 13, kDestructor = 14 }; - virtual bool setRunAndEventInfo(EventID& id, TimeValue_t& time, edm::EventAuxiliary::ExperimentType& eType); - virtual void produce(Event &); + bool setRunAndEventInfo(EventID& id, TimeValue_t& time, edm::EventAuxiliary::ExperimentType& eType) override; + void produce(Event &) override; // To test exception throws from sources int whenToThrow_; @@ -83,21 +81,11 @@ namespace edm { if (whenToThrow_ == kBeginLumi) throw cms::Exception("TestThrow") << "ThrowingSource::beginLuminosityBlock"; } - void - ThrowingSource::endLuminosityBlock(LuminosityBlock& lb) { - if (whenToThrow_ == kEndLumi) throw cms::Exception("TestThrow") << "ThrowingSource::endLuminosityBlock"; - } - void ThrowingSource::beginRun(Run& run) { if (whenToThrow_ == kBeginRun) throw cms::Exception("TestThrow") << "ThrowingSource::beginRun"; } - void - ThrowingSource::endRun(Run& run) { - if (whenToThrow_ == kEndRun) throw cms::Exception("TestThrow") << "ThrowingSource::endRun"; - } - std::unique_ptr ThrowingSource::readFile_() { if (whenToThrow_ == kReadFile) throw cms::Exception("TestThrow") << "ThrowingSource::readFile_"; diff --git a/FWCore/Sources/interface/PuttableSourceBase.h b/FWCore/Sources/interface/PuttableSourceBase.h index 4d0edc20c1a35..8352dcaf184b8 100644 --- a/FWCore/Sources/interface/PuttableSourceBase.h +++ b/FWCore/Sources/interface/PuttableSourceBase.h @@ -47,15 +47,11 @@ namespace edm { void beginJob() override; private: void doBeginLumi(LuminosityBlockPrincipal& lbp, ProcessContext const*) override; - void doEndLumi(LuminosityBlockPrincipal& lbp, bool cleaningUpAfterException, ProcessContext const*) override; void doBeginRun(RunPrincipal& rp, ProcessContext const*) override; - void doEndRun(RunPrincipal& rp, bool cleaningUpAfterException, ProcessContext const*) override; virtual void beginRun(Run&); - virtual void endRun(Run&); virtual void beginLuminosityBlock(LuminosityBlock&); - virtual void endLuminosityBlock(LuminosityBlock&); PuttableSourceBase(const PuttableSourceBase&) = delete; diff --git a/FWCore/Sources/src/PuttableSourceBase.cc b/FWCore/Sources/src/PuttableSourceBase.cc index 9d9110800f7f5..7a79070768061 100644 --- a/FWCore/Sources/src/PuttableSourceBase.cc +++ b/FWCore/Sources/src/PuttableSourceBase.cc @@ -70,14 +70,6 @@ PuttableSourceBase::doBeginRun(RunPrincipal& rp, ProcessContext const* ) { commit_(run); } -void -PuttableSourceBase::doEndRun(RunPrincipal& rp, bool cleaningUpAfterException, ProcessContext const* ) { - Run run(rp, moduleDescription(), nullptr, true); - run.setProducer(this); - callWithTryCatchAndPrint( [this,&run](){ endRun(run); }, "Calling Source::endRun", cleaningUpAfterException ); - commit_(run); -} - void PuttableSourceBase::doBeginLumi(LuminosityBlockPrincipal& lbp, ProcessContext const* ) { LuminosityBlock lb(lbp, moduleDescription(), nullptr, false); @@ -86,28 +78,12 @@ PuttableSourceBase::doBeginLumi(LuminosityBlockPrincipal& lbp, ProcessContext co commit_(lb); } -void -PuttableSourceBase::doEndLumi(LuminosityBlockPrincipal& lbp, bool cleaningUpAfterException, ProcessContext const* ) { - LuminosityBlock lb(lbp, moduleDescription(), nullptr, true); - lb.setProducer(this); - callWithTryCatchAndPrint( [this,&lb](){ endLuminosityBlock(lb); }, "Calling Source::endLuminosityBlock", cleaningUpAfterException ); - commit_(lb); -} - void PuttableSourceBase::beginRun(Run&) { } -void -PuttableSourceBase::endRun(Run&) { -} - void PuttableSourceBase::beginLuminosityBlock(LuminosityBlock&) { } -void -PuttableSourceBase::endLuminosityBlock(LuminosityBlock&) { -} - From e6cf1566cc33f5178f2ab7b449344b6e0ad4a549 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 9 Jan 2018 17:10:45 -0600 Subject: [PATCH 25/52] Added EventProcessor::globalEndLumiAsync --- FWCore/Framework/interface/EventProcessor.h | 1 + FWCore/Framework/src/EventProcessor.cc | 123 +++++++++++--------- 2 files changed, 71 insertions(+), 53 deletions(-) diff --git a/FWCore/Framework/interface/EventProcessor.h b/FWCore/Framework/interface/EventProcessor.h index 49dfcb657bac1..141f700a05b0c 100644 --- a/FWCore/Framework/interface/EventProcessor.h +++ b/FWCore/Framework/interface/EventProcessor.h @@ -210,6 +210,7 @@ namespace edm { void beginLumi(std::shared_ptr& status); void beginLumiAsync(edm::WaitingTaskHolder iHolder, std::shared_ptr& oStatus); void endLumi(std::shared_ptr status); + void globalEndLumiAsync(edm::WaitingTaskHolder iTask, std::shared_ptr iLumiStatus); std::pair readRun(); std::pair readAndMergeRun(); diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 6bc2422efa476..585a0bf6666c7 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1186,69 +1186,86 @@ namespace edm { }); } + void EventProcessor::globalEndLumiAsync(edm::WaitingTaskHolder iTask, std::shared_ptr iLumiStatus) { + auto t = edm::make_waiting_task(tbb::task::allocate_root(), [t = std::move(iTask), status = iLumiStatus, this] (std::exception_ptr const* iPtr) mutable { + std::exception_ptr ptr; + if(iPtr) { + ptr = *iPtr; + } else { + if(looper_) { + auto& lp = *(status->lumiPrincipal()); + EventSetup const& es = esp_->eventSetup(); + looper_->doEndLuminosityBlock(lp, es, &processContext_); + } + } + t.doneWaiting(ptr); + //release our hold on the IOV + iovQueue_.resume(); + status->resumeGlobalLumiQueue(); + }); + + auto& lp = *(iLumiStatus->lumiPrincipal()); + + IOVSyncValue ts(EventID(lp.run(), lp.luminosityBlock(), EventID::maxEventNumber()), + lp.beginTime()); + + + typedef OccurrenceTraits Traits; + EventSetup const& es = esp_->eventSetup(); + + endGlobalTransitionAsync(WaitingTaskHolder(t), + *schedule_, + lp, + ts, + es, + subProcesses_, + iLumiStatus->cleaningUpAfterException()); + } + void EventProcessor::endLumi(std::shared_ptr status) { bool cleaningUpAfterException = status->cleaningUpAfterException(); LuminosityBlockPrincipal& lumiPrincipal = *status-> lumiPrincipal(); + lumiPrincipal.setEndTime(input_->timestamp()); - //need to release the IOV - auto dtr = [](SerialTaskQueue* iQueue) { iQueue->resume();}; - std::unique_ptr guard(&iovQueue_, dtr); - - { - lumiPrincipal.setEndTime(input_->timestamp()); - } - //NOTE: Using the max event number for the end of a lumi block is a bad idea - // lumi blocks know their start and end times why not also start and end events? - IOVSyncValue ts(EventID(lumiPrincipal.run(), lumiPrincipal.luminosityBlock(), EventID::maxEventNumber()), - lumiPrincipal.endTime()); + auto globalWaitTask = make_empty_waiting_task(); + globalWaitTask->increment_ref_count(); + + auto globalEndTask = edm::make_waiting_task(tbb::task::allocate_root(), + [this, + waitTask=WaitingTaskHolder(globalWaitTask.get()), + status](std::exception_ptr const* iPtr) { - SendSourceTerminationSignalIfException sentry(actReg_.get()); - espController_->eventSetupForInstance(ts); - sentry.completedSuccessfully(); - } - EventSetup const& es = esp_->eventSetup(); - if(status->didGlobalBeginSucceed()){ - //To wait, the ref count has to b 1+#streams - auto streamLoopWaitTask = make_empty_waiting_task(); - streamLoopWaitTask->increment_ref_count(); - - typedef OccurrenceTraits Traits; - - endStreamsTransitionAsync(streamLoopWaitTask.get(), - *schedule_, - preallocations_.numberOfStreams(), - lumiPrincipal, - ts, - es, - subProcesses_, - cleaningUpAfterException); - streamLoopWaitTask->wait_for_all(); - if(streamLoopWaitTask->exceptionPtr() != nullptr) { - std::rethrow_exception(* (streamLoopWaitTask->exceptionPtr()) ); + if(iPtr) { + WaitingTaskHolder t(waitTask); + t.doneWaiting(*iPtr); } - } - if(looper_) { - //looper_->doStreamEndLuminosityBlock(schedule_->streamID(),lumiPrincipal, es); - } + globalEndLumiAsync(std::move(waitTask), std::move(status)); + }); + { - auto globalWaitTask = make_empty_waiting_task(); - globalWaitTask->increment_ref_count(); + WaitingTaskHolder globalTaskHolder{globalEndTask}; + + //NOTE: Using the max event number for the end of a lumi block is a bad idea + // lumi blocks know their start and end times why not also start and end events? + IOVSyncValue ts(EventID(lumiPrincipal.run(), lumiPrincipal.luminosityBlock(), EventID::maxEventNumber()), + lumiPrincipal.endTime()); + EventSetup const& es = esp_->eventSetup(); + if(status->didGlobalBeginSucceed()){ + typedef OccurrenceTraits Traits; - typedef OccurrenceTraits Traits; - endGlobalTransitionAsync(WaitingTaskHolder(globalWaitTask.get()), - *schedule_, - lumiPrincipal, - ts, - es, - subProcesses_, - cleaningUpAfterException); - globalWaitTask->wait_for_all(); - if(globalWaitTask->exceptionPtr() != nullptr) { - std::rethrow_exception(* (globalWaitTask->exceptionPtr()) ); + endStreamsTransitionAsync(globalEndTask, + *schedule_, + preallocations_.numberOfStreams(), + lumiPrincipal, + ts, + es, + subProcesses_, + cleaningUpAfterException); } } - if(looper_) { - looper_->doEndLuminosityBlock(lumiPrincipal, es, &processContext_); + globalWaitTask->wait_for_all(); + if(globalWaitTask->exceptionPtr() != nullptr) { + std::rethrow_exception(* (globalWaitTask->exceptionPtr()) ); } } From 53d88dc34aa204f7958bd42b85c393668cc36e61 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 10 Jan 2018 15:08:01 -0600 Subject: [PATCH 26/52] Removed lumiAsync methods from StreamSchedule The LuminosityBlock specific processing will be handled by the EventProcessor, not the StreamSchedule. --- FWCore/Framework/src/StreamSchedule.cc | 12 ------------ FWCore/Framework/src/StreamSchedule.h | 11 ----------- 2 files changed, 23 deletions(-) diff --git a/FWCore/Framework/src/StreamSchedule.cc b/FWCore/Framework/src/StreamSchedule.cc index 9a7ed43701ac3..ea7af6461cabf 100644 --- a/FWCore/Framework/src/StreamSchedule.cc +++ b/FWCore/Framework/src/StreamSchedule.cc @@ -714,18 +714,6 @@ namespace edm { return iExcept; } - void - StreamSchedule::processOneBeginLumiAsync(WaitingTaskHolder iTask, - std::shared_ptr iLumiStatus, - EventSetup const& eventSetup) { - lumiStatus_ = std::move(iLumiStatus); - using Traits = OccurrenceTraits; - processOneStreamAsync(std::move(iTask), *(lumiStatus_->lumiPrincipal()), eventSetup); - } - void - StreamSchedule::processOneEndLumiAsync(WaitingTaskHolder iTask, bool cleaningUpAfterException) {} - - void StreamSchedule::availablePaths(std::vector& oLabelsToFill) const { oLabelsToFill.reserve(trig_paths_.size()); diff --git a/FWCore/Framework/src/StreamSchedule.h b/FWCore/Framework/src/StreamSchedule.h index 48d20efe26231..bf42b3eaa9a9f 100644 --- a/FWCore/Framework/src/StreamSchedule.h +++ b/FWCore/Framework/src/StreamSchedule.h @@ -111,7 +111,6 @@ namespace edm { class EndPathStatusInserter; class PreallocationConfiguration; class WaitingTaskHolder; - class LuminosityBlockProcessingStatus; namespace service { class TriggerNamesService; @@ -188,14 +187,6 @@ namespace edm { EventSetup const& eventSetup, bool cleaningUpAfterException = false); - //Handle LuminosityBlocks - void processOneBeginLumiAsync(WaitingTaskHolder iTask, - std::shared_ptr, - EventSetup const& eventSetup); - void processOneEndLumiAsync(WaitingTaskHolder iTask, bool cleaningUpAfterException); - - std::shared_ptr activeLuminosityBlockProcessingStatus() { return lumiStatus_;} - void beginStream(); void endStream(); @@ -346,8 +337,6 @@ namespace edm { WorkerManager workerManager_; std::shared_ptr actReg_; // We do not use propagate_const because the registry itself is mutable. - std::shared_ptr lumiStatus_; - edm::propagate_const results_; edm::propagate_const results_inserter_; From 107e11f660e0781e9a6b578be096de08111b084a Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 10 Jan 2018 15:15:13 -0600 Subject: [PATCH 27/52] Lumi end time determined by LuminosityBlockProcessingStatus The LuminosityBlockProcessingStatus now sees all the times for each Event in a LuminosityBlock and keeps only the largest time. This is then used to set the end time for the LuminosityBlock and the endLumi transition. --- FWCore/Framework/interface/EventProcessor.h | 1 + FWCore/Framework/src/EventProcessor.cc | 10 +++++++--- FWCore/Framework/src/LuminosityBlockProcessingStatus.h | 7 +++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/FWCore/Framework/interface/EventProcessor.h b/FWCore/Framework/interface/EventProcessor.h index 141f700a05b0c..64560d59acfb5 100644 --- a/FWCore/Framework/interface/EventProcessor.h +++ b/FWCore/Framework/interface/EventProcessor.h @@ -294,6 +294,7 @@ namespace edm { edm::propagate_const> schedule_; std::vector streamQueues_; std::unique_ptr lumiQueue_; + std::vector> streamLumiStatus_; std::vector subProcesses_; edm::propagate_const> historyAppender_; diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 585a0bf6666c7..516898bd6e8c9 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -496,6 +496,7 @@ namespace edm { lumiQueue_ = std::make_unique(nConcurrentLumis); streamQueues_.resize(nStreams); + streamLumiStatus_.resize(nStreams); // initialize the input source input_ = makeInput(*parameterSet, @@ -1135,6 +1136,7 @@ namespace edm { for(unsigned int i=0; ilumiPrincipal(); event.setLuminosityBlockPrincipal(lp); beginStreamTransitionAsync(holder, *schedule_,i,*lp,ts,es,subProcesses_); @@ -1224,8 +1226,8 @@ namespace edm { void EventProcessor::endLumi(std::shared_ptr status) { bool cleaningUpAfterException = status->cleaningUpAfterException(); - LuminosityBlockPrincipal& lumiPrincipal = *status-> lumiPrincipal(); - lumiPrincipal.setEndTime(input_->timestamp()); + LuminosityBlockPrincipal& lumiPrincipal = *status->lumiPrincipal(); + lumiPrincipal.setEndTime(status->lastTimestamp()); auto globalWaitTask = make_empty_waiting_task(); globalWaitTask->increment_ref_count(); @@ -1235,6 +1237,7 @@ namespace edm { waitTask=WaitingTaskHolder(globalWaitTask.get()), status](std::exception_ptr const* iPtr) { + for(auto & s: streamLumiStatus_) { s.reset();} if(iPtr) { WaitingTaskHolder t(waitTask); t.doneWaiting(*iPtr); @@ -1252,7 +1255,6 @@ namespace edm { EventSetup const& es = esp_->eventSetup(); if(status->didGlobalBeginSucceed()){ typedef OccurrenceTraits Traits; - endStreamsTransitionAsync(globalEndTask, *schedule_, preallocations_.numberOfStreams(), @@ -1491,6 +1493,8 @@ namespace edm { SendSourceTerminationSignalIfException sentry(actReg_.get()); input_->readEvent(event, streamContext); + + streamLumiStatus_[iStreamIndex]->updateLastTimestamp(input_->timestamp()); sentry.completedSuccessfully(); FDEBUG(1) << "\treadEvent\n"; diff --git a/FWCore/Framework/src/LuminosityBlockProcessingStatus.h b/FWCore/Framework/src/LuminosityBlockProcessingStatus.h index 3b4ee41ddd279..6dde492a78d28 100644 --- a/FWCore/Framework/src/LuminosityBlockProcessingStatus.h +++ b/FWCore/Framework/src/LuminosityBlockProcessingStatus.h @@ -74,12 +74,19 @@ class LuminosityBlockProcessingStatus void noExceptionHappened() { cleaningUpAfterException_ = false; } bool cleaningUpAfterException() const { return cleaningUpAfterException_;} + + //These should only be called while in the InputSource's task queue + void updateLastTimestamp( edm::Timestamp const& iTime) { + if (iTime> endTime_) { endTime_ = iTime;} + } + edm::Timestamp const& lastTimestamp() const { return endTime_;} private: // ---------- member data -------------------------------- std::shared_ptr lumiPrincipal_; LimitedTaskQueue::Resumer globalLumiQueueResumer_; EventProcessor* eventProcessor_ = nullptr; std::atomic nStreamsStillProcessingLumi_{0}; //read/write as streams finish lumi so must be atomic + edm::Timestamp endTime_{}; bool stopProcessingEvents_{false}; //read/write in m_sourceQueue OR from main thread when no tasks running bool lumiEnding_{false}; //read/write in m_sourceQueue NOTE: This is a useful cache instead of recalculating each call bool continuingLumi_{false}; //read/write in m_sourceQueue OR from main thread when no tasks running From e8cd880b760f07e79e82539233197c2de0d898e7 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 11 Jan 2018 11:13:39 -0600 Subject: [PATCH 28/52] Added LuminosityBlockProcessingStatus::setEndTime Added a thread-safe function to call setEndTime on LuminosityBlockPrincipal only once. --- .../src/LuminosityBlockProcessingStatus.cc | 33 +++++++++++++++++++ .../src/LuminosityBlockProcessingStatus.h | 9 ++--- 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 FWCore/Framework/src/LuminosityBlockProcessingStatus.cc diff --git a/FWCore/Framework/src/LuminosityBlockProcessingStatus.cc b/FWCore/Framework/src/LuminosityBlockProcessingStatus.cc new file mode 100644 index 0000000000000..99a4eaae45cf2 --- /dev/null +++ b/FWCore/Framework/src/LuminosityBlockProcessingStatus.cc @@ -0,0 +1,33 @@ +// -*- C++ -*- +// +// Package: FWCore/Framework +// Class : LuminosityBlockProcessingStatus +// +// Implementation: +// [Notes on implementation] +// +// Original Author: Chris Jones +// Created: Thu, 11 Jan 2018 16:41:46 GMT +// + +// system include files + +// user include files +#include "LuminosityBlockProcessingStatus.h" +#include "FWCore/Framework/interface/LuminosityBlockPrincipal.h" + +namespace edm { + void LuminosityBlockProcessingStatus::setEndTime() { + if(2 != endTimeSetStatus_) { + //not already set + char expected = 0; + if(endTimeSetStatus_.compare_exchange_strong(expected,1)) { + lumiPrincipal_->setEndTime(endTime_); + endTimeSetStatus_.store(2); + } else { + //wait until time is set + while( 2 != endTimeSetStatus_.load()) {} + } + } + } +} diff --git a/FWCore/Framework/src/LuminosityBlockProcessingStatus.h b/FWCore/Framework/src/LuminosityBlockProcessingStatus.h index 6dde492a78d28..a91a9a8ad4a6a 100644 --- a/FWCore/Framework/src/LuminosityBlockProcessingStatus.h +++ b/FWCore/Framework/src/LuminosityBlockProcessingStatus.h @@ -24,6 +24,7 @@ // user include files #include "FWCore/Concurrency/interface/LimitedTaskQueue.h" +#include "DataFormats/Provenance/interface/Timestamp.h" // forward declarations namespace edm { @@ -32,16 +33,12 @@ namespace edm { class LuminosityBlockPrincipal; class WaitingTaskHolder; class LuminosityBlockProcessingStatus; - void globalEndLumiAsync(edm::WaitingTaskHolder iTask, std::shared_ptr iLumiStatus); #endif class LuminosityBlockProcessingStatus { public: - friend void globalEndLumiAsync(WaitingTaskHolder iTask, std::shared_ptr iLumiStatus); - - LuminosityBlockProcessingStatus(EventProcessor* iEP, unsigned int iNStreams): eventProcessor_(iEP), nStreamsStillProcessingLumi_(iNStreams) {} @@ -80,6 +77,9 @@ class LuminosityBlockProcessingStatus if (iTime> endTime_) { endTime_ = iTime;} } edm::Timestamp const& lastTimestamp() const { return endTime_;} + + //Called once all events in Lumi have been processed + void setEndTime(); private: // ---------- member data -------------------------------- std::shared_ptr lumiPrincipal_; @@ -87,6 +87,7 @@ class LuminosityBlockProcessingStatus EventProcessor* eventProcessor_ = nullptr; std::atomic nStreamsStillProcessingLumi_{0}; //read/write as streams finish lumi so must be atomic edm::Timestamp endTime_{}; + std::atomic endTimeSetStatus_{0}; bool stopProcessingEvents_{false}; //read/write in m_sourceQueue OR from main thread when no tasks running bool lumiEnding_{false}; //read/write in m_sourceQueue NOTE: This is a useful cache instead of recalculating each call bool continuingLumi_{false}; //read/write in m_sourceQueue OR from main thread when no tasks running From 50ebccbc7b34f271ecb7f0437a6c313b04d3a84a Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 11 Jan 2018 14:37:08 -0600 Subject: [PATCH 29/52] Added EventProcessor::streamEndLumiAsync method Created a separate streamEndLumiAsync which is needed to allow a stream once it is finished processing all events in a LuminosityBlock to immediately do its end lumi transition without waiting for all other streams to finish. --- FWCore/Framework/interface/EventProcessor.h | 4 +- FWCore/Framework/src/EventProcessor.cc | 71 ++++++++++++--------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/FWCore/Framework/interface/EventProcessor.h b/FWCore/Framework/interface/EventProcessor.h index 64560d59acfb5..b037f2582b8e2 100644 --- a/FWCore/Framework/interface/EventProcessor.h +++ b/FWCore/Framework/interface/EventProcessor.h @@ -211,7 +211,9 @@ namespace edm { void beginLumiAsync(edm::WaitingTaskHolder iHolder, std::shared_ptr& oStatus); void endLumi(std::shared_ptr status); void globalEndLumiAsync(edm::WaitingTaskHolder iTask, std::shared_ptr iLumiStatus); - + void streamEndLumiAsync(edm::WaitingTaskHolder iTask, + unsigned int iStreamIndex, + std::shared_ptr iLumiStatus); std::pair readRun(); std::pair readAndMergeRun(); void readLuminosityBlock(LuminosityBlockProcessingStatus&); diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 516898bd6e8c9..3071846bc598d 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1135,6 +1135,7 @@ namespace edm { for(unsigned int i=0; ilumiPrincipal(); @@ -1224,45 +1225,55 @@ namespace edm { iLumiStatus->cleaningUpAfterException()); } - void EventProcessor::endLumi(std::shared_ptr status) { - bool cleaningUpAfterException = status->cleaningUpAfterException(); - LuminosityBlockPrincipal& lumiPrincipal = *status->lumiPrincipal(); - lumiPrincipal.setEndTime(status->lastTimestamp()); + void EventProcessor::streamEndLumiAsync(edm::WaitingTaskHolder iTask, + unsigned int iStreamIndex, + std::shared_ptr iLumiStatus) { - auto globalWaitTask = make_empty_waiting_task(); - globalWaitTask->increment_ref_count(); - - auto globalEndTask = edm::make_waiting_task(tbb::task::allocate_root(), - [this, - waitTask=WaitingTaskHolder(globalWaitTask.get()), - status](std::exception_ptr const* iPtr) - { - for(auto & s: streamLumiStatus_) { s.reset();} + auto t =edm::make_waiting_task(tbb::task::allocate_root(), [this, iStreamIndex, iTask](std::exception_ptr const* iPtr) mutable { + std::exception_ptr ptr; if(iPtr) { - WaitingTaskHolder t(waitTask); - t.doneWaiting(*iPtr); + ptr = *iPtr; + } + auto status =streamLumiStatus_[iStreamIndex]; + //reset status before releasing queue else get race condtion + streamLumiStatus_[iStreamIndex].reset(); + streamQueues_[iStreamIndex].resume(); + + //are we the last one? + if( status->streamFinishedLumi()) { + globalEndLumiAsync(iTask, std::move(status)); } - globalEndLumiAsync(std::move(waitTask), std::move(status)); + iTask.doneWaiting(ptr); }); - { - WaitingTaskHolder globalTaskHolder{globalEndTask}; + edm::WaitingTaskHolder lumiDoneTask{t}; + + iLumiStatus->setEndTime(); - //NOTE: Using the max event number for the end of a lumi block is a bad idea - // lumi blocks know their start and end times why not also start and end events? + if(iLumiStatus->didGlobalBeginSucceed()) { + auto & lumiPrincipal = *iLumiStatus->lumiPrincipal(); IOVSyncValue ts(EventID(lumiPrincipal.run(), lumiPrincipal.luminosityBlock(), EventID::maxEventNumber()), lumiPrincipal.endTime()); EventSetup const& es = esp_->eventSetup(); - if(status->didGlobalBeginSucceed()){ - typedef OccurrenceTraits Traits; - endStreamsTransitionAsync(globalEndTask, - *schedule_, - preallocations_.numberOfStreams(), - lumiPrincipal, - ts, - es, - subProcesses_, - cleaningUpAfterException); + + bool cleaningUpAfterException = iLumiStatus->cleaningUpAfterException(); + + using Traits = OccurrenceTraits; + endStreamTransitionAsync(std::move(lumiDoneTask), + *schedule_,iStreamIndex, + lumiPrincipal,ts,es, + subProcesses_,cleaningUpAfterException); + } + } + + + void EventProcessor::endLumi(std::shared_ptr status) { + auto globalWaitTask = make_empty_waiting_task(); + globalWaitTask->increment_ref_count(); + { + WaitingTaskHolder globalTaskHolder{globalWaitTask.get()}; + for(unsigned int i=0; i< preallocations_.numberOfStreams(); ++i) { + streamEndLumiAsync(globalTaskHolder, i, status); } } globalWaitTask->wait_for_all(); From 9823ff4d2e2cf2f25f51be9cf4bd752c7669ec03 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 19 Jan 2018 16:56:15 -0600 Subject: [PATCH 30/52] Added the numerical values as comments to help with debugging --- FWCore/Framework/test/transition_test_cfg.py | 60 ++++++++++++++------ 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/FWCore/Framework/test/transition_test_cfg.py b/FWCore/Framework/test/transition_test_cfg.py index 681f5ce8e07e3..d6e9e5c5f8255 100644 --- a/FWCore/Framework/test/transition_test_cfg.py +++ b/FWCore/Framework/test/transition_test_cfg.py @@ -3,7 +3,7 @@ def chooseTrans(index): d = ( - ["Simple", + ["Simple", #0 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -24,7 +24,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Less events than streams", + ["Less events than streams", #1 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -37,7 +37,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Multiple different Lumis", + ["Multiple different Lumis", #2 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -58,7 +58,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Empty Lumi", + ["Empty Lumi", #3 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -75,7 +75,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Empty Lumi at end", + ["Empty Lumi at end", #4 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -92,7 +92,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Multiple different runs", + ["Multiple different runs", #5 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -115,7 +115,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Empty run", + ["Empty run", #6 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -132,7 +132,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Empty run at end", + ["Empty run at end", #7 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -149,7 +149,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Empty run no lumi", + ["Empty run no lumi", #8 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -158,7 +158,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Empty file at end", + ["Empty file at end", #9 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -175,7 +175,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Empty file", + ["Empty file", #10 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -192,7 +192,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Merge run across files", + ["Merge run across files", #11 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -217,7 +217,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Merge run & lumi across files", + ["Merge run & lumi across files", #12 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -242,7 +242,33 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Delayed lumi merge", + ["Different run across files", #13 + cms.untracked.VPSet( + cms.PSet(type = cms.untracked.string("IsFile"), + id = cms.untracked.EventID(0,0,0)), + cms.PSet(type = cms.untracked.string("IsRun"), + id = cms.untracked.EventID(1,0,0)), + cms.PSet(type = cms.untracked.string("IsLumi"), + id = cms.untracked.EventID(1,1,0)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,1)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(1,1,2)), + cms.PSet(type = cms.untracked.string("IsFile"), + id = cms.untracked.EventID(0,0,0)), + cms.PSet(type = cms.untracked.string("IsRun"), + id = cms.untracked.EventID(2,0,0)), + cms.PSet(type = cms.untracked.string("IsLumi"), + id = cms.untracked.EventID(2,1,0)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(2,1,1)), + cms.PSet(type = cms.untracked.string("IsEvent"), + id = cms.untracked.EventID(2,1,2)), + cms.PSet(type = cms.untracked.string("IsStop"), + id = cms.untracked.EventID(0,0,0)) + ) ], + + ["Delayed lumi merge", #14 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -265,7 +291,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Delayed lumi merge 2", + ["Delayed lumi merge 2", #15 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -288,7 +314,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Delayed run merge", + ["Delayed run merge", #16 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), @@ -313,7 +339,7 @@ def chooseTrans(index): cms.PSet(type = cms.untracked.string("IsStop"), id = cms.untracked.EventID(0,0,0)) ) ], - ["Delayed run merge 2", + ["Delayed run merge 2", #17 cms.untracked.VPSet( cms.PSet(type = cms.untracked.string("IsFile"), id = cms.untracked.EventID(0,0,0)), From 8b8b5e02740b7b70be4aad669d49c45fe29c563e Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 19 Jan 2018 17:12:01 -0600 Subject: [PATCH 31/52] Combine Event and LuminosityBlock processing The last step of begin stream luminosity block now starts processing events on that stream. When a stream finishes events in a luminosity block, the end stream luminosity block is started. Global end luminosity block is triggered when all stream end transitions for that luminosity block have finished. --- FWCore/Framework/interface/EventProcessor.h | 23 +- FWCore/Framework/src/EventProcessor.cc | 402 ++++++++++-------- .../src/LuminosityBlockProcessingStatus.h | 17 +- FWCore/Framework/src/TransitionProcessors.icc | 138 +----- FWCore/Framework/test/MockEventProcessor.cc | 56 ++- FWCore/Framework/test/MockEventProcessor.h | 11 +- 6 files changed, 322 insertions(+), 325 deletions(-) diff --git a/FWCore/Framework/interface/EventProcessor.h b/FWCore/Framework/interface/EventProcessor.h index b037f2582b8e2..93b0706ddfce9 100644 --- a/FWCore/Framework/interface/EventProcessor.h +++ b/FWCore/Framework/interface/EventProcessor.h @@ -51,6 +51,7 @@ namespace edm { class SubProcess; class WaitingTaskHolder; class LuminosityBlockProcessingStatus; + class IOVSyncValue; namespace eventsetup { class EventSetupProvider; @@ -185,6 +186,8 @@ namespace edm { // transition handling. InputSource::ItemType nextTransitionType(); + InputSource::ItemType lastTransitionType() const { if(deferredExceptionPtrIsSet_) {return InputSource::IsStop;} + return lastSourceTransition_;} std::pair nextRunID(); edm::LuminosityBlockNumber_t nextLuminosityBlockID(); @@ -207,9 +210,14 @@ namespace edm { void beginRun(ProcessHistoryID const& phid, RunNumber_t run, bool& globalBeginSucceeded); void endRun(ProcessHistoryID const& phid, RunNumber_t run, bool globalBeginSucceeded, bool cleaningUpAfterException); - void beginLumi(std::shared_ptr& status); - void beginLumiAsync(edm::WaitingTaskHolder iHolder, std::shared_ptr& oStatus); - void endLumi(std::shared_ptr status); + InputSource::ItemType processLumis(std::shared_ptr const& iRunResource); + void endUnfinishedLumi(); + + void beginLumiAsync(edm::IOVSyncValue const& iSyncValue, + std::shared_ptr const& iRunResource, + edm::WaitingTaskHolder iHolder); + void continueLumiAsync(edm::WaitingTaskHolder iHolder); + void globalEndLumiAsync(edm::WaitingTaskHolder iTask, std::shared_ptr iLumiStatus); void streamEndLumiAsync(edm::WaitingTaskHolder iTask, unsigned int iStreamIndex, @@ -231,8 +239,6 @@ namespace edm { bool setDeferredException(std::exception_ptr); - InputSource::ItemType readAndProcessEvents(); - private: //------------------------------------------------------------------ // @@ -243,11 +249,10 @@ namespace edm { serviceregistry::ServiceLegacy); bool readNextEventForStream(unsigned int iStreamIndex, - std::atomic* finishedProcessingEvents); + LuminosityBlockProcessingStatus& iLumiStatus); void handleNextEventForStreamAsync(WaitingTaskHolder iTask, - unsigned int iStreamIndex, - std::atomic* finishedProcessingEvents); + unsigned int iStreamIndex); //read the next event using Stream iStreamIndex @@ -286,6 +291,7 @@ namespace edm { edm::propagate_const> thinnedAssociationsHelper_; ServiceToken serviceToken_; edm::propagate_const> input_; + InputSource::ItemType lastSourceTransition_; edm::propagate_const> espController_; edm::propagate_const> esp_; edm::SerialTaskQueue iovQueue_; @@ -324,7 +330,6 @@ namespace edm { PreallocationConfiguration preallocations_; bool asyncStopRequestedWhileProcessingEvents_; - std::atomic nextItemTypeFromProcessingEvents_; StatusCode asyncStopStatusCodeFromProcessingEvents_; bool firstEventInBlock_=true; diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 3071846bc598d..0fc4070fac490 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -283,7 +283,6 @@ namespace edm { looperBeginJobRun_(false), forceESCacheClearOnNewRun_(false), asyncStopRequestedWhileProcessingEvents_(false), - nextItemTypeFromProcessingEvents_(InputSource::IsEvent), eventSetupDataToExcludeFromPrefetching_() { std::shared_ptr parameterSet = PythonProcessDesc(config).parameterSet(); @@ -323,7 +322,6 @@ namespace edm { looperBeginJobRun_(false), forceESCacheClearOnNewRun_(false), asyncStopRequestedWhileProcessingEvents_(false), - nextItemTypeFromProcessingEvents_(InputSource::IsEvent), eventSetupDataToExcludeFromPrefetching_() { init(processDesc, token, legacy); @@ -359,7 +357,6 @@ namespace edm { looperBeginJobRun_(false), forceESCacheClearOnNewRun_(false), asyncStopRequestedWhileProcessingEvents_(false), - nextItemTypeFromProcessingEvents_(InputSource::IsEvent), eventSetupDataToExcludeFromPrefetching_() { if(isPython) { @@ -723,6 +720,11 @@ namespace edm { InputSource::ItemType EventProcessor::nextTransitionType() { + if (deferredExceptionPtrIsSet_.load()) { + lastSourceTransition_ = InputSource::IsStop; + return InputSource::IsStop; + } + SendSourceTerminationSignalIfException sentry(actReg_.get()); InputSource::ItemType itemType; //For now, do nothing with InputSource::IsSynchronize @@ -730,16 +732,17 @@ namespace edm { itemType = input_->nextItemType(); } while( itemType == InputSource::IsSynchronize); + lastSourceTransition_ = itemType; sentry.completedSuccessfully(); StatusCode returnCode=epSuccess; if(checkForAsyncStopRequest(returnCode)) { actReg_->preSourceEarlyTerminationSignal_(TerminationOrigin::ExternalSignal); - return InputSource::IsStop; + lastSourceTransition_ = InputSource::IsStop; } - return itemType; + return lastSourceTransition_; } std::pair @@ -763,8 +766,6 @@ namespace edm { // make the services available ServiceRegistry::Operate operate(serviceToken_); - - nextItemTypeFromProcessingEvents_=InputSource::IsEvent; asyncStopRequestedWhileProcessingEvents_=false; try { FilesProcessor fp(fileModeNoMerge_); @@ -1075,118 +1076,170 @@ namespace edm { } } - void - EventProcessor::beginLumi(std::shared_ptr& oStatus) { + InputSource::ItemType + EventProcessor::processLumis(std::shared_ptr const& iRunResource) { auto waitTask = make_empty_waiting_task(); waitTask->increment_ref_count(); - beginLumiAsync(WaitingTaskHolder{waitTask.get()},oStatus); + if(streamLumiStatus_[0]) { + continueLumiAsync(WaitingTaskHolder{waitTask.get()}); + } else { + beginLumiAsync(IOVSyncValue(EventID(input_->run(), input_->luminosityBlock(), 0), + input_->timestamp()), + iRunResource, + WaitingTaskHolder{waitTask.get()}); + } waitTask->wait_for_all(); if(waitTask->exceptionPtr() != nullptr) { std::rethrow_exception(* (waitTask->exceptionPtr()) ); } + return lastTransitionType(); } void - EventProcessor::beginLumiAsync(edm::WaitingTaskHolder iHolder, std::shared_ptr& oStatus) { - oStatus= std::make_shared(this, preallocations_.numberOfStreams()) ; + EventProcessor::beginLumiAsync(IOVSyncValue const& iSync, + std::shared_ptr const& iRunResource, edm::WaitingTaskHolder iHolder) { + auto status= std::make_shared(this, preallocations_.numberOfStreams(), iRunResource) ; - sourceResourcesAcquirer_.serialQueueChain().push([this,iHolder,oStatus]() mutable { - //make the services available - ServiceRegistry::Operate operate(serviceToken_); + auto lumiWork = [this, iHolder, iSync, status](edm::LimitedTaskQueue::Resumer iResumer) mutable { + status->setResumer(std::move(iResumer)); + + sourceResourcesAcquirer_.serialQueueChain().push([this,iHolder,status]() mutable { + //make the services available + ServiceRegistry::Operate operate(serviceToken_); - try { - readLuminosityBlock(*oStatus); + try { + readLuminosityBlock(*status); - LuminosityBlockPrincipal& lumiPrincipal = *oStatus->lumiPrincipal(); - { - SendSourceTerminationSignalIfException sentry(actReg_.get()); + LuminosityBlockPrincipal& lumiPrincipal = *status->lumiPrincipal(); + { + SendSourceTerminationSignalIfException sentry(actReg_.get()); - input_->doBeginLumi(lumiPrincipal, &processContext_); - sentry.completedSuccessfully(); - } + input_->doBeginLumi(lumiPrincipal, &processContext_); + sentry.completedSuccessfully(); + } - Service rng; - if(rng.isAvailable()) { - LuminosityBlock lb(lumiPrincipal, ModuleDescription(), nullptr, false); - rng->preBeginLumi(lb); - } - - IOVSyncValue ts(EventID(lumiPrincipal.run(), lumiPrincipal.luminosityBlock(), 0), lumiPrincipal.beginTime()); - - //Task to start the stream beginLumis - auto beginStreamsTask= make_waiting_task(tbb::task::allocate_root() - ,[this, holder = iHolder, oStatus, ts] (std::exception_ptr const* iPtr) mutable { - if (iPtr) { - holder.doneWaiting(*iPtr); - } else { - oStatus->globalBeginDidSucceed(); - EventSetup const& es = esp_->eventSetup(); - if(looper_) { - try { - looper_->doBeginLuminosityBlock(*(oStatus->lumiPrincipal()), es, &processContext_); - }catch(...) { - holder.doneWaiting(std::current_exception()); - return; + Service rng; + if(rng.isAvailable()) { + LuminosityBlock lb(lumiPrincipal, ModuleDescription(), nullptr, false); + rng->preBeginLumi(lb); + } + + IOVSyncValue ts(EventID(lumiPrincipal.run(), lumiPrincipal.luminosityBlock(), 0), lumiPrincipal.beginTime()); + + //Task to start the stream beginLumis + auto beginStreamsTask= make_waiting_task(tbb::task::allocate_root() + ,[this, holder = iHolder, status, ts] (std::exception_ptr const* iPtr) mutable { + if (iPtr) { + holder.doneWaiting(*iPtr); + } else { + //make the services available + ServiceRegistry::Operate operate(serviceToken_); + + status->globalBeginDidSucceed(); + EventSetup const& es = esp_->eventSetup(); + if(looper_) { + try { + looper_->doBeginLuminosityBlock(*(status->lumiPrincipal()), es, &processContext_); + }catch(...) { + holder.doneWaiting(std::current_exception()); + return; + } + } + typedef OccurrenceTraits Traits; + + for(unsigned int i=0; ilumiPrincipal(); + event.setLuminosityBlockPrincipal(lp); + beginStreamTransitionAsync(WaitingTaskHolder{eventTask}, *schedule_,i,*lp,ts,es,subProcesses_); + }); } } - typedef OccurrenceTraits Traits; - - for(unsigned int i=0; ilumiPrincipal(); - event.setLuminosityBlockPrincipal(lp); - beginStreamTransitionAsync(holder, *schedule_,i,*lp,ts,es,subProcesses_); - }); - } - } - }); - - //task to start the global begin lumi - WaitingTaskHolder beginStreamsHolder{beginStreamsTask}; - auto lumiAction =[this,beginStreamsHolder , oStatus, ts](LimitedTaskQueue::Resumer iResumer) mutable { - oStatus->setResumer(std::move(iResumer)); + }); + + //task to start the global begin lumi + WaitingTaskHolder beginStreamsHolder{beginStreamsTask}; EventSetup const& es = esp_->eventSetup(); { typedef OccurrenceTraits Traits; beginGlobalTransitionAsync(beginStreamsHolder, *schedule_, - *(oStatus->lumiPrincipal()), + *(status->lumiPrincipal()), ts, es, subProcesses_); } - }; - + } catch(...) { + iHolder.doneWaiting(std::current_exception()); + } + }); + }; - //Safe to do check now since can not have multiple beginLumis at same time in this part of the code - // because we do not attempt to read from the source again until we try to get the first event in a lumi - if(espController_->isWithinValidityInterval(ts)) { - iovQueue_.pause(); - lumiQueue_->pushAndPause(std::move(lumiAction)); - } else { - //If EventSetup fails, need beginStreamsHolder in order to pass back exception - iovQueue_.push([this,lumiAction,beginStreamsHolder,ts]() mutable { - try { - SendSourceTerminationSignalIfException sentry(actReg_.get()); - espController_->eventSetupForInstance(ts); - sentry.completedSuccessfully(); - } catch(...) { - beginStreamsHolder.doneWaiting(std::current_exception()); - return; - } - iovQueue_.pause(); - lumiQueue_->pushAndPause(std::move(lumiAction)); - }); + //Safe to do check now since can not have multiple beginLumis at same time in this part of the code + // because we do not attempt to read from the source again until we try to get the first event in a lumi + if(espController_->isWithinValidityInterval(iSync)) { + iovQueue_.pause(); + lumiQueue_->pushAndPause(std::move(lumiWork)); + } else { + //If EventSetup fails, need beginStreamsHolder in order to pass back exception + iovQueue_.push([this,iHolder,lumiWork,iSync]() mutable { + try { + SendSourceTerminationSignalIfException sentry(actReg_.get()); + espController_->eventSetupForInstance(iSync); + sentry.completedSuccessfully(); + } catch(...) { + iHolder.doneWaiting(std::current_exception()); + return; } - } catch(...) { - iHolder.doneWaiting(std::current_exception()); - } + iovQueue_.pause(); + lumiQueue_->pushAndPause(std::move(lumiWork)); + }); + } + } + + void + EventProcessor::continueLumiAsync(edm::WaitingTaskHolder iHolder) { + { + //all streams are sharing the same status at the moment + auto status = streamLumiStatus_[0]; + status->needToContinueLumi(); + status->startProcessingEvents(); + } + + unsigned int streamIndex = 0; + for(; streamIndex< preallocations_.numberOfStreams()-1; ++streamIndex) { + tbb::task::enqueue( *edm::make_waiting_task(tbb::task::allocate_root(), + [this,streamIndex,h = iHolder](std::exception_ptr const* iPtr) mutable + { + if(iPtr) { + h.doneWaiting(*iPtr); + } else { + handleNextEventForStreamAsync(std::move(h), streamIndex); + } + }) ); + + } + //need a temporary Task so that the temporary WaitingTaskHolder assigned to h will go out of scope + // before the call to spawn_and_wait_for_all + auto t = edm::make_waiting_task(tbb::task::allocate_root(),[this,streamIndex,h=iHolder](std::exception_ptr const*){ + handleNextEventForStreamAsync(h,streamIndex); }); + tbb::task::spawn(*t); } void EventProcessor::globalEndLumiAsync(edm::WaitingTaskHolder iTask, std::shared_ptr iLumiStatus) { @@ -1195,16 +1248,36 @@ namespace edm { if(iPtr) { ptr = *iPtr; } else { - if(looper_) { - auto& lp = *(status->lumiPrincipal()); - EventSetup const& es = esp_->eventSetup(); - looper_->doEndLuminosityBlock(lp, es, &processContext_); + try { + ServiceRegistry::Operate operate(serviceToken_); + + //TODO: Only supposed to call writeLumi if beginLumi succeeded + writeLumi(*status); + + if(looper_) { + auto& lp = *(status->lumiPrincipal()); + EventSetup const& es = esp_->eventSetup(); + looper_->doEndLuminosityBlock(lp, es, &processContext_); + } + }catch(...) { + if(not ptr) { + ptr = std::current_exception(); + } } } - t.doneWaiting(ptr); + deleteLumiFromCache(*status); //release our hold on the IOV iovQueue_.resume(); status->resumeGlobalLumiQueue(); + try { + status.reset(); + } catch(...) { + if( not ptr) { + ptr = std::current_exception(); + } + } + //have to wait until reset is called since that could call endRun + t.doneWaiting(ptr); }); auto& lp = *(iLumiStatus->lumiPrincipal()); @@ -1267,18 +1340,22 @@ namespace edm { } - void EventProcessor::endLumi(std::shared_ptr status) { - auto globalWaitTask = make_empty_waiting_task(); - globalWaitTask->increment_ref_count(); - { - WaitingTaskHolder globalTaskHolder{globalWaitTask.get()}; - for(unsigned int i=0; i< preallocations_.numberOfStreams(); ++i) { - streamEndLumiAsync(globalTaskHolder, i, status); + void EventProcessor::endUnfinishedLumi() { + auto status = streamLumiStatus_[0]; + if(status) { + status.reset(); + auto globalWaitTask = make_empty_waiting_task(); + globalWaitTask->increment_ref_count(); + { + WaitingTaskHolder globalTaskHolder{globalWaitTask.get()}; + for(unsigned int i=0; i< preallocations_.numberOfStreams(); ++i) { + streamEndLumiAsync(globalTaskHolder, i, streamLumiStatus_[i]); + } + } + globalWaitTask->wait_for_all(); + if(globalWaitTask->exceptionPtr() != nullptr) { + std::rethrow_exception(* (globalWaitTask->exceptionPtr()) ); } - } - globalWaitTask->wait_for_all(); - if(globalWaitTask->exceptionPtr() != nullptr) { - std::rethrow_exception(* (globalWaitTask->exceptionPtr()) ); } } @@ -1321,6 +1398,7 @@ namespace edm { << "Contact a Framework Developer\n"; } auto lbp = principalCache_.getAvailableLumiPrincipalPtr(); + assert(lbp); lbp->setAux(*input_->luminosityBlockAuxiliary()); { SendSourceTerminationSignalIfException sentry(actReg_.get()); @@ -1371,7 +1449,7 @@ namespace edm { } bool EventProcessor::readNextEventForStream(unsigned int iStreamIndex, - std::atomic* finishedProcessingEvents) { + LuminosityBlockProcessingStatus& iStatus) { if(shouldWeStop()) { return false; } @@ -1380,7 +1458,7 @@ namespace edm { return false; } - if(finishedProcessingEvents->load(std::memory_order_acquire)) { + if(iStatus.wasEventProcessingStopped()) { return false; } @@ -1390,31 +1468,40 @@ namespace edm { // of delayed provenance reading and reading data in response to // edm::Refs etc std::lock_guard guard(*(sourceMutex_.get())); - if(not firstEventInBlock_) { - //The state machine already called input_->nextItemType - // and found an event. We can't call input_->nextItemType - // again since it would move to the next transition - InputSource::ItemType itemType = input_->nextItemType(); - if (InputSource::IsEvent !=itemType) { - nextItemTypeFromProcessingEvents_ = itemType; - finishedProcessingEvents->store(true,std::memory_order_release); - //std::cerr<<"next item type "<run() == input_->run() and + iStatus.lumiPrincipal()->luminosityBlock() == nextLumi) { + readAndMergeLumi(iStatus); + itemType = nextTransitionType(); + nextLumi =nextLuminosityBlockID(); } - if((asyncStopRequestedWhileProcessingEvents_=checkForAsyncStopRequest(asyncStopStatusCodeFromProcessingEvents_))) { - //std::cerr<<"task told to async stop\n"; - actReg_->preSourceEarlyTerminationSignal_(TerminationOrigin::ExternalSignal); - return false; + if(InputSource::IsLumi == itemType) { + iStatus.setNextSyncValue(IOVSyncValue(EventID(input_->run(), input_->luminosityBlock(), 0), input_->timestamp())); } - } else { - firstEventInBlock_ = false; + } + if(InputSource::IsEvent != itemType) { + iStatus.stopProcessingEvents(); + + //IsFile may continue processing the lumi and + // looper_ can cause the input source to declare a new IsRun which is actually + // just a continuation of the previous run + if(InputSource::IsStop == itemType or + InputSource::IsLumi == itemType or + (InputSource::IsRun == itemType and iStatus.lumiPrincipal()->run() != input_->run())) { + iStatus.endLumi(); + } + return false; } readEvent(iStreamIndex); } catch (...) { bool expected =false; if(deferredExceptionPtrIsSet_.compare_exchange_strong(expected,true)) { deferredExceptionPtr_ = std::current_exception(); - } return false; } @@ -1422,15 +1509,14 @@ namespace edm { } void EventProcessor::handleNextEventForStreamAsync(WaitingTaskHolder iTask, - unsigned int iStreamIndex, - std::atomic* finishedProcessingEvents) + unsigned int iStreamIndex) { - sourceResourcesAcquirer_.serialQueueChain().push([this,finishedProcessingEvents,iTask,iStreamIndex]() mutable { + sourceResourcesAcquirer_.serialQueueChain().push([this,iTask,iStreamIndex]() mutable { ServiceRegistry::Operate operate(serviceToken_); - + auto& status = streamLumiStatus_[iStreamIndex]; try { - if(readNextEventForStream(iStreamIndex, finishedProcessingEvents) ) { - auto recursionTask = make_waiting_task(tbb::task::allocate_root(), [this,iTask,iStreamIndex,finishedProcessingEvents](std::exception_ptr const* iPtr) mutable { + if(readNextEventForStream(iStreamIndex, *status) ) { + auto recursionTask = make_waiting_task(tbb::task::allocate_root(), [this,iTask,iStreamIndex](std::exception_ptr const* iPtr) mutable { if(iPtr) { bool expected = false; if(deferredExceptionPtrIsSet_.compare_exchange_strong(expected,true)) { @@ -1440,13 +1526,21 @@ namespace edm { //the stream will stop now return; } - handleNextEventForStreamAsync(iTask, iStreamIndex,finishedProcessingEvents); + handleNextEventForStreamAsync(iTask, iStreamIndex); }); processEventAsync( WaitingTaskHolder(recursionTask), iStreamIndex); } else { //the stream will stop now - iTask.doneWaiting(std::exception_ptr{}); + if(status->isLumiEnding()) { + if(lastTransitionType() == InputSource::IsLumi and not status->haveStartedNextLumi()) { + status->startNextLumi(); + beginLumiAsync(status->nextSyncValue(), status->runResource(), iTask); + } + streamEndLumiAsync(iTask,iStreamIndex, status); + } else { + iTask.doneWaiting(std::exception_ptr{}); + } } } catch(...) { bool expected = false; @@ -1459,44 +1553,6 @@ namespace edm { }); } - InputSource::ItemType EventProcessor::readAndProcessEvents() { - nextItemTypeFromProcessingEvents_ = InputSource::IsEvent; //needed for looper - asyncStopRequestedWhileProcessingEvents_ = false; - - std::atomic finishedProcessingEvents{false}; - auto finishedProcessingEventsPtr = &finishedProcessingEvents; - - //The state machine already found the event so - // we have to avoid looking again - firstEventInBlock_ = true; - - //To wait, the ref count has to b 1+#streams - auto eventLoopWaitTask = make_empty_waiting_task(); - eventLoopWaitTask->increment_ref_count(); - - const unsigned int kNumStreams = preallocations_.numberOfStreams(); - unsigned int iStreamIndex = 0; - for(; iStreamIndexspawn_and_wait_for_all( *t); - - //One of the processing threads saw an exception - if(deferredExceptionPtrIsSet_) { - std::rethrow_exception(deferredExceptionPtr_); - } - return nextItemTypeFromProcessingEvents_.load(); - } - void EventProcessor::readEvent(unsigned int iStreamIndex) { //TODO this will have to become per stream auto& event = principalCache_.eventPrincipal(iStreamIndex); @@ -1604,7 +1660,10 @@ namespace edm { } pc.setLastOperationSucceeded(succeeded); } while(!pc.lastOperationSucceeded()); - if(status != EDLooperBase::kContinue) shouldWeStop_ = true; + if(status != EDLooperBase::kContinue) { + shouldWeStop_ = true; + lastSourceTransition_=InputSource::IsStop; + } } bool EventProcessor::shouldWeStop() const { @@ -1641,5 +1700,4 @@ namespace edm { } return false; } - } diff --git a/FWCore/Framework/src/LuminosityBlockProcessingStatus.h b/FWCore/Framework/src/LuminosityBlockProcessingStatus.h index a91a9a8ad4a6a..a9b75c21504e7 100644 --- a/FWCore/Framework/src/LuminosityBlockProcessingStatus.h +++ b/FWCore/Framework/src/LuminosityBlockProcessingStatus.h @@ -25,6 +25,7 @@ // user include files #include "FWCore/Concurrency/interface/LimitedTaskQueue.h" #include "DataFormats/Provenance/interface/Timestamp.h" +#include "FWCore/Framework/interface/IOVSyncValue.h" // forward declarations namespace edm { @@ -39,8 +40,8 @@ class LuminosityBlockProcessingStatus { public: - LuminosityBlockProcessingStatus(EventProcessor* iEP, unsigned int iNStreams): - eventProcessor_(iEP), nStreamsStillProcessingLumi_(iNStreams) {} + LuminosityBlockProcessingStatus(EventProcessor* iEP, unsigned int iNStreams, std::shared_ptr iRunResource): + run_(std::move(iRunResource)) , eventProcessor_(iEP), nStreamsStillProcessingLumi_(iNStreams){} std::shared_ptr& lumiPrincipal() { return lumiPrincipal_;} @@ -48,6 +49,8 @@ class LuminosityBlockProcessingStatus globalLumiQueueResumer_ = std::move(iResumer); } void resumeGlobalLumiQueue() { + //free lumi for next usage + lumiPrincipal_.reset(); globalLumiQueueResumer_.resume(); } @@ -78,13 +81,23 @@ class LuminosityBlockProcessingStatus } edm::Timestamp const& lastTimestamp() const { return endTime_;} + void setNextSyncValue(IOVSyncValue iValue) { + nextSyncValue_ = std::move(iValue); + } + + const IOVSyncValue nextSyncValue() const { return nextSyncValue_;} + + std::shared_ptr const& runResource() const {return run_;} + //Called once all events in Lumi have been processed void setEndTime(); private: // ---------- member data -------------------------------- std::shared_ptr lumiPrincipal_; + std::shared_ptr run_; LimitedTaskQueue::Resumer globalLumiQueueResumer_; EventProcessor* eventProcessor_ = nullptr; + IOVSyncValue nextSyncValue_; std::atomic nStreamsStillProcessingLumi_{0}; //read/write as streams finish lumi so must be atomic edm::Timestamp endTime_{}; std::atomic endTimeSetStatus_{0}; diff --git a/FWCore/Framework/src/TransitionProcessors.icc b/FWCore/Framework/src/TransitionProcessors.icc index 0fad14ea35f1b..1c2695c638269 100644 --- a/FWCore/Framework/src/TransitionProcessors.icc +++ b/FWCore/Framework/src/TransitionProcessors.icc @@ -83,139 +83,29 @@ struct RunResources { bool globalTransitionSucceeded_ = false; }; -struct LumiResources { - LumiResources(std::shared_ptr run, edm::LuminosityBlockNumber_t lumi) noexcept : - run_(std::move(run)), - lumi_(lumi) {} - - ~LumiResources() noexcept { - try { - //If we skip empty lumis, this would be called conditionally - run_->ep_.endLumi(status_); - - if (success_) { - run_->ep_.writeLumi(*status_); - } - - run_->ep_.deleteLumiFromCache(*status_); - - } catch(...) { - if(status_->cleaningUpAfterException() or not run_->ep_.setDeferredException(std::current_exception())) { - std::string message("Another exception was caught while trying to clean up lumis after the primary fatal exception."); - run_->ep_.setExceptionMessageLumis(message); - } - } - - } - - edm::ProcessHistoryID processHistoryID() const { - return run_->processHistoryID(); - } - edm::RunNumber_t run() const { - return run_->run(); - } - edm::LuminosityBlockNumber_t lumi() const { - return lumi_; - } - - void normalEnd() { - status_->noExceptionHappened(); - } - - void succeeded() { - success_ = true; - } - - std::shared_ptr run_; - std::shared_ptr status_; - edm::LuminosityBlockNumber_t lumi_; - bool success_ = false; -}; - -struct EventResources { - unsigned long long event_; - std::shared_ptr lumi_; -}; - -class EventsInLumiProcessor { +class LumisInRunProcessor { public: - EventsInLumiProcessor(){} - - edm::InputSource::ItemType processEvents(EventProcessor& iEP, std::shared_ptr iLumi) { - auto ret = iEP.readAndProcessEvents(); - if(iEP.shouldWeStop()) { - //looper requested stopping event processing - return edm::InputSource::IsStop; - } - while( ret == edm::InputSource::IsSynchronize ) { - ret = iEP.nextTransitionType(); - } - return ret; + ~LumisInRunProcessor() noexcept { + normalEnd(); } -private: - //void readEvent(StreamID, InputSource& ); - //void processEvent(StreamID, InputSource& , std::shared_ptr ) { - // - //} -}; - -class LumisInRunProcessor { -public: edm::InputSource::ItemType processLumis(EventProcessor& iEP, std::shared_ptr iRun) { - bool finished = false; - auto nextTransition = edm::InputSource::IsLumi; - do { - switch(nextTransition) { - case edm::InputSource::IsLumi: - { - processLumi(iEP,iRun); - nextTransition = iEP.nextTransitionType(); - break; - } - case edm::InputSource::IsEvent: - { - nextTransition = events_.processEvents(iEP,currentLumi_); - break; - } - default: - finished = true; - } - - } while(not finished); - return nextTransition; + currentRun_ = std::move(iRun); + makeSureLumiEnds_ = true; + return iEP.processLumis(std::shared_ptr{currentRun_}); } void normalEnd() { - if (currentLumi_) { - currentLumi_->normalEnd(); + if (makeSureLumiEnds_) { + makeSureLumiEnds_ = false; + currentRun_->ep_.endUnfinishedLumi(); } - currentLumi_.reset(); + currentRun_.reset(); } private: - void processLumi(EventProcessor& iEP, std::shared_ptr iRun) { - auto lumiID = iEP.nextLuminosityBlockID(); - if ( (not currentLumi_) or - currentLumi_->run_.get() != iRun.get() or - currentLumi_->lumi() != lumiID) { - //switching to a different lumi - if(currentLumi_) { - currentLumi_->normalEnd(); - } - currentLumi_ = std::make_shared(iRun,lumiID); - iEP.beginLumi(currentLumi_->status_); - //only if we succeed at beginLumi should we run writeLumi - currentLumi_->succeeded(); - } else { - //merge - auto id = iEP.readAndMergeLumi(*currentLumi_->status_); - assert((id >= 0) and (static_cast(id) == lumiID) ); - } - } - - std::shared_ptr currentLumi_; - EventsInLumiProcessor events_; + std::shared_ptr currentRun_; + bool makeSureLumiEnds_ = false; }; @@ -261,6 +151,10 @@ private: if(currentRun_) { //Both the current run and lumi end here lumis_.normalEnd(); + if(edm::InputSource::IsStop == iEP.lastTransitionType()) { + //an exception happened while processing the end lumi + return; + } currentRun_->normalEnd(); } currentRun_ = std::make_shared(iEP,runID.first,runID.second); diff --git a/FWCore/Framework/test/MockEventProcessor.cc b/FWCore/Framework/test/MockEventProcessor.cc index d0e3f14ed9a07..12fb0ac25f922 100644 --- a/FWCore/Framework/test/MockEventProcessor.cc +++ b/FWCore/Framework/test/MockEventProcessor.cc @@ -70,7 +70,7 @@ namespace edm { token t; if( not (input_ >> t)) { reachedEndOfInput_ = true; - return InputSource::IsStop; + return lastTransition_=InputSource::IsStop; } char ch = t.id; @@ -79,11 +79,11 @@ namespace edm { if(ch == 'r') { output_ << " *** nextItemType: Run " << t.value << " ***\n"; run_ = t.value; - return InputSource::IsRun; + return lastTransition_=InputSource::IsRun; } else if(ch == 'l') { output_ << " *** nextItemType: Lumi " << t.value << " ***\n"; lumi_ = t.value; - return InputSource::IsLumi; + return lastTransition_=InputSource::IsLumi; } else if(ch == 'e') { output_ << " *** nextItemType: Event ***\n"; // a special value for test purposes only @@ -93,29 +93,34 @@ namespace edm { } else { shouldWeStop_ = false; } - return InputSource::IsEvent; + return lastTransition_=InputSource::IsEvent; } else if(ch == 'f') { output_ << " *** nextItemType: File " << t.value << " ***\n"; // a special value for test purposes only if(t.value == 0) shouldWeCloseOutput_ = false; else shouldWeCloseOutput_ = true; - return InputSource::IsFile; + return lastTransition_=InputSource::IsFile; } else if(ch == 's') { output_ << " *** nextItemType: Stop " << t.value << " ***\n"; // a special value for test purposes only if(t.value == 0) shouldWeEndLoop_ = false; else shouldWeEndLoop_ = true; - return InputSource::IsStop; + return lastTransition_=InputSource::IsStop; } else if(ch == 'x') { output_ << " *** nextItemType: Restart " << t.value << " ***\n"; shouldWeEndLoop_ = t.value; - return InputSource::IsStop; + return lastTransition_=InputSource::IsStop; } else if(ch == 't') { output_ << " *** nextItemType: Throw " << t.value << " ***\n"; shouldThrow_ = true; return nextTransitionType(); } - return InputSource::IsInvalid; + return lastTransition_=InputSource::IsInvalid; + } + + InputSource::ItemType + MockEventProcessor::lastTransitionType() const { + return lastTransition_; } std::pair @@ -232,17 +237,34 @@ namespace edm { output_ << "\tendRun " << run << postfix; } - void MockEventProcessor::beginLumi(std::shared_ptr& status) { - status = std::make_shared(this,1); - auto lumi = readLuminosityBlock(*status); - output_ << "\tbeginLumi " << run_ << "/" << lumi << "\n"; - throwIfNeeded(); - status->globalBeginDidSucceed(); + InputSource::ItemType MockEventProcessor::processLumis(std::shared_ptr iRunResource) { + + assert(false); + if(lumiStatus_) { + //Need to do event processing here + readAndProcessEvents(); + } else { + lumiStatus_ = std::make_shared(this,1,iRunResource); + auto lumi = readLuminosityBlock(*lumiStatus_); + output_ << "\tbeginLumi " << run_ << "/" << lumi << "\n"; + throwIfNeeded(); + lumiStatus_->globalBeginDidSucceed(); + //Need to do event processing here + readAndProcessEvents(); + } + return lastTransitionType(); } - void MockEventProcessor::endLumi(std::shared_ptr status) { - auto postfix = status->didGlobalBeginSucceed()? "\n" : " global failed\n"; - output_ << "\tendLumi " << status->lumiPrincipal()->run_ << "/" << status->lumiPrincipal()->lumi_ << postfix; + void MockEventProcessor::endUnfinishedLumi() { + if(lumiStatus_) { + endLumi(); + } + } + + void MockEventProcessor::endLumi() { + auto postfix = lumiStatus_->didGlobalBeginSucceed()? "\n" : " global failed\n"; + output_ << "\tendLumi " << lumiStatus_->lumiPrincipal()->run_ << "/" << lumiStatus_->lumiPrincipal()->lumi_ << postfix; + lumiStatus_.reset(); } std::pair MockEventProcessor::readRun() { diff --git a/FWCore/Framework/test/MockEventProcessor.h b/FWCore/Framework/test/MockEventProcessor.h index 3641d7c84764e..fbeac2f031eb5 100644 --- a/FWCore/Framework/test/MockEventProcessor.h +++ b/FWCore/Framework/test/MockEventProcessor.h @@ -34,6 +34,7 @@ namespace edm { void runToCompletion(); InputSource::ItemType nextTransitionType(); + InputSource::ItemType lastTransitionType() const; std::pair nextRunID(); edm::LuminosityBlockNumber_t nextLuminosityBlockID(); @@ -56,8 +57,8 @@ namespace edm { void beginRun(ProcessHistoryID const& phid, RunNumber_t run, bool& globalTransitionSucceeded); void endRun(ProcessHistoryID const& phid, RunNumber_t run, bool globalTranstitionSucceeded, bool cleaningUpAfterException); - void beginLumi(std::shared_ptr& status); - void endLumi(std::shared_ptr); + InputSource::ItemType processLumis(std::shared_ptr); + void endUnfinishedLumi(); std::pair readRun(); std::pair readAndMergeRun(); @@ -74,18 +75,22 @@ namespace edm { void setExceptionMessageRuns(std::string& message); void setExceptionMessageLumis(std::string& message); - InputSource::ItemType readAndProcessEvents(); bool setDeferredException(std::exception_ptr); private: + InputSource::ItemType readAndProcessEvents(); void readAndProcessEvent(); void throwIfNeeded(); + void endLumi(); std::string mockData_; std::ostream & output_; std::istringstream input_; + std::shared_ptr lumiStatus_; + InputSource::ItemType lastTransition_; + int run_; int lumi_; From 71f088661735b8574299ecd08154be1275ca2788 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 19 Jan 2018 21:51:32 -0600 Subject: [PATCH 32/52] Fixed rebase problem This change was missing after rebasing --- FWCore/Framework/src/LuminosityBlockProcessingStatus.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FWCore/Framework/src/LuminosityBlockProcessingStatus.h b/FWCore/Framework/src/LuminosityBlockProcessingStatus.h index a9b75c21504e7..5168134cbd334 100644 --- a/FWCore/Framework/src/LuminosityBlockProcessingStatus.h +++ b/FWCore/Framework/src/LuminosityBlockProcessingStatus.h @@ -72,6 +72,9 @@ class LuminosityBlockProcessingStatus bool haveStartedNextLumi() const { return startedNextLumi_;} void startNextLumi() { startedNextLumi_ = true;} + bool didGlobalBeginSucceed() const {return globalBeginSucceeded_;} + void globalBeginDidSucceed() { globalBeginSucceeded_ = true;} + void noExceptionHappened() { cleaningUpAfterException_ = false; } bool cleaningUpAfterException() const { return cleaningUpAfterException_;} From 43f14078f09d2bb7adba3b27496636417b4e764f Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sat, 20 Jan 2018 12:43:33 -0600 Subject: [PATCH 33/52] Only call nextLuminosityBlockID if there is a next Lumi --- FWCore/Framework/src/EventProcessor.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 0fc4070fac490..e1fa1832f3d46 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1472,13 +1472,11 @@ namespace edm { auto itemType = iStatus.continuingLumi()? InputSource::IsLumi : nextTransitionType(); if(InputSource::IsLumi == itemType) { iStatus.haveContinuedLumi(); - auto nextLumi =nextLuminosityBlockID(); while(itemType == InputSource::IsLumi and iStatus.lumiPrincipal()->run() == input_->run() and - iStatus.lumiPrincipal()->luminosityBlock() == nextLumi) { + iStatus.lumiPrincipal()->luminosityBlock() == nextLuminosityBlockID()) { readAndMergeLumi(iStatus); itemType = nextTransitionType(); - nextLumi =nextLuminosityBlockID(); } if(InputSource::IsLumi == itemType) { iStatus.setNextSyncValue(IOVSyncValue(EventID(input_->run(), input_->luminosityBlock(), 0), input_->timestamp())); From b25874939b107c4e65503df73ae1ad676d177ead Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sat, 20 Jan 2018 15:46:06 -0600 Subject: [PATCH 34/52] Do not use #streams > #threads in standard test Having #streams > #threads is a very strange configuration and makes no sense for these tests. --- FWCore/Framework/test/test_global_modules_cfg.py | 8 +++++--- FWCore/Framework/test/test_limited_modules_cfg.py | 8 +++++--- FWCore/Framework/test/test_one_modules_cfg.py | 8 +++++--- FWCore/Framework/test/test_stream_modules_cfg.py | 8 +++++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/FWCore/Framework/test/test_global_modules_cfg.py b/FWCore/Framework/test/test_global_modules_cfg.py index e11abcee94ed8..ca3b710cf535e 100644 --- a/FWCore/Framework/test/test_global_modules_cfg.py +++ b/FWCore/Framework/test/test_global_modules_cfg.py @@ -2,15 +2,17 @@ nEvtLumi = 4 nEvtRun = 2*nEvtLumi -nStreams = 16 -nEvt = nStreams*nEvtRun*nEvtLumi +nRuns = 64 +nStreams = 4 +nEvt = nRuns*nEvtRun process = cms.Process("TESTGLOBALMODULES") import FWCore.Framework.test.cmsExceptionsFatalOption_cff process.options = cms.untracked.PSet( - numberOfStreams = cms.untracked.uint32(nStreams) + numberOfStreams = cms.untracked.uint32(nStreams), + numberOfThreads = cms.untracked.uint32(nStreams) ) diff --git a/FWCore/Framework/test/test_limited_modules_cfg.py b/FWCore/Framework/test/test_limited_modules_cfg.py index 65def3c2051f4..41678b2850f9c 100644 --- a/FWCore/Framework/test/test_limited_modules_cfg.py +++ b/FWCore/Framework/test/test_limited_modules_cfg.py @@ -2,15 +2,17 @@ nEvtLumi = 4 nEvtRun = 2*nEvtLumi -nStreams = 16 -nEvt = nStreams*nEvtRun*nEvtLumi +nRuns = 64 +nStreams = 4 +nEvt = nRuns*nEvtRun process = cms.Process("TESTGLOBALMODULES") import FWCore.Framework.test.cmsExceptionsFatalOption_cff process.options = cms.untracked.PSet( - numberOfStreams = cms.untracked.uint32(nStreams) + numberOfStreams = cms.untracked.uint32(nStreams), + numberOfThreads = cms.untracked.uint32(nStreams) ) diff --git a/FWCore/Framework/test/test_one_modules_cfg.py b/FWCore/Framework/test/test_one_modules_cfg.py index 32cca017a7959..98f50ce4bf7b9 100644 --- a/FWCore/Framework/test/test_one_modules_cfg.py +++ b/FWCore/Framework/test/test_one_modules_cfg.py @@ -2,14 +2,16 @@ nEvtLumi = 4 nEvtRun = 2*nEvtLumi -nStreams = 16 -nEvt = nStreams*nEvtRun*nEvtLumi +nRuns = 64 +nStreams = 4 +nEvt = nRuns*nEvtRun process = cms.Process("TESTONEMODULES") import FWCore.Framework.test.cmsExceptionsFatalOption_cff process.options = cms.untracked.PSet( - numberOfStreams = cms.untracked.uint32(nStreams) + numberOfStreams = cms.untracked.uint32(nStreams), + numberOfThreads = cms.untracked.uint32(nStreams) ) process.maxEvents = cms.untracked.PSet( diff --git a/FWCore/Framework/test/test_stream_modules_cfg.py b/FWCore/Framework/test/test_stream_modules_cfg.py index 3a21d5892ca7f..da75cdd629c47 100644 --- a/FWCore/Framework/test/test_stream_modules_cfg.py +++ b/FWCore/Framework/test/test_stream_modules_cfg.py @@ -2,14 +2,16 @@ nEvtLumi = 4 nEvtRun = 2*nEvtLumi -nStreams = 16 -nEvt = nStreams*nEvtRun*nEvtLumi +nRuns = 64 +nStreams = 4 +nEvt = nRuns*nEvtRun process = cms.Process("TESTSTREAMMODULES") import FWCore.Framework.test.cmsExceptionsFatalOption_cff process.options = cms.untracked.PSet( - numberOfStreams = cms.untracked.uint32(nStreams) + numberOfStreams = cms.untracked.uint32(nStreams), + numberOfThreads = cms.untracked.uint32(nStreams) ) From 425dc0aaad34ba05a1b6a9649e18c7f852499562 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sat, 20 Jan 2018 17:10:29 -0600 Subject: [PATCH 35/52] Include stream id in start event message --- FWCore/Framework/interface/InputSource.h | 3 +- FWCore/Framework/src/InputSource.cc | 7 ++-- .../test/unit_test_outputs/infos.log | 2 +- .../unit_test_outputs/u16_altDebugs.mmlog | 4 +-- .../test/unit_test_outputs/u16_default.log | 4 +-- .../test/unit_test_outputs/u16_infos.mmlog | 4 +-- .../test/unit_test_outputs/u17_all.log | 4 +-- .../test/unit_test_outputs/u18_everything.log | 4 +-- .../test/unit_test_outputs/u19_debugs.log | 4 +-- .../test/unit_test_outputs/u19_infos.log | 4 +-- .../test/unit_test_outputs/u19d_debugs.log | 4 +-- .../test/unit_test_outputs/u19d_infos.log | 4 +-- .../test/unit_test_outputs/u1_debugs.log | 4 +-- .../test/unit_test_outputs/u1_default.log | 4 +-- .../test/unit_test_outputs/u1_infos.log | 4 +-- .../test/unit_test_outputs/u1d_debugs.log | 4 +-- .../test/unit_test_outputs/u1d_default.log | 4 +-- .../test/unit_test_outputs/u1d_infos.log | 4 +-- .../test/unit_test_outputs/u20_cerr.log | 2 +- .../test/unit_test_outputs/u21_infos.log | 4 +-- .../test/unit_test_outputs/u23_infos.log | 2 +- .../test/unit_test_outputs/u25_only.log | 2 +- .../test/unit_test_outputs/u27_infos.log | 2 +- .../test/unit_test_outputs/u28_output.log | 6 ++-- .../test/unit_test_outputs/u30_infos.log | 10 +++--- .../test/unit_test_outputs/u31_infos.log | 32 +++++++++---------- .../test/unit_test_outputs/u33_all.log | 4 +-- .../test/unit_test_outputs/u33d_all.log | 4 +-- .../test/unit_test_outputs/u35_infos.log | 4 +-- .../test/unit_test_outputs/u3_infos.log | 6 ++-- .../test/unit_test_outputs/u7_log.log | 4 +-- .../unit_test_outputs/u8_overall_unnamed.log | 2 +- 32 files changed, 79 insertions(+), 77 deletions(-) diff --git a/FWCore/Framework/interface/InputSource.h b/FWCore/Framework/interface/InputSource.h index c14c4f8594652..f31c9b3eb6924 100644 --- a/FWCore/Framework/interface/InputSource.h +++ b/FWCore/Framework/interface/InputSource.h @@ -50,6 +50,7 @@ Some examples of InputSource subclasses may be: #include "FWCore/Utilities/interface/Signal.h" #include "FWCore/Utilities/interface/get_underlying_safe.h" +#include "FWCore/Utilities/interface/StreamID.h" #include #include @@ -153,7 +154,7 @@ namespace edm { void setLuminosityBlockNumber_t(LuminosityBlockNumber_t lb) {setLumi(lb);} /// issue an event report - void issueReports(EventID const& eventID); + void issueReports(EventID const& eventID, StreamID streamID); /// Register any produced products virtual void registerProducts(); diff --git a/FWCore/Framework/src/InputSource.cc b/FWCore/Framework/src/InputSource.cc index 7f3271aee5734..9fcc7d0a7bb26 100644 --- a/FWCore/Framework/src/InputSource.cc +++ b/FWCore/Framework/src/InputSource.cc @@ -317,7 +317,7 @@ namespace edm { if(remainingEvents_ > 0) --remainingEvents_; ++readCount_; setTimestamp(ep.time()); - issueReports(ep.id()); + issueReports(ep.id(), ep.streamID()); } bool @@ -334,7 +334,7 @@ namespace edm { if (result) { if(remainingEvents_ > 0) --remainingEvents_; ++readCount_; - issueReports(ep.id()); + issueReports(ep.id(), ep.streamID()); } } return result; @@ -361,12 +361,13 @@ namespace edm { } void - InputSource::issueReports(EventID const& eventID) { + InputSource::issueReports(EventID const& eventID, StreamID streamID) { if(isInfoEnabled()) { LogVerbatim("FwkReport") << "Begin processing the " << readCount_ << suffix(readCount_) << " record. Run " << eventID.run() << ", Event " << eventID.event() << ", LumiSection " << eventID.luminosityBlock() + << " on stream "<LogInfo was used to send a job report %MSG -Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 at {Timestamp} +Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UnitTestClient_A:sendSomeMessages Run: 1 Event: 2 LogError was used to send this message-which is long enough to span lines but-will not be broken up by the logger any more %MSG @@ -42,7 +42,7 @@ LogInfo was used to send this other message %MSG-i FwkJob: UnitTestClient_A:sendSomeMessages Run: 1 Event: 2 LogInfo was used to send a job report %MSG -Begin processing the 3rd record. Run 1, Event 3, LumiSection 1 at {Timestamp} +Begin processing the 3rd record. Run 1, Event 3, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UnitTestClient_A:sendSomeMessages Run: 1 Event: 3 LogError was used to send this message-which is long enough to span lines but-will not be broken up by the logger any more %MSG diff --git a/FWCore/MessageService/test/unit_test_outputs/u30_infos.log b/FWCore/MessageService/test/unit_test_outputs/u30_infos.log index 09f2d61ecae03..6bf5879ed4029 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u30_infos.log +++ b/FWCore/MessageService/test/unit_test_outputs/u30_infos.log @@ -1,14 +1,14 @@ -Begin processing the 1st record. Run 1, Event 1, LumiSection 1 at {Timestamp} +Begin processing the 1st record. Run 1, Event 1, LumiSection 1 on stream 0 at {Timestamp} %MSG-i NoFreshErrors: UTC_SUMMARY:ssm_sum Run: 1 Event: 1 Not in this event, anyway %MSG -Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 at {Timestamp} +Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 on stream 0 at {Timestamp} %MSG-i NoFreshErrors: UTC_SUMMARY:ssm_sum Run: 1 Event: 2 Not in this event, anyway %MSG -Begin processing the 3rd record. Run 1, Event 3, LumiSection 1 at {Timestamp} +Begin processing the 3rd record. Run 1, Event 3, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_S1:ssm_1a Run: 1 Event: 3 S1 with identifier 11 n = 3 %MSG @@ -39,7 +39,7 @@ cat_B UTC_S2:ssm_2a 4 grouped_cat UTC_S1:ssm_1a 1 grouped_cat UTC_S2:ssm_2a 1 -Begin processing the 4th record. Run 1, Event 4, LumiSection 1 at {Timestamp} +Begin processing the 4th record. Run 1, Event 4, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_S1:ssm_1a Run: 1 Event: 4 S1 with identifier 11 n = 4 %MSG @@ -73,7 +73,7 @@ cat_B UTC_S2:ssm_2a 5 grouped_cat UTC_S1:ssm_1a 1 grouped_cat UTC_S2:ssm_2a 1 -Begin processing the 5th record. Run 1, Event 5, LumiSection 1 at {Timestamp} +Begin processing the 5th record. Run 1, Event 5, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_S1:ssm_1a Run: 1 Event: 5 S1 with identifier 11 n = 5 %MSG diff --git a/FWCore/MessageService/test/unit_test_outputs/u31_infos.log b/FWCore/MessageService/test/unit_test_outputs/u31_infos.log index 28f6b529a60a0..1bf6502db3e8a 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u31_infos.log +++ b/FWCore/MessageService/test/unit_test_outputs/u31_infos.log @@ -1,4 +1,4 @@ -Begin processing the 1st record. Run 1, Event 1, LumiSection 1 at {Timestamp} +Begin processing the 1st record. Run 1, Event 1, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 1 T1 error with identifier 11 event 0 %MSG @@ -53,7 +53,7 @@ T2 warning with identifier 23 event 0 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 1 T2 timer error with identifier 23 event 0 %MSG -Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 at {Timestamp} +Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 2 T1 error with identifier 11 event 1 %MSG @@ -108,7 +108,7 @@ T2 warning with identifier 23 event 1 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 2 T2 timer error with identifier 23 event 1 %MSG -Begin processing the 3rd record. Run 1, Event 3, LumiSection 1 at {Timestamp} +Begin processing the 3rd record. Run 1, Event 3, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 3 T1 error with identifier 11 event 2 %MSG @@ -163,7 +163,7 @@ T2 warning with identifier 23 event 2 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 3 T2 timer error with identifier 23 event 2 %MSG -Begin processing the 4th record. Run 1, Event 4, LumiSection 1 at {Timestamp} +Begin processing the 4th record. Run 1, Event 4, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 4 T1 error with identifier 11 event 3 %MSG @@ -218,7 +218,7 @@ T2 warning with identifier 23 event 3 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 4 T2 timer error with identifier 23 event 3 %MSG -Begin processing the 5th record. Run 1, Event 5, LumiSection 1 at {Timestamp} +Begin processing the 5th record. Run 1, Event 5, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 5 T1 error with identifier 11 event 4 %MSG @@ -273,7 +273,7 @@ T2 warning with identifier 23 event 4 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 5 T2 timer error with identifier 23 event 4 %MSG -Begin processing the 6th record. Run 1, Event 6, LumiSection 1 at {Timestamp} +Begin processing the 6th record. Run 1, Event 6, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 6 T1 error with identifier 11 event 5 %MSG @@ -328,7 +328,7 @@ T2 warning with identifier 23 event 5 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 6 T2 timer error with identifier 23 event 5 %MSG -Begin processing the 7th record. Run 1, Event 7, LumiSection 1 at {Timestamp} +Begin processing the 7th record. Run 1, Event 7, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 7 T1 error with identifier 11 event 6 %MSG @@ -383,7 +383,7 @@ T2 warning with identifier 23 event 6 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 7 T2 timer error with identifier 23 event 6 %MSG -Begin processing the 8th record. Run 1, Event 8, LumiSection 1 at {Timestamp} +Begin processing the 8th record. Run 1, Event 8, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 8 T1 error with identifier 11 event 7 %MSG @@ -438,7 +438,7 @@ T2 warning with identifier 23 event 7 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 8 T2 timer error with identifier 23 event 7 %MSG -Begin processing the 9th record. Run 1, Event 9, LumiSection 1 at {Timestamp} +Begin processing the 9th record. Run 1, Event 9, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 9 T1 error with identifier 11 event 8 %MSG @@ -493,7 +493,7 @@ T2 warning with identifier 23 event 8 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 9 T2 timer error with identifier 23 event 8 %MSG -Begin processing the 10th record. Run 1, Event 10, LumiSection 1 at {Timestamp} +Begin processing the 10th record. Run 1, Event 10, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 10 T1 error with identifier 11 event 9 %MSG @@ -602,7 +602,7 @@ Category timer Module UTC_T2:ssm_2b Severity Error Count 1 Category timer Module UTC_T2:ssm_2c Severity Error Count 1 -------------------------- -Begin processing the 11th record. Run 1, Event 11, LumiSection 1 at {Timestamp} +Begin processing the 11th record. Run 1, Event 11, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 11 T1 error with identifier 11 event 10 %MSG @@ -657,7 +657,7 @@ T2 warning with identifier 23 event 10 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 11 T2 timer error with identifier 23 event 10 %MSG -Begin processing the 12th record. Run 1, Event 12, LumiSection 1 at {Timestamp} +Begin processing the 12th record. Run 1, Event 12, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 12 T1 error with identifier 11 event 11 %MSG @@ -712,7 +712,7 @@ T2 warning with identifier 23 event 11 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 12 T2 timer error with identifier 23 event 11 %MSG -Begin processing the 13th record. Run 1, Event 13, LumiSection 1 at {Timestamp} +Begin processing the 13th record. Run 1, Event 13, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 13 T1 error with identifier 11 event 12 %MSG @@ -767,7 +767,7 @@ T2 warning with identifier 23 event 12 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 13 T2 timer error with identifier 23 event 12 %MSG -Begin processing the 14th record. Run 1, Event 14, LumiSection 1 at {Timestamp} +Begin processing the 14th record. Run 1, Event 14, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 14 T1 error with identifier 11 event 13 %MSG @@ -822,7 +822,7 @@ T2 warning with identifier 23 event 13 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 14 T2 timer error with identifier 23 event 13 %MSG -Begin processing the 15th record. Run 1, Event 15, LumiSection 1 at {Timestamp} +Begin processing the 15th record. Run 1, Event 15, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 15 T1 error with identifier 11 event 14 %MSG @@ -877,7 +877,7 @@ T2 warning with identifier 23 event 14 %MSG-e timer: UTC_T2:ssm_2c Run: 1 Event: 15 T2 timer error with identifier 23 event 14 %MSG -Begin processing the 16th record. Run 1, Event 16, LumiSection 1 at {Timestamp} +Begin processing the 16th record. Run 1, Event 16, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_T1:ssm_1a Run: 1 Event: 16 T1 error with identifier 11 event 15 %MSG diff --git a/FWCore/MessageService/test/unit_test_outputs/u33_all.log b/FWCore/MessageService/test/unit_test_outputs/u33_all.log index 6d77406a36e96..7b7557faaa047 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u33_all.log +++ b/FWCore/MessageService/test/unit_test_outputs/u33_all.log @@ -16,7 +16,7 @@ T1 beginLumi warning with identifier 11 event 0 %MSG-w cat_BL: UTC_V1:ssm_1b@beginLumi Run: 1 Lumi: 1 T1 beginLumi warning with identifier 12 event 0 %MSG -Begin processing the 1st record. Run 1, Event 1, LumiSection 1 at {Timestamp} +Begin processing the 1st record. Run 1, Event 1, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_V1:ssm_1a Run: 1 Event: 1 T1 analyze error with identifier 11 event 0 %MSG @@ -50,7 +50,7 @@ T1 analyze warning with identifier 22 event 0 %MSG-i cat_A: UTC_V2:ssm_2b Run: 1 Event: 1 T1 analyze info with identifier 22 event 0 %MSG -Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 at {Timestamp} +Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_V1:ssm_1a Run: 1 Event: 2 T1 analyze error with identifier 11 event 1 %MSG diff --git a/FWCore/MessageService/test/unit_test_outputs/u33d_all.log b/FWCore/MessageService/test/unit_test_outputs/u33d_all.log index 0a268037f1512..818cdddf998ae 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u33d_all.log +++ b/FWCore/MessageService/test/unit_test_outputs/u33d_all.log @@ -25,7 +25,7 @@ T1 beginLumi warning with identifier 12 event 0 %MSG-d cat_BL: UTC_Vd1:ssm_1b@beginLumi Run: 1 Lumi: 1 UnitTestClient_Vd.cc:54 T1 beginLumi debug with identifier 12 event 0 %MSG -Begin processing the 1st record. Run 1, Event 1, LumiSection 1 at {Timestamp} +Begin processing the 1st record. Run 1, Event 1, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_Vd1:ssm_1a Run: 1 Event: 1 T1 analyze error with identifier 11 event 0 %MSG @@ -62,7 +62,7 @@ T1 analyze warning with identifier 22 event 0 %MSG-i cat_A: UTC_Vd2:ssm_2b Run: 1 Event: 1 T1 analyze info with identifier 22 event 0 %MSG -Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 at {Timestamp} +Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UTC_Vd1:ssm_1a Run: 1 Event: 2 T1 analyze error with identifier 11 event 1 %MSG diff --git a/FWCore/MessageService/test/unit_test_outputs/u35_infos.log b/FWCore/MessageService/test/unit_test_outputs/u35_infos.log index 959e35a65a0e2..e4fcb89171aad 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u35_infos.log +++ b/FWCore/MessageService/test/unit_test_outputs/u35_infos.log @@ -1,4 +1,4 @@ -Begin processing the 1st record. Run 1, Event 1, LumiSection 1 at {Timestamp} +Begin processing the 1st record. Run 1, Event 1, LumiSection 1 on stream 0 at {Timestamp} %MSG-w cat_A: UnitTestClient_W:sendSomeMessages Run: 1 Event: 1 LogWarning was used to send this message %MSG @@ -8,7 +8,7 @@ LogInfo was used to send this message %MSG-w cat_C: UnitTestClient_W:sendSomeMessages Run: 1 Event: 1 LogWarningThatSuppressesLikeLogInfo was used to send this message %MSG -Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 at {Timestamp} +Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 on stream 0 at {Timestamp} %MSG-w cat_A: UnitTestClient_W:sendSomeMessages Run: 1 Event: 2 LogWarning was used to send this message %MSG diff --git a/FWCore/MessageService/test/unit_test_outputs/u3_infos.log b/FWCore/MessageService/test/unit_test_outputs/u3_infos.log index 128424151a448..83ca4de13c70e 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u3_infos.log +++ b/FWCore/MessageService/test/unit_test_outputs/u3_infos.log @@ -1,4 +1,4 @@ -Begin processing the 1st record. Run 1, Event 1, LumiSection 1 at {Timestamp} +Begin processing the 1st record. Run 1, Event 1, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UnitTestClient_A:sendSomeMessages Run: 1 Event: 1 LogError was used to send this message-which is long enough to span lines but-will not be broken up by the logger any more %MSG @@ -17,7 +17,7 @@ LogInfo was used to send this message %MSG-i cat_B: UnitTestClient_A:sendSomeMessages Run: 1 Event: 1 LogInfo was used to send this other message %MSG -Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 at {Timestamp} +Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UnitTestClient_A:sendSomeMessages Run: 1 Event: 2 LogError was used to send this message-which is long enough to span lines but-will not be broken up by the logger any more %MSG @@ -36,7 +36,7 @@ LogInfo was used to send this message %MSG-i cat_B: UnitTestClient_A:sendSomeMessages Run: 1 Event: 2 LogInfo was used to send this other message %MSG -Begin processing the 3rd record. Run 1, Event 3, LumiSection 1 at {Timestamp} +Begin processing the 3rd record. Run 1, Event 3, LumiSection 1 on stream 0 at {Timestamp} %MSG-e cat_A: UnitTestClient_A:sendSomeMessages Run: 1 Event: 3 LogError was used to send this message-which is long enough to span lines but-will not be broken up by the logger any more %MSG diff --git a/FWCore/MessageService/test/unit_test_outputs/u7_log.log b/FWCore/MessageService/test/unit_test_outputs/u7_log.log index ce69e07563686..196fbbde98cc9 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u7_log.log +++ b/FWCore/MessageService/test/unit_test_outputs/u7_log.log @@ -1,11 +1,11 @@ -Begin processing the 1st record. Run 1, Event 1, LumiSection 1 at {Timestamp} +Begin processing the 1st record. Run 1, Event 1, LumiSection 1 on stream 0 at {Timestamp} %MSG-w cat_A: UnitTestClient_D:sendSomeMessages Run: 1 Event: 1 This message should not appear in the framework job report %MSG %MSG-w special: UnitTestClient_D:sendSomeMessages Run: 1 Event: 1 This message should appear in restrict but the others should not %MSG -Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 at {Timestamp} +Begin processing the 2nd record. Run 1, Event 2, LumiSection 1 on stream 0 at {Timestamp} %MSG-w cat_A: UnitTestClient_D:sendSomeMessages Run: 1 Event: 2 This message should not appear in the framework job report %MSG diff --git a/FWCore/MessageService/test/unit_test_outputs/u8_overall_unnamed.log b/FWCore/MessageService/test/unit_test_outputs/u8_overall_unnamed.log index d455ccad14b81..90c58f2ca01cd 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u8_overall_unnamed.log +++ b/FWCore/MessageService/test/unit_test_outputs/u8_overall_unnamed.log @@ -1,4 +1,4 @@ -Begin processing the 1st record. Run 1, Event 1, LumiSection 1 at {Timestamp} +Begin processing the 1st record. Run 1, Event 1, LumiSection 1 on stream 0 at {Timestamp} %MSG-i expect_overall_unnamed: UnitTestClient_E:sendSomeMessages Run: 1 Event: 1 The following outputs are expected: unlisted_category appearing in events 1,2,3,4,5,10,15,25,45 From ff4301358ed07524ffc8d1ec50ae6806309c2605 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sun, 21 Jan 2018 14:40:39 -0600 Subject: [PATCH 36/52] Added method taskHasFailed to WaitingTaskHolder --- FWCore/Concurrency/interface/WaitingTaskHolder.h | 1 + 1 file changed, 1 insertion(+) diff --git a/FWCore/Concurrency/interface/WaitingTaskHolder.h b/FWCore/Concurrency/interface/WaitingTaskHolder.h index 142b9791c0f58..370a870ce2555 100644 --- a/FWCore/Concurrency/interface/WaitingTaskHolder.h +++ b/FWCore/Concurrency/interface/WaitingTaskHolder.h @@ -60,6 +60,7 @@ namespace edm { } // ---------- const member functions --------------------- + bool taskHasFailed() const { return m_task->exceptionPtr() != nullptr; } // ---------- static member functions -------------------- From d30854b66c38b05fc33b18614386d4266d8a2a38 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sun, 21 Jan 2018 14:58:14 -0600 Subject: [PATCH 37/52] Do not start a new LuminosityBlock if there was an exception New LuminosityBlocks can be started before the previous LuminosityBlock has finished all its end transition processing. If that end transition had an exception, we should not start the new LuminosityBlock. --- FWCore/Framework/src/EventProcessor.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index e1fa1832f3d46..728d7e989d0b8 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1100,9 +1100,13 @@ namespace edm { void EventProcessor::beginLumiAsync(IOVSyncValue const& iSync, std::shared_ptr const& iRunResource, edm::WaitingTaskHolder iHolder) { + if(iHolder.taskHasFailed()) { return; } + auto status= std::make_shared(this, preallocations_.numberOfStreams(), iRunResource) ; auto lumiWork = [this, iHolder, iSync, status](edm::LimitedTaskQueue::Resumer iResumer) mutable { + if(iHolder.taskHasFailed()) { return; } + status->setResumer(std::move(iResumer)); sourceResourcesAcquirer_.serialQueueChain().push([this,iHolder,status]() mutable { From 7e09ac37a1d747b49b3b3d3fbee0c2be65835653 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 22 Jan 2018 08:07:01 -0600 Subject: [PATCH 38/52] Code cleanup --- FWCore/Framework/src/streamTransitionAsync.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/FWCore/Framework/src/streamTransitionAsync.h b/FWCore/Framework/src/streamTransitionAsync.h index 3700a27d32454..3cd34bdaac8a1 100644 --- a/FWCore/Framework/src/streamTransitionAsync.h +++ b/FWCore/Framework/src/streamTransitionAsync.h @@ -122,18 +122,17 @@ namespace edm { iWait.doneWaiting(excpt); }); WaitingTaskHolder h(delayError); - for_all(iSubProcesses, [&h,iStreamIndex, &iPrincipal, iTS,cleaningUpAfterException](auto& subProcess){ - subProcessDoStreamEndTransitionAsync(h,subProcess,iStreamIndex,iPrincipal, iTS,cleaningUpAfterException); }); + for(auto& subProcess: iSubProcesses) { + subProcessDoStreamEndTransitionAsync(h,subProcess,iStreamIndex,iPrincipal, iTS,cleaningUpAfterException); + } } else { - for_all(iSubProcesses, [&iWait,iStreamIndex, &iPrincipal, iTS,cleaningUpAfterException](auto& subProcess){ - subProcessDoStreamEndTransitionAsync(iWait,subProcess,iStreamIndex,iPrincipal, iTS,cleaningUpAfterException); }); + for(auto& subProcess: iSubProcesses) { + subProcessDoStreamEndTransitionAsync(iWait,subProcess,iStreamIndex,iPrincipal, iTS,cleaningUpAfterException); + } } }); - WaitingTaskHolder h(subs); - iSchedule.processOneStreamAsync(std::move(h), iStreamIndex,iPrincipal, iES,cleaningUpAfterException); - - + iSchedule.processOneStreamAsync(WaitingTaskHolder(subs), iStreamIndex,iPrincipal, iES,cleaningUpAfterException); } template From c2fe1764367f28566fee38d5008bd3d7ea8c145d Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 22 Jan 2018 08:53:53 -0600 Subject: [PATCH 39/52] Call doneWaiting earlier to signal failure By setting doneWaiting early, a waiting beginLumiAsync call can see that there was a failure in the previous endLumi and then not processes the new lumi. --- FWCore/Framework/src/EventProcessor.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 728d7e989d0b8..9ad56002dcc1c 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1251,6 +1251,10 @@ namespace edm { std::exception_ptr ptr; if(iPtr) { ptr = *iPtr; + WaitingTaskHolder tmp(t); + //set the exception early to prevent a beginLumi from running + // we use a copy to keep t from resetting on doneWaiting call. + tmp.doneWaiting(ptr); } else { try { ServiceRegistry::Operate operate(serviceToken_); From d7f16458b6c10a253c4cc5101673ee9e63dcea5f Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 22 Jan 2018 10:14:20 -0600 Subject: [PATCH 40/52] Fixed LumiSummary test modules The LumiSummary test modules had an assumption that all streams stop processing events before any stream does an endLumi call. This is not the case anymore and should not have been in the code to begin with (since it was violating the threading design). By clearing and getting the value from the luminosity block cache atomically, we avoid a problem where the endLumi could be called while another stream is calling the event method of the module. --- FWCore/Framework/test/stubs/TestStreamAnalyzers.cc | 11 ++++++++--- FWCore/Framework/test/stubs/TestStreamFilters.cc | 11 ++++++++--- FWCore/Framework/test/stubs/TestStreamProducers.cc | 11 ++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/FWCore/Framework/test/stubs/TestStreamAnalyzers.cc b/FWCore/Framework/test/stubs/TestStreamAnalyzers.cc index 914a156b8542b..7df05b0ec2b90 100644 --- a/FWCore/Framework/test/stubs/TestStreamAnalyzers.cc +++ b/FWCore/Framework/test/stubs/TestStreamAnalyzers.cc @@ -339,6 +339,7 @@ struct Cache { class LumiSummaryIntAnalyzer : public edm::stream::EDAnalyzer,edm::LuminosityBlockSummaryCache> { public: static std::atomic m_count; + static std::atomic m_lumiSumCalls; unsigned int trans_; static std::atomic cvalue_; static std::atomic gbl; @@ -392,10 +393,12 @@ struct Cache { void endLuminosityBlockSummary(edm::LuminosityBlock const&, edm::EventSetup const&, Cache* gCache) const override { + ++m_lumiSumCalls; bls=false; els=true; - gCache->value += luminosityBlockCache()->value; - luminosityBlockCache()->value = 0; + //This routine could be called at the same time as another stream is calling analyze so must do the change atomically + auto v = luminosityBlockCache()->value.exchange(0); + gCache->value += v; if ( el ) { throw cms::Exception("end out of sequence") << "endLuminosityBlock seen before endLuminosityBlockSummary"; @@ -404,6 +407,7 @@ struct Cache { static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const&, edm::EventSetup const&, LuminosityBlockContext const*, Cache* gCache){ ++m_count; + auto nLumis = m_lumiSumCalls.load(); gbls=false; gels=true; if ( !els ) { @@ -412,7 +416,7 @@ struct Cache { } if ( gCache->value != cvalue_) { throw cms::Exception("cache value") - << gCache->value << " but it was supposed to be " << cvalue_; + << gCache->value << " but it was supposed to be " << cvalue_<<" endLumiBlockSummary called "< edmtest::stream::RunIntAnalyzer::m_count{0}; std::atomic edmtest::stream::LumiIntAnalyzer::m_count{0}; std::atomic edmtest::stream::RunSummaryIntAnalyzer::m_count{0}; std::atomic edmtest::stream::LumiSummaryIntAnalyzer::m_count{0}; +std::atomic edmtest::stream::LumiSummaryIntAnalyzer::m_lumiSumCalls{0}; std::atomic edmtest::stream::GlobalIntAnalyzer::cvalue_{0}; std::atomic edmtest::stream::RunIntAnalyzer::cvalue_{0}; std::atomic edmtest::stream::LumiIntAnalyzer::cvalue_{0}; diff --git a/FWCore/Framework/test/stubs/TestStreamFilters.cc b/FWCore/Framework/test/stubs/TestStreamFilters.cc index 636db7547b5d7..8097bf1fe2840 100644 --- a/FWCore/Framework/test/stubs/TestStreamFilters.cc +++ b/FWCore/Framework/test/stubs/TestStreamFilters.cc @@ -320,6 +320,7 @@ struct Cache { class LumiSummaryIntFilter : public edm::stream::EDFilter,edm::LuminosityBlockSummaryCache> { public: static std::atomic m_count; + static std::atomic m_lumiSumCalls; unsigned int trans_; static std::atomic cvalue_; static std::atomic gbl; @@ -374,10 +375,12 @@ struct Cache { } void endLuminosityBlockSummary(edm::LuminosityBlock const&, edm::EventSetup const&, Cache* gCache) const override { + ++m_lumiSumCalls; bls=false; els=true; - gCache->value += luminosityBlockCache()->value; - luminosityBlockCache()->value = 0; + //This routine could be called at the same time as another stream is calling filter so must do the change atomically + auto v = luminosityBlockCache()->value.exchange(0); + gCache->value += v; if ( el ) { throw cms::Exception("end out of sequence") << "endLuminosityBlock seen before endLuminosityBlockSummary"; @@ -386,6 +389,7 @@ struct Cache { static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const&, edm::EventSetup const&, LuminosityBlockContext const*, Cache* gCache){ ++m_count; + auto nLumis = m_lumiSumCalls.load(); gbls=false; gels=true; if ( !els ) { @@ -395,7 +399,7 @@ struct Cache { } if( gCache->value != cvalue_) { throw cms::Exception("cache value") - << gCache->value << " but it was supposed to be " << cvalue_; + << gCache->value << " but it was supposed to be " << cvalue_<<" endLumiBlockSummary called "< edmtest::stream::RunSummaryIntFilter::brs{false}; std::atomic edmtest::stream::RunSummaryIntFilter::ers{false}; std::atomic edmtest::stream::RunSummaryIntFilter::br{false}; std::atomic edmtest::stream::RunSummaryIntFilter::er{false}; +std::atomic edmtest::stream::LumiSummaryIntFilter::m_lumiSumCalls{0}; std::atomic edmtest::stream::LumiSummaryIntFilter::gbl{false}; std::atomic edmtest::stream::LumiSummaryIntFilter::gel{false}; std::atomic edmtest::stream::LumiSummaryIntFilter::gbls{false}; diff --git a/FWCore/Framework/test/stubs/TestStreamProducers.cc b/FWCore/Framework/test/stubs/TestStreamProducers.cc index ad80d285ff04e..07481f81ff39b 100644 --- a/FWCore/Framework/test/stubs/TestStreamProducers.cc +++ b/FWCore/Framework/test/stubs/TestStreamProducers.cc @@ -346,6 +346,7 @@ struct UnsafeCache { class LumiSummaryIntProducer : public edm::stream::EDProducer,edm::LuminosityBlockSummaryCache> { public: static std::atomic m_count; + static std::atomic m_lumiSumCalls; unsigned int trans_; static std::atomic cvalue_; static std::atomic gbl; @@ -400,10 +401,12 @@ struct UnsafeCache { void endLuminosityBlockSummary(edm::LuminosityBlock const&, edm::EventSetup const&, UnsafeCache* gCache) const override { + ++m_lumiSumCalls; bls=false; els=true; - gCache->value += luminosityBlockCache()->value; - luminosityBlockCache()->value = 0; + //This routine could be called at the same time as another stream is calling produce so must do the change atomically + auto v = luminosityBlockCache()->value.exchange(0); + gCache->value += v; if ( el ) { throw cms::Exception("end out of sequence") << "endLuminosityBlock seen before endLuminosityBlockSummary"; @@ -412,6 +415,7 @@ struct UnsafeCache { static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const&, edm::EventSetup const&, LuminosityBlockContext const*, UnsafeCache* gCache) { ++m_count; + auto nLumis =m_lumiSumCalls.load(); gbls=false; gels=true; if ( !els ) { @@ -420,7 +424,7 @@ struct UnsafeCache { } if ( gCache->value != cvalue_) { throw cms::Exception("cache value") - << gCache->value << " but it was supposed to be " << cvalue_; + << gCache->value << " but it was supposed to be " << cvalue_<<" endLumiBlockSummary called "< edmtest::stream::RunSummaryIntProducer::brs{false}; std::atomic edmtest::stream::RunSummaryIntProducer::ers{false}; std::atomic edmtest::stream::RunSummaryIntProducer::br{false}; std::atomic edmtest::stream::RunSummaryIntProducer::er{false}; +std::atomic edmtest::stream::LumiSummaryIntProducer::m_lumiSumCalls{0}; std::atomic edmtest::stream::LumiSummaryIntProducer::gbl{false}; std::atomic edmtest::stream::LumiSummaryIntProducer::gel{false}; std::atomic edmtest::stream::LumiSummaryIntProducer::gbls{false}; From 97d6a9abbfcccef68a319209902adbe0920dd979 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 22 Jan 2018 10:43:20 -0600 Subject: [PATCH 41/52] Make sure task will be run even if there is an exception If an exception happens in the service system, we still want to be sure the end task will be executed. --- FWCore/Framework/src/StreamSchedule.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/FWCore/Framework/src/StreamSchedule.h b/FWCore/Framework/src/StreamSchedule.h index bf42b3eaa9a9f..994025a075746 100644 --- a/FWCore/Framework/src/StreamSchedule.h +++ b/FWCore/Framework/src/StreamSchedule.h @@ -427,9 +427,15 @@ namespace edm { }); auto task = make_functor_task(tbb::task::allocate_root(), [this,doneTask,&ep,&es,token] () mutable { - ServiceRegistry::Operate op(token); - T::preScheduleSignal(actReg_.get(), &streamContext_); WaitingTaskHolder h(doneTask); + + ServiceRegistry::Operate op(token); + try { + T::preScheduleSignal(actReg_.get(), &streamContext_); + }catch(...) { + h.doneWaiting(std::current_exception()); + return; + } workerManager_.resetAll(); for(auto& p : end_paths_) { From f30fcb5c406dd06312ba79729ca8e4da7d70d642 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 22 Jan 2018 14:05:53 -0600 Subject: [PATCH 42/52] Only call writeLumi if begin lumi succeeded --- FWCore/Framework/src/EventProcessor.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 9ad56002dcc1c..ec020018d826c 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1259,9 +1259,10 @@ namespace edm { try { ServiceRegistry::Operate operate(serviceToken_); - //TODO: Only supposed to call writeLumi if beginLumi succeeded - writeLumi(*status); - + //Only call writeLumi if beginLumi succeeded + if(status->didGlobalBeginSucceed()) { + writeLumi(*status); + } if(looper_) { auto& lp = *(status->lumiPrincipal()); EventSetup const& es = esp_->eventSetup(); From f68aa3672730a297d4b63d889d5c8cc6d6379d5b Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 22 Jan 2018 14:07:24 -0600 Subject: [PATCH 43/52] Update MockEventProcessor The EventProcessor now uses more concurrency which means less work done in the TransitionProcessors and more in the EventProcessor. The MockEventProcessor had to be updated to match the new behavior. --- FWCore/Framework/test/MockEventProcessor.cc | 47 ++++++++++++++++----- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/FWCore/Framework/test/MockEventProcessor.cc b/FWCore/Framework/test/MockEventProcessor.cc index 12fb0ac25f922..9a5b8251efbd4 100644 --- a/FWCore/Framework/test/MockEventProcessor.cc +++ b/FWCore/Framework/test/MockEventProcessor.cc @@ -135,11 +135,20 @@ namespace edm { InputSource::ItemType MockEventProcessor::readAndProcessEvents() { - readAndProcessEvent(); - if(shouldWeStop()) { - return InputSource::IsEvent; - } - return nextTransitionType(); + bool first = true; + do { + if(first) { + first = false; + } else { + shouldWeStop(); + } + readAndProcessEvent(); + if(shouldWeStop()) { + return InputSource::IsEvent; + } + }while(nextTransitionType() == InputSource::IsEvent); + + return lastTransitionType(); } @@ -239,25 +248,43 @@ namespace edm { InputSource::ItemType MockEventProcessor::processLumis(std::shared_ptr iRunResource) { - assert(false); - if(lumiStatus_) { - //Need to do event processing here - readAndProcessEvents(); + if(lumiStatus_ and + lumiStatus_->runResource() == iRunResource and + lumiStatus_->lumiPrincipal()->lumi_ == lumi_) { + readAndMergeLumi(*lumiStatus_); + + if(nextTransitionType() == InputSource::IsEvent) { + readAndProcessEvents(); + if(shouldWeStop()) { + return edm::InputSource::IsStop; + } + } } else { + endUnfinishedLumi(); lumiStatus_ = std::make_shared(this,1,iRunResource); auto lumi = readLuminosityBlock(*lumiStatus_); output_ << "\tbeginLumi " << run_ << "/" << lumi << "\n"; throwIfNeeded(); lumiStatus_->globalBeginDidSucceed(); //Need to do event processing here - readAndProcessEvents(); + if(nextTransitionType() == InputSource::IsEvent) { + readAndProcessEvents(); + if(shouldWeStop()) { + return edm::InputSource::IsStop; + } + } } return lastTransitionType(); } void MockEventProcessor::endUnfinishedLumi() { if(lumiStatus_) { + auto tmp = lumiStatus_; endLumi(); + if(tmp->didGlobalBeginSucceed()) { + writeLumi(*tmp); + } + deleteLumiFromCache(*tmp); } } From 415ddeb7733ee033e122ce7455708c97ba7e96d4 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 22 Jan 2018 19:43:05 -0600 Subject: [PATCH 44/52] Provide access to the index --- FWCore/Framework/interface/LuminosityBlockForOutput.h | 5 +++++ FWCore/Framework/src/LuminosityBlockForOutput.cc | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/FWCore/Framework/interface/LuminosityBlockForOutput.h b/FWCore/Framework/interface/LuminosityBlockForOutput.h index 58e87ca262227..1679ef6890b01 100644 --- a/FWCore/Framework/interface/LuminosityBlockForOutput.h +++ b/FWCore/Framework/interface/LuminosityBlockForOutput.h @@ -23,6 +23,7 @@ For its usage, see "FWCore/Framework/interface/PrincipalGetAdapter.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/OccurrenceForOutput.h" #include "FWCore/Utilities/interface/propagate_const.h" +#include "FWCore/Utilities/interface/LuminosityBlockIndex.h" #include #include @@ -49,6 +50,10 @@ namespace edm { Timestamp const& beginTime() const {return aux_.beginTime();} Timestamp const& endTime() const {return aux_.endTime();} + /**\return Reusable index which can be used to separate data for different simultaneous LuminosityBlocks. + */ + LuminosityBlockIndex index() const; + RunForOutput const& getRun() const { return *run_; diff --git a/FWCore/Framework/src/LuminosityBlockForOutput.cc b/FWCore/Framework/src/LuminosityBlockForOutput.cc index 937319e4d06bc..74c664a21e613 100644 --- a/FWCore/Framework/src/LuminosityBlockForOutput.cc +++ b/FWCore/Framework/src/LuminosityBlockForOutput.cc @@ -21,4 +21,11 @@ namespace edm { LuminosityBlockForOutput::luminosityBlockPrincipal() const { return dynamic_cast(principal()); } + + /**\return Reusable index which can be used to separate data for different simultaneous LuminosityBlocks. + */ + LuminosityBlockIndex LuminosityBlockForOutput::index() const { + return luminosityBlockPrincipal().index(); + } + } From bbc0943e4f1c5149127fa28a6bd78449b674beb9 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 22 Jan 2018 19:46:12 -0600 Subject: [PATCH 45/52] Handle more than one LuminosityBlock in the cache Now the LuminosityBlock cache is configured to have space for the number of allowed concurrent LuminosityBlocks allowed in the job. --- .../interface/global/EDAnalyzerBase.h | 1 + .../Framework/interface/global/EDFilterBase.h | 1 + .../interface/global/EDProducerBase.h | 1 + .../interface/global/OutputModuleBase.h | 1 + .../Framework/interface/global/implementors.h | 19 ++++++++++++------- .../global/outputmoduleAbilityToImplementor.h | 18 +++++++++++------- .../interface/limited/EDAnalyzerBase.h | 1 + .../interface/limited/EDFilterBase.h | 1 + .../interface/limited/EDProducerBase.h | 1 + .../interface/limited/OutputModuleBase.h | 1 + .../interface/limited/implementors.h | 19 ++++++++++++------- .../outputmoduleAbilityToImplementor.h | 18 +++++++++++------- .../interface/stream/EDAnalyzerAdaptor.h | 5 +++++ .../interface/stream/EDAnalyzerAdaptorBase.h | 1 + .../interface/stream/ProducingModuleAdaptor.h | 4 ++++ .../stream/ProducingModuleAdaptorBase.h | 1 + FWCore/Framework/src/global/EDAnalyzerBase.cc | 2 ++ FWCore/Framework/src/global/EDFilterBase.cc | 2 ++ FWCore/Framework/src/global/EDProducerBase.cc | 2 ++ .../Framework/src/global/OutputModuleBase.cc | 1 + .../Framework/src/limited/EDAnalyzerBase.cc | 2 ++ FWCore/Framework/src/limited/EDFilterBase.cc | 2 ++ .../Framework/src/limited/EDProducerBase.cc | 2 ++ .../Framework/src/limited/OutputModuleBase.cc | 1 + .../src/stream/EDAnalyzerAdaptorBase.cc | 1 + .../src/stream/ProducingModuleAdaptorBase.cc | 2 ++ .../Framework/test/global_module_t.cppunit.cc | 9 ++++++--- .../test/limited_module_t.cppunit.cc | 4 ++-- 28 files changed, 90 insertions(+), 33 deletions(-) diff --git a/FWCore/Framework/interface/global/EDAnalyzerBase.h b/FWCore/Framework/interface/global/EDAnalyzerBase.h index 1d32706e97ac4..f13c4af441178 100644 --- a/FWCore/Framework/interface/global/EDAnalyzerBase.h +++ b/FWCore/Framework/interface/global/EDAnalyzerBase.h @@ -121,6 +121,7 @@ namespace edm { virtual void preallocStreams(unsigned int); + virtual void preallocLumis(unsigned int); virtual void preallocate(PreallocationConfiguration const&); virtual void doBeginStream_(StreamID id); virtual void doEndStream_(StreamID id); diff --git a/FWCore/Framework/interface/global/EDFilterBase.h b/FWCore/Framework/interface/global/EDFilterBase.h index d783ec3ecf1e5..27acd6876bd91 100644 --- a/FWCore/Framework/interface/global/EDFilterBase.h +++ b/FWCore/Framework/interface/global/EDFilterBase.h @@ -129,6 +129,7 @@ namespace edm { virtual void endJob(){} virtual void preallocStreams(unsigned int); + virtual void preallocLumis(unsigned int); virtual void preallocate(PreallocationConfiguration const&); virtual void doBeginStream_(StreamID id); virtual void doEndStream_(StreamID id); diff --git a/FWCore/Framework/interface/global/EDProducerBase.h b/FWCore/Framework/interface/global/EDProducerBase.h index 70e956307ae37..998ef9b608e32 100644 --- a/FWCore/Framework/interface/global/EDProducerBase.h +++ b/FWCore/Framework/interface/global/EDProducerBase.h @@ -132,6 +132,7 @@ namespace edm { virtual void endJob(){} virtual void preallocStreams(unsigned int); + virtual void preallocLumis(unsigned int); virtual void preallocate(PreallocationConfiguration const&); virtual void doBeginStream_(StreamID id); virtual void doEndStream_(StreamID id); diff --git a/FWCore/Framework/interface/global/OutputModuleBase.h b/FWCore/Framework/interface/global/OutputModuleBase.h index ec79e595e2816..223c4e329b69d 100644 --- a/FWCore/Framework/interface/global/OutputModuleBase.h +++ b/FWCore/Framework/interface/global/OutputModuleBase.h @@ -248,6 +248,7 @@ namespace edm { virtual bool isFileOpen() const { return true; } virtual void preallocStreams(unsigned int){} + virtual void preallocLumis(unsigned int){} virtual void preallocate(PreallocationConfiguration const&){} virtual void doBeginStream_(StreamID){} virtual void doEndStream_(StreamID){} diff --git a/FWCore/Framework/interface/global/implementors.h b/FWCore/Framework/interface/global/implementors.h index 0a7c71662f3d7..a6cbe0803ef3b 100644 --- a/FWCore/Framework/interface/global/implementors.h +++ b/FWCore/Framework/interface/global/implementors.h @@ -24,6 +24,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/LuminosityBlock.h" #include "FWCore/Utilities/interface/StreamID.h" #include "FWCore/Utilities/interface/RunIndex.h" #include "FWCore/Utilities/interface/LuminosityBlockIndex.h" @@ -120,20 +121,24 @@ namespace edm { LuminosityBlockCacheHolder& operator=(LuminosityBlockCacheHolder const&) = delete; ~LuminosityBlockCacheHolder() noexcept(false) override {}; protected: - C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return cache_.get(); } + void preallocLumis(unsigned int iNLumis) final { + caches_.reset( new std::shared_ptr[iNLumis]); + } + + C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return caches_[iID].get(); } private: - void doBeginLuminosityBlock_(LuminosityBlock const& rp, EventSetup const& c) final { - cache_ = globalBeginLuminosityBlock(rp,c); + void doBeginLuminosityBlock_(LuminosityBlock const& lp, EventSetup const& c) final { + caches_[lp.index()] = globalBeginLuminosityBlock(lp,c); } - void doEndLuminosityBlock_(LuminosityBlock const& rp, EventSetup const& c) final { - globalEndLuminosityBlock(rp,c); - cache_.reset(); + void doEndLuminosityBlock_(LuminosityBlock const& lp, EventSetup const& c) final { + globalEndLuminosityBlock(lp,c); + caches_[lp.index()].reset(); } virtual std::shared_ptr globalBeginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0; virtual void globalEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0; //When threaded we will have a container for N items whre N is # of simultaneous runs - std::shared_ptr cache_; + std::unique_ptr[]> caches_; }; template class EndRunSummaryProducer; diff --git a/FWCore/Framework/interface/global/outputmoduleAbilityToImplementor.h b/FWCore/Framework/interface/global/outputmoduleAbilityToImplementor.h index 4e6818d16db32..3121d148e5993 100644 --- a/FWCore/Framework/interface/global/outputmoduleAbilityToImplementor.h +++ b/FWCore/Framework/interface/global/outputmoduleAbilityToImplementor.h @@ -22,6 +22,7 @@ #include "FWCore/Framework/interface/moduleAbilities.h" #include "FWCore/Framework/interface/global/implementors.h" #include "FWCore/Framework/interface/global/OutputModuleBase.h" +#include "FWCore/Framework/interface/LuminosityBlockForOutput.h" // forward declarations @@ -79,20 +80,23 @@ namespace edm { LuminosityBlockCacheHolder& operator=(LuminosityBlockCacheHolder const&) = delete; ~LuminosityBlockCacheHolder() noexcept(false) override {}; protected: - C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return cache_.get(); } + void preallocLumis(unsigned int iNLumis) final { + caches_.reset(new std::shared_ptr[iNLumis]); + } + C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return caches_[iID].get(); } private: - void doBeginLuminosityBlock_(LuminosityBlockForOutput const& rp) final { - cache_ = globalBeginLuminosityBlock(rp); + void doBeginLuminosityBlock_(LuminosityBlockForOutput const& lp) final { + caches_[lp.index()] = globalBeginLuminosityBlock(lp); } - void doEndLuminosityBlock_(LuminosityBlockForOutput const& rp) final { - globalEndLuminosityBlock(rp); - cache_.reset(); + void doEndLuminosityBlock_(LuminosityBlockForOutput const& lp) final { + globalEndLuminosityBlock(lp); + caches_[lp.index()].reset(); } virtual std::shared_ptr globalBeginLuminosityBlock(LuminosityBlockForOutput const&) const = 0; virtual void globalEndLuminosityBlock(LuminosityBlockForOutput const&) const = 0; //When threaded we will have a container for N items whre N is # of simultaneous runs - std::shared_ptr cache_; + std::unique_ptr[]> caches_; }; template struct AbilityToImplementor; diff --git a/FWCore/Framework/interface/limited/EDAnalyzerBase.h b/FWCore/Framework/interface/limited/EDAnalyzerBase.h index c337c52ae3ab9..47cb2485e9468 100644 --- a/FWCore/Framework/interface/limited/EDAnalyzerBase.h +++ b/FWCore/Framework/interface/limited/EDAnalyzerBase.h @@ -127,6 +127,7 @@ namespace edm { virtual void preallocStreams(unsigned int); + virtual void preallocLumis(unsigned int); virtual void preallocate(PreallocationConfiguration const&); virtual void doBeginStream_(StreamID id); virtual void doEndStream_(StreamID id); diff --git a/FWCore/Framework/interface/limited/EDFilterBase.h b/FWCore/Framework/interface/limited/EDFilterBase.h index b24d02735f353..fcdcc63b3af8e 100644 --- a/FWCore/Framework/interface/limited/EDFilterBase.h +++ b/FWCore/Framework/interface/limited/EDFilterBase.h @@ -130,6 +130,7 @@ namespace edm { virtual void endJob(){} virtual void preallocStreams(unsigned int); + virtual void preallocLumis(unsigned int); virtual void preallocate(PreallocationConfiguration const&); virtual void doBeginStream_(StreamID id); virtual void doEndStream_(StreamID id); diff --git a/FWCore/Framework/interface/limited/EDProducerBase.h b/FWCore/Framework/interface/limited/EDProducerBase.h index bc973032cdc07..048b12bd3f2df 100644 --- a/FWCore/Framework/interface/limited/EDProducerBase.h +++ b/FWCore/Framework/interface/limited/EDProducerBase.h @@ -133,6 +133,7 @@ namespace edm { virtual void endJob(){} virtual void preallocStreams(unsigned int); + virtual void preallocLumis(unsigned int); virtual void preallocate(PreallocationConfiguration const&); virtual void doBeginStream_(StreamID id); virtual void doEndStream_(StreamID id); diff --git a/FWCore/Framework/interface/limited/OutputModuleBase.h b/FWCore/Framework/interface/limited/OutputModuleBase.h index 38fd2f59e8910..852a3dabe3c06 100644 --- a/FWCore/Framework/interface/limited/OutputModuleBase.h +++ b/FWCore/Framework/interface/limited/OutputModuleBase.h @@ -254,6 +254,7 @@ namespace edm { virtual bool isFileOpen() const { return true; } virtual void preallocStreams(unsigned int){} + virtual void preallocLumis(unsigned int){} virtual void preallocate(PreallocationConfiguration const&){} virtual void doBeginStream_(StreamID){} virtual void doEndStream_(StreamID){} diff --git a/FWCore/Framework/interface/limited/implementors.h b/FWCore/Framework/interface/limited/implementors.h index 57fa75b1bea72..9d131a621a91b 100644 --- a/FWCore/Framework/interface/limited/implementors.h +++ b/FWCore/Framework/interface/limited/implementors.h @@ -24,6 +24,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/LuminosityBlock.h" #include "FWCore/Utilities/interface/StreamID.h" #include "FWCore/Utilities/interface/RunIndex.h" #include "FWCore/Utilities/interface/LuminosityBlockIndex.h" @@ -121,20 +122,24 @@ namespace edm { LuminosityBlockCacheHolder& operator=(LuminosityBlockCacheHolder const&) = delete; ~LuminosityBlockCacheHolder() noexcept(false) {}; protected: - C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return cache_.get(); } + C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return caches_[iID].get(); } private: - void doBeginLuminosityBlock_(LuminosityBlock const& rp, EventSetup const& c) final { - cache_ = globalBeginLuminosityBlock(rp,c); + void preallocLumis(unsigned int iNLumis) final { + caches_.reset( new std::shared_ptr[iNLumis]); } - void doEndLuminosityBlock_(LuminosityBlock const& rp, EventSetup const& c) final { - globalEndLuminosityBlock(rp,c); - cache_.reset(); + + void doBeginLuminosityBlock_(LuminosityBlock const& lp, EventSetup const& c) final { + caches_[lp.index()] = globalBeginLuminosityBlock(lp,c); + } + void doEndLuminosityBlock_(LuminosityBlock const& lp, EventSetup const& c) final { + globalEndLuminosityBlock(lp,c); + caches_[lp.index()].reset(); } virtual std::shared_ptr globalBeginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0; virtual void globalEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0; //When threaded we will have a container for N items whre N is # of simultaneous runs - std::shared_ptr cache_; + std::unique_ptr[]> caches_; }; template class EndRunSummaryProducer; diff --git a/FWCore/Framework/interface/limited/outputmoduleAbilityToImplementor.h b/FWCore/Framework/interface/limited/outputmoduleAbilityToImplementor.h index 4804124c20a0b..a0659af9f3131 100644 --- a/FWCore/Framework/interface/limited/outputmoduleAbilityToImplementor.h +++ b/FWCore/Framework/interface/limited/outputmoduleAbilityToImplementor.h @@ -22,6 +22,7 @@ #include "FWCore/Framework/interface/moduleAbilities.h" #include "FWCore/Framework/interface/limited/implementors.h" #include "FWCore/Framework/interface/limited/OutputModuleBase.h" +#include "FWCore/Framework/interface/LuminosityBlockForOutput.h" // forward declarations @@ -78,20 +79,23 @@ namespace edm { LuminosityBlockCacheHolder& operator=(LuminosityBlockCacheHolder const&) = delete; ~LuminosityBlockCacheHolder() noexcept(false) override {}; protected: - C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return cache_.get(); } + C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return caches_[iID].get(); } private: - void doBeginLuminosityBlock_(LuminosityBlockForOutput const& rp) final { - cache_ = globalBeginLuminosityBlock(rp); + void preallocLumis(unsigned int iNLumis) final { + caches_.reset(new std::shared_ptr[iNLumis]); } - void doEndLuminosityBlock_(LuminosityBlockForOutput const& rp) final { - globalEndLuminosityBlock(rp); - cache_.reset(); + void doBeginLuminosityBlock_(LuminosityBlockForOutput const& lp) final { + caches_[lp.index()] = globalBeginLuminosityBlock(lp); + } + void doEndLuminosityBlock_(LuminosityBlockForOutput const& lp) final { + globalEndLuminosityBlock(lp); + caches_[lp.index()].reset(); } virtual std::shared_ptr globalBeginLuminosityBlock(LuminosityBlockForOutput const&) const = 0; virtual void globalEndLuminosityBlock(LuminosityBlockForOutput const&) const = 0; //When threaded we will have a container for N items whre N is # of simultaneous runs - std::shared_ptr cache_; + std::unique_ptr[]> caches_; }; template struct AbilityToImplementor; diff --git a/FWCore/Framework/interface/stream/EDAnalyzerAdaptor.h b/FWCore/Framework/interface/stream/EDAnalyzerAdaptor.h index 6f5b0e67325e0..9e9142e9abf96 100644 --- a/FWCore/Framework/interface/stream/EDAnalyzerAdaptor.h +++ b/FWCore/Framework/interface/stream/EDAnalyzerAdaptor.h @@ -88,6 +88,11 @@ namespace edm { m_pset= nullptr; } + void preallocLumis(unsigned int iNLumis) final { + m_lumis.resize(iNLumis); + m_lumiSummaries.resize(iNLumis); + } + void doEndJob() final { MyGlobal::endJob(m_global.get()); } diff --git a/FWCore/Framework/interface/stream/EDAnalyzerAdaptorBase.h b/FWCore/Framework/interface/stream/EDAnalyzerAdaptorBase.h index 77ed062f32a42..ea17d7ab29ddf 100644 --- a/FWCore/Framework/interface/stream/EDAnalyzerAdaptorBase.h +++ b/FWCore/Framework/interface/stream/EDAnalyzerAdaptorBase.h @@ -117,6 +117,7 @@ namespace edm { ActivityRegistry*, ModuleCallingContext const*) ; void doPreallocate(PreallocationConfiguration const&); + virtual void preallocLumis(unsigned int) {} //For now this is a placeholder /*virtual*/ void preActionBeforeRunEventAsync(WaitingTask* iTask, ModuleCallingContext const& iModuleCallingContext, Principal const& iPrincipal) const {} diff --git a/FWCore/Framework/interface/stream/ProducingModuleAdaptor.h b/FWCore/Framework/interface/stream/ProducingModuleAdaptor.h index 2eef6648599ae..7319e76014d11 100644 --- a/FWCore/Framework/interface/stream/ProducingModuleAdaptor.h +++ b/FWCore/Framework/interface/stream/ProducingModuleAdaptor.h @@ -93,6 +93,10 @@ namespace edm { m_pset= nullptr; } + void preallocLumis(unsigned int iNLumis) final { + m_lumis.resize(iNLumis); + m_lumiSummaries.resize(iNLumis); + } void doEndJob() final { MyGlobal::endJob(m_global.get()); } diff --git a/FWCore/Framework/interface/stream/ProducingModuleAdaptorBase.h b/FWCore/Framework/interface/stream/ProducingModuleAdaptorBase.h index 572859d6db6f5..f7494ab13d90f 100644 --- a/FWCore/Framework/interface/stream/ProducingModuleAdaptorBase.h +++ b/FWCore/Framework/interface/stream/ProducingModuleAdaptorBase.h @@ -141,6 +141,7 @@ namespace edm { const ProducingModuleAdaptorBase& operator=(const ProducingModuleAdaptorBase&) = delete; // stop default void doPreallocate(PreallocationConfiguration const&); + virtual void preallocLumis(unsigned int) {} virtual void setupStreamModules() = 0; void doBeginJob(); virtual void doEndJob() = 0; diff --git a/FWCore/Framework/src/global/EDAnalyzerBase.cc b/FWCore/Framework/src/global/EDAnalyzerBase.cc index 03766c89f3b7b..4a94fc87ad79d 100644 --- a/FWCore/Framework/src/global/EDAnalyzerBase.cc +++ b/FWCore/Framework/src/global/EDAnalyzerBase.cc @@ -64,6 +64,7 @@ namespace edm { void EDAnalyzerBase::doPreallocate(PreallocationConfiguration const& iPrealloc) { preallocStreams(iPrealloc.numberOfStreams()); + preallocLumis(iPrealloc.numberOfLuminosityBlocks()); preallocate(iPrealloc); } @@ -180,6 +181,7 @@ namespace edm { } void EDAnalyzerBase::preallocStreams(unsigned int) {} + void EDAnalyzerBase::preallocLumis(unsigned int) {} void EDAnalyzerBase::preallocate(PreallocationConfiguration const&) {} void EDAnalyzerBase::doBeginStream_(StreamID id){} void EDAnalyzerBase::doEndStream_(StreamID id) {} diff --git a/FWCore/Framework/src/global/EDFilterBase.cc b/FWCore/Framework/src/global/EDFilterBase.cc index eb18ca6effae1..e194a5e083461 100644 --- a/FWCore/Framework/src/global/EDFilterBase.cc +++ b/FWCore/Framework/src/global/EDFilterBase.cc @@ -91,6 +91,7 @@ namespace edm { } previousParentageIds_.reset(new ParentageID[nStreams]); preallocStreams(nStreams); + preallocLumis(iPrealloc.numberOfLuminosityBlocks()); preallocate(iPrealloc); } @@ -218,6 +219,7 @@ namespace edm { } void EDFilterBase::preallocStreams(unsigned int) {} + void EDFilterBase::preallocLumis(unsigned int) {} void EDFilterBase::preallocate(PreallocationConfiguration const&) {} void EDFilterBase::doBeginStream_(StreamID id){} void EDFilterBase::doEndStream_(StreamID id) {} diff --git a/FWCore/Framework/src/global/EDProducerBase.cc b/FWCore/Framework/src/global/EDProducerBase.cc index fb6f857d7bed1..47c37b74aba66 100644 --- a/FWCore/Framework/src/global/EDProducerBase.cc +++ b/FWCore/Framework/src/global/EDProducerBase.cc @@ -92,6 +92,7 @@ namespace edm { } previousParentageIds_.reset( new ParentageID[nStreams]); preallocStreams(nStreams); + preallocLumis(iPrealloc.numberOfLuminosityBlocks()); preallocate(iPrealloc); } @@ -219,6 +220,7 @@ namespace edm { } void EDProducerBase::preallocStreams(unsigned int) {} + void EDProducerBase::preallocLumis(unsigned int) {} void EDProducerBase::preallocate(PreallocationConfiguration const&) {} void EDProducerBase::doBeginStream_(StreamID id){} void EDProducerBase::doEndStream_(StreamID id) {} diff --git a/FWCore/Framework/src/global/OutputModuleBase.cc b/FWCore/Framework/src/global/OutputModuleBase.cc index 164784233a43e..4ccba94480768 100644 --- a/FWCore/Framework/src/global/OutputModuleBase.cc +++ b/FWCore/Framework/src/global/OutputModuleBase.cc @@ -216,6 +216,7 @@ namespace edm { } } preallocStreams(nstreams); + preallocLumis(iPC.numberOfLuminosityBlocks()); preallocate(iPC); } diff --git a/FWCore/Framework/src/limited/EDAnalyzerBase.cc b/FWCore/Framework/src/limited/EDAnalyzerBase.cc index 0f4d9ab601649..2dd80e046d70a 100644 --- a/FWCore/Framework/src/limited/EDAnalyzerBase.cc +++ b/FWCore/Framework/src/limited/EDAnalyzerBase.cc @@ -65,6 +65,7 @@ namespace edm { void EDAnalyzerBase::doPreallocate(PreallocationConfiguration const& iPrealloc) { preallocStreams(iPrealloc.numberOfStreams()); + preallocLumis(iPrealloc.numberOfLuminosityBlocks()); preallocate(iPrealloc); } @@ -181,6 +182,7 @@ namespace edm { } void EDAnalyzerBase::preallocStreams(unsigned int) {} + void EDAnalyzerBase::preallocLumis(unsigned int) {} void EDAnalyzerBase::preallocate(PreallocationConfiguration const&) {} void EDAnalyzerBase::doBeginStream_(StreamID id){} void EDAnalyzerBase::doEndStream_(StreamID id) {} diff --git a/FWCore/Framework/src/limited/EDFilterBase.cc b/FWCore/Framework/src/limited/EDFilterBase.cc index ed9e79843ef10..8e201bb3848a5 100644 --- a/FWCore/Framework/src/limited/EDFilterBase.cc +++ b/FWCore/Framework/src/limited/EDFilterBase.cc @@ -68,6 +68,7 @@ namespace edm { previousParentages_.reset(new std::vector[nStreams]); previousParentageIds_.reset(new ParentageID[nStreams]); preallocStreams(nStreams); + preallocLumis(iPrealloc.numberOfLuminosityBlocks()); preallocate(iPrealloc); } @@ -195,6 +196,7 @@ namespace edm { } void EDFilterBase::preallocStreams(unsigned int) {} + void EDFilterBase::preallocLumis(unsigned int) {} void EDFilterBase::preallocate(PreallocationConfiguration const&) {} void EDFilterBase::doBeginStream_(StreamID id){} void EDFilterBase::doEndStream_(StreamID id) {} diff --git a/FWCore/Framework/src/limited/EDProducerBase.cc b/FWCore/Framework/src/limited/EDProducerBase.cc index efe6b39a67fa1..c9d0e62f29be4 100644 --- a/FWCore/Framework/src/limited/EDProducerBase.cc +++ b/FWCore/Framework/src/limited/EDProducerBase.cc @@ -68,6 +68,7 @@ namespace edm { previousParentages_.reset(new std::vector[nStreams]); previousParentageIds_.reset( new ParentageID[nStreams]); preallocStreams(nStreams); + preallocLumis(iPrealloc.numberOfLuminosityBlocks()); preallocate(iPrealloc); } @@ -195,6 +196,7 @@ namespace edm { } void EDProducerBase::preallocStreams(unsigned int) {} + void EDProducerBase::preallocLumis(unsigned int) {} void EDProducerBase::preallocate(PreallocationConfiguration const&) {} void EDProducerBase::doBeginStream_(StreamID id){} void EDProducerBase::doEndStream_(StreamID id) {} diff --git a/FWCore/Framework/src/limited/OutputModuleBase.cc b/FWCore/Framework/src/limited/OutputModuleBase.cc index c90ecf3d8033a..7778466a9104b 100644 --- a/FWCore/Framework/src/limited/OutputModuleBase.cc +++ b/FWCore/Framework/src/limited/OutputModuleBase.cc @@ -217,6 +217,7 @@ namespace edm { } } preallocStreams(nstreams); + preallocLumis(iPC.numberOfLuminosityBlocks()); preallocate(iPC); } diff --git a/FWCore/Framework/src/stream/EDAnalyzerAdaptorBase.cc b/FWCore/Framework/src/stream/EDAnalyzerAdaptorBase.cc index 347a702c7fc2c..6ae6e0ba89ece 100644 --- a/FWCore/Framework/src/stream/EDAnalyzerAdaptorBase.cc +++ b/FWCore/Framework/src/stream/EDAnalyzerAdaptorBase.cc @@ -74,6 +74,7 @@ EDAnalyzerAdaptorBase::doPreallocate(PreallocationConfiguration const& iPrealloc m_streamModules.resize(iPrealloc.numberOfStreams(), static_cast(nullptr)); setupStreamModules(); + preallocLumis(iPrealloc.numberOfLuminosityBlocks()); } void diff --git a/FWCore/Framework/src/stream/ProducingModuleAdaptorBase.cc b/FWCore/Framework/src/stream/ProducingModuleAdaptorBase.cc index a42c1d7ddd4e3..6d90e9b0f371f 100644 --- a/FWCore/Framework/src/stream/ProducingModuleAdaptorBase.cc +++ b/FWCore/Framework/src/stream/ProducingModuleAdaptorBase.cc @@ -57,8 +57,10 @@ namespace edm { m_streamModules.resize(iPrealloc.numberOfStreams(), static_cast(nullptr)); setupStreamModules(); + preallocLumis(iPrealloc.numberOfLuminosityBlocks()); } + template< typename T> void ProducingModuleAdaptorBase::registerProductsAndCallbacks(ProducingModuleAdaptorBase const*, ProductRegistry* reg) { diff --git a/FWCore/Framework/test/global_module_t.cppunit.cc b/FWCore/Framework/test/global_module_t.cppunit.cc index e904b207efc73..de6ecabb0f25c 100644 --- a/FWCore/Framework/test/global_module_t.cppunit.cc +++ b/FWCore/Framework/test/global_module_t.cppunit.cc @@ -91,6 +91,7 @@ class testGlobalModule: public CppUnit::TestFixture std::map> m_transToFunc; edm::ProcessConfiguration m_procConfig; + edm::PreallocationConfiguration m_preallocConfig; std::shared_ptr m_prodReg; std::shared_ptr m_idHelper; std::shared_ptr m_associationsHelper; @@ -343,6 +344,7 @@ static const edm::StreamID s_streamID0 = makeID(); CPPUNIT_TEST_SUITE_REGISTRATION(testGlobalModule); testGlobalModule::testGlobalModule(): +m_preallocConfig{}, m_prodReg(new edm::ProductRegistry{}), m_idHelper(new edm::BranchIDListHelper{}), m_associationsHelper(new edm::ThinnedAssociationsHelper{}), @@ -448,6 +450,9 @@ namespace { template void testGlobalModule::testTransitions(std::shared_ptr iMod, Expectations const& iExpect) { + edm::maker::ModuleHolderT h(iMod,nullptr); + h.preallocate(edm::PreallocationConfiguration{}); + edm::WorkerT w{iMod,m_desc,nullptr}; for(auto& keyVal: m_transToFunc) { testTransition(iMod,&w,keyVal.first,iExpect,keyVal.second); @@ -466,8 +471,6 @@ void testGlobalModule::basicTest() void testGlobalModule::streamTest() { auto testProd = std::make_shared(); - edm::maker::ModuleHolderT h(testProd,nullptr); - h.preallocate(edm::PreallocationConfiguration{}); CPPUNIT_ASSERT(0 == testProd->m_count); testTransitions(testProd, {Trans::kBeginStream, Trans::kStreamBeginRun, Trans::kStreamBeginLuminosityBlock, Trans::kEvent, @@ -493,7 +496,7 @@ void testGlobalModule::runSummaryTest() void testGlobalModule::lumiTest() { auto testProd = std::make_shared(); - + CPPUNIT_ASSERT(0 == testProd->m_count); testTransitions(testProd, {Trans::kGlobalBeginLuminosityBlock, Trans::kEvent, Trans::kGlobalEndLuminosityBlock}); } diff --git a/FWCore/Framework/test/limited_module_t.cppunit.cc b/FWCore/Framework/test/limited_module_t.cppunit.cc index a7fc81fdc5311..ac0ebaf09f5d9 100644 --- a/FWCore/Framework/test/limited_module_t.cppunit.cc +++ b/FWCore/Framework/test/limited_module_t.cppunit.cc @@ -475,6 +475,8 @@ namespace { template void testLimitedModule::testTransitions(std::shared_ptr iMod, Expectations const& iExpect) { + edm::maker::ModuleHolderT h(iMod,nullptr); + h.preallocate(edm::PreallocationConfiguration{}); edm::WorkerT w{iMod,m_desc,nullptr}; for(auto& keyVal: m_transToFunc) { testTransition(iMod,&w,keyVal.first,iExpect,keyVal.second); @@ -493,8 +495,6 @@ void testLimitedModule::basicTest() void testLimitedModule::streamTest() { auto testProd = std::make_shared(); - edm::maker::ModuleHolderT h(testProd,nullptr); - h.preallocate(edm::PreallocationConfiguration{}); CPPUNIT_ASSERT(0 == testProd->m_count); testTransitions(testProd, {Trans::kBeginStream, Trans::kStreamBeginRun, Trans::kStreamBeginLuminosityBlock, Trans::kEvent, From 109b79b5880419c1515e9bd27b0ac5529ae2a201 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 23 Jan 2018 10:44:22 -0600 Subject: [PATCH 46/52] Make sure Service System is active on thread --- FWCore/Framework/src/EventProcessor.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index ec020018d826c..0d6aeb8d3d39c 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1166,6 +1166,9 @@ namespace edm { handleNextEventForStreamAsync(std::move(h), i); } }); + //make the services available + ServiceRegistry::Operate operate(serviceToken_); + auto& event = principalCache_.eventPrincipal(i); streamLumiStatus_[i] = status; auto lp = status->lumiPrincipal(); From 6f52ef2d0cc09bdd349f7f760a7d3af687dfd41d Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 23 Jan 2018 10:51:18 -0600 Subject: [PATCH 47/52] Add configuration to set number of concurrent LuminosityBlocks --- FWCore/Framework/src/EventProcessor.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 0d6aeb8d3d39c..170c9aa1813fa 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -432,13 +432,13 @@ namespace edm { } */ unsigned int nConcurrentLumis =1; - /* - if(optionsPset.existsAs("numberOfConcurrentLuminosityBlocks",false)) { + + if(optionsPset.existsAs("numberOfConcurrentLuminosityBlocks",false)) { nConcurrentLumis = optionsPset.getUntrackedParameter("numberOfConcurrentLuminosityBlocks"); - } else { + } else { nConcurrentLumis = nConcurrentRuns; - } - */ + } + //Check that relationships between threading parameters makes sense /* if(nThreads Date: Tue, 23 Jan 2018 13:54:54 -0600 Subject: [PATCH 48/52] Removed trivial member functions --- EventFilter/Utilities/plugins/FRDStreamSource.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/EventFilter/Utilities/plugins/FRDStreamSource.h b/EventFilter/Utilities/plugins/FRDStreamSource.h index 33399dbb48bdb..47a772999693d 100644 --- a/EventFilter/Utilities/plugins/FRDStreamSource.h +++ b/EventFilter/Utilities/plugins/FRDStreamSource.h @@ -31,11 +31,6 @@ class FRDStreamSource : public edm::ProducerSourceFromFiles { bool setRunAndEventInfo(edm::EventID& id, edm::TimeValue_t& theTime, edm::EventAuxiliary::ExperimentType& eType) override; void produce(edm::Event& e) override; - void beginRun(edm::Run&) override {} - void endRun(edm::Run&) override {} - void beginLuminosityBlock(edm::LuminosityBlock&) override {} - void endLuminosityBlock(edm::LuminosityBlock&) override {} - bool openFile(const std::string& fileName); From 3e44789352964b6eba7eadc81290f02435662986 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Tue, 23 Jan 2018 13:55:22 -0600 Subject: [PATCH 49/52] Updated to match new LuminosityBlockPrincipal constructor --- Mixing/Base/src/PileUp.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mixing/Base/src/PileUp.cc b/Mixing/Base/src/PileUp.cc index eec86569e2796..3a70a79f6c622 100644 --- a/Mixing/Base/src/PileUp.cc +++ b/Mixing/Base/src/PileUp.cc @@ -202,8 +202,8 @@ namespace edm { } void PileUp::beginLuminosityBlock(const edm::LuminosityBlock& lumi, const edm::EventSetup& setup) { if (provider_.get() != nullptr) { - auto aux = std::make_shared(lumi.luminosityBlockAuxiliary()); - lumiPrincipal_.reset(new LuminosityBlockPrincipal(aux, productRegistry_, *processConfiguration_, nullptr, 0)); + lumiPrincipal_.reset(new LuminosityBlockPrincipal(productRegistry_, *processConfiguration_, nullptr, 0)); + lumiPrincipal_->setAux(lumi.luminosityBlockAuxiliary()); lumiPrincipal_->setRunPrincipal(runPrincipal_); provider_->beginLuminosityBlock(*lumiPrincipal_, setup, lumi.moduleCallingContext(), *streamContext_); } From c0d2795da7ca8d3227112c41e13d417262ade740 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 23 Jan 2018 15:58:26 -0600 Subject: [PATCH 50/52] Handle exceptions at end Lumi Need to explicitly pass messages to the EventProcessor if there is an exception at end lumi. This fixes a bug where an exception would cause a terminate because of the noexcept specification. --- FWCore/Framework/src/TransitionProcessors.icc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/FWCore/Framework/src/TransitionProcessors.icc b/FWCore/Framework/src/TransitionProcessors.icc index 1c2695c638269..c856a59efbe8c 100644 --- a/FWCore/Framework/src/TransitionProcessors.icc +++ b/FWCore/Framework/src/TransitionProcessors.icc @@ -95,11 +95,19 @@ public: return iEP.processLumis(std::shared_ptr{currentRun_}); } - void normalEnd() { - if (makeSureLumiEnds_) { - makeSureLumiEnds_ = false; - currentRun_->ep_.endUnfinishedLumi(); + void normalEnd() noexcept { + try { + if (makeSureLumiEnds_) { + makeSureLumiEnds_ = false; + currentRun_->ep_.endUnfinishedLumi(); + } + } catch(...) { + if(not currentRun_->ep_.setDeferredException(std::current_exception())) { + std::string message("Another exception was caught while trying to clean up lumis after the primary fatal exception."); + currentRun_->ep_.setExceptionMessageLumis(message); + } } + currentRun_.reset(); } private: From 17c846e272a2de4e1e97b55ac4bcc05829d2b9bf Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 23 Jan 2018 19:24:18 -0600 Subject: [PATCH 51/52] Get correct LuminosityBlock time The proper time to use for the EventSetup at LuminosityBlock boundaries is the one from InputSource::luminosityBlockAuxiliary. --- FWCore/Framework/src/EventProcessor.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 170c9aa1813fa..4c3f9b10bcd47 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1085,7 +1085,7 @@ namespace edm { continueLumiAsync(WaitingTaskHolder{waitTask.get()}); } else { beginLumiAsync(IOVSyncValue(EventID(input_->run(), input_->luminosityBlock(), 0), - input_->timestamp()), + input_->luminosityBlockAuxiliary()->beginTime()), iRunResource, WaitingTaskHolder{waitTask.get()}); } @@ -1491,7 +1491,8 @@ namespace edm { itemType = nextTransitionType(); } if(InputSource::IsLumi == itemType) { - iStatus.setNextSyncValue(IOVSyncValue(EventID(input_->run(), input_->luminosityBlock(), 0), input_->timestamp())); + iStatus.setNextSyncValue(IOVSyncValue(EventID(input_->run(), input_->luminosityBlock(), 0), + input_->luminosityBlockAuxiliary()->beginTime())); } } if(InputSource::IsEvent != itemType) { From a8f345d4e33a8a0af17130ee9784cd84108f93a0 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 24 Jan 2018 08:54:53 -0600 Subject: [PATCH 52/52] Make Service system available at end Lumi --- FWCore/Framework/src/EventProcessor.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 4c3f9b10bcd47..0f83997de4a71 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1301,6 +1301,7 @@ namespace edm { typedef OccurrenceTraits Traits; EventSetup const& es = esp_->eventSetup(); + ServiceRegistry::Operate operate(serviceToken_); endGlobalTransitionAsync(WaitingTaskHolder(t), *schedule_, lp,