26 #include "boost/graph/graph_traits.hpp"
27 #include "boost/graph/adjacency_list.hpp"
28 #include "boost/graph/depth_first_search.hpp"
29 #include "boost/graph/visitors.hpp"
44 using std::placeholders::_1;
46 bool binary_search_string(std::vector<std::string>
const&
v,
std::string const&
s) {
47 return std::binary_search(v.begin(), v.end(),
s);
53 std::shared_ptr<TriggerResultInserter>
55 PreallocationConfiguration
const& iPrealloc,
56 ProductRegistry&
preg,
57 ExceptionToActionTable
const&
actions,
58 std::shared_ptr<ActivityRegistry>
areg,
61 ParameterSet* trig_pset = proc_pset.getPSetForUpdate(
"@trigger_paths");
62 trig_pset->registerIt();
64 WorkerParams work_args(trig_pset, preg, &iPrealloc, processConfiguration, actions);
65 ModuleDescription
md(trig_pset->id(),
66 "TriggerResultInserter",
68 processConfiguration.get(),
71 areg->preModuleConstructionSignal_(
md);
72 bool postCalled =
false;
73 std::shared_ptr<TriggerResultInserter> returnValue;
75 maker::ModuleHolderT<TriggerResultInserter> holder(std::make_shared<TriggerResultInserter>(*trig_pset, iPrealloc.numberOfStreams()),static_cast<Maker const*>(
nullptr));
76 holder.setModuleDescription(
md);
77 holder.registerProductsAndCallbacks(&preg);
78 returnValue =holder.module();
81 areg->postModuleConstructionSignal_(
md);
86 areg->postModuleConstructionSignal_(
md);
99 checkAndInsertAlias(
std::string const& friendlyClassName,
105 ProductRegistry
const& preg,
106 std::multimap<BranchKey, BranchKey>& aliasMap,
107 std::map<BranchKey, BranchKey>& aliasKeys) {
110 BranchKey
key(friendlyClassName, moduleLabel, productInstanceName, processName);
111 if(preg.productList().find(
key) == preg.productList().end()) {
114 for(
auto const& product : preg.productList()) {
115 if(moduleLabel == product.first.moduleLabel() && processName == product.first.processName()) {
117 <<
"There are no products of type '" << friendlyClassName <<
"'\n"
118 <<
"with module label '" << moduleLabel <<
"' and instance name '" << productInstanceName <<
"'.\n";
123 std::string const& theInstanceAlias(instanceAlias == star ? productInstanceName : instanceAlias);
124 BranchKey aliasKey(friendlyClassName, alias, theInstanceAlias, processName);
125 if(preg.productList().find(aliasKey) != preg.productList().end()) {
127 <<
"A product of type '" << friendlyClassName <<
"'\n"
128 <<
"with module label '" << alias <<
"' and instance name '" << theInstanceAlias <<
"'\n"
129 <<
"already exists.\n";
131 auto iter = aliasKeys.find(aliasKey);
132 if(
iter != aliasKeys.end()) {
136 <<
"The module label alias '" << alias <<
"' and product instance alias '" << theInstanceAlias <<
"'\n"
137 <<
"are used for multiple products of type '" << friendlyClassName <<
"'\n"
138 <<
"One has module label '" << moduleLabel <<
"' and product instance name '" << productInstanceName <<
"',\n"
139 <<
"the other has module label '" <<
iter->second.moduleLabel() <<
"' and product instance name '" <<
iter->second.productInstanceName() <<
"'.\n";
142 auto prodIter = preg.productList().find(
key);
143 if(prodIter != preg.productList().end()) {
144 if (!prodIter->second.produced()) {
146 <<
"The module label alias '" << alias <<
"' and product instance alias '" << theInstanceAlias <<
"'\n"
147 <<
"are used for a product of type '" << friendlyClassName <<
"'\n"
148 <<
"with module label '" << moduleLabel <<
"' and product instance name '" << productInstanceName <<
"',\n"
149 <<
"An EDAlias can only be used for products produced in the current process. This one is not.\n";
151 aliasMap.insert(std::make_pair(
key, aliasKey));
152 aliasKeys.insert(std::make_pair(aliasKey,
key));
159 std::vector<std::string>
aliases = proc_pset.getParameter<std::vector<std::string> >(
"@all_aliases");
160 if(aliases.empty()) {
167 desc.add<
std::string>(
"fromProductInstance", star);
170 std::multimap<BranchKey, BranchKey> aliasMap;
172 std::map<BranchKey, BranchKey> aliasKeys;
176 ParameterSet const& aliasPSet = proc_pset.getParameterSet(alias);
177 std::vector<std::string> vPSetNames = aliasPSet.getParameterNamesForType<
VParameterSet>();
185 if(productInstanceName == star) {
187 BranchKey lowerBound(friendlyClassName, moduleLabel,
empty,
empty);
188 for(ProductRegistry::ProductList::const_iterator it = preg.productList().lower_bound(lowerBound);
189 it != preg.productList().end() && it->first.friendlyClassName() == friendlyClassName && it->first.moduleLabel() == moduleLabel;
191 if(it->first.processName() != processName) {
196 checkAndInsertAlias(friendlyClassName, moduleLabel, it->first.productInstanceName(), processName, alias, instanceAlias,
preg, aliasMap, aliasKeys);
201 for(
auto const& product : preg.productList()) {
202 if(moduleLabel == product.first.moduleLabel() && processName == product.first.processName()) {
204 <<
"There are no products of type '" << friendlyClassName <<
"'\n"
205 <<
"with module label '" << moduleLabel <<
"'.\n";
210 checkAndInsertAlias(friendlyClassName, moduleLabel, productInstanceName, processName, alias, instanceAlias, preg, aliasMap, aliasKeys);
218 for(
auto const& aliasEntry : aliasMap) {
219 ProductRegistry::ProductList::const_iterator it = preg.productList().find(aliasEntry.first);
220 assert(it != preg.productList().end());
221 preg.addLabelAlias(it->second, aliasEntry.second.moduleLabel(), aliasEntry.second.productInstanceName());
226 typedef std::vector<std::string>
vstring;
229 vstring
const& end_path_name_list,
230 vstring& modulesInConfig,
231 std::set<std::string>
const& usedModuleLabels,
232 std::map<
std::string, std::vector<std::pair<std::string, int> > >& outputModulePathPositions) {
244 vstring outputModuleLabels;
246 std::string const moduleEdmType(
"@module_edm_type");
252 std::set<std::string> modulesInConfigSet(modulesInConfig.begin(), modulesInConfig.end());
256 vstring scheduledPaths = proc_pset.getParameter<vstring>(
"@paths");
257 std::set<std::string> modulesOnPaths;
259 std::set<std::string> noEndPaths(scheduledPaths.begin(),scheduledPaths.end());
260 for(
auto const&
endPath: end_path_name_list) {
265 for(
auto const&
path: noEndPaths) {
266 labels = proc_pset.getParameter<vstring>(
path);
267 modulesOnPaths.insert(labels.begin(),labels.end());
273 std::vector<std::string> labelsToBeDropped;
274 labelsToBeDropped.reserve(modulesInConfigSet.size());
275 std::set_difference(modulesInConfigSet.begin(),modulesInConfigSet.end(),
276 usedModuleLabels.begin(),usedModuleLabels.end(),
277 std::back_inserter(labelsToBeDropped));
279 const unsigned int sizeBeforeOutputModules = labelsToBeDropped.size();
280 for (
auto const& modLabel: usedModuleLabels) {
281 edmType = proc_pset.getParameterSet(modLabel).getParameter<
std::string>(moduleEdmType);
282 if (edmType == outputModule) {
283 outputModuleLabels.push_back(modLabel);
284 labelsToBeDropped.push_back(modLabel);
286 if(edmType == edAnalyzer) {
287 if(modulesOnPaths.end()==modulesOnPaths.find(modLabel)) {
288 labelsToBeDropped.push_back(modLabel);
293 std::inplace_merge(labelsToBeDropped.begin(),
294 labelsToBeDropped.begin()+sizeBeforeOutputModules,
295 labelsToBeDropped.end());
301 vstring::iterator endAfterRemove = std::remove_if(modulesInConfig.begin(), modulesInConfig.end(), std::bind(binary_search_string, std::ref(labelsToBeDropped), _1));
302 modulesInConfig.erase(endAfterRemove, modulesInConfig.end());
303 proc_pset.addParameter<vstring>(
std::string(
"@all_modules"), modulesInConfig);
306 vstring endPathsToBeDropped;
308 for (vstring::const_iterator iEndPath = end_path_name_list.begin(), endEndPath = end_path_name_list.end();
309 iEndPath != endEndPath;
311 labels = proc_pset.getParameter<vstring>(*iEndPath);
312 vstring::iterator iSave = labels.begin();
313 vstring::iterator iBegin = labels.begin();
315 for (vstring::iterator iLabel = labels.begin(), iEnd = labels.end();
316 iLabel != iEnd; ++iLabel) {
317 if (binary_search_string(labelsToBeDropped, *iLabel)) {
318 if (binary_search_string(outputModuleLabels, *iLabel)) {
319 outputModulePathPositions[*iLabel].emplace_back(*iEndPath, iSave - iBegin);
322 if (iSave != iLabel) {
323 iSave->swap(*iLabel);
328 labels.erase(iSave, labels.end());
329 if (labels.empty()) {
331 proc_pset.eraseSimpleParameter(*iEndPath);
332 endPathsToBeDropped.push_back(*iEndPath);
334 proc_pset.addParameter<vstring>(*iEndPath,
labels);
340 endAfterRemove = std::remove_if(scheduledPaths.begin(), scheduledPaths.end(), std::bind(binary_search_string, std::ref(endPathsToBeDropped), _1));
341 scheduledPaths.erase(endAfterRemove, scheduledPaths.end());
342 proc_pset.addParameter<vstring>(
std::string(
"@paths"), scheduledPaths);
345 vstring scheduledEndPaths = proc_pset.getParameter<vstring>(
"@end_paths");
346 endAfterRemove = std::remove_if(scheduledEndPaths.begin(), scheduledEndPaths.end(), std::bind(binary_search_string, std::ref(endPathsToBeDropped), _1));
347 scheduledEndPaths.erase(endAfterRemove, scheduledEndPaths.end());
348 proc_pset.addParameter<vstring>(
std::string(
"@end_paths"), scheduledEndPaths);
364 std::shared_ptr<ActivityRegistry> areg,
365 std::shared_ptr<ProcessConfiguration> processConfiguration,
370 resultsInserter_{tns.
getTrigPaths().empty()? std::shared_ptr<TriggerResultInserter>{} :makeInserter(proc_pset,prealloc,preg,actions,areg,processConfiguration)},
377 assert(0<
prealloc.numberOfStreams());
378 streamSchedules_.reserve(
prealloc.numberOfStreams());
379 for(
unsigned int i=0;
i<
prealloc.numberOfStreams();++
i) {
380 streamSchedules_.emplace_back(std::make_shared<StreamSchedule>(resultsInserter_,
moduleRegistry_,proc_pset,tns,
prealloc,preg,branchIDListHelper,actions,areg,processConfiguration,
nullptr==subProcPSet,
StreamID{
i},processContext));
385 const std::string kTriggerResults(
"TriggerResults");
386 std::vector<std::string> modulesToUse;
387 modulesToUse.reserve(streamSchedules_[0]->allWorkers().
size());
388 for(
auto const& worker : streamSchedules_[0]->allWorkers()) {
389 if(worker->description().moduleLabel() != kTriggerResults) {
390 modulesToUse.push_back(worker->description().moduleLabel());
394 unsigned int n = streamSchedules_[0]->numberOfUnscheduledModules();
396 std::vector<std::string>
temp;
397 temp.reserve(modulesToUse.size());
398 auto itBeginUnscheduled = modulesToUse.begin()+modulesToUse.size()-
n;
399 std::copy(itBeginUnscheduled,modulesToUse.end(),
400 std::back_inserter(temp));
401 std::copy(modulesToUse.begin(),itBeginUnscheduled,std::back_inserter(temp));
402 temp.swap(modulesToUse);
412 std::set<std::string> usedModuleLabels;
413 for(
auto const worker: allWorkers()) {
414 if(worker->description().moduleLabel() != kTriggerResults) {
415 usedModuleLabels.insert(worker->description().moduleLabel());
418 std::vector<std::string> modulesInConfig(proc_pset.getParameter<std::vector<std::string> >(
"@all_modules"));
419 std::map<std::string, std::vector<std::pair<std::string, int> > > outputModulePathPositions;
420 reduceParameterSet(proc_pset, tns.getEndPaths(), modulesInConfig, usedModuleLabels,
421 outputModulePathPositions);
422 processEDAliases(proc_pset, processConfiguration->processName(),
preg);
423 proc_pset.registerIt();
425 processConfiguration->setParameterSetID(proc_pset.id());
426 processConfiguration->setProcessConfigurationID();
430 size_t all_workers_count = allWorkers().size();
439 limitOutput(proc_pset, branchIDListHelper.branchIDLists());
445 assert (all_workers_count == allWorkers().
size());
447 branchIDListHelper.updateFromRegistry(preg);
451 for(
auto const& worker : streamSchedules_[0]->allWorkers()) {
452 worker->registerThinnedAssociations(preg, thinnedAssociationsHelper);
454 thinnedAssociationsHelper.sort();
457 c->setEventSelectionInfo(outputModulePathPositions, preg.anyProductProduced());
458 c->selectProducts(preg, thinnedAssociationsHelper);
462 std::vector<const ModuleDescription*> modDesc;
463 const auto& workers = allWorkers();
464 modDesc.reserve(workers.size());
467 std::back_inserter(modDesc),
469 return iWorker->descPtr();
475 auto timeKeeperPtr = summaryTimeKeeper_.get();
500 int maxEventSpecs = 0;
501 int maxEventsOut = -1;
508 std::vector<std::string> psetNamesE;
515 if (maxEventSpecs > 1) {
517 "\nAt most, one form of 'output' may appear in the 'maxEvents' parameter set";
522 if (vMaxEventsOut != 0 && !vMaxEventsOut->
empty()) {
523 std::string const& moduleLabel =
c->description().moduleLabel();
528 "\nNo entry in 'maxEvents' for output module label '" << moduleLabel <<
"'.\n";
540 if (!
c->limitReached()) {
545 LogInfo(
"SuccessfulTermination")
546 <<
"The job is terminating successfully because each output module\n"
547 <<
"has reached its configured limit.\n";
565 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Event Summary ------------";
580 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Path Summary ------------";
582 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
583 << std::right << std::setw(10) <<
"Run" <<
" "
584 << std::right << std::setw(10) <<
"Passed" <<
" "
585 << std::right << std::setw(10) <<
"Failed" <<
" "
586 << std::right << std::setw(10) <<
"Error" <<
" "
590 << std::right << std::setw(5) << 1
591 << std::right << std::setw(5) <<
p.bitPosition <<
" "
592 << std::right << std::setw(10) <<
p.timesRun <<
" "
593 << std::right << std::setw(10) <<
p.timesPassed <<
" "
594 << std::right << std::setw(10) <<
p.timesFailed <<
" "
595 << std::right << std::setw(10) <<
p.timesExcept <<
" "
617 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"-------End-Path Summary ------------";
619 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
620 << std::right << std::setw(10) <<
"Run" <<
" "
621 << std::right << std::setw(10) <<
"Passed" <<
" "
622 << std::right << std::setw(10) <<
"Failed" <<
" "
623 << std::right << std::setw(10) <<
"Error" <<
" "
627 << std::right << std::setw(5) << 0
628 << std::right << std::setw(5) <<
p.bitPosition <<
" "
629 << std::right << std::setw(10) <<
p.timesRun <<
" "
630 << std::right << std::setw(10) <<
p.timesPassed <<
" "
631 << std::right << std::setw(10) <<
p.timesFailed <<
" "
632 << std::right << std::setw(10) <<
p.timesExcept <<
" "
638 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Modules in Path: " <<
p.name <<
" ------------";
640 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
641 << std::right << std::setw(10) <<
"Visited" <<
" "
642 << std::right << std::setw(10) <<
"Passed" <<
" "
643 << std::right << std::setw(10) <<
"Failed" <<
" "
644 << std::right << std::setw(10) <<
"Error" <<
" "
647 unsigned int bitpos = 0;
648 for (
auto const&
mod:
p.moduleInPathSummaries) {
650 << std::right << std::setw(5) << 1
651 << std::right << std::setw(5) << bitpos <<
" "
652 << std::right << std::setw(10) <<
mod.timesVisited <<
" "
653 << std::right << std::setw(10) <<
mod.timesPassed <<
" "
654 << std::right << std::setw(10) <<
mod.timesFailed <<
" "
655 << std::right << std::setw(10) <<
mod.timesExcept <<
" "
656 <<
mod.moduleLabel <<
"";
663 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"------ Modules in End-Path: " <<
p.name <<
" ------------";
665 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
666 << std::right << std::setw(10) <<
"Visited" <<
" "
667 << std::right << std::setw(10) <<
"Passed" <<
" "
668 << std::right << std::setw(10) <<
"Failed" <<
" "
669 << std::right << std::setw(10) <<
"Error" <<
" "
672 unsigned int bitpos=0;
673 for (
auto const&
mod:
p.moduleInPathSummaries) {
675 << std::right << std::setw(5) << 0
676 << std::right << std::setw(5) << bitpos <<
" "
677 << std::right << std::setw(10) <<
mod.timesVisited <<
" "
678 << std::right << std::setw(10) <<
mod.timesPassed <<
" "
679 << std::right << std::setw(10) <<
mod.timesFailed <<
" "
680 << std::right << std::setw(10) <<
mod.timesExcept <<
" "
681 <<
mod.moduleLabel <<
"";
687 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Module Summary ------------";
689 << std::right << std::setw(10) <<
"Visited" <<
" "
690 << std::right << std::setw(10) <<
"Run" <<
" "
691 << std::right << std::setw(10) <<
"Passed" <<
" "
692 << std::right << std::setw(10) <<
"Failed" <<
" "
693 << std::right << std::setw(10) <<
"Error" <<
" "
697 << std::right << std::setw(10) << worker.timesVisited <<
" "
698 << std::right << std::setw(10) << worker.timesRun <<
" "
699 << std::right << std::setw(10) << worker.timesPassed <<
" "
700 << std::right << std::setw(10) << worker.timesFailed <<
" "
701 << std::right << std::setw(10) << worker.timesExcept <<
" "
702 << worker.moduleLabel <<
"";
712 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Event Summary ---[sec]----";
714 << std::setprecision(6) << std::fixed
720 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Path Summary ---[sec]----";
722 << std::right << std::setw(22) <<
"per event "
723 << std::right << std::setw(22) <<
"per path-run "
726 << std::right << std::setw(10) <<
"CPU" <<
" "
727 << std::right << std::setw(10) <<
"Real" <<
" "
728 << std::right << std::setw(10) <<
"CPU" <<
" "
729 << std::right << std::setw(10) <<
"Real" <<
" "
732 const int timesRun =
std::max(1,
p.timesRun);
734 << std::setprecision(6) << std::fixed
735 << std::right << std::setw(10) <<
p.cpuTime/totalEvents <<
" "
736 << std::right << std::setw(10) <<
p.realTime/totalEvents <<
" "
737 << std::right << std::setw(10) <<
p.cpuTime/timesRun <<
" "
738 << std::right << std::setw(10) <<
p.realTime/timesRun <<
" "
742 << std::right << std::setw(10) <<
"CPU" <<
" "
743 << std::right << std::setw(10) <<
"Real" <<
" "
744 << std::right << std::setw(10) <<
"CPU" <<
" "
745 << std::right << std::setw(10) <<
"Real" <<
" "
748 << std::right << std::setw(22) <<
"per event "
749 << std::right << std::setw(22) <<
"per path-run "
753 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"-------End-Path Summary ---[sec]----";
755 << std::right << std::setw(22) <<
"per event "
756 << std::right << std::setw(22) <<
"per endpath-run "
759 << std::right << std::setw(10) <<
"CPU" <<
" "
760 << std::right << std::setw(10) <<
"Real" <<
" "
761 << std::right << std::setw(10) <<
"CPU" <<
" "
762 << std::right << std::setw(10) <<
"Real" <<
" "
765 const int timesRun =
std::max(1,
p.timesRun);
768 << std::setprecision(6) << std::fixed
769 << std::right << std::setw(10) <<
p.cpuTime/totalEvents <<
" "
770 << std::right << std::setw(10) <<
p.realTime/totalEvents <<
" "
771 << std::right << std::setw(10) <<
p.cpuTime/timesRun <<
" "
772 << std::right << std::setw(10) <<
p.realTime/timesRun <<
" "
776 << std::right << std::setw(10) <<
"CPU" <<
" "
777 << std::right << std::setw(10) <<
"Real" <<
" "
778 << std::right << std::setw(10) <<
"CPU" <<
" "
779 << std::right << std::setw(10) <<
"Real" <<
" "
782 << std::right << std::setw(22) <<
"per event "
783 << std::right << std::setw(22) <<
"per endpath-run "
788 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Modules in Path: " <<
p.name <<
" ---[sec]----";
790 << std::right << std::setw(22) <<
"per event "
791 << std::right << std::setw(22) <<
"per module-visit "
794 << std::right << std::setw(10) <<
"CPU" <<
" "
795 << std::right << std::setw(10) <<
"Real" <<
" "
796 << std::right << std::setw(10) <<
"CPU" <<
" "
797 << std::right << std::setw(10) <<
"Real" <<
" "
799 for (
auto const&
mod:
p.moduleInPathSummaries) {
801 << std::setprecision(6) << std::fixed
802 << std::right << std::setw(10) <<
mod.cpuTime/totalEvents <<
" "
803 << std::right << std::setw(10) <<
mod.realTime/totalEvents <<
" "
804 << std::right << std::setw(10) <<
mod.cpuTime/
std::max(1,
mod.timesVisited) <<
" "
805 << std::right << std::setw(10) <<
mod.realTime/
std::max(1,
mod.timesVisited) <<
" "
806 <<
mod.moduleLabel <<
"";
810 << std::right << std::setw(10) <<
"CPU" <<
" "
811 << std::right << std::setw(10) <<
"Real" <<
" "
812 << std::right << std::setw(10) <<
"CPU" <<
" "
813 << std::right << std::setw(10) <<
"Real" <<
" "
816 << std::right << std::setw(22) <<
"per event "
817 << std::right << std::setw(22) <<
"per module-visit "
822 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"------ Modules in End-Path: " <<
p.name <<
" ---[sec]----";
824 << std::right << std::setw(22) <<
"per event "
825 << std::right << std::setw(22) <<
"per module-visit "
828 << std::right << std::setw(10) <<
"CPU" <<
" "
829 << std::right << std::setw(10) <<
"Real" <<
" "
830 << std::right << std::setw(10) <<
"CPU" <<
" "
831 << std::right << std::setw(10) <<
"Real" <<
" "
833 for (
auto const&
mod:
p.moduleInPathSummaries) {
835 << std::setprecision(6) << std::fixed
836 << std::right << std::setw(10) <<
mod.cpuTime/totalEvents <<
" "
837 << std::right << std::setw(10) <<
mod.realTime/totalEvents <<
" "
838 << std::right << std::setw(10) <<
mod.cpuTime/
std::max(1,
mod.timesVisited) <<
" "
839 << std::right << std::setw(10) <<
mod.realTime/
std::max(1,
mod.timesVisited) <<
" "
840 <<
mod.moduleLabel <<
"";
844 << std::right << std::setw(10) <<
"CPU" <<
" "
845 << std::right << std::setw(10) <<
"Real" <<
" "
846 << std::right << std::setw(10) <<
"CPU" <<
" "
847 << std::right << std::setw(10) <<
"Real" <<
" "
850 << std::right << std::setw(22) <<
"per event "
851 << std::right << std::setw(22) <<
"per module-visit "
855 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Module Summary ---[sec]----";
857 << std::right << std::setw(22) <<
"per event "
858 << std::right << std::setw(22) <<
"per module-run "
859 << std::right << std::setw(22) <<
"per module-visit "
862 << std::right << std::setw(10) <<
"CPU" <<
" "
863 << std::right << std::setw(10) <<
"Real" <<
" "
864 << std::right << std::setw(10) <<
"CPU" <<
" "
865 << std::right << std::setw(10) <<
"Real" <<
" "
866 << std::right << std::setw(10) <<
"CPU" <<
" "
867 << std::right << std::setw(10) <<
"Real" <<
" "
871 << std::setprecision(6) << std::fixed
872 << std::right << std::setw(10) << worker.cpuTime/totalEvents <<
" "
873 << std::right << std::setw(10) << worker.realTime/totalEvents <<
" "
874 << std::right << std::setw(10) << worker.cpuTime/
std::max(1, worker.timesRun) <<
" "
875 << std::right << std::setw(10) << worker.realTime/
std::max(1, worker.timesRun) <<
" "
876 << std::right << std::setw(10) << worker.cpuTime/
std::max(1, worker.timesVisited) <<
" "
877 << std::right << std::setw(10) << worker.realTime/
std::max(1, worker.timesVisited) <<
" "
878 << worker.moduleLabel <<
"";
881 << std::right << std::setw(10) <<
"CPU" <<
" "
882 << std::right << std::setw(10) <<
"Real" <<
" "
883 << std::right << std::setw(10) <<
"CPU" <<
" "
884 << std::right << std::setw(10) <<
"Real" <<
" "
885 << std::right << std::setw(10) <<
"CPU" <<
" "
886 << std::right << std::setw(10) <<
"Real" <<
" "
889 << std::right << std::setw(22) <<
"per event "
890 << std::right << std::setw(22) <<
"per module-run "
891 << std::right << std::setw(22) <<
"per module-visit "
895 LogVerbatim(
"FwkSummary") <<
"T---Report end!" <<
"";
900 using std::placeholders::_1;
905 using std::placeholders::_1;
910 using std::placeholders::_1;
915 using std::placeholders::_1;
920 using std::placeholders::_1;
925 using std::placeholders::_1;
933 using std::placeholders::_1;
938 using std::placeholders::_1;
959 using std::placeholders::_1;
963 using std::placeholders::_1;
972 if (worker->description().moduleLabel() == iLabel) {
977 if (
nullptr == found) {
986 s->replaceModule(newMod,iLabel);
1002 std::vector<ModuleDescription const*>
1004 std::vector<ModuleDescription const*>
result;
1009 result.push_back(p);
1026 std::vector<std::string>& oLabelsToFill)
const {
1034 s->enableEndPaths(active);
1049 s->getTriggerReport(rep);
1063 int returnValue = 0;
1065 returnValue += s->totalEvents();
1072 int returnValue = 0;
1074 returnValue += s->totalEventsPassed();
1081 int returnValue = 0;
1083 returnValue += s->totalEventsFailed();
1138 typedef std::pair<unsigned int, unsigned int> SimpleEdge;
1139 typedef std::map<SimpleEdge, std::vector<unsigned int>> EdgeToPathMap;
1141 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS> Graph;
1143 typedef boost::graph_traits<Graph>::edge_descriptor Edge;
1144 struct cycle_detector :
public boost::dfs_visitor<> {
1146 cycle_detector(EdgeToPathMap
const& iEdgeToPathMap,
1147 std::vector<std::string>
const& iPathNames,
1148 std::map<std::string,unsigned int>
const& iModuleNamesToIndex):
1149 m_edgeToPathMap(iEdgeToPathMap),
1150 m_pathNames(iPathNames),
1151 m_namesToIndex(iModuleNamesToIndex){}
1153 void tree_edge(Edge iEdge, Graph
const&) {
1154 m_stack.push_back(iEdge);
1157 void finish_edge(Edge iEdge, Graph
const& iGraph) {
1158 if(not m_stack.empty()) {
1159 if (iEdge == m_stack.back()) {
1166 void back_edge(Edge iEdge, Graph
const& iGraph) {
1171 IndexMap
const&
index =
get(boost::vertex_index, iGraph);
1173 unsigned int vertex = index[
target(iEdge,iGraph)];
1176 std::list<Edge>::iterator itFirst = m_stack.begin();
1178 bool seenVertex =
false;
1179 while(itFirst != m_stack.end()) {
1180 if(not seenVertex) {
1181 if(index[
source(*itFirst,iGraph)] == vertex) {
1185 if (index[
source(*itFirst,iGraph)] != vertex) {
1190 if(itFirst != m_stack.begin()) {
1197 std::vector<Edge> tempStack;
1198 tempStack.reserve(m_stack.size()+1);
1199 tempStack.insert(tempStack.end(),itFirst,m_stack.end());
1200 tempStack.emplace_back(iEdge);
1202 unsigned int nPathDependencyOnly =0;
1203 for(
auto const&
edge: tempStack) {
1207 auto iFound = m_edgeToPathMap.find(SimpleEdge(in,out));
1208 bool pathDependencyOnly =
true;
1209 for(
auto dependency : iFound->second) {
1211 pathDependencyOnly =
false;
1215 if (pathDependencyOnly) {
1216 ++nPathDependencyOnly;
1219 if(nPathDependencyOnly < 2) {
1220 reportError(tempStack,index,iGraph);
1225 return m_pathNames[iIndex];
1229 for(
auto const& item : m_namesToIndex) {
1230 if(item.second == iIndex) {
1238 reportError(std::vector<Edge>
const& iEdges,
1240 Graph
const& iGraph)
const {
1241 std::stringstream oStream;
1242 oStream <<
"Module run order problem found: \n";
1243 bool first_edge =
true;
1244 for(
auto const&
edge: iEdges) {
1245 unsigned int in =iIndex[
source(
edge,iGraph)];
1246 unsigned int out =iIndex[
target(
edge,iGraph)];
1255 auto iFound = m_edgeToPathMap.find(SimpleEdge(in,out));
1256 bool pathDependencyOnly =
true;
1257 for(
auto dependency : iFound->second) {
1259 pathDependencyOnly =
false;
1263 if (pathDependencyOnly) {
1269 oStream<<
"\n Running in the threaded framework would lead to indeterminate results."
1270 "\n Please change order of modules in mentioned Path(s) to avoid inconsistent module ordering.";
1272 LogError(
"UnrunnableSchedule")<<oStream.str();
1275 EdgeToPathMap
const& m_edgeToPathMap;
1276 std::vector<std::string>
const& m_pathNames;
1277 std::map<std::string,unsigned int> m_namesToIndex;
1279 std::list<Edge> m_stack;
1287 std::map<std::string,unsigned int> moduleNamesToIndex;
1289 moduleNamesToIndex.insert( std::make_pair(worker->description().moduleLabel(),
1290 worker->description().id()));
1294 EdgeToPathMap edgeToPathMap;
1297 std::vector<std::string> pathNames;
1301 std::vector<std::string> moduleNames;
1302 std::vector<std::string> reducedModuleNames;
1303 unsigned int pathIndex=0;
1304 for(
auto const&
path: pathNames) {
1305 moduleNames.clear();
1306 reducedModuleNames.clear();
1307 std::set<std::string> alreadySeenNames;
1311 unsigned int lastModuleIndex;
1312 for(
auto const&
name: moduleNames) {
1313 auto found = alreadySeenNames.insert(
name);
1316 unsigned int moduleIndex = moduleNamesToIndex[
name];
1317 if(not lastModuleName.empty() ) {
1318 edgeToPathMap[std::make_pair(moduleIndex,lastModuleIndex)].push_back(pathIndex);
1320 lastModuleName =
name;
1321 lastModuleIndex = moduleIndex;
1328 std::vector<const char*> dependentModules;
1331 dependentModules.clear();
1333 worker->modulesDependentUpon(dependentModules);
1334 auto found = moduleNamesToIndex.find(worker->description().moduleLabel());
1335 if (
found == moduleNamesToIndex.end()) {
1339 unsigned int moduleIndex =
found->second;
1340 for(
auto name: dependentModules) {
1346 std::vector<SimpleEdge> outList;
1347 outList.reserve(edgeToPathMap.size());
1348 for(
auto const& edgeInfo: edgeToPathMap) {
1349 outList.push_back(edgeInfo.first);
1352 Graph
g(outList.begin(),outList.end(), moduleNamesToIndex.size());
1354 cycle_detector detector(edgeToPathMap,pathNames,moduleNamesToIndex);
1355 boost::depth_first_search(
g,boost::visitor(detector));
std::vector< PathSummary > endPathSummaries
T getUntrackedParameter(std::string const &, T const &) const
std::vector< PathTimingSummary > endPathSummaries
void checkForCorrectness() const
Check that the schedule is actually runable.
void stopEvent(StreamContext const &)
std::vector< BranchIDList > BranchIDLists
virtual void openFile(FileBlock const &fb)=0
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
void availablePaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all paths in the process
static std::string const source("source")
virtual void writeRun(RunPrincipal const &rp, ProcessContext const *)=0
preallocConfig_(prealloc)
void restartModuleEvent(StreamContext const &, ModuleCallingContext const &)
bool endPathsEnabled() const
all_output_communicators_()
void respondToCloseInputFile(FileBlock const &fb)
void startModuleEvent(StreamContext const &, ModuleCallingContext const &)
std::vector< Worker * > AllWorkers
std::vector< ParameterSet > VParameterSet
void writeRun(RunPrincipal const &rp, ProcessContext const *)
void endStream(unsigned int)
void writeLumi(LuminosityBlockPrincipal const &lbp, ProcessContext const *)
void enableEndPaths(bool active)
std::shared_ptr< ProductHolderIndexHelper > const & productLookup(BranchType branchType) const
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
std::shared_ptr< ModuleRegistry > moduleRegistry_
std::vector< WorkerSummary > workerSummaries
void startEvent(StreamID)
static unsigned int getUniqueID()
Returns a unique id each time called. Intended to be passed to ModuleDescription's constructor's modI...
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
int totalEventsFailed() const
bool changeModule(std::string const &iLabel, ParameterSet const &iPSet, const ProductRegistry &iRegistry)
void eraseOrSetUntrackedParameterSet(std::string const &name)
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
int totalEventsPassed() const
std::string moduleName(Provenance const &provenance)
virtual void updateLookup(BranchType iBranchType, ProductHolderIndexHelper const &)=0
tuple path
else: Piece not in the list, fine.
std::vector< PathSummary > trigPathSummaries
EventSummary eventSummary
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists)
wantSummary_(tns.wantSummary())
virtual void openNewFileIfNeeded()=0
EventTimingSummary eventSummary
Schedule(ParameterSet &proc_pset, service::TriggerNamesService &tns, ProductRegistry &pregistry, BranchIDListHelper &branchIDListHelper, ThinnedAssociationsHelper &thinnedAssociationsHelper, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ProcessConfiguration > processConfiguration, const ParameterSet *subProcPSet, PreallocationConfiguration const &config, ProcessContext const *processContext)
void clearCounters()
Clear all the counters in the trigger report.
std::vector< PathTimingSummary > trigPathSummaries
std::vector< std::shared_ptr< StreamSchedule > > streamSchedules_
void setProcessParameterSetID(ParameterSetID const &id)
Associated free functions.
bool terminate() const
Return whether each output module has reached its maximum count.
void respondToOpenInputFile(FileBlock const &fb)
virtual void writeLumi(LuminosityBlockPrincipal const &lbp, ProcessContext const *)=0
void stopPath(StreamContext const &, PathContext const &, HLTPathStatus const &)
void stopModuleEvent(StreamContext const &, ModuleCallingContext const &)
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
void getTriggerReport(TriggerReport &rep) const
virtual bool shouldWeCloseFile() const =0
PreallocationConfiguration preallocConfig_
moduleRegistry_(new ModuleRegistry())
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
volatile bool endpathsAreActive_
void respondToOpenInputFile(FileBlock const &fb)
void startPath(StreamContext const &, PathContext const &)
bool search_all(ForwardSequence const &s, Datum const &d)
std::unique_ptr< SystemTimeKeeper > summaryTimeKeeper_
virtual std::unique_ptr< OutputModuleCommunicator > createOutputModuleCommunicator()=0
AllOutputModuleCommunicators all_output_communicators_
void loadMissingDictionaries()
void modulesInPath(std::string const &iPathLabel, std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill in execution order the labels of all modules in path iPathLabel ...
void pauseModuleEvent(StreamContext const &, ModuleCallingContext const &)
void beginStream(unsigned int)
void respondToCloseInputFile(FileBlock const &fb)
void preForkReleaseResources()
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Strings const & getTrigPaths() const
std::unique_ptr< GlobalSchedule > globalSchedule_
void beginJob(ProductRegistry const &)
virtual void closeFile()=0
void openNewOutputFilesIfNeeded()
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const
void preForkReleaseResources()
void openOutputFiles(FileBlock &fb)
std::vector< WorkerTimingSummary > workerSummaries
T mod(const T &a, const T &b)
void endJob(ExceptionCollector &collector)
void getTriggerTimingReport(TriggerTimingReport &rep) const
bool shouldWeCloseOutput() const
std::vector< std::string > vstring
tuple size
Write out results.
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)