LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::PathManager Class Reference

#include "PathManager.h"

Classes

struct  ModulesByThreadingType
 

Public Member Functions

 PathManager (fhicl::ParameterSet const &procPS, UpdateOutputCallbacks &preg, ProductDescriptions &productsToProduce, ActionTable const &exceptActions, ActivityRegistry const &areg, detail::EnabledModules enabled_modules)
 
 PathManager (PathManager const &)=delete
 
 PathManager (PathManager &&)=delete
 
PathManageroperator= (PathManager const &)=delete
 
PathManageroperator= (PathManager &&)=delete
 
std::vector< PathSpectriggerPathSpecs () const
 
void createModulesAndWorkers (GlobalTaskGroup &task_group, detail::SharedResources &resources, std::vector< std::string > const &producing_services)
 
std::unique_ptr< WorkerreleaseTriggerResultsInserter (ScheduleID)
 
PathsInfotriggerPathsInfo (ScheduleID)
 
PerScheduleContainer< PathsInfo > const & triggerPathsInfo ()
 
PathsInfoendPathInfo (ScheduleID)
 
PerScheduleContainer< PathsInfo > const & endPathInfo ()
 

Private Types

using maybe_module_t = std::variant< ModuleBase *, std::string >
 

Private Member Functions

std::map< std::string, detail::ModuleConfigInfomoduleInformation_ (detail::EnabledModules const &enabled_modules) const
 
ModulesByThreadingType makeModules_ (ScheduleID::size_type n)
 
std::unique_ptr< ReplicatedProducermakeTriggerResultsInserter_ (ScheduleID scheduleID)
 
maybe_module_t makeModule_ (fhicl::ParameterSet const &module_pset, ModuleDescription const &md, ScheduleID) const
 
std::vector< WorkerInPathfillWorkers_ (PathContext const &pc, std::vector< WorkerInPath::ConfigInfo > const &wci_list, std::map< std::string, std::shared_ptr< Worker >> &workers, GlobalTaskGroup &task_group, detail::SharedResources &resources)
 
std::shared_ptr< WorkermakeWorker_ (ModuleDescription const &md, WorkerParams const &wp)
 
ModuleType loadModuleType_ (std::string const &lib_spec) const
 
ModuleThreadingType loadModuleThreadingType_ (std::string const &lib_spec) const
 
detail::collection_map_t getModuleGraphInfoCollection_ (std::vector< std::string > const &producing_services)
 
void fillModuleOnlyDeps_ (std::string const &path_name, detail::configs_t const &worker_configs, std::map< std::string, std::set< ProductInfo >> const &produced_products, std::map< std::string, std::set< std::string >> const &viewable_products, detail::collection_map_t &info_collection) const
 
void fillSelectEventsDeps_ (detail::configs_t const &worker_configs, detail::collection_map_t &info_collection) const
 
std::vector< std::string > triggerPathNames_ () const
 
std::vector< std::string > prependedTriggerPathNames_ () const
 

Private Attributes

UpdateOutputCallbacksoutputCallbacks_
 
ActionTable const & exceptActions_
 
ActivityRegistry const & actReg_
 
fhicl::ParameterSet procPS_
 
art::detail::module_entries_for_ordered_path_t triggerPathSpecs_
 
PerScheduleContainer< PathsInfotriggerPathsInfo_
 
PerScheduleContainer< PathsInfoendPathInfo_
 
ProductDescriptionsproductsToProduce_
 
cet::LibraryManager lm_ {Suffixes::module()}
 
std::string processName_ {}
 
std::map< std::string, detail::ModuleConfigInfoallModules_ {}
 
art::detail::paths_to_modules_t protoTrigPathLabels_ {}
 
art::detail::configs_t protoEndPathLabels_ {}
 
ModulesByThreadingType modules_ {}
 
PerScheduleContainer< std::unique_ptr< Worker > > triggerResultsWorkers_
 

Detailed Description

Definition at line 50 of file PathManager.h.

Member Typedef Documentation

using art::PathManager::maybe_module_t = std::variant<ModuleBase*, std::string>
private

Definition at line 91 of file PathManager.h.

Constructor & Destructor Documentation

art::PathManager::PathManager ( fhicl::ParameterSet const &  procPS,
UpdateOutputCallbacks preg,
ProductDescriptions productsToProduce,
ActionTable const &  exceptActions,
ActivityRegistry const &  areg,
detail::EnabledModules  enabled_modules 
)

Definition at line 70 of file PathManager.cc.

References actReg_, allModules_, endPathInfo_, exceptActions_, art::Globals::instance(), moduleInformation_(), art::PathSpec::name, art::detail::Normal, art::Globals::nschedules(), art::path_spec(), prependedTriggerPathNames_(), processName_, procPS_, productsToProduce_, protoEndPathLabels_, protoTrigPathLabels_, fhicl::ParameterSetRegistry::put(), fhicl::ParameterSet::put(), art::Globals::setProcessName(), art::Globals::setTriggerPathNames(), art::Globals::setTriggerPSet(), util::size(), triggerPathNames_(), triggerPathsInfo_, triggerPathSpecs_, and triggerResultsWorkers_.

