12 #pragma GCC diagnostic push 13 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" 14 #include <boost/graph/depth_first_search.hpp> 15 #pragma GCC diagnostic pop 41 using std::pair<I, I>::pair;
60 source_ = module.
id();
63 boost::add_vertex(graph_);
75 unsigned int pid = registerProcess(context);
81 boost::get_property(graph, boost::graph_name) = context.
processName();
85 for (
size_t i = 0;
i <
size; ++
i)
86 boost::add_vertex(graph);
89 std::vector<unsigned int>
modules;
90 modules.reserve(size);
92 modules.push_back(
module->id());
100 boost::add_edge(consumer->id(),
module->id(), graph_);
108 size = pathsAndConsumes.
paths().size();
109 assert (tns.getTrigPaths().size() ==
size);
110 std::vector<PathType> paths;
112 for (
unsigned int i = 0;
i <
size; ++
i) {
113 std::vector<unsigned int>
modules;
115 modules.push_back(
module->id());
117 graph_.m_graph[
module->id()].scheduled_ =
true;
122 size = pathsAndConsumes.
endPaths().size();
123 std::vector<PathType> endPaths;
124 endPaths.reserve(size);
125 for (
unsigned int i = 0;
i <
size; ++
i) {
126 std::vector<unsigned int>
modules;
128 modules.push_back(
module->id());
130 graph_.m_graph[
module->id()].scheduled_ =
true;
137 process_description_.emplace_back(
143 assert(process_description_.size() == pid+1);
148 process_description_[parent_pid].subprocesses_.push_back(pid);
157 return boost::num_vertices(graph_);
165 return graph_.m_graph[source_].module_;
173 return graph_.m_graph[module].module_;
181 return graph_.m_graph[module];
186 std::vector<unsigned int>
189 std::vector<unsigned int>
colors(boost::num_vertices(graph_));
190 auto colormap = boost::make_container_vertex_map(colors);
193 boost::default_dfs_visitor visitor;
194 boost::depth_first_visit(graph_, module, visitor, colormap);
198 unsigned int size = 0;
199 for (
unsigned int color : colors)
200 if (boost::black_color ==
color)
204 for (
unsigned int i = 0;
i < colors.size(); ++
i)
205 if (boost::black_color == colors[
i])
206 dependencies[j++] =
i;
217 std::pair<std::vector<unsigned int>, std::vector<unsigned int>>
220 std::vector<unsigned int>
colors(boost::num_vertices(graph_));
221 auto colormap = boost::make_container_vertex_map(colors);
224 boost::default_dfs_visitor visitor;
225 for (
unsigned int module: path)
226 boost::depth_first_visit(graph_,
module, visitor, colormap);
228 unsigned int size = 0;
229 for (
unsigned int color : colors)
235 dependencies.resize(0);
236 std::vector<unsigned int> indices(path.size());
240 for (
unsigned int &
color : colors)
244 struct record_vertices : boost::default_dfs_visitor {
245 record_vertices(std::vector<unsigned int> &
vertices) :
246 vertices_(vertices) { }
248 void discover_vertex(
unsigned int vertex,
GraphType const& graph) {
249 vertices_.push_back(vertex);
252 std::vector<unsigned int> & vertices_;
254 record_vertices recorder(dependencies);
256 for (
unsigned int module: path) {
258 if (colors[
module] != boost::black_color)
259 boost::depth_first_visit(graph_,
module, recorder, colormap);
260 indices.push_back(dependencies.size());
263 return std::make_pair(dependencies, indices);
271 static unsigned int s_id = 0;
276 <<
"ProcessCallGraph::preBeginJob(): called for subprocess \"" << context.
processName() <<
"\"" 282 if (
id != process_id_.end()) {
284 <<
"ProcessCallGraph::preBeginJob(): called twice for the same " 298 if (
id == process_id_.end())
300 <<
"ProcessCallGraph::processId(): unexpected " << (context.
isSubProcess() ?
"subprocess" :
"process") <<
" " << context.
processName();
309 auto id = process_id_.find(processName);
310 if (
id == process_id_.end())
312 <<
"ProcessCallGraph::processId(): unexpected (sub)process " <<
processName;
320 return process_description_;
327 return process_description_.at(pid);
334 unsigned int pid = processId(context);
335 return process_description_[
pid];
342 unsigned int pid = processId(processName);
343 return process_description_[
pid];
unsigned int registerProcess(edm::ProcessContext const &)
std::string const & processName() const
unsigned int processId(edm::ProcessContext const &) const
std::vector< ModuleDescription const * > const & modulesOnEndPath(unsigned int endPathIndex) const
std::vector< ModuleDescription const * > const & modulesOnPath(unsigned int pathIndex) const
edm::ModuleDescription const & source() const
ProcessContext const & parentProcessContext() const
std::vector< ModuleDescription const * > const & allModules() const
EDMModuleType edmModuleTypeEnum(edm::ModuleDescription const &module)
std::vector< std::string > const & endPaths() const
U second(std::pair< T, U > const &p)
void preBeginJob(edm::PathsAndConsumesOfModulesBase const &, edm::ProcessContext const &)
std::vector< ProcessType > const & processes() const
ProcessType const & processDescription(unsigned int) const
const std::complex< double > I
void preSourceConstruction(edm::ModuleDescription const &)
boost::subgraph< boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, NodeType, boost::property< boost::edge_index_t, int >, boost::property< boost::graph_name_t, std::string > >> GraphType
std::vector< unsigned int > depends(unsigned int module) const
std::vector< ModuleDescription const * > const & modulesWhoseProductsAreConsumedBy(unsigned int moduleID) const
std::vector< std::string > const & paths() const
std::pair< std::vector< unsigned int >, std::vector< unsigned int > > dependencies(std::vector< unsigned int > const &path)
unsigned int size() const
edm::ModuleDescription const & module(unsigned int module) const
iterator_pair_as_a_range< I > make_range(std::pair< I, I > p)
bool isSubProcess() const
NodeType const & operator[](unsigned int module) const