Skip to content

Commit 38bc364

Browse files
authored
Merge pull request #48416 from Dr15Jones/moreRefactorWorker
Refactored how begin/end/Job/Stream are implemented
2 parents a9d51ca + 2225e32 commit 38bc364

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+776
-715
lines changed

FWCore/Framework/interface/GlobalSchedule.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ namespace edm {
7373
ServiceToken const& token,
7474
bool cleaningUpAfterException = false);
7575

76-
void beginJob(ProcessContext const&);
77-
void endJob(ExceptionCollector& collector);
76+
void beginJob(ModuleRegistry&);
77+
void endJob(ExceptionCollector& collector, ModuleRegistry&);
7878

7979
/// Return a vector allowing const access to all the
8080
/// ModuleDescriptions for this GlobalSchedule.
@@ -112,17 +112,17 @@ namespace edm {
112112
std::exception_ptr&);
113113

114114
std::vector<WorkerManager> workerManagers_;
115+
std::vector<unsigned int> beginJobFailedForModule_;
115116
std::shared_ptr<ActivityRegistry> actReg_; // We do not use propagate_const because the registry itself is mutable.
116117
std::vector<edm::propagate_const<WorkerPtr>> extraWorkers_;
117118
ProcessContext const* processContext_;
118119

119-
// The next 4 variables use the same naming convention, even though we have no intention
120-
// to ever have concurrent ProcessBlocks or Jobs. They are all related to the number of
120+
// The next 3 variables use the same naming convention, even though we have no intention
121+
// to ever have concurrent ProcessBlocks. They are all related to the number of
121122
// WorkerManagers needed for global transitions.
122123
unsigned int numberOfConcurrentLumis_;
123124
unsigned int numberOfConcurrentRuns_;
124125
static constexpr unsigned int numberOfConcurrentProcessBlocks_ = 1;
125-
static constexpr unsigned int numberOfConcurrentJobs_ = 1;
126126
};
127127

128128
template <typename T>

FWCore/Framework/interface/ModuleRegistry.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ namespace edm {
3636
struct MakeModuleParams;
3737
class ModuleDescription;
3838
class PreallocationConfiguration;
39-
namespace maker {
40-
class ModuleHolder;
41-
}
4239

4340
class ModuleRegistry {
4441
public:
@@ -81,6 +78,9 @@ namespace edm {
8178
holder->finishModuleInitialization(md, iPrealloc, iReg);
8279
labelToModule_.emplace(md.moduleLabel(), std::move(holder));
8380

81+
if (maxModuleID_ < module->moduleDescription().id()) {
82+
maxModuleID_ = module->moduleDescription().id();
83+
}
8484
// if exception then post will be called in the catch block
8585
postCalled = true;
8686
iPost(md);
@@ -104,14 +104,12 @@ namespace edm {
104104
}
105105
}
106106

107-
void finishModulesInitialization(ProductRegistry const& iRegistry,
108-
eventsetup::ESRecordsToProductResolverIndices const& iESIndices,
109-
ProcessBlockHelperBase const& processBlockHelperBase,
110-
std::string const& processName);
107+
unsigned int maxModuleID() const { return maxModuleID_; }
111108

112109
private:
113110
std::map<std::string, edm::propagate_const<std::shared_ptr<maker::ModuleHolder>>> labelToModule_;
114111
ModuleTypeResolverMaker const* typeResolverMaker_;
112+
unsigned int maxModuleID_ = 0;
115113
};
116114
} // namespace edm
117115

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#ifndef FWCore_Framework_ModuleRegistryUtilities_h
2+
#define FWCore_Framework_ModuleRegistryUtilities_h
3+
4+
#include <string>
5+
#include <vector>
6+
#include <mutex>
7+
namespace edm {
8+
class ModuleRegistry;
9+
class ActivityRegistry;
10+
class ProductRegistry;
11+
class StreamContext;
12+
class GlobalContext;
13+
namespace eventsetup {
14+
class ESRecordsToProductResolverIndices;
15+
}
16+
class ProcessBlockHelperBase;
17+
class ExceptionCollector;
18+
19+
void finishModulesInitialization(ModuleRegistry& iModuleRegistry,
20+
ProductRegistry const& iProductRegistry,
21+
eventsetup::ESRecordsToProductResolverIndices const& iESIndices,
22+
ProcessBlockHelperBase const& processBlockHelperBase,
23+
std::string const& processName);
24+
/** beginJobFailedForModule has the module id of each module which threw an exception during
25+
* the call to beginJob function. The vector should be passed to `runEndJobForModules`.
26+
* If an exception is thrown, it will be of type cms::Exception.
27+
*/
28+
void runBeginJobForModules(GlobalContext const& iGlobalContext,
29+
ModuleRegistry& iModuleRegistry,
30+
edm::ActivityRegistry& iActivityRegistry,
31+
std::vector<unsigned int>& beginJobFailedForModule) noexcept(false);
32+
33+
/// The vector holds module id for modules which should not have their endJob called.
34+
void runEndJobForModules(GlobalContext const& iGlobalContext,
35+
ModuleRegistry& iModuleRegistry,
36+
ActivityRegistry& iRegistry,
37+
ExceptionCollector& collector,
38+
std::vector<unsigned int> const& beginJobFailedForModule) noexcept;
39+
40+
/** beginStreamFailedForModule holds module id for each module which threw an exception during
41+
* the call to beginStream function. This vector is used to determine which modules should not
42+
* have their endStream called. The vector should be passed to `runEndStreamForModules`.
43+
* If an exception is thrown, it will be of type cms::Exception.
44+
*/
45+
void runBeginStreamForModules(StreamContext const& iStreamContext,
46+
ModuleRegistry& iModuleRegistry,
47+
edm::ActivityRegistry& iActivityRegistry,
48+
std::vector<unsigned int>& beginStreamFailedForModule) noexcept(false);
49+
50+
/// The vector hold module id for modules which should not have their endStream called.
51+
void runEndStreamForModules(StreamContext const& iStreamContext,
52+
ModuleRegistry& iModuleRegistry,
53+
ActivityRegistry& iRegistry,
54+
ExceptionCollector& collector,
55+
std::mutex& collectorMutex,
56+
std::vector<unsigned int> const& beginStreamFailedForModule) noexcept;
57+
58+
} // namespace edm
59+
#endif // FWCore_Framework_ModuleRegistryUtilities_h

