16 #include <type_traits> 19 #pragma GCC diagnostic push 20 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" 21 #include <boost/graph/adjacency_list.hpp> 22 #include <boost/graph/graphviz.hpp> 23 #include <boost/graph/lookup_edge.hpp> 24 #pragma GCC diagnostic pop 45 std::unordered_set<T> make_unordered_set(std::vector<T> &&entries) {
46 std::unordered_set<T> u;
71 "Unknown",
"Source",
"ESSource",
"ESProducer",
"EDAnalyzer",
"EDProducer",
"EDFilter",
"OutputModule"};
99 boost::subgraph<boost::adjacency_list<
106 boost::property<boost::vertex_attribute_t,
110 boost::property<boost::edge_index_t,
112 boost::property<boost::edge_attribute_t, GraphvizAttributes>>,
117 boost::property<boost::graph_graph_attribute_t,
119 boost::property<boost::graph_vertex_attribute_t,
121 boost::property<boost::graph_edge_attribute_t, GraphvizAttributes>>>>>>
144 EDMModuleType::ESSource,
146 EDMModuleType::EDAnalyzer,
147 EDMModuleType::EDProducer,
148 EDMModuleType::EDFilter,
149 EDMModuleType::OutputModule}) {
150 if (t ==
module_type_desc[
static_cast<std::underlying_type_t<EDMModuleType>
>(
v)])
163 desc.
addUntracked<std::vector<std::string>>(
"highlightModules", {});
165 descriptions.
add(
"DependencyGraph", desc);
169 : m_filename(config.getUntrackedParameter<
std::
string>(
"fileName")),
171 make_unordered_set(config.getUntrackedParameter<
std::vector<
std::
string>>(
"highlightModules"))),
172 m_showPathDependencies(config.getUntrackedParameter<
bool>(
"showPathDependencies")),
173 m_initialized(
false) {
180 template <
typename I>
183 using std::pair<I, I>::pair;
189 template <
typename I>
203 attributes[
"style"] =
"filled";
204 attributes[
"color"] =
"black";
212 edm::LogError(
"DependencyGraph") <<
"You have requested an instance of the DependencyGraph Service in the \"" 214 <<
"\" SubProcess, which is not supported.\nPlease move it to the main process.";
221 boost::get_property(
m_graph, boost::graph_graph_attribute)[
"label"] =
"process " + context.
processName();
222 boost::get_property(
m_graph, boost::graph_graph_attribute)[
"labelloc"] =
"top";
226 for (
size_t i = 0;
i <
size; ++
i)
232 auto &graph =
m_graph.create_subgraph();
235 boost::get_property(graph, boost::graph_name) =
"cluster" + context.
processName();
236 boost::get_property(graph, boost::graph_graph_attribute)[
"label"] =
"subprocess " + context.
processName();
237 boost::get_property(graph, boost::graph_graph_attribute)[
"labelloc"] =
"top";
241 for (
size_t i = 0;
i <
size; ++
i)
242 boost::add_vertex(graph);
251 attributes[
"label"] =
module->moduleLabel();
252 attributes[
"tooltip"] =
module->moduleName();
254 attributes[
"style"] =
"filled";
255 attributes[
"color"] =
"black";
256 attributes[
"fillcolor"] =
highlighted(
module->moduleLabel()) ?
"green" :
"lightgrey";
260 auto const &paths = pathsAndConsumes.
paths();
261 auto const &endps = pathsAndConsumes.
endPaths();
266 edm::LogInfo(
"DependencyGraph") <<
"module " << consumer->moduleLabel() <<
" depends on module " 268 auto edge_status = boost::add_edge(consumer->id(),
module->id(),
m_graph);
271 auto const &edge = edge_status.first;
273 attributes[
"color"] =
"darkgreen";
280 for (
unsigned int i = 0;
i < paths.size(); ++
i) {
285 attributes[
"fillcolor"] =
highlighted(
module->moduleLabel()) ?
"lightgreen" :
"white";
287 edm::LogInfo(
"DependencyGraph") <<
"module " <<
module->moduleLabel() <<
" follows module " 289 auto edge_status = boost::lookup_edge(
module->id(), previous->
id(),
m_graph);
290 bool found = edge_status.second;
293 auto const &edge = edge_status.first;
295 attributes[
"style"] =
"dashed";
298 attributes[
"color"] =
"darkgreen";
304 for (
unsigned int i = 0;
i < endps.size(); ++
i) {
309 attributes[
"fillcolor"] =
highlighted(
module->moduleLabel()) ?
"lightgreen" :
"white";
311 edm::LogInfo(
"DependencyGraph") <<
"module " <<
module->moduleLabel() <<
" follows module " 313 auto edge_status = boost::lookup_edge(
module->id(), previous->
id(),
m_graph);
314 bool found = edge_status.second;
317 auto const &edge = edge_status.first;
319 attributes[
"style"] =
"dashed";
322 attributes[
"color"] =
"darkgreen";
336 boost::write_graphviz(out,
m_graph);
boost::subgraph< boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, boost::property< boost::vertex_attribute_t, GraphvizAttributes, node >, boost::property< boost::edge_index_t, int, boost::property< boost::edge_attribute_t, GraphvizAttributes > >, boost::property< boost::graph_name_t, std::string, boost::property< boost::graph_graph_attribute_t, GraphvizAttributes, boost::property< boost::graph_vertex_attribute_t, GraphvizAttributes, boost::property< boost::graph_edge_attribute_t, GraphvizAttributes > > > > > > m_graph
std::string const & processName() const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
iterator_pair_as_a_range< I > make_range(std::pair< I, I > p)
void watchPreSourceConstruction(PreSourceConstruction::slot_type const &iSlot)
void preBeginJob(PathsAndConsumesOfModulesBase const &, ProcessContext const &)
std::vector< ModuleDescription const * > const & modulesOnEndPath(unsigned int endPathIndex) const
std::string const & moduleName() const
std::vector< ModuleDescription const * > const & modulesOnPath(unsigned int pathIndex) const
constexpr const char * module_type_desc[]
std::string const & moduleLabel() 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)
std::map< std::string, std::string > GraphvizAttributes
void preSourceConstruction(ModuleDescription const &)
const std::complex< double > I
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_SERVICE(type)
static const char * edmModuleType(edm::ModuleDescription const &module)
std::unordered_set< std::string > m_highlightModules
bool m_showPathDependencies
bool isProcessWideService(ZombieKillerService const *)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static EDMModuleType edmModuleTypeEnum(edm::ModuleDescription const &module)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< ModuleDescription const * > const & modulesWhoseProductsAreConsumedBy(unsigned int moduleID) const
void watchPreBeginJob(PreBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
DependencyGraph(const ParameterSet &, ActivityRegistry &)
std::vector< std::string > const & paths() const
static const char * shapes[]
ParameterSetID const & parameterSetID() const
bool highlighted(std::string const &module)
static const char * module_type_desc[]
bool isSubProcess() const
const char * edmModuleType(edm::ModuleDescription const &module)
T get(const Candidate &c)
static Registry * instance()
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal