CMS 3D CMS Logo

ProcessCallGraph.h
Go to the documentation of this file.
1 #ifndef HLTrigger_Timer_interface_ProcessCallGraph_h
2 #define HLTrigger_Timer_interface_ProcessCallGraph_h
3 
4 /*
5  *
6  */
7 
8 #include <iostream>
9 #include <utility>
10 #include <vector>
11 #include <string>
12 #include <type_traits>
13 
14 // boost optional (used by boost graph) results in some false positives with -Wmaybe-uninitialized
15 #pragma GCC diagnostic push
16 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
17 #include <boost/graph/adjacency_list.hpp>
18 #include <boost/graph/lookup_edge.hpp>
19 #include <boost/graph/subgraph.hpp>
20 #pragma GCC diagnostic pop
21 
26 
28 public:
29  struct NodeType {
32  bool scheduled_;
33  };
34 
35  // directed graph, with `NodeType` properties attached to each vertex
36  using GraphType = boost::subgraph<boost::adjacency_list<
37  // edge list
38  boost::vecS,
39  // vertex list
40  boost::vecS,
41  boost::directedS,
42  // vertex properties
43  NodeType,
44  // edge propoerties, used internally by boost::subgraph
45  boost::property<boost::edge_index_t, int>,
46  // graph properties, used to name each boost::subgraph
47  boost::property<boost::graph_name_t, std::string>>>;
48 
49  // store the details of each path: name, modules on the path, and their dependencies
50  struct PathType {
52  std::vector<unsigned int> modules_on_path_;
53  std::vector<unsigned int> modules_and_dependencies_;
54  std::vector<unsigned int>
55  last_dependency_of_module_; // one-after-the-last dependency of each module, as indices into modules_and_dependencies_
56 
57  PathType() = default;
58 
60  std::vector<unsigned int> mop,
61  std::vector<unsigned int> mad,
62  std::vector<unsigned int> ldom)
63  : name_(std::move(name)),
64  modules_on_path_(std::move(mop)),
67 
68  PathType(PathType const &other) = default;
69 
70  PathType(PathType &&other) = default;
71 
72  ~PathType() = default;
73 
74  PathType &operator=(PathType const &other) = default;
75  };
76 
77  // store the details of each process: name, modules call subgraph, modules, paths and endpaths, subprocess pids
78  struct ProcessType {
80  GraphType const &graph_;
81  std::vector<unsigned int> modules_;
82  std::vector<PathType> paths_;
83  std::vector<PathType> endPaths_;
84  std::vector<unsigned int> subprocesses_;
85 
86  ProcessType() = delete;
87 
89  GraphType const &graph,
90  std::vector<unsigned int> modules,
91  std::vector<PathType> paths,
92  std::vector<PathType> endPaths,
93  std::vector<unsigned int> subprocesses = {})
94  : name_(std::move(name)),
95  graph_(graph),
98  endPaths_(std::move(endPaths)),
99  subprocesses_(std::move(subprocesses)) {}
100 
102  GraphType const &graph,
103  std::vector<unsigned int> &&modules,
104  std::vector<PathType> &&paths,
105  std::vector<PathType> &&endPaths,
106  std::vector<unsigned int> &&subprocesses = {})
107  : name_(std::move(name)),
108  graph_(graph),
111  endPaths_(std::move(endPaths)),
112  subprocesses_(std::move(subprocesses)) {}
113 
114  ProcessType(ProcessType const &other) = default;
115  ProcessType(ProcessType &&other) = default;
116 
117  ProcessType &operator=(ProcessType const &other) = delete;
118  ProcessType &operator=(ProcessType &&other) = delete;
119  };
120 
121 public:
122  // default c'tor
124 
125  // to be called from preSourceConstruction(...)
127 
128  // to be called from preBeginJob(...)
130 
131  // number of modules stored in the call graph
132  unsigned int size() const;
133 
134  // retrieve the ModuleDescription associated to the Source
135  edm::ModuleDescription const &source() const;
136 
137  // retrieve the ModuleDescription associated to the given id
138  edm::ModuleDescription const &module(unsigned int module) const;
139 
140  // retrieve the full information for a given module
141  NodeType const &operator[](unsigned int module) const;
142 
143  // find the dependencies of the given module
144  std::vector<unsigned int> depends(unsigned int module) const;
145 
146  // find the dependencies of all modules in the given path
147  std::pair<std::vector<unsigned int>, std::vector<unsigned int>> dependencies(std::vector<unsigned int> const &path);
148 
149  // retrieve the "process id" of a process, given its ProcessContex
150  unsigned int processId(edm::ProcessContext const &) const;
151 
152  // retrieve the "process id" of a process, given its name
153  unsigned int processId(std::string const &) const;
154 
155  // retrieve the processes
156  std::vector<ProcessType> const &processes() const;
157 
158  // retrieve information about a process, given its "process id"
159  ProcessType const &processDescription(unsigned int) const;
160 
161  // retrieve information about a process, given its ProcessContex
162  ProcessType const &processDescription(edm::ProcessContext const &) const;
163 
164  // retrieve information about a process, given its name
165  ProcessType const &processDescription(std::string const &) const;
166 
167 private:
168  // register a (sub)process and assigns it a "process id"
169  unsigned int registerProcess(edm::ProcessContext const &);
170 
171 private:
173 
174  // module id of the Source
175  unsigned int source_;
176 
177  // map each (sub)process name to a "process id"
178  std::unordered_map<std::string, unsigned int> process_id_;
179 
180  // description of each process
181  std::vector<ProcessType> process_description_;
182 };
183 
184 #endif // not defined HLTrigger_Timer_interface_ProcessCallGraph_h
ProcessCallGraph::NodeType
Definition: ProcessCallGraph.h:29
ProcessCallGraph::ProcessCallGraph
ProcessCallGraph()
EDMModuleType.h
ProcessCallGraph::ProcessType::operator=
ProcessType & operator=(ProcessType const &other)=delete
ProcessCallGraph::processes
const std::vector< ProcessType > & processes() const
Definition: ProcessCallGraph.cc:275
ProcessCallGraph::PathType::modules_and_dependencies_
std::vector< unsigned int > modules_and_dependencies_
Definition: ProcessCallGraph.h:53
ProcessCallGraph::process_description_
std::vector< ProcessType > process_description_
Definition: ProcessCallGraph.h:181
ProcessCallGraph::PathType::modules_on_path_
std::vector< unsigned int > modules_on_path_
Definition: ProcessCallGraph.h:52
modules
Definition: MuonCleanerBySegments.cc:35
ProcessCallGraph::NodeType::scheduled_
bool scheduled_
Definition: ProcessCallGraph.h:32
edm::ProcessContext
Definition: ProcessContext.h:27
ProcessCallGraph::PathType::operator=
PathType & operator=(PathType const &other)=default
ProcessCallGraph::ProcessType::graph_
const GraphType & graph_
Definition: ProcessCallGraph.h:80
ProcessCallGraph::graph_
GraphType graph_
Definition: ProcessCallGraph.h:172
ProcessCallGraph::processDescription
const ProcessType & processDescription(unsigned int) const
Definition: ProcessCallGraph.cc:278
ProcessCallGraph::depends
std::vector< unsigned int > depends(unsigned int module) const
Definition: ProcessCallGraph.cc:155
ProcessCallGraph::GraphType
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
Definition: ProcessCallGraph.h:47
ProcessCallGraph::ProcessType::paths_
std::vector< PathType > paths_
Definition: ProcessCallGraph.h:82
edm::ModuleDescription
Definition: ModuleDescription.h:21
ProcessCallGraph::size
unsigned int size() const
Definition: ProcessCallGraph.cc:139
ModuleDescription.h
ProcessCallGraph::ProcessType
Definition: ProcessCallGraph.h:78
ProcessCallGraph::NodeType::module_
edm::ModuleDescription module_
Definition: ProcessCallGraph.h:30
ProcessCallGraph::ProcessType::name_
std::string name_
Definition: ProcessCallGraph.h:79
ProcessCallGraph::operator[]
const NodeType & operator[](unsigned int module) const
Definition: ProcessCallGraph.cc:150
ProcessCallGraph::PathType::~PathType
~PathType()=default
ProcessCallGraph::PathType::name_
std::string name_
Definition: ProcessCallGraph.h:51
ProcessCallGraph::source_
unsigned int source_
Definition: ProcessCallGraph.h:175
trackingPlots.other
other
Definition: trackingPlots.py:1460
ProcessCallGraph::dependencies
std::pair< std::vector< unsigned int >, std::vector< unsigned int > > dependencies(std::vector< unsigned int > const &path)
Definition: ProcessCallGraph.cc:184
ExHuME_CEPDijetsGG_M100_10TeV_cff.ProcessType
ProcessType
Definition: ExHuME_CEPDijetsGG_M100_10TeV_cff.py:15
ProcessCallGraph::ProcessType::endPaths_
std::vector< PathType > endPaths_
Definition: ProcessCallGraph.h:83
ProcessCallGraph::ProcessType::subprocesses_
std::vector< unsigned int > subprocesses_
Definition: ProcessCallGraph.h:84
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::EDMModuleType
EDMModuleType
Definition: EDMModuleType.h:8
ProcessCallGraph
Definition: ProcessCallGraph.h:27
ProcessCallGraph::ProcessType::ProcessType
ProcessType(std::string name, GraphType const &graph, std::vector< unsigned int > modules, std::vector< PathType > paths, std::vector< PathType > endPaths, std::vector< unsigned int > subprocesses={})
Definition: ProcessCallGraph.h:88
ProcessCallGraph::ProcessType::ProcessType
ProcessType()=delete
ProcessCallGraph::ProcessType::ProcessType
ProcessType(std::string &&name, GraphType const &graph, std::vector< unsigned int > &&modules, std::vector< PathType > &&paths, std::vector< PathType > &&endPaths, std::vector< unsigned int > &&subprocesses={})
Definition: ProcessCallGraph.h:101
ProcessCallGraph::NodeType::type_
edm::EDMModuleType type_
Definition: ProcessCallGraph.h:31
ProcessCallGraph::registerProcess
unsigned int registerProcess(edm::ProcessContext const &)
Definition: ProcessCallGraph.cc:231
ProcessCallGraph::source
const edm::ModuleDescription & source() const
Definition: ProcessCallGraph.cc:142
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::PathsAndConsumesOfModulesBase
Definition: PathsAndConsumesOfModulesBase.h:35
ProcessCallGraph::PathType
Definition: ProcessCallGraph.h:50
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
ProcessCallGraph::ProcessType::modules_
std::vector< unsigned int > modules_
Definition: ProcessCallGraph.h:81
Skims_PA_cff.paths
paths
Definition: Skims_PA_cff.py:18
ProcessCallGraph::process_id_
std::unordered_map< std::string, unsigned int > process_id_
Definition: ProcessCallGraph.h:178
ProcessCallGraph::PathType::PathType
PathType()=default
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
ProcessCallGraph::processId
unsigned int processId(edm::ProcessContext const &) const
Definition: ProcessCallGraph.cc:255
ProcessCallGraph::module
const edm::ModuleDescription & module(unsigned int module) const
Definition: ProcessCallGraph.cc:145
ProcessContext.h
PathsAndConsumesOfModulesBase.h
ProcessCallGraph::PathType::last_dependency_of_module_
std::vector< unsigned int > last_dependency_of_module_
Definition: ProcessCallGraph.h:55
ProcessCallGraph::preBeginJob
void preBeginJob(edm::PathsAndConsumesOfModulesBase const &, edm::ProcessContext const &)
Definition: ProcessCallGraph.cc:64
ProcessCallGraph::PathType::PathType
PathType(std::string name, std::vector< unsigned int > mop, std::vector< unsigned int > mad, std::vector< unsigned int > ldom)
Definition: ProcessCallGraph.h:59
ProcessCallGraph::preSourceConstruction
void preSourceConstruction(edm::ModuleDescription const &)
Definition: ProcessCallGraph.cc:51