76  : outputCallbacks_{outputCallbacks}
77  , exceptActions_{exceptActions}
78  , actReg_{actReg}
79  , procPS_{procPS}
80  , triggerPathSpecs_{enabled_modules.trigger_path_specs()}
82  , endPathInfo_(Globals::instance()->nschedules())
83  , productsToProduce_{productsToProduce}
84  , processName_{procPS.get<string>("process_name", {})}
85  , allModules_{moduleInformation_(enabled_modules)}
87  {
88  // Trigger paths
89  auto const& trigger_path_specs = enabled_modules.trigger_path_specs();
90  protoTrigPathLabels_.reserve(trigger_path_specs.size());
91  std::set<std::string> recorded_path_name;
92  for (auto const& [path_spec, entries] : trigger_path_specs) {
93  if (not recorded_path_name.insert(path_spec.name).second)
94  continue;
95 
96  if (entries.empty())
97  continue;
98 
99  detail::configs_t worker_config_infos{};
100  for (auto const& [label, action] : entries) {
101  auto const& mci = allModules_.at(label);
102  auto const mci_p = cet::make_exempt_ptr(&mci);
103  worker_config_infos.emplace_back(mci_p, action);
104  }
105  protoTrigPathLabels_.emplace_back(path_spec,
106  std::move(worker_config_infos));
107  }
108 
109  // Finalize trigger path names and make available in Globals
111 
112  ParameterSet triggerPSet;
113  triggerPSet.put("trigger_paths", prependedTriggerPathNames_());
115  Globals::instance()->setTriggerPSet(triggerPSet);
117 
118  // End path(s)
119  auto const& end_paths = enabled_modules.end_paths();
120  protoEndPathLabels_.reserve(end_paths.size());
121  for (auto const& [path_spec, entries] : end_paths) {
122  if (not recorded_path_name.insert(path_spec.name).second)
123  continue;
124 
125  if (entries.empty())
126  continue;
127 
128  for (auto const& [label, action] : entries) {
129  assert(action == detail::FilterAction::Normal);
130  auto const& mci = allModules_.at(label);
131  auto const mci_p = cet::make_exempt_ptr(&mci);
132  protoEndPathLabels_.emplace_back(mci_p, action);
133  }
134  }
135 
136  if (size(end_paths) > 1u) {
137  mf::LogInfo("PathConfiguration")
138  << "Multiple end paths have been combined into one end path,\n"
139  << "\"end_path\" since order is irrelevant.";
140  }
141  }
ProductDescriptions & productsToProduce_
Definition: PathManager.h:130
void setProcessName(std::string const &)
Definition: Globals.cc:54
static ParameterSetID const & put(ParameterSet const &ps)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< std::string > triggerPathNames_() const
Definition: PathManager.cc:151
PerScheduleContainer< std::unique_ptr< Worker > > triggerResultsWorkers_
Definition: PathManager.h:142
art::detail::paths_to_modules_t protoTrigPathLabels_
Definition: PathManager.h:139
void setTriggerPSet(fhicl::ParameterSet const &)
Definition: Globals.cc:66
std::string processName_
Definition: PathManager.h:137
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
PerScheduleContainer< PathsInfo > triggerPathsInfo_
Definition: PathManager.h:128
std::vector< WorkerInPath::ConfigInfo > configs_t
ScheduleID::size_type nschedules() const
Definition: Globals.cc:24
std::vector< std::string > prependedTriggerPathNames_() const
Definition: PathManager.cc:160
PerScheduleContainer< PathsInfo > endPathInfo_
Definition: PathManager.h:129
std::map< std::string, detail::ModuleConfigInfo > allModules_
Definition: PathManager.h:138
std::string name
Definition: PathSpec.h:48
std::map< std::string, detail::ModuleConfigInfo > moduleInformation_(detail::EnabledModules const &enabled_modules) const
Definition: PathManager.cc:296
UpdateOutputCallbacks & outputCallbacks_
Definition: PathManager.h:123
ActionTable const & exceptActions_
Definition: PathManager.h:124
art::detail::module_entries_for_ordered_path_t triggerPathSpecs_
Definition: PathManager.h:127
void setTriggerPathNames(std::vector< std::string > const &)
Definition: Globals.cc:78
PathSpec path_spec(std::string const &path_spec)
Definition: PathSpec.cc:22
art::detail::configs_t protoEndPathLabels_
Definition: PathManager.h:140
static Globals * instance()
Definition: Globals.cc:17
ActivityRegistry const & actReg_
Definition: PathManager.h:125
fhicl::ParameterSet procPS_
Definition: PathManager.h:126
void put(std::string const &key)
art::PathManager::PathManager ( PathManager const &  )
delete
art::PathManager::PathManager ( PathManager &&  )
delete

Member Function Documentation

void art::PathManager::createModulesAndWorkers ( GlobalTaskGroup task_group,
detail::SharedResources resources,
std::vector< std::string > const &  producing_services 
)

Definition at line 169 of file PathManager.cc.

References actReg_, allModules_, art::errors::Configuration, art::PathContext::end_path_spec(), endPathInfo_, exceptActions_, fillWorkers_(), fhicl::ParameterSet::get(), getModuleGraphInfoCollection_(), art::Globals::instance(), art::detail::make_module_graph(), makeModules_(), makeTriggerResultsInserter_(), modules_, art::GlobalTaskGroup::native_group(), art::Globals::nschedules(), outputCallbacks_, art::path_spec(), art::detail::print_module_graph(), procPS_, productsToProduce_, protoEndPathLabels_, protoTrigPathLabels_, art::PathManager::ModulesByThreadingType::replicated, sc, triggerPathsInfo_, and triggerResultsWorkers_.

