28 unsigned int hint = 0;
60 <<
"PathsAndConsumesOfModules::removeModules() is trying to remove a module with label "
74 for (
auto iBranchType = 0
U; iBranchType !=
NumBranchTypes; ++iBranchType) {
81 if (idToIndex.second >= iModule) {
91 unsigned int moduleID)
const {
96 unsigned int dummy = 0;
98 std::vector<std::pair<unsigned int, unsigned int>>::const_iterator iter =
102 <<
"PathsAndConsumesOfModules::moduleDescription: Unknown moduleID " << moduleID <<
"\n";
112 unsigned int endPathIndex)
const {
117 unsigned int moduleID,
BranchType branchType)
const {
132 unsigned int dummy = 0;
134 std::vector<std::pair<unsigned int, unsigned int>>::const_iterator iter =
138 <<
"PathsAndConsumesOfModules::moduleIndex: Unknown moduleID " << moduleID <<
"\n";
148 std::unordered_set<unsigned int>& consumedModules) {
151 if (consumedModules.find(module->
id()) != consumedModules.end()) {
154 consumedModules.insert(module->
id());
158 findAllConsumedModules(iPnC,
c, consumedModules);
167 const std::string kTriggerResults(
"TriggerResults");
169 std::vector<std::string> pathNames = iPnC.
paths();
170 const unsigned int kFirstEndPathIndex = pathNames.size();
171 pathNames.insert(pathNames.end(), iPnC.
endPaths().begin(), iPnC.
endPaths().end());
179 std::vector<ModuleDescription const*> consumerModules;
180 for (
unsigned int pathIndex = 0; pathIndex != pathNames.size(); ++pathIndex) {
181 std::vector<ModuleDescription const*>
const* moduleDescriptions;
182 if (pathIndex < kFirstEndPathIndex) {
185 moduleDescriptions = &(iPnC.
modulesOnEndPath(pathIndex - kFirstEndPathIndex));
187 std::copy(moduleDescriptions->begin(), moduleDescriptions->end(), std::back_inserter(consumerModules));
199 }
else if (std::binary_search(consumedByChildren.begin(),
200 consumedByChildren.end(),
202 std::binary_search(consumedByChildren.begin(),
203 consumedByChildren.end(),
211 std::unordered_set<unsigned int> consumedModules;
213 findAllConsumedModules(iPnC,
description, consumedModules);
218 std::vector<ModuleDescription const*> unusedModules;
221 std::back_inserter(unusedModules),
223 return consumedModules.find(
description->id()) == consumedModules.end();
225 return unusedModules;
272 std::unordered_map<unsigned int, std::string> moduleIndexToNames;
274 std::unordered_map<std::string, unsigned int> pathStatusInserterModuleLabelToModuleID;
277 const std::string kTriggerResults(
"TriggerResults");
278 const std::string kPathStatusInserter(
"PathStatusInserter");
279 const std::string kEndPathStatusInserter(
"EndPathStatusInserter");
281 unsigned int largestIndex = 0;
282 unsigned int kPathToTriggerResultsDependencyLastIndex =
kInvalidIndex;
285 if (kTriggerResults ==
description->moduleLabel()) {
291 if (
description->moduleName() == kPathStatusInserter ||
description->moduleName() == kEndPathStatusInserter) {
295 kPathToTriggerResultsDependencyLastIndex = largestIndex;
343 std::unordered_map<unsigned int, std::vector<unsigned int>> moduleIndexToPathIndex;
346 std::vector<std::string> pathNames = iPnC.
paths();
347 const unsigned int kFirstEndPathIndex = pathNames.size();
353 const std::string kFinishedProcessing(
"@FinishedProcessing");
354 const unsigned int kFinishedProcessingIndex{0};
355 moduleIndexToNames.insert(std::make_pair(kFinishedProcessingIndex, kFinishedProcessing));
357 pathNames.insert(pathNames.end(), iPnC.
endPaths().begin(), iPnC.
endPaths().end());
358 std::vector<std::vector<unsigned int>> pathIndexToModuleIndexOrder(pathNames.size());
360 for (
unsigned int pathIndex = 0; pathIndex != pathNames.size(); ++pathIndex) {
361 std::set<unsigned int> alreadySeenIndex;
363 std::vector<ModuleDescription const*>
const* moduleDescriptions;
364 if (pathIndex < kFirstEndPathIndex) {
367 moduleDescriptions = &(iPnC.
modulesOnEndPath(pathIndex - kFirstEndPathIndex));
370 auto& pathOrder = pathIndexToModuleIndexOrder[pathIndex];
371 pathOrder.reserve(moduleDescriptions->size() + 1);
372 for (
auto const&
description : *moduleDescriptions) {
376 unsigned int const moduleIndex =
description->id();
377 pathOrder.push_back(moduleIndex);
378 auto&
paths = moduleIndexToPathIndex[moduleIndex];
379 paths.push_back(pathIndex);
381 edgeToPathMap[std::make_pair(moduleIndex, lastModuleIndex)].push_back(pathIndex);
383 lastModuleIndex = moduleIndex;
388 auto labelToID = pathStatusInserterModuleLabelToModuleID.find(pathNames[pathIndex]);
389 if (labelToID == pathStatusInserterModuleLabelToModuleID.end()) {
392 <<
"PathsAndConsumesOfModules::moduleDescription:checkForModuleDependencyCorrectness Could not find "
393 "PathStatusInserter\n";
395 unsigned int pathStatusInserterModuleID = labelToID->second;
396 if (pathIndex < kFirstEndPathIndex) {
398 edgeToPathMap[std::make_pair(pathStatusInserterModuleID, lastModuleIndex)].push_back(pathIndex);
399 moduleIndexToNames.insert(std::make_pair(pathStatusInserterModuleID, kPathEnded));
401 edgeToPathMap[std::make_pair(kTriggerResultsIndex, pathStatusInserterModuleID)].push_back(
405 edgeToPathMap[std::make_pair(kFinishedProcessingIndex, pathStatusInserterModuleID)].push_back(
407 pathOrder.push_back(pathStatusInserterModuleID);
410 if ((not moduleDescriptions->empty())) {
412 ++kPathToTriggerResultsDependencyLastIndex;
413 edgeToPathMap[std::make_pair(moduleDescriptions->front()->id(), kPathToTriggerResultsDependencyLastIndex)]
414 .push_back(pathIndex);
415 moduleIndexToNames.insert(std::make_pair(kPathToTriggerResultsDependencyLastIndex, kEndPathStart));
416 edgeToPathMap[std::make_pair(kPathToTriggerResultsDependencyLastIndex, kTriggerResultsIndex)].push_back(
418 pathOrder.insert(pathOrder.begin(), kPathToTriggerResultsDependencyLastIndex);
421 ++kPathToTriggerResultsDependencyLastIndex;
422 edgeToPathMap[std::make_pair(pathStatusInserterModuleID, lastModuleIndex)].push_back(pathIndex);
423 moduleIndexToNames.insert(std::make_pair(pathStatusInserterModuleID, kPathEnded));
424 edgeToPathMap[std::make_pair(kFinishedProcessingIndex, pathStatusInserterModuleID)].push_back(
426 pathOrder.push_back(pathStatusInserterModuleID);
434 unsigned int const moduleIndex =
description->id();
436 for (
auto const& depDescription : dependentModules) {
437 if (iPrintDependencies) {
439 <<
"ModuleDependency '" <<
description->moduleLabel() <<
"' depends on data products from module '"
440 << depDescription->moduleLabel() <<
"'";
445 auto depID = depDescription->id();
446 auto itPathsFound = moduleIndexToPathIndex.find(moduleIndex);
447 bool keepDataDependency =
true;
448 auto itDepsPathsFound = moduleIndexToPathIndex.find(depID);
449 if (itPathsFound != moduleIndexToPathIndex.end() and itDepsPathsFound != moduleIndexToPathIndex.end()) {
450 keepDataDependency =
false;
451 for (
auto const pathIndex : itPathsFound->second) {
452 for (
auto idToCheck : pathIndexToModuleIndexOrder[pathIndex]) {
453 if (idToCheck == depID) {
457 if (idToCheck == moduleIndex) {
460 keepDataDependency =
true;
464 if (keepDataDependency) {
469 if (keepDataDependency) {
479 if (not moduleIndexToPathIndex.empty()) {