26 unsigned int hint = 0;
49 unsigned int dummy = 0;
50 auto target = std::make_pair(moduleID, dummy);
51 std::vector<std::pair<unsigned int, unsigned int>>::const_iterator iter =
64 unsigned int endPathIndex)
const {
69 unsigned int moduleID)
const {
79 unsigned int dummy = 0;
80 auto target = std::make_pair(moduleID, dummy);
81 std::vector<std::pair<unsigned int, unsigned int>>::const_iterator iter =
133 std::unordered_map<unsigned int, std::string> moduleIndexToNames;
135 std::unordered_map<std::string, unsigned int> pathStatusInserterModuleLabelToModuleID;
138 const std::string kTriggerResults(
"TriggerResults");
139 const std::string kPathStatusInserter(
"PathStatusInserter");
140 const std::string kEndPathStatusInserter(
"EndPathStatusInserter");
142 unsigned int largestIndex = 0;
143 unsigned int kPathToTriggerResultsDependencyLastIndex =
kInvalidIndex;
146 if (kTriggerResults ==
description->moduleLabel()) {
152 if (
description->moduleName() == kPathStatusInserter ||
description->moduleName() == kEndPathStatusInserter) {
156 kPathToTriggerResultsDependencyLastIndex = largestIndex;
204 std::unordered_map<unsigned int, std::vector<unsigned int>> moduleIndexToPathIndex;
208 const unsigned int kFirstEndPathIndex = pathNames.size();
214 const std::string kFinishedProcessing(
"@FinishedProcessing");
215 const unsigned int kFinishedProcessingIndex{0};
216 moduleIndexToNames.insert(std::make_pair(kFinishedProcessingIndex, kFinishedProcessing));
218 pathNames.insert(pathNames.end(), iPnC.
endPaths().begin(), iPnC.
endPaths().end());
219 std::vector<std::vector<unsigned int>> pathIndexToModuleIndexOrder(pathNames.size());
221 for (
unsigned int pathIndex = 0; pathIndex != pathNames.size(); ++pathIndex) {
222 std::set<unsigned int> alreadySeenIndex;
224 std::vector<ModuleDescription const*>
const* moduleDescriptions;
225 if (pathIndex < kFirstEndPathIndex) {
228 moduleDescriptions = &(iPnC.
modulesOnEndPath(pathIndex - kFirstEndPathIndex));
231 auto& pathOrder = pathIndexToModuleIndexOrder[pathIndex];
232 pathOrder.reserve(moduleDescriptions->size() + 1);
233 for (
auto const&
description : *moduleDescriptions) {
238 pathOrder.push_back(moduleIndex);
240 paths.push_back(pathIndex);
242 edgeToPathMap[std::make_pair(moduleIndex, lastModuleIndex)].push_back(pathIndex);
249 auto labelToID = pathStatusInserterModuleLabelToModuleID.find(pathNames[pathIndex]);
250 if (labelToID == pathStatusInserterModuleLabelToModuleID.end()) {
253 <<
"PathsAndConsumesOfModules::moduleDescription:checkForModuleDependencyCorrectness Could not find " 254 "PathStatusInserter\n";
256 unsigned int pathStatusInserterModuleID = labelToID->second;
257 if (pathIndex < kFirstEndPathIndex) {
259 edgeToPathMap[std::make_pair(pathStatusInserterModuleID, lastModuleIndex)].push_back(pathIndex);
260 moduleIndexToNames.insert(std::make_pair(pathStatusInserterModuleID, kPathEnded));
262 edgeToPathMap[std::make_pair(kTriggerResultsIndex, pathStatusInserterModuleID)].push_back(
266 edgeToPathMap[std::make_pair(kFinishedProcessingIndex, pathStatusInserterModuleID)].push_back(
268 pathOrder.push_back(pathStatusInserterModuleID);
271 if ((not moduleDescriptions->empty())) {
273 ++kPathToTriggerResultsDependencyLastIndex;
274 edgeToPathMap[std::make_pair(moduleDescriptions->front()->id(), kPathToTriggerResultsDependencyLastIndex)]
275 .push_back(pathIndex);
276 moduleIndexToNames.insert(std::make_pair(kPathToTriggerResultsDependencyLastIndex, kEndPathStart));
277 edgeToPathMap[std::make_pair(kPathToTriggerResultsDependencyLastIndex, kTriggerResultsIndex)].push_back(
279 pathOrder.insert(pathOrder.begin(), kPathToTriggerResultsDependencyLastIndex);
282 ++kPathToTriggerResultsDependencyLastIndex;
283 edgeToPathMap[std::make_pair(pathStatusInserterModuleID, lastModuleIndex)].push_back(pathIndex);
284 moduleIndexToNames.insert(std::make_pair(pathStatusInserterModuleID, kPathEnded));
285 edgeToPathMap[std::make_pair(kFinishedProcessingIndex, pathStatusInserterModuleID)].push_back(
287 pathOrder.push_back(pathStatusInserterModuleID);
297 for (
auto const& depDescription : dependentModules) {
298 if (iPrintDependencies) {
300 <<
"ModuleDependency '" <<
description->moduleLabel() <<
"' depends on data products from module '" 301 << depDescription->moduleLabel() <<
"'";
306 auto depID = depDescription->id();
307 auto itPathsFound = moduleIndexToPathIndex.find(moduleIndex);
308 bool keepDataDependency =
true;
309 auto itDepsPathsFound = moduleIndexToPathIndex.find(depID);
310 if (itPathsFound != moduleIndexToPathIndex.end() and itDepsPathsFound != moduleIndexToPathIndex.end()) {
311 keepDataDependency =
false;
312 for (
auto const pathIndex : itPathsFound->second) {
313 for (
auto idToCheck : pathIndexToModuleIndexOrder[pathIndex]) {
314 if (idToCheck == depID) {
318 if (idToCheck == moduleIndex) {
321 keepDataDependency =
true;
325 if (keepDataDependency) {
330 if (keepDataDependency) {
340 if (not moduleIndexToPathIndex.empty()) {
virtual std::vector< ConsumesInfo > consumesInfo() const =0
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
std::vector< std::vector< ModuleDescription const * > > modulesWhoseProductsAreConsumedBy_
void throwIfImproperDependencies(EdgeToPathMap const &, std::vector< std::vector< unsigned int >> const &iPathIndexToModuleIndexOrder, std::vector< std::string > const &iPathNames, std::unordered_map< unsigned int, std::string > const &iModuleIndexToNames)
std::map< SimpleEdge, std::vector< unsigned int >> EdgeToPathMap
std::vector< ModuleDescription const * > const & doModulesOnPath(unsigned int pathIndex) const override
constexpr auto kDataDependencyIndex
std::vector< ModuleDescription const * > const & modulesOnEndPath(unsigned int endPathIndex) const
std::vector< ModuleDescription const * > const & modulesOnPath(unsigned int pathIndex) const
unsigned int moduleIndex(unsigned int moduleID) const
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
std::vector< std::pair< unsigned int, unsigned int > > moduleIDToIndex_
std::vector< ModuleDescription const * > const & doModulesWhoseProductsAreConsumedBy(unsigned int moduleID) const override
std::vector< ModuleDescription const * > allModuleDescriptions_
std::vector< std::string > paths_
std::vector< ModuleDescription const * > const & allModules() const
std::vector< std::string > const & endPaths() const
std::vector< ModuleDescription const * > const & doModulesOnEndPath(unsigned int endPathIndex) const override
void initialize(Schedule const *, std::shared_ptr< ProductRegistry const >)
std::vector< std::vector< ModuleDescription const * > > modulesOnPaths_
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
std::vector< std::string > endPaths_
std::vector< ConsumesInfo > doConsumesInfo(unsigned int moduleID) const override
void fillModuleAndConsumesInfo(std::vector< ModuleDescription const * > &allModuleDescriptions, std::vector< std::pair< unsigned int, unsigned int >> &moduleIDToIndex, std::vector< std::vector< ModuleDescription const * >> &modulesWhoseProductsAreConsumedBy, ProductRegistry const &preg) const
void checkForModuleDependencyCorrectness(edm::PathsAndConsumesOfModulesBase const &iPnC, bool iPrintDependencies)
std::shared_ptr< ProductRegistry const > preg_
std::vector< ModuleDescription const * > const & modulesWhoseProductsAreConsumedBy(unsigned int moduleID) const
~PathsAndConsumesOfModules() override
Schedule const * schedule_
std::vector< std::string > const & paths() const
std::vector< std::vector< ModuleDescription const * > > modulesOnEndPaths_
ModuleDescription const * doModuleDescription(unsigned int moduleID) const override
constexpr auto kInvalidIndex
void endPaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all end paths in the process
void moduleDescriptionsInPath(std::string const &iPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const