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