Skip to content

Commit a4ef629

Browse files
authored
Merge pull request #48519 from Dr15Jones/scheduleBuilder
Use ScheduleBuilder to handle module construction
2 parents dc30688 + efb9f6f commit a4ef629

Some content is hidden

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

42 files changed

+1835
-1412
lines changed

FWCore/Framework/interface/GlobalSchedule.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "DataFormats/Provenance/interface/ModuleDescription.h"
55
#include "FWCore/Common/interface/FWCoreCommonFwd.h"
6-
#include "FWCore/Framework/interface/EventPrincipal.h"
76
#include "FWCore/Framework/interface/ExceptionActions.h"
87
#include "FWCore/Framework/interface/ExceptionHelpers.h"
98
#include "FWCore/Framework/interface/Frameworkfwd.h"
@@ -13,7 +12,6 @@
1312
#include "FWCore/Framework/interface/RunPrincipal.h"
1413
#include "FWCore/Framework/interface/WorkerManager.h"
1514
#include "FWCore/Framework/interface/maker/Worker.h"
16-
#include "FWCore/Framework/interface/SignallingProductRegistryFiller.h"
1715
#include "FWCore/MessageLogger/interface/ExceptionMessages.h"
1816
#include "FWCore/ServiceRegistry/interface/GlobalContext.h"
1917
#include "FWCore/ServiceRegistry/interface/ServiceRegistry.h"
@@ -46,24 +44,25 @@ namespace edm {
4644
class PathStatusInserter;
4745
class EndPathStatusInserter;
4846

47+
namespace maker {
48+
class ModuleHolder;
49+
}
50+
4951
class GlobalSchedule {
5052
public:
51-
typedef std::vector<std::string> vstring;
52-
typedef std::vector<Worker*> AllWorkers;
53-
typedef std::shared_ptr<Worker> WorkerPtr;
54-
typedef std::vector<Worker*> Workers;
53+
using vstring = std::vector<std::string>;
54+
using AllWorkers = std::vector<Worker*>;
55+
using WorkerPtr = std::shared_ptr<Worker>;
56+
using Wokers = std::vector<Worker*>;
5557

5658
GlobalSchedule(std::shared_ptr<TriggerResultInserter> inserter,
5759
std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>>& pathStatusInserters,
5860
std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>>& endPathStatusInserters,
5961
std::shared_ptr<ModuleRegistry> modReg,
60-
std::vector<std::string> const& modulesToUse,
61-
ParameterSet& proc_pset,
62-
SignallingProductRegistryFiller& pregistry,
62+
std::vector<edm::ModuleDescription const*> const& modulesToUse,
6363
PreallocationConfiguration const& prealloc,
6464
ExceptionToActionTable const& actions,
6565
std::shared_ptr<ActivityRegistry> areg,
66-
std::shared_ptr<ProcessConfiguration const> processConfiguration,
6766
ProcessContext const* processContext);
6867
GlobalSchedule(GlobalSchedule const&) = delete;
6968

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef FWCore_Framework_ModuleInPath_h
2+
#define FWCore_Framework_ModuleInPath_h
3+
4+
/** Class used to hold the traits for how a module should be handled in a Path
5+
*/
6+
7+
#include "FWCore/Framework/interface/WorkerInPath.h"
8+
9+
namespace edm {
10+
class ModuleDescription;
11+
12+
struct ModuleInPath {
13+
ModuleInPath(ModuleDescription const* iDesc, WorkerInPath::FilterAction iAct, unsigned int iPlace, bool iConcurrent)
14+
: description_(iDesc), placeInPath_(iPlace), action_(iAct), runConcurrently_(iConcurrent) {}
15+
ModuleDescription const* description_;
16+
unsigned int placeInPath_;
17+
WorkerInPath::FilterAction action_;
18+
bool runConcurrently_;
19+
};
20+
} // namespace edm
21+
#endif

FWCore/Framework/interface/ModuleRegistry.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace edm {
3636
struct MakeModuleParams;
3737
class ModuleDescription;
3838
class PreallocationConfiguration;
39+
class SignallingProductRegistryFiller;
3940

4041
class ModuleRegistry {
4142
public:
@@ -104,6 +105,14 @@ namespace edm {
104105
}
105106
}
106107

108+
template <typename F>
109+
void forAllModuleHolders(F iFunc) const {
110+
for (auto& labelMod : labelToModule_) {
111+
maker::ModuleHolder const* t = labelMod.second.get();
112+
iFunc(t);
113+
}
114+
}
115+
107116
unsigned int maxModuleID() const { return maxModuleID_; }
108117

109118
private:

FWCore/Framework/interface/OutputModuleCore.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ namespace edm {
208208
void doOpenFile(FileBlock const& fb);
209209
void doRespondToOpenInputFile(FileBlock const& fb);
210210
void doRespondToCloseInputFile(FileBlock const& fb);
211-
void doRespondToCloseOutputFile() {}
212-
void doRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) {}
213211

214212
/// Tell the OutputModule that is must end the current file.
215213
void doCloseFile();

FWCore/Framework/interface/PathsAndConsumesOfModules.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@
2929
namespace edm {
3030

3131
class ModuleDescription;
32+
class ModuleRegistry;
3233
class ProductRegistry;
3334
class Schedule;
3435

36+
namespace maker {
37+
class ModuleHolder;
38+
} // namespace maker
3539
namespace eventsetup {
3640
struct ComponentDescription;
3741
class ESProductResolverProvider;
@@ -96,9 +100,8 @@ namespace edm {
96100
std::vector<std::vector<ModuleDescription const*>> modulesOnPaths_;
97101
std::vector<std::vector<ModuleDescription const*>> modulesOnEndPaths_;
98102

99-
// Gives a translation from the module ID to the index into the
100-
// following data member
101-
std::vector<std::pair<unsigned int, unsigned int>> moduleIDToIndex_;
103+
// Gives a translation from the module ID to the holder
104+
std::vector<edm::maker::ModuleHolder const*> moduleIDToHolder_;
102105

103106
std::array<std::vector<std::vector<ModuleDescription const*>>, NumBranchTypes> modulesWhoseProductsAreConsumedBy_;
104107

FWCore/Framework/interface/Schedule.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ namespace edm {
289289
/// returns the collection of pointers to workers
290290
AllWorkers const& allWorkers() const;
291291

292+
ModuleRegistry const& moduleRegistry() const { return *moduleRegistry_; }
293+
292294
/// Convert "@currentProcess" in InputTag process names to the actual current process name.
293295
void convertCurrentProcessAlias(std::string const& processName);
294296

@@ -301,8 +303,10 @@ namespace edm {
301303
return get_underlying_safe(resultsInserter_);
302304
}
303305
std::shared_ptr<TriggerResultInserter>& resultsInserter() { return get_underlying_safe(resultsInserter_); }
304-
std::shared_ptr<ModuleRegistry const> moduleRegistry() const { return get_underlying_safe(moduleRegistry_); }
305-
std::shared_ptr<ModuleRegistry>& moduleRegistry() { return get_underlying_safe(moduleRegistry_); }
306+
std::shared_ptr<ModuleRegistry const> moduleRegistrySharedPtr() const {
307+
return get_underlying_safe(moduleRegistry_);
308+
}
309+
std::shared_ptr<ModuleRegistry>& moduleRegistrySharedPtr() { return get_underlying_safe(moduleRegistry_); }
306310

307311
edm::propagate_const<std::shared_ptr<ModuleRegistry>> moduleRegistry_;
308312
edm::propagate_const<std::shared_ptr<TriggerResultInserter>> resultsInserter_;

FWCore/Framework/interface/StreamSchedule.h

Lines changed: 36 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@
4848
The order of the paths from the input configuration is
4949
preserved in the main paths list.
5050
51-
------------------------
52-
53-
The StreamSchedule uses the TriggerNamesService to get the names of the
54-
trigger paths and end paths. When a TriggerResults object is created
55-
the results are stored in the same order as the trigger names from
56-
TriggerNamesService.
5751
5852
*/
5953

@@ -64,10 +58,10 @@
6458
#include "FWCore/Framework/interface/ExceptionHelpers.h"
6559
#include "FWCore/Framework/interface/Frameworkfwd.h"
6660
#include "FWCore/Framework/interface/OccurrenceTraits.h"
67-
#include "FWCore/Framework/interface/UnscheduledCallProducer.h"
6861
#include "FWCore/Framework/interface/WorkerManager.h"
6962
#include "FWCore/Framework/interface/Path.h"
7063
#include "FWCore/Framework/interface/TransitionInfoTypes.h"
64+
#include "FWCore/Framework/interface/ModuleInPath.h"
7165
#include "FWCore/Framework/interface/maker/Worker.h"
7266
#include "FWCore/Framework/interface/EarlyDeleteHelper.h"
7367
#include "FWCore/MessageLogger/interface/ExceptionMessages.h"
@@ -109,42 +103,52 @@ namespace edm {
109103
class ExceptionCollector;
110104
class ExceptionToActionTable;
111105
class OutputModuleCommunicator;
112-
class UnscheduledCallProducer;
113106
class WorkerInPath;
114107
class ModuleRegistry;
115108
class TriggerResultInserter;
116109
class PathStatusInserter;
117110
class EndPathStatusInserter;
118-
class PreallocationConfiguration;
119-
class ConditionalTaskHelper;
120111

121-
namespace service {
122-
class TriggerNamesService;
112+
namespace maker {
113+
class ModuleHolder;
123114
}
124115

125116
class StreamSchedule {
126117
public:
127-
typedef std::vector<std::string> vstring;
128-
typedef std::vector<Path> TrigPaths;
129-
typedef std::shared_ptr<HLTGlobalStatus> TrigResPtr;
130-
typedef std::shared_ptr<HLTGlobalStatus const> TrigResConstPtr;
131-
typedef std::vector<Worker*> AllWorkers;
132-
133-
typedef std::vector<Worker*> Workers;
134-
135-
typedef std::vector<WorkerInPath> PathWorkers;
118+
using vstring = std::vector<std::string>;
119+
using TrigPaths = std::vector<Path>;
120+
using TrigResPtr = std::shared_ptr<HLTGlobalStatus>;
121+
using TrigResConstPtr = std::shared_ptr<HLTGlobalStatus const>;
122+
using AllWorkers = std::vector<Worker*>;
123+
124+
using Workers = std::vector<Worker*>;
125+
126+
using PathWorkers = std::vector<WorkerInPath>;
127+
128+
struct PathInfo {
129+
PathInfo(std::string name, std::vector<edm::ModuleInPath> modules, std::shared_ptr<PathStatusInserter> inserter)
130+
: name_(std::move(name)), modules_(std::move(modules)), inserter_(std::move(inserter)) {}
131+
std::string name_;
132+
std::vector<edm::ModuleInPath> modules_;
133+
std::shared_ptr<PathStatusInserter> inserter_;
134+
};
135+
struct EndPathInfo {
136+
EndPathInfo(std::string name,
137+
std::vector<edm::ModuleInPath> modules,
138+
std::shared_ptr<EndPathStatusInserter> inserter)
139+
: name_(std::move(name)), modules_(std::move(modules)), inserter_(std::move(inserter)) {}
140+
std::string name_;
141+
std::vector<edm::ModuleInPath> modules_;
142+
std::shared_ptr<EndPathStatusInserter> inserter_;
143+
};
136144

137-
StreamSchedule(std::shared_ptr<TriggerResultInserter> inserter,
138-
std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>>& pathStatusInserters,
139-
std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>>& endPathStatusInserters,
145+
StreamSchedule(std::vector<PathInfo> const& paths,
146+
std::vector<EndPathInfo> const& endPaths,
147+
std::vector<ModuleDescription const*> const& unscheduledModules,
148+
std::shared_ptr<TriggerResultInserter> inserter,
140149
std::shared_ptr<ModuleRegistry>,
141-
ParameterSet& proc_pset,
142-
service::TriggerNamesService const& tns,
143-
PreallocationConfiguration const& prealloc,
144-
SignallingProductRegistryFiller& pregistry,
145150
ExceptionToActionTable const& actions,
146151
std::shared_ptr<ActivityRegistry> areg,
147-
std::shared_ptr<ProcessConfiguration const> processConfiguration,
148152
StreamID streamID,
149153
ProcessContext const* processContext);
150154

@@ -232,13 +236,6 @@ namespace edm {
232236

233237
StreamContext const& context() const { return streamContext_; }
234238

235-
struct AliasInfo {
236-
std::string friendlyClassName;
237-
std::string instanceLabel;
238-
std::string originalInstanceLabel;
239-
std::string originalModuleLabel;
240-
};
241-
242239
private:
243240
/// returns the action table
244241
ExceptionToActionTable const& actionTable() const { return workerManagerLumisAndEvents_.actionTable(); }
@@ -251,56 +248,15 @@ namespace edm {
251248

252249
void reportSkipped(EventPrincipal const& ep) const;
253250

254-
std::vector<Worker*> tryToPlaceConditionalModules(
255-
Worker*,
256-
std::unordered_set<std::string>& conditionalModules,
257-
std::unordered_multimap<std::string, edm::ProductDescription const*> const& conditionalModuleBranches,
258-
std::unordered_multimap<std::string, AliasInfo> const& aliasMap,
259-
ParameterSet& proc_pset,
260-
SignallingProductRegistryFiller& preg,
261-
PreallocationConfiguration const* prealloc,
262-
std::shared_ptr<ProcessConfiguration const> processConfiguration);
263-
PathWorkers fillWorkers(ParameterSet& proc_pset,
264-
SignallingProductRegistryFiller& preg,
265-
PreallocationConfiguration const* prealloc,
266-
std::shared_ptr<ProcessConfiguration const> processConfiguration,
267-
std::string const& name,
268-
bool ignoreFilters,
269-
std::vector<std::string> const& endPathNames,
270-
ConditionalTaskHelper const& conditionalTaskHelper,
271-
std::unordered_set<std::string>& allConditionalModules);
272-
void fillTrigPath(ParameterSet& proc_pset,
273-
SignallingProductRegistryFiller& preg,
274-
PreallocationConfiguration const* prealloc,
275-
std::shared_ptr<ProcessConfiguration const> processConfiguration,
276-
int bitpos,
277-
std::string const& name,
278-
TrigResPtr,
279-
std::vector<std::string> const& endPathNames,
280-
ConditionalTaskHelper const& conditionalTaskHelper,
281-
std::unordered_set<std::string>& allConditionalModules);
282-
void fillEndPath(ParameterSet& proc_pset,
283-
SignallingProductRegistryFiller& preg,
284-
PreallocationConfiguration const* prealloc,
285-
std::shared_ptr<ProcessConfiguration const> processConfiguration,
286-
int bitpos,
287-
std::string const& name,
288-
std::vector<std::string> const& endPathNames,
289-
ConditionalTaskHelper const& conditionalTaskHelper,
290-
std::unordered_set<std::string>& allConditionalModules);
291-
292-
void addToAllWorkers(Worker* w);
251+
PathWorkers fillWorkers(std::vector<ModuleInPath> const&);
252+
void fillTrigPath(PathInfo const&, int bitpos, TrigResPtr);
253+
void fillEndPath(EndPathInfo const&, int bitpos);
293254

294255
void resetEarlyDelete();
295256

296257
TrigResConstPtr results() const { return get_underlying_safe(results_); }
297258
TrigResPtr& results() { return get_underlying_safe(results_); }
298259

299-
void makePathStatusInserters(
300-
std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>>& pathStatusInserters,
301-
std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>>& endPathStatusInserters,
302-
ExceptionToActionTable const& actions);
303-
304260
template <typename T>
305261
void preScheduleSignal(StreamContext const*) const;
306262

FWCore/Framework/interface/WorkerManager.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818
#include <vector>
1919

2020
namespace edm {
21-
class ExceptionCollector;
2221
class ExceptionToActionTable;
2322
class ModuleRegistry;
24-
class ModuleTypeResolverMaker;
25-
class PreallocationConfiguration;
2623
class Worker;
2724
namespace eventsetup {
2825
class ESRecordsToProductResolverIndices;
@@ -40,13 +37,7 @@ namespace edm {
4037

4138
void deleteModuleIfExists(std::string const& moduleLabel);
4239

43-
void addToUnscheduledWorkers(ParameterSet& pset,
44-
SignallingProductRegistryFiller& preg,
45-
PreallocationConfiguration const* prealloc,
46-
std::shared_ptr<ProcessConfiguration const> processConfiguration,
47-
std::string label,
48-
std::set<std::string>& unscheduledLabels,
49-
std::vector<std::string>& shouldBeUsedLabels);
40+
void addToUnscheduledWorkers(ModuleDescription const& iDescription);
5041

5142
template <typename T, typename U>
5243
void processOneOccurrenceAsync(WaitingTaskHolder,
@@ -74,20 +65,22 @@ namespace edm {
7465

7566
ExceptionToActionTable const& actionTable() const { return *actionTable_; }
7667

77-
Worker* getWorker(ParameterSet& pset,
78-
SignallingProductRegistryFiller& preg,
79-
PreallocationConfiguration const* prealloc,
80-
std::shared_ptr<ProcessConfiguration const> processConfiguration,
81-
std::string const& label,
82-
bool addToAllWorkers = true);
83-
8468
template <typename T>
69+
requires requires(T const& x) { x.moduleDescription(); }
8570
Worker* getWorkerForModule(T const& module) {
8671
auto* worker = getWorkerForExistingModule(module.moduleDescription().moduleLabel());
8772
assert(worker != nullptr);
8873
assert(worker->matchesBaseClassPointer(static_cast<typename T::ModuleType const*>(&module)));
8974
return worker;
9075
}
76+
77+
Worker* getWorkerForModule(edm::ModuleDescription const& iDescription) {
78+
auto* worker = getWorkerForExistingModule(iDescription.moduleLabel());
79+
assert(worker != nullptr);
80+
assert(worker->description() == &iDescription);
81+
return worker;
82+
}
83+
9184
void resetAll();
9285

9386
private:

0 commit comments

Comments
 (0)