28 unsigned int hint = 0;
52 unsigned int dummy = 0;
53 auto target = std::make_pair(moduleID, dummy);
54 std::vector<std::pair<unsigned int, unsigned int> >::const_iterator iter =
58 <<
"PathsAndConsumesOfModules::moduleDescription: Unknown moduleID\n";
63 std::vector<ModuleDescription const*>
const&
68 std::vector<ModuleDescription const*>
const&
73 std::vector<ModuleDescription const*>
const&
78 std::vector<ConsumesInfo>
86 unsigned int dummy = 0;
87 auto target = std::make_pair(moduleID, dummy);
88 std::vector<std::pair<unsigned int, unsigned int> >::const_iterator iter =
92 <<
"PathsAndConsumesOfModules::moduleIndex: Unknown moduleID\n";
140 bool iPrintDependencies) {
143 std::unordered_map<unsigned int, std::string> moduleIndexToNames;
145 std::unordered_map<std::string, unsigned int> pathStatusInserterModuleLabelToModuleID;
148 const std::string kTriggerResults(
"TriggerResults");
149 const std::string kPathStatusInserter(
"PathStatusInserter");
150 const std::string kEndPathStatusInserter(
"EndPathStatusInserter");
152 unsigned int largestIndex = 0;
153 unsigned int kPathToTriggerResultsDependencyLastIndex =
kInvalidIndex;
155 moduleIndexToNames.insert(std::make_pair(
description->id(),
157 if(kTriggerResults ==
description->moduleLabel()) {
163 if(
description->moduleName() == kPathStatusInserter ||
description->moduleName() == kEndPathStatusInserter) {
167 kPathToTriggerResultsDependencyLastIndex = largestIndex ;
216 std::unordered_map<unsigned int, std::vector<unsigned int>> moduleIndexToPathIndex;
219 std::vector<std::string> pathNames = iPnC.
paths();
220 const unsigned int kFirstEndPathIndex = pathNames.size();
226 const std::string kFinishedProcessing(
"@FinishedProcessing");
227 const unsigned int kFinishedProcessingIndex{0};
228 moduleIndexToNames.insert(std::make_pair(kFinishedProcessingIndex,
229 kFinishedProcessing));
232 pathNames.insert(pathNames.end(), iPnC.
endPaths().begin(), iPnC.
endPaths().end());
233 std::vector<std::vector<unsigned int>> pathIndexToModuleIndexOrder(pathNames.size());
236 for(
unsigned int pathIndex = 0; pathIndex != pathNames.size(); ++pathIndex) {
237 std::set<unsigned int> alreadySeenIndex;
239 std::vector<ModuleDescription const*>
const* moduleDescriptions;
240 if(pathIndex < kFirstEndPathIndex) {
246 auto& pathOrder =pathIndexToModuleIndexOrder[pathIndex];
247 pathOrder.reserve(moduleDescriptions->size() + 1);
248 for(
auto const&
description: *moduleDescriptions) {
253 pathOrder.push_back(moduleIndex);
255 paths.push_back(pathIndex);
257 edgeToPathMap[std::make_pair(moduleIndex,lastModuleIndex)].push_back(pathIndex);
264 auto labelToID = pathStatusInserterModuleLabelToModuleID.find(pathNames[pathIndex]);
265 if(labelToID == pathStatusInserterModuleLabelToModuleID.end()) {
268 <<
"PathsAndConsumesOfModules::moduleDescription:checkForModuleDependencyCorrectness Could not find PathStatusInserter\n";
270 unsigned int pathStatusInserterModuleID = labelToID->second;
271 if( pathIndex < kFirstEndPathIndex) {
273 edgeToPathMap[std::make_pair(pathStatusInserterModuleID, lastModuleIndex)].push_back(pathIndex);
274 moduleIndexToNames.insert(std::make_pair(pathStatusInserterModuleID,
277 edgeToPathMap[std::make_pair(kTriggerResultsIndex, pathStatusInserterModuleID)].push_back(
kDataDependencyIndex);
280 edgeToPathMap[std::make_pair(kFinishedProcessingIndex, pathStatusInserterModuleID)].push_back(
kDataDependencyIndex);
281 pathOrder.push_back(pathStatusInserterModuleID);
284 if( (not moduleDescriptions->empty()) ) {
286 ++kPathToTriggerResultsDependencyLastIndex;
287 edgeToPathMap[std::make_pair(moduleDescriptions->front()->id(),kPathToTriggerResultsDependencyLastIndex)].push_back(pathIndex);
288 moduleIndexToNames.insert(std::make_pair(kPathToTriggerResultsDependencyLastIndex,
290 edgeToPathMap[std::make_pair(kPathToTriggerResultsDependencyLastIndex,kTriggerResultsIndex)].push_back(
kDataDependencyIndex);
291 pathOrder.insert(pathOrder.begin(),kPathToTriggerResultsDependencyLastIndex);
294 ++kPathToTriggerResultsDependencyLastIndex;
295 edgeToPathMap[std::make_pair(pathStatusInserterModuleID, lastModuleIndex)].push_back(pathIndex);
296 moduleIndexToNames.insert(std::make_pair(pathStatusInserterModuleID,
298 edgeToPathMap[std::make_pair(kFinishedProcessingIndex, pathStatusInserterModuleID)].push_back(
kDataDependencyIndex);
299 pathOrder.push_back(pathStatusInserterModuleID);
310 for(
auto const& depDescription: dependentModules) {
311 if(iPrintDependencies) {
313 "' depends on data products from module '" << depDescription->moduleLabel()<<
"'";
318 auto depID =depDescription->id();
319 auto itPathsFound = moduleIndexToPathIndex.find(moduleIndex);
320 bool keepDataDependency =
true;
321 auto itDepsPathsFound =moduleIndexToPathIndex.find(depID);
322 if(itPathsFound != moduleIndexToPathIndex.end() and itDepsPathsFound != moduleIndexToPathIndex.end()) {
323 keepDataDependency =
false;
324 for(
auto const pathIndex: itPathsFound->second) {
325 for(
auto idToCheck: pathIndexToModuleIndexOrder[pathIndex]) {
326 if(idToCheck == depID) {
330 if(idToCheck == moduleIndex) {
333 keepDataDependency =
true;
337 if(keepDataDependency) {
342 if(keepDataDependency) {
virtual std::vector< ConsumesInfo > consumesInfo() const =0
constexpr auto kInvalidIndex
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
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 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
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