173  {
174  // For each configured schedule, create the trigger paths and the
175  // workers on each path.
176  auto const nschedules =
178 
179  // The modules created are managed by shared_ptrs. Once the
180  // workers claim (co-)ownership of the modules, the 'modules'
181  // object can be destroyed.
182  modules_ = makeModules_(nschedules);
183 
184  // FIXME: THE PATHS INFO OBJECTS SHOULD BECOME OWNERS OF THE WORKERS
185  // I IMAGINE AN API LIKE:
186  //
187  // pinfo.fillWorkers(pc, worker_config_infos, task_group, resources);
188  // pinfo.add_path(...);
189  //
190  // PERHAPS WOULD BE BETTER SOMETHING LIKE:
191  //
192  // Paths;
193  // wp.add_path(....);
194 
195  for (ScheduleID::size_type i = 0; i != nschedules; ++i) {
196  ScheduleID const sid{i};
197  auto& pinfo = triggerPathsInfo_[sid];
198  ScheduleContext const sc{sid};
199  for (auto const& [path_spec, worker_config_infos] :
201 
202  PathContext const pc{
203  sc, path_spec, sorted_module_labels(worker_config_infos)};
204  auto wips = fillWorkers_(
205  pc, worker_config_infos, pinfo.workers(), task_group, resources);
206  pinfo.add_path(
207  exceptActions_, actReg_, pc, std::move(wips), task_group);
208  }
209 
210  if (protoEndPathLabels_.empty()) {
211  continue;
212  }
213 
214  // Create the end path and the workers on it.
215  auto& einfo = endPathInfo_[sid];
216  PathContext const pc{sc,
218  sorted_module_labels(protoEndPathLabels_)};
219  auto wips = fillWorkers_(
220  pc, protoEndPathLabels_, einfo.workers(), task_group, resources);
221  einfo.add_path(exceptActions_, actReg_, pc, std::move(wips), task_group);
222  }
223 
224  // Create trigger-results inserters
225  PerScheduleContainer<std::unique_ptr<ModuleBase>> trigger_results(
226  nschedules);
227  for (ScheduleID::size_type i = 0; i != nschedules; ++i) {
228  ScheduleID const sid{i};
229  auto results_inserter = makeTriggerResultsInserter_(sid);
230  if (!results_inserter)
231  continue;
232 
233  WorkerParams const wp{outputCallbacks_,
235  actReg_,
237  sid,
238  task_group.native_group(),
239  resources};
240  triggerResultsWorkers_[sid] = results_inserter->makeWorker(wp);
241  trigger_results[sid] = std::move(results_inserter);
242  }
243 
244  modules_.replicated.emplace("TriggerResults", std::move(trigger_results));
245 
246  using namespace detail;
247  auto const graph_info_collection =
248  getModuleGraphInfoCollection_(producing_services);
249  ModuleGraphInfoMap const modInfos{graph_info_collection};
250  auto const module_graph =
251  make_module_graph(modInfos, protoTrigPathLabels_, protoEndPathLabels_);
252  auto const graph_filename =
253  procPS_.get<string>("services.scheduler.dataDependencyGraph", {});
254  if (!graph_filename.empty()) {
255  cet::ostream_handle osh{graph_filename};
256  print_module_graph(osh, modInfos, module_graph.first);
257  cerr << "Generated data-dependency graph file: " << graph_filename
258  << '\n';
259  }
260  auto const& err = module_graph.second;
261  if (!err.empty()) {
262  throw Exception{errors::Configuration} << err << '\n';
263  }
264 
265  // No longer need worker/module config objects.
266  protoTrigPathLabels_.clear();
267  protoEndPathLabels_.clear();
268  allModules_.clear();
269  }
ProductDescriptions & productsToProduce_
Definition: PathManager.h:130
std::map< module_label_t, PerScheduleContainer< std::unique_ptr< ModuleBase > > > replicated
Definition: PathManager.h:81
PerScheduleContainer< std::unique_ptr< Worker > > triggerResultsWorkers_
Definition: PathManager.h:142
art::detail::paths_to_modules_t protoTrigPathLabels_
Definition: PathManager.h:139
PerScheduleContainer< PathsInfo > triggerPathsInfo_
Definition: PathManager.h:128
ScheduleID::size_type nschedules() const
Definition: Globals.cc:24
T get(std::string const &key) const
Definition: ParameterSet.h:314
PerScheduleContainer< PathsInfo > endPathInfo_
Definition: PathManager.h:129
std::vector< WorkerInPath > fillWorkers_(PathContext const &pc, std::vector< WorkerInPath::ConfigInfo > const &wci_list, std::map< std::string, std::shared_ptr< Worker >> &workers, GlobalTaskGroup &task_group, detail::SharedResources &resources)
Definition: PathManager.cc:474
std::map< std::string, detail::ModuleConfigInfo > allModules_
Definition: PathManager.h:138
void print_module_graph(std::ostream &os, ModuleGraphInfoMap const &modInfos, ModuleGraph const &graph)
ModulesByThreadingType makeModules_(ScheduleID::size_type n)
Definition: PathManager.cc:341
static auto end_path_spec()
Definition: PathContext.h:20
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
UpdateOutputCallbacks & outputCallbacks_
Definition: PathManager.h:123
ActionTable const & exceptActions_
Definition: PathManager.h:124
id_type size_type
Definition: ScheduleID.h:25
Float_t sc
Definition: plot.C:23
detail::collection_map_t getModuleGraphInfoCollection_(std::vector< std::string > const &producing_services)
Definition: PathManager.cc:582
PathSpec path_spec(std::string const &path_spec)
Definition: PathSpec.cc:22
art::detail::configs_t protoEndPathLabels_
Definition: PathManager.h:140
static Globals * instance()
Definition: Globals.cc:17
ModulesByThreadingType modules_
Definition: PathManager.h:141
ActivityRegistry const & actReg_
Definition: PathManager.h:125
std::unique_ptr< ReplicatedProducer > makeTriggerResultsInserter_(ScheduleID scheduleID)
Definition: PathManager.cc:445
fhicl::ParameterSet procPS_
Definition: PathManager.h:126
std::pair< ModuleGraph, std::string > make_module_graph(ModuleGraphInfoMap const &modInfos, paths_to_modules_t const &trigger_paths, configs_t const &end_path)
PathsInfo & art::PathManager::endPathInfo ( ScheduleID  sid)

Definition at line 284 of file PathManager.cc.

References endPathInfo_.

Referenced by art::detail::writeSummary().

285  {
286  return endPathInfo_.at(sid);
287  }
PerScheduleContainer< PathsInfo > endPathInfo_
Definition: PathManager.h:129
PerScheduleContainer< PathsInfo > const & art::PathManager::endPathInfo ( )

Definition at line 290 of file PathManager.cc.

References endPathInfo_.

