File indexing completed on 2025-06-04 22:36:16
0001 #ifndef HLTrigger_Timer_interface_ProcessCallGraph_h
0002 #define HLTrigger_Timer_interface_ProcessCallGraph_h
0003
0004 #include <memory>
0005 #include <utility>
0006 #include <vector>
0007 #include <string>
0008
0009
0010 #pragma GCC diagnostic push
0011 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
0012 #include <boost/graph/adjacency_list.hpp>
0013 #include <boost/graph/lookup_edge.hpp>
0014 #include <boost/graph/subgraph.hpp>
0015 #pragma GCC diagnostic pop
0016
0017 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0018 #include "FWCore/ServiceRegistry/interface/ServiceRegistryfwd.h"
0019 #include "HLTrigger/Timer/interface/EDMModuleType.h"
0020
0021 class ProcessCallGraph {
0022 public:
0023 struct NodeType {
0024 edm::ModuleDescription module_;
0025 edm::EDMModuleType type_ = edm::EDMModuleType::kUnknown;
0026 bool scheduled_ = false;
0027 };
0028
0029
0030 using GraphType = boost::subgraph<boost::adjacency_list<
0031
0032 boost::vecS,
0033
0034 boost::vecS,
0035 boost::directedS,
0036
0037 NodeType,
0038
0039 boost::property<boost::edge_index_t, int>,
0040
0041 boost::property<boost::graph_name_t, std::string>>>;
0042
0043
0044 struct PathType {
0045 std::string name_;
0046 std::vector<unsigned int> modules_on_path_;
0047 std::vector<unsigned int> modules_and_dependencies_;
0048 std::vector<unsigned int>
0049 last_dependency_of_module_;
0050
0051 PathType() = default;
0052
0053 PathType(std::string name,
0054 std::vector<unsigned int> mop,
0055 std::vector<unsigned int> mad,
0056 std::vector<unsigned int> ldom)
0057 : name_(std::move(name)),
0058 modules_on_path_(std::move(mop)),
0059 modules_and_dependencies_(std::move(mad)),
0060 last_dependency_of_module_(std::move(ldom)) {}
0061 };
0062
0063
0064 struct ProcessType {
0065 std::string name_;
0066 GraphType const &graph_;
0067 std::vector<unsigned int> modules_;
0068 std::vector<PathType> paths_;
0069 std::vector<PathType> endPaths_;
0070
0071 ProcessType(std::string name,
0072 GraphType const &graph,
0073 std::vector<unsigned int> modules,
0074 std::vector<PathType> paths,
0075 std::vector<PathType> endPaths)
0076 : name_(std::move(name)),
0077 graph_(graph),
0078 modules_(std::move(modules)),
0079 paths_(std::move(paths)),
0080 endPaths_(std::move(endPaths)) {}
0081 };
0082
0083
0084 ProcessCallGraph() = default;
0085
0086
0087 void preSourceConstruction(edm::ModuleDescription const &);
0088
0089
0090 void lookupInitializationComplete(edm::PathsAndConsumesOfModulesBase const &, edm::ProcessContext const &);
0091
0092
0093 unsigned int size() const;
0094
0095
0096 edm::ModuleDescription const &source() const;
0097
0098
0099 edm::ModuleDescription const &module(unsigned int module) const;
0100
0101
0102 NodeType const &operator[](unsigned int module) const;
0103
0104
0105 std::vector<unsigned int> depends(unsigned int module) const;
0106
0107
0108 std::pair<std::vector<unsigned int>, std::vector<unsigned int>> dependencies(std::vector<unsigned int> const &path);
0109
0110
0111 ProcessType const &processDescription() const;
0112
0113 private:
0114 GraphType graph_;
0115
0116
0117 unsigned int source_ = edm::ModuleDescription::invalidID();
0118
0119
0120 std::unique_ptr<ProcessType> process_description_;
0121 };
0122
0123 #endif