Skip to content

Commit 8f020f9

Browse files
committed
Move functionality from Worker to ModuleHolder
- moved module finalization calls to ModuleHolder
1 parent 94123ac commit 8f020f9

File tree

11 files changed

+290
-254
lines changed

11 files changed

+290
-254
lines changed

FWCore/Framework/interface/GlobalSchedule.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ namespace edm {
9999
/// returns the collection of pointers to workers
100100
AllWorkers const& allWorkers() const { return workerManagers_[0].allWorkers(); }
101101

102-
void releaseMemoryPostLookupSignal();
103-
104102
private:
105103
/// returns the action table
106104
ExceptionToActionTable const& actionTable() const { return workerManagers_[0].actionTable(); }

FWCore/Framework/interface/WorkerManager.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ namespace edm {
6767
void setupResolvers(Principal& principal);
6868
void setupOnDemandSystem(EventTransitionInfo const&);
6969

70-
void beginJob(ProductRegistry const& iRegistry,
71-
eventsetup::ESRecordsToProductResolverIndices const&,
72-
ProcessBlockHelperBase const&,
73-
GlobalContext const&);
70+
void beginJob(GlobalContext const&);
7471
void endJob(ExceptionCollector&, GlobalContext const&);
7572

7673
void beginStream(StreamID, StreamContext const&);
@@ -99,8 +96,6 @@ namespace edm {
9996
}
10097
void resetAll();
10198

102-
void releaseMemoryPostLookupSignal();
103-
10499
private:
105100
Worker* getWorkerForExistingModule(std::string const& label);
106101

FWCore/Framework/interface/maker/ModuleHolder.h

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,24 @@
2323

2424
// user include files
2525
#include "FWCore/Framework/interface/maker/WorkerT.h"
26-
#include "FWCore/Framework/interface/OutputModuleCommunicatorT.h"
2726
#include "FWCore/Framework/interface/SignallingProductRegistryFiller.h"
27+
#include "FWCore/Framework/interface/OutputModuleCommunicator.h"
28+
29+
#include "FWCore/Utilities/interface/BranchType.h"
30+
#include "FWCore/Utilities/interface/ProductResolverIndex.h"
31+
32+
#include <unordered_map>
33+
#include <string>
2834
// forward declarations
2935
namespace edm {
3036
class ModuleDescription;
3137
class SignallingProductRegistryFiller;
3238
class ExceptionToActionTable;
3339
class PreallocationConfiguration;
40+
class ProductResolverIndexHelper;
41+
class ProductResolverIndexAndSkipBit;
42+
class ProductRegistry;
43+
class ThinnedAssociationsHelper;
3444

3545
namespace maker {
3646
class ModuleHolder {
@@ -46,6 +56,22 @@ namespace edm {
4656
virtual void replaceModuleFor(Worker*) const = 0;
4757

4858
virtual std::unique_ptr<OutputModuleCommunicator> createOutputModuleCommunicator() = 0;
59+
60+
void registerThinnedAssociations(ProductRegistry const& registry, ThinnedAssociationsHelper& helper);
61+
//Used to make EDGetToken work
62+
virtual void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&) = 0;
63+
virtual void updateLookup(eventsetup::ESRecordsToProductResolverIndices const&) = 0;
64+
virtual void releaseMemoryPostLookupSignal() = 0;
65+
virtual void selectInputProcessBlocks(ProductRegistry const&, ProcessBlockHelperBase const&) = 0;
66+
virtual void resolvePutIndicies(
67+
BranchType iBranchType,
68+
std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const&
69+
iIndicies) = 0;
70+
virtual void convertCurrentProcessAlias(std::string const& processName) = 0;
71+
72+
private:
73+
virtual void implRegisterThinnedAssociations(ProductRegistry const& registry,
74+
ThinnedAssociationsHelper& helper) = 0;
4975
};
5076

5177
template <typename T>
@@ -59,7 +85,7 @@ namespace edm {
5985
assert(nullptr != w);
6086
w->setModule(m_mod);
6187
}
62-
std::unique_ptr<Worker> makeWorker(ExceptionToActionTable const* actions) const override {
88+
std::unique_ptr<Worker> makeWorker(ExceptionToActionTable const* actions) const final {
6389
return std::make_unique<edm::WorkerT<T>>(module(), moduleDescription(), actions);
6490
}
6591

@@ -73,18 +99,30 @@ namespace edm {
7399
iModule.registerProductsAndCallbacks(&iModule, iReg);
74100
}
75101
};
76-
ModuleDescription const& moduleDescription() const override { return m_mod->moduleDescription(); }
102+
ModuleDescription const& moduleDescription() const final { return m_mod->moduleDescription(); }
77103

78104
void finishModuleInitialization(ModuleDescription const& iDesc,
79105
PreallocationConfiguration const& iPrealloc,
80106
SignallingProductRegistryFiller* iReg) override {
81107
finishModuleInitialization(*m_mod, iDesc, iPrealloc, iReg);
82108
}
83-
std::unique_ptr<OutputModuleCommunicator> createOutputModuleCommunicator() override {
84-
return OutputModuleCommunicatorT<T>::createIfNeeded(m_mod.get());
109+
std::unique_ptr<OutputModuleCommunicator> createOutputModuleCommunicator() final;
110+
111+
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&) final;
112+
void updateLookup(eventsetup::ESRecordsToProductResolverIndices const&) final;
113+
void releaseMemoryPostLookupSignal() final;
114+
void selectInputProcessBlocks(ProductRegistry const&, ProcessBlockHelperBase const&) final;
115+
void resolvePutIndicies(
116+
BranchType iBranchType,
117+
std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const&
118+
iIndicies) final;
119+
void convertCurrentProcessAlias(std::string const& processName) final {
120+
m_mod->convertCurrentProcessAlias(processName);
85121
}
86122

87123
private:
124+
void implRegisterThinnedAssociations(ProductRegistry const& registry, ThinnedAssociationsHelper& helper) final;
125+
88126
std::shared_ptr<T> m_mod;
89127
};
90128
} // namespace maker

FWCore/Framework/interface/maker/Worker.h

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ namespace edm {
131131
virtual bool wantsStreamRuns() const noexcept = 0;
132132
virtual bool wantsStreamLuminosityBlocks() const noexcept = 0;
133133

134+
//returns non-nullptr if the module can only process one Run at a time
134135
virtual SerialTaskQueue* globalRunsQueue() = 0;
136+
//returns non-nullptr if the module can only process one LuminosityBlock at a time
135137
virtual SerialTaskQueue* globalLuminosityBlocksQueue() = 0;
136138

139+
//Run only for OutputModules. Causes TriggerResults information to be used to decide if module should run.
137140
void prePrefetchSelectionAsync(oneapi::tbb::task_group&,
138141
WaitingTask* task,
139142
ServiceToken const&,
@@ -177,6 +180,7 @@ namespace edm {
177180
StreamContext const*) noexcept;
178181

179182
void callWhenDoneAsync(WaitingTaskHolder task) { waitingTasks_.add(std::move(task)); }
183+
// Called if filter earlier in the path has failed.
180184
void skipOnPath(EventPrincipal const& iEvent);
181185
void beginJob(GlobalContext const&);
182186
void endJob(GlobalContext const&);
@@ -185,7 +189,6 @@ namespace edm {
185189
void respondToOpenInputFile(FileBlock const& fb) { implRespondToOpenInputFile(fb); }
186190
void respondToCloseInputFile(FileBlock const& fb) { implRespondToCloseInputFile(fb); }
187191
void respondToCloseOutputFile() { implRespondToCloseOutputFile(); }
188-
void registerThinnedAssociations(ProductRegistry const& registry, ThinnedAssociationsHelper& helper);
189192

190193
void reset() {
191194
cached_exception_ = std::exception_ptr();
@@ -209,18 +212,6 @@ namespace edm {
209212

210213
void setEarlyDeleteHelper(EarlyDeleteHelper* iHelper);
211214

212-
//Used to make EDGetToken work
213-
virtual void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&) = 0;
214-
virtual void updateLookup(eventsetup::ESRecordsToProductResolverIndices const&) = 0;
215-
virtual void releaseMemoryPostLookupSignal() = 0;
216-
virtual void selectInputProcessBlocks(ProductRegistry const&, ProcessBlockHelperBase const&) = 0;
217-
virtual void resolvePutIndicies(
218-
BranchType iBranchType,
219-
std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const&
220-
iIndicies) = 0;
221-
222-
virtual void convertCurrentProcessAlias(std::string const& processName) = 0;
223-
224215
virtual std::vector<ModuleConsumesInfo> moduleConsumesInfos() const = 0;
225216
virtual std::vector<ModuleConsumesMinimalESInfo> moduleConsumesMinimalESInfos() const = 0;
226217

@@ -314,8 +305,6 @@ namespace edm {
314305
virtual void implRespondToCloseInputFile(FileBlock const& fb) = 0;
315306
virtual void implRespondToCloseOutputFile() = 0;
316307

317-
virtual void implRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) = 0;
318-
319308
virtual TaskQueueAdaptor serializeRunModule() = 0;
320309

321310
bool shouldRethrowException(std::exception_ptr iPtr,

FWCore/Framework/interface/maker/WorkerT.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@ namespace edm {
5959
SerialTaskQueue* globalRunsQueue() final;
6060
SerialTaskQueue* globalLuminosityBlocksQueue() final;
6161

62-
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&) final;
63-
void updateLookup(eventsetup::ESRecordsToProductResolverIndices const&) final;
64-
void releaseMemoryPostLookupSignal() final;
65-
void selectInputProcessBlocks(ProductRegistry const&, ProcessBlockHelperBase const&) final;
66-
67-
void resolvePutIndicies(
68-
BranchType iBranchType,
69-
std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const&
70-
iIndicies) final;
71-
7262
template <typename D>
7363
void callWorkerBeginStream(D, StreamID);
7464
template <typename D>
@@ -125,14 +115,9 @@ namespace edm {
125115
void implRespondToOpenInputFile(FileBlock const& fb) override;
126116
void implRespondToCloseInputFile(FileBlock const& fb) override;
127117
void implRespondToCloseOutputFile() override;
128-
void implRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) override;
129118
std::string workerType() const override;
130119
TaskQueueAdaptor serializeRunModule() override;
131120

132-
void convertCurrentProcessAlias(std::string const& processName) override {
133-
module_->convertCurrentProcessAlias(processName);
134-
}
135-
136121
std::vector<ModuleConsumesInfo> moduleConsumesInfos() const override;
137122
std::vector<ModuleConsumesMinimalESInfo> moduleConsumesMinimalESInfos() const final {
138123
return module_->moduleConsumesMinimalESInfos();

FWCore/Framework/src/GlobalSchedule.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ namespace edm {
9696
exceptionContext(ex, globalContext, "Handling pre signal, likely in a service function");
9797
throw;
9898
}
99-
workerManagers_[managerIndex].beginJob(iRegistry, iESIndices, processBlockHelperBase, globalContext);
99+
workerManagers_[managerIndex].beginJob(globalContext);
100100
} catch (...) {
101101
exceptionPtr = std::current_exception();
102102
}
@@ -176,12 +176,6 @@ namespace edm {
176176
}
177177
}
178178

179-
void GlobalSchedule::releaseMemoryPostLookupSignal() {
180-
unsigned int const managerIndex =
181-
numberOfConcurrentLumis_ + numberOfConcurrentRuns_ + numberOfConcurrentProcessBlocks_;
182-
workerManagers_[managerIndex].releaseMemoryPostLookupSignal();
183-
}
184-
185179
std::vector<ModuleDescription const*> GlobalSchedule::getAllModuleDescriptions() const {
186180
std::vector<ModuleDescription const*> result;
187181
result.reserve(allWorkers().size());

0 commit comments

Comments
 (0)