FWCore/Framework/interface/Schedule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ namespace edm {
170170
void beginJob(ProductRegistry const&,
171171
eventsetup::ESRecordsToProductResolverIndices const&,
172172
ProcessBlockHelperBase const&,
173-
ProcessContext const&);
173+
std::string const& processName);
174174
void endJob(ExceptionCollector& collector);
175175
void sendFwkSummaryToMessageLogger() const;
176176

FWCore/Framework/interface/StreamSchedule.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ namespace edm {
162162
ServiceToken const& token,
163163
bool cleaningUpAfterException = false);
164164

165-
void beginStream();
166-
void endStream(ExceptionCollector& collector, std::mutex& collectorMutex) noexcept;
165+
void beginStream(ModuleRegistry& iModuleRegistry);
166+
void endStream(ModuleRegistry& iModuleRegistry, ExceptionCollector& collector, std::mutex& collectorMutex) noexcept;
167167

168168
StreamID streamID() const { return streamID_; }
169169

@@ -222,7 +222,6 @@ namespace edm {
222222
edm::ProductRegistry const& preg);
223223

224224
/// returns the collection of pointers to workers
225-
AllWorkers const& allWorkersBeginEnd() const { return workerManagerBeginEnd_.allWorkers(); }
226225
AllWorkers const& allWorkersRuns() const { return workerManagerRuns_.allWorkers(); }
227226
AllWorkers const& allWorkersLumisAndEvents() const { return workerManagerLumisAndEvents_.allWorkers(); }
228227

@@ -310,7 +309,7 @@ namespace edm {
310309

311310
void handleException(StreamContext const&, bool cleaningUpAfterException, std::exception_ptr&) const noexcept;
312311

313-
WorkerManager workerManagerBeginEnd_;
312+
std::vector<unsigned int> moduleBeginStreamFailed_;
314313
WorkerManager workerManagerRuns_;
315314
WorkerManager workerManagerLumisAndEvents_;
316315
std::shared_ptr<ActivityRegistry> actReg_; // We do not use propagate_const because the registry itself is mutable.

FWCore/Framework/interface/WorkerManager.h

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

70-
void beginJob(GlobalContext const&);
71-
void endJob(ExceptionCollector&, GlobalContext const&);
72-
73-
void beginStream(StreamID, StreamContext const&);
74-
void endStream(StreamID, StreamContext const&, ExceptionCollector&, std::mutex& collectorMutex) noexcept;
75-
7670
AllWorkers const& allWorkers() const { return allWorkers_; }
7771
AllWorkers const& unscheduledWorkers() const { return unscheduled_.workers(); }
7872

FWCore/Framework/interface/global/EDAnalyzerBase.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ namespace edm {
105105
void doRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) {}
106106

107107
void registerProductsAndCallbacks(EDAnalyzerBase* module, SignallingProductRegistryFiller* reg);
108-
std::string workerType() const { return "WorkerT<EDAnalyzer>"; }
109108

110109
virtual void analyze(StreamID, Event const&, EventSetup const&) const = 0;
111110
virtual void beginJob() {}

FWCore/Framework/interface/global/EDFilterBase.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ namespace edm {
114114
void registerProductsAndCallbacks(EDFilterBase* module, SignallingProductRegistryFiller* reg) {
115115
registerProducts(module, reg, moduleDescription_);
116116
}
117-
std::string workerType() const { return "WorkerT<EDProducer>"; }
118117

119118
virtual bool filter(StreamID, Event&, EventSetup const&) const = 0;
120119
virtual void beginJob() {}

FWCore/Framework/interface/global/EDProducerBase.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ namespace edm {
111111
void registerProductsAndCallbacks(EDProducerBase* module, SignallingProductRegistryFiller* reg) {
112112
registerProducts(module, reg, moduleDescription_);
113113
}
114-
std::string workerType() const { return "WorkerT<EDProducer>"; }
115114

116115
virtual void produce(StreamID, Event&, EventSetup const&) const = 0;
117116
//For now this is a placeholder

FWCore/Framework/interface/global/OutputModuleBase.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ namespace edm {
6666
Principal const& iPrincipal) const noexcept {}
6767

6868
private:
69-
std::string workerType() const { return "WorkerT<edm::global::OutputModuleBase>"; }
70-
7169
virtual void preallocStreams(unsigned int) {}
7270
virtual void preallocate(PreallocationConfiguration const&) {}
7371
virtual void doBeginStream_(StreamID) {}

0 commit comments

Comments
 (0)