291  {
292  return endPathInfo_;
293  }
PerScheduleContainer< PathsInfo > endPathInfo_
Definition: PathManager.h:129
void art::PathManager::fillModuleOnlyDeps_ ( std::string const &  path_name,
detail::configs_t const &  worker_configs,
std::map< std::string, std::set< ProductInfo >> const &  produced_products,
std::map< std::string, std::set< std::string >> const &  viewable_products,
detail::collection_map_t info_collection 
) const
private

Definition at line 648 of file PathManager.cc.

References util::cbegin(), util::cend(), art::ConsumesInfo::consumables(), art::detail::consumed_products_for_module(), util::end(), art::ConsumesInfo::instance(), and processName_.

Referenced by getModuleGraphInfoCollection_().

654  {
655  auto const worker_config_begin = cbegin(worker_configs);
656 
657  for (auto it = worker_config_begin, end = cend(worker_configs); it != end;
658  ++it) {
659  auto const& mci = *it->moduleConfigInfo;
660  auto const& module_name = mci.modDescription.moduleLabel();
661  auto& graph_info = info_collection[module_name];
662  graph_info.paths.insert(path_name);
663  graph_info.module_type = mci.moduleType;
664 
665  auto found = produced_products.find(module_name);
666  if (found != cend(produced_products)) {
667  graph_info.produced_products = found->second;
668  }
669 
670  auto const& consumables =
671  ConsumesInfo::instance()->consumables(module_name);
672  graph_info.consumed_products =
674  consumables,
675  produced_products,
676  viewable_products,
677  worker_config_begin,
678  it);
679  }
680  }
consumables_t::mapped_type const & consumables(std::string const &module_label) const
Definition: ConsumesInfo.h:110
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:93
static ConsumesInfo * instance()
Definition: ConsumesInfo.cc:27
std::string processName_
Definition: PathManager.h:137
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
std::set< ProductInfo > consumed_products_for_module(std::string const &current_process, ConsumesInfo::consumables_t::mapped_type const &consumables, std::map< std::string, std::set< ProductInfo >> const &produced_products, std::map< std::string, std::set< std::string >> const &viewable_products, config_const_iterator const config_begin, config_const_iterator const config_it)
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
Definition: StdUtils.h:85
void art::PathManager::fillSelectEventsDeps_ ( detail::configs_t const &  worker_configs,
detail::collection_map_t info_collection 
) const
private

Definition at line 694 of file PathManager.cc.

References art::is_observer(), art::path_spec(), art::path_specs(), and art::detail::remove_whitespace().

Referenced by getModuleGraphInfoCollection_().

696  {
697  for (auto const& worker_config : worker_configs) {
698  auto const& mci = *worker_config.moduleConfigInfo;
699  auto const& module_name = mci.modDescription.moduleLabel();
700  auto const& ps = mci.modPS;
701  auto& graph_info = info_collection[module_name];
702  assert(is_observer(graph_info.module_type));
703  auto path_specs = ps.get<vector<string>>("SelectEvents", {});
704  for (auto& path_spec : path_specs) {
706 
707  smatch matches;
708  regex_match(path_spec, matches, regex);
709  // By the time we have gotten here, all modules have been
710  // constructed, and it is guaranteed that the specified paths
711  // are in accord with the above regex.
712  // 0: Full match
713  // 1: Optional process name
714  // 2: Optional '!' or 'exception@'
715  // 3: Required path specification
716  // 4: Optional '&noexception'
717  assert(matches.size() == 5);
718  graph_info.select_events.insert(matches[3]);
719  }
720  }
721  }
std::vector< PathSpec > path_specs(std::vector< std::string > const &path_spec_strs)
Definition: PathSpec.cc:34
void remove_whitespace(std::string &str)
PathSpec path_spec(std::string const &path_spec)
Definition: PathSpec.cc:22
bool is_observer(ModuleType const mt)
Definition: ModuleType.h:28
vector< WorkerInPath > art::PathManager::fillWorkers_ ( PathContext const &  pc,
std::vector< WorkerInPath::ConfigInfo > const &  wci_list,
std::map< std::string, std::shared_ptr< Worker >> &  workers,
GlobalTaskGroup task_group,
detail::SharedResources resources 
)
private

Definition at line 474 of file PathManager.cc.

References actReg_, exceptActions_, makeWorker_(), art::GlobalTaskGroup::native_group(), outputCallbacks_, art::PathContext::pathID(), util::pi(), productsToProduce_, art::PathContext::scheduleID(), TDEBUG, TDEBUG_FUNC_SI, and art::to_string().

Referenced by createModulesAndWorkers().

479  {
480  auto const sid = pc.scheduleID();
481  auto const pi = pc.pathID();
482  vector<WorkerInPath> wips;
483  for (auto const& wci : wci_list) {
484  auto const& mci = *wci.moduleConfigInfo;
485  auto const filterAction = wci.filterAction;
486  auto const& module_label = mci.modDescription.moduleLabel();
487 
488  auto const& md = mci.modDescription;
489  std::shared_ptr<Worker> worker{nullptr};
490  // Workers present on multiple paths are shared so that their
491  // work is only done once per schedule.
492  if (auto it = workers.find(module_label); it != workers.end()) {
493  TDEBUG_FUNC_SI(5, sid)
494  << "Reusing worker " << hex << it->second << dec
495  << " path: " << to_string(pi) << " type: " << md.moduleName()
496  << " label: " << module_label;
497  worker = it->second;
498  } else {
499  WorkerParams const wp{outputCallbacks_,
501  actReg_,
503  sid,
504  task_group.native_group(),
505  resources};
506  worker = makeWorker_(mci.modDescription, wp);
507  TDEBUG(5) << "Made worker " << hex << worker << dec << " (" << sid
508  << ") path: " << to_string(pi) << " type: " << md.moduleName()
509  << " label: " << module_label << '\n';
510  }
511 
512  assert(worker);
513  workers.emplace(module_label, worker);
514  wips.emplace_back(
515  cet::make_exempt_ptr(worker.get()), filterAction, pc, task_group);
516  }
517  return wips;
518  }
ProductDescriptions & productsToProduce_
Definition: PathManager.h:130
std::shared_ptr< Worker > makeWorker_(ModuleDescription const &md, WorkerParams const &wp)
Definition: PathManager.cc:521
#define TDEBUG_FUNC_SI(LEVEL, SI)
#define TDEBUG(LEVEL)
UpdateOutputCallbacks & outputCallbacks_
Definition: PathManager.h:123
ActionTable const & exceptActions_
Definition: PathManager.h:124
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ActivityRegistry const & actReg_
Definition: PathManager.h:125
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
collection_map_t art::PathManager::getModuleGraphInfoCollection_ ( std::vector< std::string > const &  producing_services)
private

