25 #include "boost/bind.hpp"
26 #include "boost/ref.hpp"
28 #include "boost/graph/graph_traits.hpp"
29 #include "boost/graph/adjacency_list.hpp"
30 #include "boost/graph/depth_first_search.hpp"
31 #include "boost/graph/visitors.hpp"
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 boost::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(
new TriggerResultInserter(*trig_pset, iPrealloc.numberOfStreams()),static_cast<Maker const*>(
nullptr));
76 holder.setModuleDescription(md);
77 holder.registerProductsAndCallbacks(&preg);
78 returnValue.reset(holder.release());
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()) {
134 if(iter->second !=
key) {
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(), boost::bind(binary_search_string, boost::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(), boost::bind(binary_search_string, boost::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(), boost::bind(binary_search_string, boost::ref(endPathsToBeDropped), _1));
347 scheduledEndPaths.erase(endAfterRemove, scheduledEndPaths.end());
348 proc_pset.addParameter<vstring>(
std::string(
"@end_paths"), scheduledEndPaths);
363 boost::shared_ptr<ActivityRegistry> areg,
364 boost::shared_ptr<ProcessConfiguration> processConfiguration,
369 resultsInserter_{tns.
getTrigPaths().empty()? std::shared_ptr<TriggerResultInserter>{} :makeInserter(proc_pset,prealloc,preg,actions,areg,processConfiguration)},
376 assert(0<
prealloc.numberOfStreams());
377 streamSchedules_.reserve(
prealloc.numberOfStreams());
378 for(
unsigned int i=0;
i<
prealloc.numberOfStreams();++
i) {
379 streamSchedules_.emplace_back(std::shared_ptr<StreamSchedule>{
new StreamSchedule{resultsInserter_.get(),
moduleRegistry_,proc_pset,tns,
prealloc,
preg,branchIDListHelper,
actions,
areg,
processConfiguration,
nullptr==subProcPSet,
StreamID{
i},processContext}});
384 const std::string kTriggerResults(
"TriggerResults");
385 std::vector<std::string> modulesToUse;
386 modulesToUse.reserve(streamSchedules_[0]->allWorkers().
size());
387 for(
auto const& worker : streamSchedules_[0]->allWorkers()) {
388 if(worker->description().moduleLabel() != kTriggerResults) {
389 modulesToUse.push_back(worker->description().moduleLabel());
393 unsigned int n = streamSchedules_[0]->numberOfUnscheduledModules();
395 std::vector<std::string>
temp;
396 temp.reserve(modulesToUse.size());
397 auto itBeginUnscheduled = modulesToUse.begin()+modulesToUse.size()-
n;
398 std::copy(itBeginUnscheduled,modulesToUse.end(),
399 std::back_inserter(temp));
400 std::copy(modulesToUse.begin(),itBeginUnscheduled,std::back_inserter(temp));
401 temp.swap(modulesToUse);
403 globalSchedule_.reset(
new GlobalSchedule{ resultsInserter_.get(),
411 std::set<std::string> usedModuleLabels;
412 for(
auto const worker: allWorkers()) {
413 if(worker->description().moduleLabel() != kTriggerResults) {
414 usedModuleLabels.insert(worker->description().moduleLabel());
417 std::vector<std::string> modulesInConfig(proc_pset.getParameter<std::vector<std::string> >(
"@all_modules"));
418 std::map<std::string, std::vector<std::pair<std::string, int> > > outputModulePathPositions;
419 reduceParameterSet(proc_pset, tns.getEndPaths(), modulesInConfig, usedModuleLabels,
420 outputModulePathPositions);
421 processEDAliases(proc_pset, processConfiguration->processName(),
preg);
422 proc_pset.registerIt();
424 processConfiguration->setParameterSetID(proc_pset.id());
425 processConfiguration->setProcessConfigurationID();
429 size_t all_workers_count = allWorkers().size();
438 limitOutput(proc_pset, branchIDListHelper.branchIDLists());
444 assert (all_workers_count == allWorkers().
size());
446 branchIDListHelper.updateFromRegistry(preg);
451 c->setEventSelectionInfo(outputModulePathPositions, preg.anyProductProduced());
452 c->selectProducts(preg);
463 int maxEventSpecs = 0;
464 int maxEventsOut = -1;
471 std::vector<std::string> psetNamesE;
478 if (maxEventSpecs > 1) {
480 "\nAt most, one form of 'output' may appear in the 'maxEvents' parameter set";
485 if (vMaxEventsOut != 0 && !vMaxEventsOut->
empty()) {
486 std::string const& moduleLabel =
c->description().moduleLabel();
491 "\nNo entry in 'maxEvents' for output module label '" << moduleLabel <<
"'.\n";
503 if (!
c->limitReached()) {
508 LogInfo(
"SuccessfulTermination")
509 <<
"The job is terminating successfully because each output module\n"
510 <<
"has reached its configured limit.\n";
528 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Event Summary ------------";
543 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Path Summary ------------";
545 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
546 << std::right << std::setw(10) <<
"Run" <<
" "
547 << std::right << std::setw(10) <<
"Passed" <<
" "
548 << std::right << std::setw(10) <<
"Failed" <<
" "
549 << std::right << std::setw(10) <<
"Error" <<
" "
553 << std::right << std::setw(5) << 1
554 << std::right << std::setw(5) <<
p.bitPosition <<
" "
555 << std::right << std::setw(10) <<
p.timesRun <<
" "
556 << std::right << std::setw(10) <<
p.timesPassed <<
" "
557 << std::right << std::setw(10) <<
p.timesFailed <<
" "
558 << std::right << std::setw(10) <<
p.timesExcept <<
" "
580 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"-------End-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) << 0
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 <<
" "
601 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Modules in Path: " <<
p.name <<
" ------------";
603 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
604 << std::right << std::setw(10) <<
"Visited" <<
" "
605 << std::right << std::setw(10) <<
"Passed" <<
" "
606 << std::right << std::setw(10) <<
"Failed" <<
" "
607 << std::right << std::setw(10) <<
"Error" <<
" "
610 unsigned int bitpos = 0;
611 for (
auto const&
mod:
p.moduleInPathSummaries) {
613 << std::right << std::setw(5) << 1
614 << std::right << std::setw(5) << bitpos <<
" "
615 << std::right << std::setw(10) <<
mod.timesVisited <<
" "
616 << std::right << std::setw(10) <<
mod.timesPassed <<
" "
617 << std::right << std::setw(10) <<
mod.timesFailed <<
" "
618 << std::right << std::setw(10) <<
mod.timesExcept <<
" "
619 <<
mod.moduleLabel <<
"";
626 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"------ Modules in End-Path: " <<
p.name <<
" ------------";
628 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
629 << std::right << std::setw(10) <<
"Visited" <<
" "
630 << std::right << std::setw(10) <<
"Passed" <<
" "
631 << std::right << std::setw(10) <<
"Failed" <<
" "
632 << std::right << std::setw(10) <<
"Error" <<
" "
635 unsigned int bitpos=0;
636 for (
auto const&
mod:
p.moduleInPathSummaries) {
638 << std::right << std::setw(5) << 0
639 << std::right << std::setw(5) << bitpos <<
" "
640 << std::right << std::setw(10) <<
mod.timesVisited <<
" "
641 << std::right << std::setw(10) <<
mod.timesPassed <<
" "
642 << std::right << std::setw(10) <<
mod.timesFailed <<
" "
643 << std::right << std::setw(10) <<
mod.timesExcept <<
" "
644 <<
mod.moduleLabel <<
"";
650 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Module Summary ------------";
652 << std::right << std::setw(10) <<
"Visited" <<
" "
653 << std::right << std::setw(10) <<
"Run" <<
" "
654 << std::right << std::setw(10) <<
"Passed" <<
" "
655 << std::right << std::setw(10) <<
"Failed" <<
" "
656 << std::right << std::setw(10) <<
"Error" <<
" "
660 << std::right << std::setw(10) << worker.timesVisited <<
" "
661 << std::right << std::setw(10) << worker.timesRun <<
" "
662 << std::right << std::setw(10) << worker.timesPassed <<
" "
663 << std::right << std::setw(10) << worker.timesFailed <<
" "
664 << std::right << std::setw(10) << worker.timesExcept <<
" "
665 << worker.moduleLabel <<
"";
675 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Event Summary ---[sec]----";
677 << std::setprecision(6) << std::fixed
683 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Path Summary ---[sec]----";
685 << std::right << std::setw(22) <<
"per event "
686 << std::right << std::setw(22) <<
"per path-run "
689 << std::right << std::setw(10) <<
"CPU" <<
" "
690 << std::right << std::setw(10) <<
"Real" <<
" "
691 << std::right << std::setw(10) <<
"CPU" <<
" "
692 << std::right << std::setw(10) <<
"Real" <<
" "
695 const int timesRun =
std::max(1,
p.timesRun);
697 << std::setprecision(6) << std::fixed
698 << std::right << std::setw(10) <<
p.cpuTime/totalEvents <<
" "
699 << std::right << std::setw(10) <<
p.realTime/totalEvents <<
" "
700 << std::right << std::setw(10) <<
p.cpuTime/timesRun <<
" "
701 << std::right << std::setw(10) <<
p.realTime/timesRun <<
" "
705 << std::right << std::setw(10) <<
"CPU" <<
" "
706 << std::right << std::setw(10) <<
"Real" <<
" "
707 << std::right << std::setw(10) <<
"CPU" <<
" "
708 << std::right << std::setw(10) <<
"Real" <<
" "
711 << std::right << std::setw(22) <<
"per event "
712 << std::right << std::setw(22) <<
"per path-run "
716 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"-------End-Path Summary ---[sec]----";
718 << std::right << std::setw(22) <<
"per event "
719 << std::right << std::setw(22) <<
"per endpath-run "
722 << std::right << std::setw(10) <<
"CPU" <<
" "
723 << std::right << std::setw(10) <<
"Real" <<
" "
724 << std::right << std::setw(10) <<
"CPU" <<
" "
725 << std::right << std::setw(10) <<
"Real" <<
" "
728 const int timesRun =
std::max(1,
p.timesRun);
731 << std::setprecision(6) << std::fixed
732 << std::right << std::setw(10) <<
p.cpuTime/totalEvents <<
" "
733 << std::right << std::setw(10) <<
p.realTime/totalEvents <<
" "
734 << std::right << std::setw(10) <<
p.cpuTime/timesRun <<
" "
735 << std::right << std::setw(10) <<
p.realTime/timesRun <<
" "
739 << std::right << std::setw(10) <<
"CPU" <<
" "
740 << std::right << std::setw(10) <<
"Real" <<
" "
741 << std::right << std::setw(10) <<
"CPU" <<
" "
742 << std::right << std::setw(10) <<
"Real" <<
" "
745 << std::right << std::setw(22) <<
"per event "
746 << std::right << std::setw(22) <<
"per endpath-run "
751 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Modules in Path: " <<
p.name <<
" ---[sec]----";
753 << std::right << std::setw(22) <<
"per event "
754 << std::right << std::setw(22) <<
"per module-visit "
757 << std::right << std::setw(10) <<
"CPU" <<
" "
758 << std::right << std::setw(10) <<
"Real" <<
" "
759 << std::right << std::setw(10) <<
"CPU" <<
" "
760 << std::right << std::setw(10) <<
"Real" <<
" "
762 for (
auto const&
mod:
p.moduleInPathSummaries) {
764 << std::setprecision(6) << std::fixed
765 << std::right << std::setw(10) <<
mod.cpuTime/totalEvents <<
" "
766 << std::right << std::setw(10) <<
mod.realTime/totalEvents <<
" "
767 << std::right << std::setw(10) <<
mod.cpuTime/
std::max(1,
mod.timesVisited) <<
" "
768 << std::right << std::setw(10) <<
mod.realTime/
std::max(1,
mod.timesVisited) <<
" "
769 <<
mod.moduleLabel <<
"";
773 << std::right << std::setw(10) <<
"CPU" <<
" "
774 << std::right << std::setw(10) <<
"Real" <<
" "
775 << std::right << std::setw(10) <<
"CPU" <<
" "
776 << std::right << std::setw(10) <<
"Real" <<
" "
779 << std::right << std::setw(22) <<
"per event "
780 << std::right << std::setw(22) <<
"per module-visit "
785 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"------ Modules in End-Path: " <<
p.name <<
" ---[sec]----";
787 << std::right << std::setw(22) <<
"per event "
788 << std::right << std::setw(22) <<
"per module-visit "
791 << std::right << std::setw(10) <<
"CPU" <<
" "
792 << std::right << std::setw(10) <<
"Real" <<
" "
793 << std::right << std::setw(10) <<
"CPU" <<
" "
794 << std::right << std::setw(10) <<
"Real" <<
" "
796 for (
auto const&
mod:
p.moduleInPathSummaries) {
798 << std::setprecision(6) << std::fixed
799 << std::right << std::setw(10) <<
mod.cpuTime/totalEvents <<
" "
800 << std::right << std::setw(10) <<
mod.realTime/totalEvents <<
" "
801 << std::right << std::setw(10) <<
mod.cpuTime/
std::max(1,
mod.timesVisited) <<
" "
802 << std::right << std::setw(10) <<
mod.realTime/
std::max(1,
mod.timesVisited) <<
" "
803 <<
mod.moduleLabel <<
"";
807 << std::right << std::setw(10) <<
"CPU" <<
" "
808 << std::right << std::setw(10) <<
"Real" <<
" "
809 << std::right << std::setw(10) <<
"CPU" <<
" "
810 << std::right << std::setw(10) <<
"Real" <<
" "
813 << std::right << std::setw(22) <<
"per event "
814 << std::right << std::setw(22) <<
"per module-visit "
818 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Module Summary ---[sec]----";
820 << std::right << std::setw(22) <<
"per event "
821 << std::right << std::setw(22) <<
"per module-run "
822 << std::right << std::setw(22) <<
"per module-visit "
825 << std::right << std::setw(10) <<
"CPU" <<
" "
826 << std::right << std::setw(10) <<
"Real" <<
" "
827 << std::right << std::setw(10) <<
"CPU" <<
" "
828 << std::right << std::setw(10) <<
"Real" <<
" "
829 << std::right << std::setw(10) <<
"CPU" <<
" "
830 << std::right << std::setw(10) <<
"Real" <<
" "
834 << std::setprecision(6) << std::fixed
835 << std::right << std::setw(10) << worker.cpuTime/totalEvents <<
" "
836 << std::right << std::setw(10) << worker.realTime/totalEvents <<
" "
837 << std::right << std::setw(10) << worker.cpuTime/
std::max(1, worker.timesRun) <<
" "
838 << std::right << std::setw(10) << worker.realTime/
std::max(1, worker.timesRun) <<
" "
839 << std::right << std::setw(10) << worker.cpuTime/
std::max(1, worker.timesVisited) <<
" "
840 << std::right << std::setw(10) << worker.realTime/
std::max(1, worker.timesVisited) <<
" "
841 << worker.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" <<
" "
848 << std::right << std::setw(10) <<
"CPU" <<
" "
849 << std::right << std::setw(10) <<
"Real" <<
" "
852 << std::right << std::setw(22) <<
"per event "
853 << std::right << std::setw(22) <<
"per module-run "
854 << std::right << std::setw(22) <<
"per module-visit "
858 LogVerbatim(
"FwkSummary") <<
"T---Report end!" <<
"";
924 if (worker->description().moduleLabel() == iLabel) {
929 if (
nullptr == found) {
938 s->replaceModule(newMod,iLabel);
943 std::vector<ModuleDescription const*>
945 std::vector<ModuleDescription const*>
result;
967 std::vector<std::string>& oLabelsToFill)
const {
975 s->enableEndPaths(active);
990 s->getTriggerReport(rep);
1000 s->getTriggerTimingReport(rep);
1006 int returnValue = 0;
1008 returnValue += s->totalEvents();
1015 int returnValue = 0;
1017 returnValue += s->totalEventsPassed();
1024 int returnValue = 0;
1026 returnValue += s->totalEventsFailed();
1081 typedef std::pair<unsigned int, unsigned int> SimpleEdge;
1082 typedef std::map<SimpleEdge, std::vector<unsigned int>> EdgeToPathMap;
1084 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS> Graph;
1086 typedef boost::graph_traits<Graph>::edge_descriptor Edge;
1087 struct cycle_detector :
public boost::dfs_visitor<> {
1089 cycle_detector(EdgeToPathMap
const& iEdgeToPathMap,
1090 std::vector<std::string>
const& iPathNames,
1091 std::map<std::string,unsigned int>
const& iModuleNamesToIndex):
1092 m_edgeToPathMap(iEdgeToPathMap),
1093 m_pathNames(iPathNames),
1094 m_namesToIndex(iModuleNamesToIndex){}
1096 void tree_edge(Edge iEdge, Graph
const&) {
1097 m_stack.push_back(iEdge);
1100 void finish_edge(Edge iEdge, Graph
const& iGraph) {
1101 if(not m_stack.empty()) {
1102 if (iEdge == m_stack.back()) {
1109 void back_edge(Edge iEdge, Graph
const& iGraph) {
1114 IndexMap
const&
index =
get(boost::vertex_index, iGraph);
1116 unsigned int vertex = index[
target(iEdge,iGraph)];
1119 std::list<Edge>::iterator itFirst = m_stack.begin();
1121 bool seenVertex =
false;
1122 while(itFirst != m_stack.end()) {
1123 if(not seenVertex) {
1124 if(index[
source(*itFirst,iGraph)] == vertex) {
1128 if (index[
source(*itFirst,iGraph)] != vertex) {
1133 if(itFirst != m_stack.begin()) {
1140 std::vector<Edge> tempStack;
1141 tempStack.reserve(m_stack.size()+1);
1142 tempStack.insert(tempStack.end(),itFirst,m_stack.end());
1143 tempStack.emplace_back(iEdge);
1145 unsigned int nPathDependencyOnly =0;
1146 for(
auto const&
edge: tempStack) {
1150 auto iFound = m_edgeToPathMap.find(SimpleEdge(in,out));
1151 bool pathDependencyOnly =
true;
1152 for(
auto dependency : iFound->second) {
1154 pathDependencyOnly =
false;
1158 if (pathDependencyOnly) {
1159 ++nPathDependencyOnly;
1162 if(nPathDependencyOnly < 2) {
1163 reportError(tempStack,index,iGraph);
1168 return m_pathNames[iIndex];
1172 for(
auto const& item : m_namesToIndex) {
1173 if(item.second == iIndex) {
1181 reportError(std::vector<Edge>
const& iEdges,
1183 Graph
const& iGraph)
const {
1184 std::stringstream oStream;
1185 oStream <<
"Module run order problem found: \n";
1186 bool first_edge =
true;
1187 for(
auto const&
edge: iEdges) {
1188 unsigned int in =iIndex[
source(
edge,iGraph)];
1189 unsigned int out =iIndex[
target(
edge,iGraph)];
1198 auto iFound = m_edgeToPathMap.find(SimpleEdge(in,out));
1199 bool pathDependencyOnly =
true;
1200 for(
auto dependency : iFound->second) {
1202 pathDependencyOnly =
false;
1206 if (pathDependencyOnly) {
1212 oStream<<
"\n Running in the threaded framework would lead to indeterminate results."
1213 "\n Please change order of modules in mentioned Path(s) to avoid inconsistent module ordering.";
1215 LogError(
"UnrunnableSchedule")<<oStream.str();
1218 EdgeToPathMap
const& m_edgeToPathMap;
1219 std::vector<std::string>
const& m_pathNames;
1220 std::map<std::string,unsigned int> m_namesToIndex;
1222 std::list<Edge> m_stack;
1230 std::map<std::string,unsigned int> moduleNamesToIndex;
1232 moduleNamesToIndex.insert( std::make_pair(worker->description().moduleLabel(),
1233 worker->description().id()));
1237 EdgeToPathMap edgeToPathMap;
1240 std::vector<std::string> pathNames;
1244 std::vector<std::string> moduleNames;
1245 std::vector<std::string> reducedModuleNames;
1246 unsigned int pathIndex=0;
1247 for(
auto const&
path: pathNames) {
1248 moduleNames.clear();
1249 reducedModuleNames.clear();
1250 std::set<std::string> alreadySeenNames;
1254 unsigned int lastModuleIndex;
1255 for(
auto const&
name: moduleNames) {
1256 auto found = alreadySeenNames.insert(
name);
1259 unsigned int moduleIndex = moduleNamesToIndex[
name];
1260 if(not lastModuleName.empty() ) {
1261 edgeToPathMap[std::make_pair(moduleIndex,lastModuleIndex)].push_back(pathIndex);
1263 lastModuleName =
name;
1264 lastModuleIndex = moduleIndex;
1271 std::vector<const char*> dependentModules;
1274 dependentModules.clear();
1276 worker->modulesDependentUpon(dependentModules);
1277 auto found = moduleNamesToIndex.find(worker->description().moduleLabel());
1278 if (
found == moduleNamesToIndex.end()) {
1282 unsigned int moduleIndex =
found->second;
1283 for(
auto name: dependentModules) {
1289 std::vector<SimpleEdge> outList;
1290 outList.reserve(edgeToPathMap.size());
1291 for(
auto const& edgeInfo: edgeToPathMap) {
1292 outList.push_back(edgeInfo.first);
1295 Graph
g(outList.begin(),outList.end(), moduleNamesToIndex.size());
1297 cycle_detector detector(edgeToPathMap,pathNames,moduleNamesToIndex);
1298 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.
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)
bool endPathsEnabled() const
all_output_communicators_()
void respondToCloseInputFile(FileBlock const &fb)
bool changeModule(std::string const &iLabel, ParameterSet const &iPSet)
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)
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
std::vector< WorkerSummary > workerSummaries
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
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)
std::vector< PathSummary > trigPathSummaries
EventSummary eventSummary
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists)
const T & max(const T &a, const T &b)
wantSummary_(tns.wantSummary())
virtual void openNewFileIfNeeded()=0
EventTimingSummary eventSummary
void clearCounters()
Clear all the counters in the trigger report.
boost::shared_ptr< ModuleRegistry > moduleRegistry_
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 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)
bool search_all(ForwardSequence const &s, Datum const &d)
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 ...
Schedule(ParameterSet &proc_pset, service::TriggerNamesService &tns, ProductRegistry &pregistry, BranchIDListHelper &branchIDListHelper, ExceptionToActionTable const &actions, boost::shared_ptr< ActivityRegistry > areg, boost::shared_ptr< ProcessConfiguration > processConfiguration, const ParameterSet *subProcPSet, PreallocationConfiguration const &config, ProcessContext const *processContext)
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)