File indexing completed on 2024-04-06 12:12:05
0001 #ifndef FWCore_Framework_Schedule_h
0002 #define FWCore_Framework_Schedule_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0061 #include "FWCore/Common/interface/FWCoreCommonFwd.h"
0062 #include "FWCore/Framework/interface/ExceptionActions.h"
0063 #include "FWCore/Framework/interface/ExceptionHelpers.h"
0064 #include "FWCore/Framework/interface/Frameworkfwd.h"
0065 #include "FWCore/Framework/interface/OccurrenceTraits.h"
0066 #include "FWCore/Framework/interface/WorkerManager.h"
0067 #include "FWCore/Framework/interface/maker/Worker.h"
0068 #include "FWCore/Framework/interface/WorkerRegistry.h"
0069 #include "FWCore/Framework/interface/GlobalSchedule.h"
0070 #include "FWCore/Framework/interface/StreamSchedule.h"
0071 #include "FWCore/Framework/interface/SystemTimeKeeper.h"
0072 #include "FWCore/Framework/interface/PreallocationConfiguration.h"
0073 #include "FWCore/MessageLogger/interface/ExceptionMessages.h"
0074 #include "FWCore/MessageLogger/interface/JobReport.h"
0075 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0076 #include "FWCore/ServiceRegistry/interface/Service.h"
0077 #include "FWCore/Utilities/interface/Algorithms.h"
0078 #include "FWCore/Utilities/interface/BranchType.h"
0079 #include "FWCore/Utilities/interface/ConvertException.h"
0080 #include "FWCore/Utilities/interface/Exception.h"
0081 #include "FWCore/Utilities/interface/StreamID.h"
0082 #include "FWCore/Utilities/interface/get_underlying_safe.h"
0083 #include "FWCore/Utilities/interface/propagate_const.h"
0084
0085 #include <array>
0086 #include <map>
0087 #include <memory>
0088 #include <set>
0089 #include <string>
0090 #include <vector>
0091 #include <sstream>
0092 #include <utility>
0093
0094 namespace edm {
0095
0096 namespace service {
0097 class TriggerNamesService;
0098 }
0099 namespace evetnsetup {
0100 class ESRecordsToProductResolverIndices;
0101 }
0102
0103 class ActivityRegistry;
0104 class BranchIDListHelper;
0105 class EventTransitionInfo;
0106 class ExceptionCollector;
0107 class MergeableRunProductMetadata;
0108 class OutputModuleCommunicator;
0109 class ProcessContext;
0110 class ProductRegistry;
0111 class PreallocationConfiguration;
0112 class StreamSchedule;
0113 class GlobalSchedule;
0114 struct TriggerTimingReport;
0115 class ModuleRegistry;
0116 class ModuleTypeResolverMaker;
0117 class ThinnedAssociationsHelper;
0118 class SubProcessParentageHelper;
0119 class TriggerResultInserter;
0120 class PathStatusInserter;
0121 class EndPathStatusInserter;
0122 class WaitingTaskHolder;
0123
0124 class Schedule {
0125 public:
0126 typedef std::vector<std::string> vstring;
0127 typedef std::vector<Worker*> AllWorkers;
0128 typedef std::vector<edm::propagate_const<std::shared_ptr<OutputModuleCommunicator>>> AllOutputModuleCommunicators;
0129
0130 typedef std::vector<Worker*> Workers;
0131
0132 Schedule(ParameterSet& proc_pset,
0133 service::TriggerNamesService const& tns,
0134 ProductRegistry& pregistry,
0135 ExceptionToActionTable const& actions,
0136 std::shared_ptr<ActivityRegistry> areg,
0137 std::shared_ptr<ProcessConfiguration const> processConfiguration,
0138 PreallocationConfiguration const& config,
0139 ProcessContext const* processContext,
0140 ModuleTypeResolverMaker const* resolverMaker);
0141 void finishSetup(ParameterSet& proc_pset,
0142 service::TriggerNamesService const& tns,
0143 ProductRegistry& preg,
0144 BranchIDListHelper& branchIDListHelper,
0145 ProcessBlockHelperBase& processBlockHelper,
0146 ThinnedAssociationsHelper& thinnedAssociationsHelper,
0147 SubProcessParentageHelper const* subProcessParentageHelper,
0148 std::shared_ptr<ActivityRegistry> areg,
0149 std::shared_ptr<ProcessConfiguration> processConfiguration,
0150 bool hasSubprocesses,
0151 PreallocationConfiguration const& prealloc,
0152 ProcessContext const* processContext);
0153
0154 void processOneEventAsync(WaitingTaskHolder iTask,
0155 unsigned int iStreamID,
0156 EventTransitionInfo&,
0157 ServiceToken const& token);
0158
0159 template <typename T>
0160 void processOneGlobalAsync(WaitingTaskHolder iTask,
0161 typename T::TransitionInfoType& transitionInfo,
0162 ServiceToken const& token,
0163 bool cleaningUpAfterException = false);
0164
0165 template <typename T>
0166 void processOneStreamAsync(WaitingTaskHolder iTask,
0167 unsigned int iStreamID,
0168 typename T::TransitionInfoType& transitionInfo,
0169 ServiceToken const& token,
0170 bool cleaningUpAfterException = false);
0171
0172 void beginJob(ProductRegistry const&,
0173 eventsetup::ESRecordsToProductResolverIndices const&,
0174 ProcessBlockHelperBase const&);
0175 void endJob(ExceptionCollector& collector);
0176
0177 void beginStream(unsigned int);
0178 void endStream(unsigned int);
0179
0180
0181 void writeLumiAsync(WaitingTaskHolder iTask,
0182 LuminosityBlockPrincipal const& lbp,
0183 ProcessContext const*,
0184 ActivityRegistry*);
0185
0186
0187 void writeRunAsync(WaitingTaskHolder iTask,
0188 RunPrincipal const& rp,
0189 ProcessContext const*,
0190 ActivityRegistry*,
0191 MergeableRunProductMetadata const*);
0192
0193 void writeProcessBlockAsync(WaitingTaskHolder iTask,
0194 ProcessBlockPrincipal const&,
0195 ProcessContext const*,
0196 ActivityRegistry*);
0197
0198
0199 void closeOutputFiles();
0200
0201
0202 void openOutputFiles(FileBlock& fb);
0203
0204
0205 void respondToOpenInputFile(FileBlock const& fb);
0206
0207
0208 void respondToCloseInputFile(FileBlock const& fb);
0209
0210
0211 bool shouldWeCloseOutput() const;
0212
0213
0214
0215
0216
0217
0218
0219 std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
0220
0221
0222 void availablePaths(std::vector<std::string>& oLabelsToFill) const;
0223
0224
0225
0226
0227 void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
0228
0229
0230 void endPaths(std::vector<std::string>& oLabelsToFill) const;
0231
0232
0233 void modulesInPath(std::string const& iPathLabel, std::vector<std::string>& oLabelsToFill) const;
0234
0235
0236
0237 void moduleDescriptionsInPath(std::string const& iPathLabel,
0238 std::vector<ModuleDescription const*>& descriptions,
0239 unsigned int hint) const;
0240
0241
0242
0243 void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
0244 std::vector<ModuleDescription const*>& descriptions,
0245 unsigned int hint) const;
0246
0247 void fillModuleAndConsumesInfo(
0248 std::vector<ModuleDescription const*>& allModuleDescriptions,
0249 std::vector<std::pair<unsigned int, unsigned int>>& moduleIDToIndex,
0250 std::array<std::vector<std::vector<ModuleDescription const*>>, NumBranchTypes>&
0251 modulesWhoseProductsAreConsumedBy,
0252 std::vector<std::vector<ModuleProcessName>>& modulesInPreviousProcessesWhoseProductsAreConsumedBy,
0253 ProductRegistry const& preg) const;
0254
0255
0256
0257
0258 int totalEvents() const;
0259
0260
0261
0262 int totalEventsPassed() const;
0263
0264
0265
0266 int totalEventsFailed() const;
0267
0268
0269
0270 void getTriggerReport(TriggerReport& rep) const;
0271
0272
0273
0274 void getTriggerTimingReport(TriggerTimingReport& rep) const;
0275
0276
0277 bool terminate() const;
0278
0279
0280 void clearCounters();
0281
0282
0283
0284 bool changeModule(std::string const& iLabel,
0285 ParameterSet const& iPSet,
0286 const ProductRegistry& iRegistry,
0287 eventsetup::ESRecordsToProductResolverIndices const&);
0288
0289
0290 void deleteModule(std::string const& iLabel, ActivityRegistry* areg);
0291
0292 void initializeEarlyDelete(std::vector<std::string> const& branchesToDeleteEarly,
0293 std::multimap<std::string, std::string> const& referencesToBranches,
0294 std::vector<std::string> const& modulesToSkip,
0295 edm::ProductRegistry const& preg);
0296
0297
0298 AllWorkers const& allWorkers() const;
0299
0300
0301 void convertCurrentProcessAlias(std::string const& processName);
0302
0303 private:
0304 void limitOutput(ParameterSet const& proc_pset,
0305 BranchIDLists const& branchIDLists,
0306 SubProcessParentageHelper const* subProcessParentageHelper);
0307
0308 std::shared_ptr<TriggerResultInserter const> resultsInserter() const {
0309 return get_underlying_safe(resultsInserter_);
0310 }
0311 std::shared_ptr<TriggerResultInserter>& resultsInserter() { return get_underlying_safe(resultsInserter_); }
0312 std::shared_ptr<ModuleRegistry const> moduleRegistry() const { return get_underlying_safe(moduleRegistry_); }
0313 std::shared_ptr<ModuleRegistry>& moduleRegistry() { return get_underlying_safe(moduleRegistry_); }
0314
0315 edm::propagate_const<std::shared_ptr<TriggerResultInserter>> resultsInserter_;
0316 std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>> pathStatusInserters_;
0317 std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>> endPathStatusInserters_;
0318 edm::propagate_const<std::shared_ptr<ModuleRegistry>> moduleRegistry_;
0319 std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
0320
0321 edm::propagate_const<std::unique_ptr<GlobalSchedule>> globalSchedule_;
0322
0323 AllOutputModuleCommunicators all_output_communicators_;
0324 PreallocationConfiguration preallocConfig_;
0325
0326 edm::propagate_const<std::unique_ptr<SystemTimeKeeper>> summaryTimeKeeper_;
0327
0328 std::vector<std::string> const* pathNames_;
0329 std::vector<std::string> const* endPathNames_;
0330 bool wantSummary_;
0331 };
0332
0333 template <typename T>
0334 void Schedule::processOneStreamAsync(WaitingTaskHolder iTaskHolder,
0335 unsigned int iStreamID,
0336 typename T::TransitionInfoType& transitionInfo,
0337 ServiceToken const& token,
0338 bool cleaningUpAfterException) {
0339 assert(iStreamID < streamSchedules_.size());
0340 streamSchedules_[iStreamID]->processOneStreamAsync<T>(
0341 std::move(iTaskHolder), transitionInfo, token, cleaningUpAfterException);
0342 }
0343
0344 template <typename T>
0345 void Schedule::processOneGlobalAsync(WaitingTaskHolder iTaskHolder,
0346 typename T::TransitionInfoType& transitionInfo,
0347 ServiceToken const& token,
0348 bool cleaningUpAfterException) {
0349 globalSchedule_->processOneGlobalAsync<T>(iTaskHolder, transitionInfo, token, cleaningUpAfterException);
0350 }
0351
0352 }
0353 #endif