Definition at line 582 of file PathManager.cc.

References util::cend(), art::PathContext::end_path(), fillModuleOnlyDeps_(), fillSelectEventsDeps_(), art::PathSpec::name, art::path_spec(), art::producer, art::producing_service, art::ProductInfo::Product, productsToProduce_, protoEndPathLabels_, protoTrigPathLabels_, and triggerPathSpecs_.

Referenced by createModulesAndWorkers().

584  {
585  collection_map_t result{};
586  auto& source_info = result["input_source"];
587  if (!protoTrigPathLabels_.empty()) {
588  set<string> path_names;
589  for (auto const& spec : triggerPathSpecs_ | ::ranges::views::keys) {
590  path_names.insert(spec.name);
591  }
592  source_info.paths = path_names;
593  result["TriggerResults"] = ModuleGraphInfo{ModuleType::producer};
594  } else if (!protoEndPathLabels_.empty()) {
595  source_info.paths = {"end_path"};
596  }
597 
598  // Prepare information for produced and viewable products
599  std::map<std::string, std::set<ProductInfo>> produced_products_per_module;
600  std::map<std::string, std::set<std::string>> viewable_products_per_module;
601  for (auto const& pd : productsToProduce_) {
602  auto const& module_name = pd.moduleLabel();
603  produced_products_per_module[module_name].emplace(
605  pd.friendlyClassName(),
606  pd.moduleLabel(),
607  pd.productInstanceName(),
608  ProcessTag{pd.processName(), pd.processName()});
609  if (pd.supportsView()) {
610  // We do not do any type-checking here due to lack of
611  // introspection abilities. That will be performed during the
612  // actual product lookup.
613  viewable_products_per_module[module_name].insert(
614  pd.productInstanceName());
615  }
616  }
617 
618  // Handle producing services, which do not currently support 'consumes'.
619  for (auto const& service_name : producing_services) {
620  auto& graph_info = result[service_name];
621  graph_info.module_type = ModuleType::producing_service;
622 
623  auto found = produced_products_per_module.find(service_name);
624  if (found == cend(produced_products_per_module)) {
625  continue;
626  }
627 
628  graph_info.produced_products = found->second;
629  }
630 
631  for (auto const& [path_spec, module_labels] : protoTrigPathLabels_) {
633  module_labels,
634  produced_products_per_module,
635  viewable_products_per_module,
636  result);
637  }
640  produced_products_per_module,
641  viewable_products_per_module,
642  result);
644  return result;
645  }
ProductDescriptions & productsToProduce_
Definition: PathManager.h:130
static std::string end_path()
Definition: PathContext.h:14
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:93
void fillModuleOnlyDeps_(std::string const &path_name, detail::configs_t const &worker_configs, std::map< std::string, std::set< ProductInfo >> const &produced_products, std::map< std::string, std::set< std::string >> const &viewable_products, detail::collection_map_t &info_collection) const
Definition: PathManager.cc:648
std::map< module_name_t, ModuleGraphInfo > collection_map_t
art::detail::paths_to_modules_t protoTrigPathLabels_
Definition: PathManager.h:139
std::string name
Definition: PathSpec.h:48
void fillSelectEventsDeps_(detail::configs_t const &worker_configs, detail::collection_map_t &info_collection) const
Definition: PathManager.cc:694
art::detail::module_entries_for_ordered_path_t triggerPathSpecs_
Definition: PathManager.h:127
PathSpec path_spec(std::string const &path_spec)
Definition: PathSpec.cc:22
art::detail::configs_t protoEndPathLabels_
Definition: PathManager.h:140
ModuleThreadingType art::PathManager::loadModuleThreadingType_ ( std::string const &  lib_spec) const
private

Definition at line 559 of file PathManager.cc.

References art::errors::Configuration, art::getReleaseVersion(), and lm_.

Referenced by moduleInformation_().

560  {
561  detail::ModuleThreadingTypeFunc_t* mod_threading_type_func{nullptr};
562  try {
563  lm_.getSymbolByLibspec(
564  lib_spec, "moduleThreadingType", mod_threading_type_func);
565  }
566  catch (Exception& e) {
567  cet::detail::wrapLibraryManagerException(
568  e, "Module", lib_spec, getReleaseVersion());
569  }
570  if (mod_threading_type_func == nullptr) {
571  throw Exception(errors::Configuration, "BadPluginLibrary")
572  << "Module " << lib_spec << " with version " << getReleaseVersion()
573  << " has internal symbol definition problems: consult an expert.";
574  }
575  return mod_threading_type_func();
576  }
std::string const & getReleaseVersion()
cet::LibraryManager lm_
Definition: PathManager.h:132
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ModuleThreadingType( ModuleThreadingTypeFunc_t)
Definition: ModuleMacros.h:35
Float_t e
Definition: plot.C:35
ModuleType art::PathManager::loadModuleType_ ( std::string const &  lib_spec) const
private

Definition at line 540 of file PathManager.cc.

References art::errors::Configuration, art::getReleaseVersion(), and lm_.

Referenced by moduleInformation_().

541  {
542  detail::ModuleTypeFunc_t* mod_type_func{nullptr};
543  try {
544  lm_.getSymbolByLibspec(lib_spec, "moduleType", mod_type_func);
545  }
546  catch (Exception& e) {
547  cet::detail::wrapLibraryManagerException(
548  e, "Module", lib_spec, getReleaseVersion());
549  }
550  if (mod_type_func == nullptr) {
551  throw Exception(errors::Configuration, "BadPluginLibrary")
552  << "Module " << lib_spec << " with version " << getReleaseVersion()
553  << " has internal symbol definition problems: consult an expert.";
554  }
555  return mod_type_func();
556  }
std::string const & getReleaseVersion()
ModuleType( ModuleTypeFunc_t)
Definition: ModuleMacros.h:34
cet::LibraryManager lm_
Definition: PathManager.h:132
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
Float_t e
Definition: plot.C:35
PathManager::maybe_module_t art::PathManager::makeModule_ ( fhicl::ParameterSet const &  module_pset,
ModuleDescription const &  md,
ScheduleID  sid 
) const
private

Definition at line 413 of file PathManager.cc.

References art::errors::Configuration, e, art::getReleaseVersion(), lm_, art::detail::module_type(), and fhicl::detail::validationException::what().

Referenced by makeModules_().

416  {
417  auto const& module_type = md.moduleName();
418  detail::ModuleMaker_t* module_factory_func{nullptr};
419  try {
420  lm_.getSymbolByLibspec(module_type, "make_module", module_factory_func);
421  }
422  catch (Exception& e) {
423  cet::detail::wrapLibraryManagerException(
424  e, "Module", module_type, getReleaseVersion());
425  }
426  if (module_factory_func == nullptr) {
427  throw Exception(errors::Configuration, "BadPluginLibrary: ")
428  << "Module " << module_type << " with version " << getReleaseVersion()
429  << " has internal symbol definition problems: consult an "
430  "expert.";
431  }
432  auto mod = module_factory_func(modPS, ProcessingFrame{sid});
433  mod->setModuleDescription(md);
434  return mod;
435  }
436  catch (fhicl::detail::validationException const& e) {
437  ostringstream es;
438  es << "\n\nModule label: " << cet::bold_fontify(md.moduleLabel())
439  << "\nmodule_type : " << cet::bold_fontify(md.moduleName()) << "\n\n"
440  << e.what();
441  return es.str();
442  }
ModuleBase *(fhicl::ParameterSet const &, ProcessingFrame const &) ModuleMaker_t
Definition: ModuleMacros.h:33
ModuleType module_type(std::string const &full_key)
std::string const & getReleaseVersion()
cet::LibraryManager lm_
Definition: PathManager.h:132
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
char const * what() const noexcept override
Float_t e
Definition: plot.C:35
PathManager::ModulesByThreadingType art::PathManager::makeModules_ ( ScheduleID::size_type  n)
private

Definition at line 341 of file PathManager.cc.

References actReg_, allModules_, art::ConsumesInfo::collectConsumes(), art::errors::Configuration, art::ScheduleID::first(), art::ConsumesInfo::instance(), art::legacy, makeModule_(), art::module, art::detail::module_type(), processName_, art::shared, art::ActivityRegistry::sPostModuleConstruction, and art::ActivityRegistry::sPreModuleConstruction.

Referenced by createModulesAndWorkers().

342  {
343  ModulesByThreadingType modules{};
344  vector<string> configErrMsgs;
345  for (auto const& [module_label, mci] : allModules_) {
346  auto const& modPS = mci.modPS;
347  auto const& md = mci.modDescription;
348  auto const module_type = md.moduleName();
349  auto const module_threading_type = md.moduleThreadingType();
350 
351  // FIXME: provide context information?
352  actReg_.sPreModuleConstruction.invoke(md);
353 
354  auto sid = ScheduleID::first();
355  auto mod = makeModule_(modPS, md, sid);
356  if (auto err_msg = get_if<std::string>(&mod)) {
357  configErrMsgs.push_back(*err_msg);
358  continue;
359  }
360 
361  assert(std::holds_alternative<ModuleBase*>(mod));
362  auto module = std::get<ModuleBase*>(mod);
363 
364  if (module_threading_type == ModuleThreadingType::shared ||
365  module_threading_type == ModuleThreadingType::legacy) {
366  modules.shared.emplace(module_label,
367  std::unique_ptr<ModuleBase>{module});
368  } else {
369  PerScheduleContainer<std::unique_ptr<ModuleBase>> replicated_modules(
370  nschedules);
371  replicated_modules[sid].reset(module);
372  ScheduleIteration schedule_iteration{sid.next(),
373  ScheduleID(nschedules)};
374 
375  auto fill_replicated_module = [&, this](ScheduleID const sid) {
376  auto repl_mod = makeModule_(modPS, md, sid);
377  if (auto mod_ptr = get_if<ModuleBase*>(&repl_mod)) {
378  replicated_modules[sid].reset(*mod_ptr);
379  }
380  };
381  schedule_iteration.for_each_schedule(fill_replicated_module);
382  modules.replicated.emplace(module_label, std::move(replicated_modules));
383  }
384 
385  actReg_.sPostModuleConstruction.invoke(md);
386 
387  // Since we store consumes information per module label, we only
388  // sort and collect it for one of the replicated-module copies.
389  // The only way this would be a problem is if someone decided to
390  // provided conditional consumes calls based on the ScheduleID
391  // presented to the replicated-module constructor.
392  module->sortConsumables(processName_);
393  ConsumesInfo::instance()->collectConsumes(module_label,
394  module->getConsumables());
395  }
396 
397  if (!configErrMsgs.empty()) {
398  constexpr cet::HorizontalRule rule{100};
399  ostringstream msg;
400  msg << '\n'
401  << rule('=') << "\n\n"
402  << "!! The following modules have been misconfigured: !!" << '\n';
403  for (auto const& err : configErrMsgs) {
404  msg << '\n' << rule('-') << '\n' << err;
405  }
406  msg << '\n' << rule('=') << '\n';
407  throw Exception(errors::Configuration) << msg.str();
408  }
409  return modules;
410  }
void collectConsumes(std::string const &module_label, consumables_t::mapped_type const &consumables)
static ConsumesInfo * instance()
Definition: ConsumesInfo.cc:27
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleConstruction
static constexpr ScheduleID first()
Definition: ScheduleID.h:50
std::string processName_
Definition: PathManager.h:137
ModuleType module_type(std::string const &full_key)
GlobalSignal< detail::SignalResponseType::LIFO, void(ModuleDescription const &)> sPostModuleConstruction
maybe_module_t makeModule_(fhicl::ParameterSet const &module_pset, ModuleDescription const &md, ScheduleID) const
Definition: PathManager.cc:413
std::map< std::string, detail::ModuleConfigInfo > allModules_
Definition: PathManager.h:138
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ActivityRegistry const & actReg_
Definition: PathManager.h:125
std::unique_ptr< ReplicatedProducer > art::PathManager::makeTriggerResultsInserter_ ( ScheduleID  scheduleID)
private

Definition at line 445 of file PathManager.cc.

References actReg_, art::getReleaseVersion(), fhicl::ParameterSet::id(), art::Globals::instance(), processName_, procPS_, art::producer, art::replicated, art::ActivityRegistry::sPostModuleConstruction, art::ActivityRegistry::sPreModuleConstruction, triggerPathsInfo_, and art::Globals::triggerPSet().

Referenced by createModulesAndWorkers().

446  {
447  auto& pathsInfo = triggerPathsInfo_.at(scheduleID);
448  if (pathsInfo.paths().empty()) {
449  return nullptr;
450  }
451 
452  auto const& trig_pset = Globals::instance()->triggerPSet();
453  ModuleDescription md{
454  trig_pset.id(),
455  "TriggerResultInserter",
456  "TriggerResults",
458  ProcessConfiguration{processName_, procPS_.id(), getReleaseVersion()}};
459  actReg_.sPreModuleConstruction.invoke(md);
460  auto producer = std::make_unique<TriggerResultInserter>(
461  trig_pset, scheduleID, pathsInfo.pathResults());
462  producer->setModuleDescription(md);
463  actReg_.sPostModuleConstruction.invoke(md);
464  return producer;
465  }
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleConstruction
std::string processName_
Definition: PathManager.h:137
fhicl::ParameterSet const & triggerPSet() const
Definition: Globals.cc:60
GlobalSignal< detail::SignalResponseType::LIFO, void(ModuleDescription const &)> sPostModuleConstruction
PerScheduleContainer< PathsInfo > triggerPathsInfo_
Definition: PathManager.h:128
std::string const & getReleaseVersion()
ParameterSetID id() const
static Globals * instance()
Definition: Globals.cc:17
ActivityRegistry const & actReg_
Definition: PathManager.h:125
fhicl::ParameterSet procPS_
Definition: PathManager.h:126
std::shared_ptr< Worker > art::PathManager::makeWorker_ ( ModuleDescription const &  md,
WorkerParams const &  wp 
)
private

Definition at line 521 of file PathManager.cc.

References art::legacy, art::module, art::ModuleDescription::moduleLabel(), modules_, art::ModuleDescription::moduleThreadingType(), art::PathManager::ModulesByThreadingType::replicated, art::WorkerParams::scheduleID_, art::shared, and art::PathManager::ModulesByThreadingType::shared.

Referenced by fillWorkers_().

522  {
523  auto get_module = [this](std::string const& module_label,
524  ModuleThreadingType const module_threading_type,
525  ScheduleID const sid) -> auto&
526  {
527  if (module_threading_type == ModuleThreadingType::shared ||
528  module_threading_type == ModuleThreadingType::legacy) {
529  return modules_.shared.at(module_label);
530  }
531  return modules_.replicated.at(module_label)[sid];
532  };
533 
534  auto& module =
535  get_module(md.moduleLabel(), md.moduleThreadingType(), wp.scheduleID_);
536  return module->makeWorker(wp);
537  }
std::map< module_label_t, PerScheduleContainer< std::unique_ptr< ModuleBase > > > replicated
Definition: PathManager.h:81
ModuleThreadingType
Definition: ModuleType.h:19
std::map< module_label_t, std::unique_ptr< ModuleBase > > shared
Definition: PathManager.h:78
ModulesByThreadingType modules_
Definition: PathManager.h:141
std::map< std::string, detail::ModuleConfigInfo > art::PathManager::moduleInformation_ ( detail::EnabledModules const &  enabled_modules) const
private

Definition at line 296 of file PathManager.cc.

References art::errors::Configuration, e, util::empty(), fhicl::ParameterSet::get(), art::getReleaseVersion(), fhicl::ParameterSet::id(), loadModuleThreadingType_(), loadModuleType_(), art::detail::module_type(), art::detail::EnabledModules::modules(), processName_, procPS_, and art::to_string().

Referenced by PathManager().

298  {
299  std::map<std::string, detail::ModuleConfigInfo> result{};
300  ostringstream es;
301  for (auto const& [module_label, key_and_type] : enabled_modules.modules()) {
302  try {
303  auto const& [key, module_type] = key_and_type;
304  auto const module_pset = procPS_.get<fhicl::ParameterSet>(key);
305  auto const lib_spec = module_pset.get<string>("module_type");
306  if (auto const actual_mod_type = loadModuleType_(lib_spec);
307  actual_mod_type != module_type) {
308  es << " ERROR: Module with label " << module_label << " of type "
309  << lib_spec << " is configured as a " << to_string(module_type)
310  << " but defined in code as a " << to_string(actual_mod_type)
311  << ".\n";
312  continue;
313  }
314 
315  ModuleDescription const md{module_pset.id(),
316  lib_spec,
317  module_label,
318  loadModuleThreadingType_(lib_spec),
319  ProcessConfiguration{processName_,
320  procPS_.id(),
321  getReleaseVersion()}};
322  detail::ModuleConfigInfo mci{md, std::move(module_pset), module_type};
323  result.try_emplace(module_label, std::move(mci));
324  }
325  catch (exception const& e) {
326  es << " ERROR: Configuration of module with label " << module_label
327  << " encountered the following error:\n"
328  << e.what();
329  }
330  }
331  if (auto err_msg = es.str(); not empty(err_msg)) {
333  << "The following were encountered while processing the module "
334  "configurations:\n"
335  << err_msg;
336  }
337  return result;
338  }
std::string processName_
Definition: PathManager.h:137
ModuleType module_type(std::string const &full_key)
T get(std::string const &key) const
Definition: ParameterSet.h:314
ModuleThreadingType loadModuleThreadingType_(std::string const &lib_spec) const
Definition: PathManager.cc:559
std::string const & getReleaseVersion()
ParameterSetID id() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
Float_t e
Definition: plot.C:35
ModuleType loadModuleType_(std::string const &lib_spec) const
Definition: PathManager.cc:540
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
fhicl::ParameterSet procPS_
Definition: PathManager.h:126
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109
PathManager& art::PathManager::operator= ( PathManager const &  )
delete
PathManager& art::PathManager::operator= ( PathManager &&  )
delete
std::vector< std::string > art::PathManager::prependedTriggerPathNames_ ( ) const
private

Definition at line 160 of file PathManager.cc.

References art::to_string(), and triggerPathSpecs_.

Referenced by PathManager().

161  {
162  using namespace ::ranges;
163  return triggerPathSpecs_ | views::keys |
164  views::transform([](auto const& spec) { return to_string(spec); }) |
165  to<std::vector>();
166  }
art::detail::module_entries_for_ordered_path_t triggerPathSpecs_
Definition: PathManager.h:127
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
std::unique_ptr< Worker > art::PathManager::releaseTriggerResultsInserter ( ScheduleID  scheduleID)

Definition at line 468 of file PathManager.cc.

References triggerResultsWorkers_.

469  {
470  return std::move(triggerResultsWorkers_.at(scheduleID));
471  }
PerScheduleContainer< std::unique_ptr< Worker > > triggerResultsWorkers_
Definition: PathManager.h:142
std::vector< std::string > art::PathManager::triggerPathNames_ ( ) const
private

Definition at line 151 of file PathManager.cc.

References triggerPathSpecs_.

Referenced by PathManager().

152  {
153  using namespace ::ranges;
154  return triggerPathSpecs_ | views::keys |
155  views::transform([](auto const& spec) { return spec.name; }) |
156  to<std::vector>();
157  }
art::detail::module_entries_for_ordered_path_t triggerPathSpecs_
Definition: PathManager.h:127
PathsInfo & art::PathManager::triggerPathsInfo ( ScheduleID  sid)

Definition at line 272 of file PathManager.cc.

References triggerPathsInfo_.

Referenced by art::detail::writeSummary().

273  {
274  return triggerPathsInfo_.at(sid);
275  }
PerScheduleContainer< PathsInfo > triggerPathsInfo_
Definition: PathManager.h:128
PerScheduleContainer< PathsInfo > const & art::PathManager::triggerPathsInfo ( )

Definition at line 278 of file PathManager.cc.

References triggerPathsInfo_.

279  {
280  return triggerPathsInfo_;
281  }
PerScheduleContainer< PathsInfo > triggerPathsInfo_
Definition: PathManager.h:128
std::vector< PathSpec > art::PathManager::triggerPathSpecs ( ) const

Definition at line 144 of file PathManager.cc.

References triggerPathSpecs_.

145  {
146  using namespace ::ranges;
147  return triggerPathSpecs_ | views::keys | to<std::vector>();
148  }
art::detail::module_entries_for_ordered_path_t triggerPathSpecs_
Definition: PathManager.h:127

Member Data Documentation

ActivityRegistry const& art::PathManager::actReg_
private
std::map<std::string, detail::ModuleConfigInfo> art::PathManager::allModules_ {}
private

Definition at line 138 of file PathManager.h.

Referenced by createModulesAndWorkers(), makeModules_(), and PathManager().

PerScheduleContainer<PathsInfo> art::PathManager::endPathInfo_
private

Definition at line 129 of file PathManager.h.

Referenced by createModulesAndWorkers(), endPathInfo(), and PathManager().

ActionTable const& art::PathManager::exceptActions_
private

Definition at line 124 of file PathManager.h.

Referenced by createModulesAndWorkers(), fillWorkers_(), and PathManager().

cet::LibraryManager art::PathManager::lm_ {Suffixes::module()}
private

Definition at line 132 of file PathManager.h.

Referenced by loadModuleThreadingType_(), loadModuleType_(), and makeModule_().

ModulesByThreadingType art::PathManager::modules_ {}
private

Definition at line 141 of file PathManager.h.

Referenced by createModulesAndWorkers(), and makeWorker_().

UpdateOutputCallbacks& art::PathManager::outputCallbacks_
private

Definition at line 123 of file PathManager.h.

Referenced by createModulesAndWorkers(), and fillWorkers_().

std::string art::PathManager::processName_ {}
private
fhicl::ParameterSet art::PathManager::procPS_
private
ProductDescriptions& art::PathManager::productsToProduce_
private
art::detail::configs_t art::PathManager::protoEndPathLabels_ {}
private
art::detail::paths_to_modules_t art::PathManager::protoTrigPathLabels_ {}
private
PerScheduleContainer<PathsInfo> art::PathManager::triggerPathsInfo_
private
PerScheduleContainer<std::unique_ptr<Worker> > art::PathManager::triggerResultsWorkers_
private

The documentation for this class was generated from the following files: