18 #include <flecsi-config.h> 25 #if defined(FLECSI_ENABLE_GRAPHVIZ) 26 #include "flecsi/util/graphviz.hh" 45 template<bool (*Predicate)(),
typename... ControlPoints>
48 using type = std::tuple<ControlPoints...>;
49 static constexpr
size_t last = std::tuple_size<type>::value - 1;
51 template<
size_t E,
typename T>
54 template<
size_t E, bool (*P)(),
typename... CPs>
56 using type = std::tuple<CPs...>;
57 static constexpr
const auto & value =
61 template<
size_t E, auto Value>
63 static constexpr
const auto & value = Value;
66 static constexpr
auto & begin =
68 static constexpr
auto & end =
71 static bool predicate() {
81 template<
typename ControlPolicy>
84 using control_points_enum =
typename ControlPolicy::control_points_enum;
87 init_walker(std::map<control_points_enum, dag> & registry)
88 : registry_(registry) {}
90 template<
typename ElementType>
94 control_points_enum>::value) {
95 registry_.try_emplace(ElementType::value, *ElementType::value);
98 init_walker(registry_).template walk_types<typename ElementType::type>();
103 std::map<control_points_enum, dag> & registry_;
114 template<
typename ControlPolicy>
117 using control_points_enum =
typename ControlPolicy::control_points_enum;
118 using node_type =
typename ControlPolicy::node_type;
121 std::map<control_points_enum, std::vector<node_type const *>> sorted,
123 : sorted_(sorted), exit_status_(exit_status) {}
134 template<
typename ElementType>
138 control_points_enum>::value) {
141 for(
auto & node : sorted_[ElementType::value]) {
142 exit_status_ |= node->execute();
148 while(ElementType::predicate()) {
150 walker.template walk_types<typename ElementType::type>();
156 std::map<control_points_enum, std::vector<node_type const *>> sorted_;
161 #if defined(FLECSI_ENABLE_GRAPHVIZ) 163 template<
typename ControlPolicy>
166 using control_points_enum =
typename ControlPolicy::control_points_enum;
167 using node_type =
typename ControlPolicy::node_type;
171 static constexpr
const char *
colors[4] = {
"#77c3ec",
176 point_writer(std::map<control_points_enum, dag> registry,
179 : registry_(registry), gv_(gv), depth_(depth) {}
181 template<
typename ElementType>
184 control_points_enum>::value) {
185 auto & dag = registry_[ElementType::value];
187 auto * root = gv_.add_node(dag.label().c_str(), dag.label().c_str());
188 gv_.set_node_attribute(root,
"shape",
"box");
189 gv_.set_node_attribute(root,
"style",
"rounded");
191 if(
size_t(ElementType::value) > 0) {
192 auto & last = registry_[
static_cast<control_points_enum
>(
193 static_cast<size_t>(ElementType::value) - 1)];
194 auto * last_node = gv_.node(last.label().c_str());
195 auto * edge = gv_.add_edge(last_node, root);
196 gv_.set_edge_attribute(edge,
"color",
"#1d76db");
197 gv_.set_edge_attribute(edge,
"fillcolor",
"#1d76db");
198 gv_.set_edge_attribute(edge,
"style",
"bold");
201 dag.add(gv_, colors[static_cast<size_t>(ElementType::value) % 4]);
203 for(
auto & n : dag) {
205 auto * edge = gv_.add_edge(root, gv_.node(n->identifier().c_str()));
206 gv_.set_edge_attribute(edge,
"penwidth",
"1.5");
211 point_writer(registry_, gv_, depth_ - 1)
212 .template walk_types<typename ElementType::type>();
214 auto & begin = registry_[ElementType::begin];
215 auto & end = registry_[ElementType::end];
217 auto * edge = gv_.add_edge(
218 gv_.node(end.label().c_str()), gv_.node(begin.label().c_str()));
220 gv_.set_edge_attribute(edge,
"label",
" cycle");
221 gv_.set_edge_attribute(edge,
"color",
"#1d76db");
222 gv_.set_edge_attribute(edge,
"fillcolor",
"#1d76db");
223 gv_.set_edge_attribute(edge,
"style",
"dashed,bold");
225 if constexpr(ElementType::begin == ElementType::end) {
226 gv_.set_edge_attribute(edge,
"dir",
"back");
230 gv_.set_edge_attribute(edge,
"tailport",
"ne");
231 gv_.set_edge_attribute(edge,
"headport",
"se");
234 gv_.set_edge_attribute(edge,
"tailport",
"e");
235 gv_.set_edge_attribute(edge,
"headport",
"e");
241 static void write_sorted(
242 std::map<control_points_enum, std::vector<node_type const *>> sorted,
244 std::vector<Agnode_t *> nodes;
246 for(
auto cp : sorted) {
247 for(
auto n : cp.second) {
248 auto * node = gv.add_node(n->identifier().c_str(), n->label().c_str());
249 nodes.push_back(node);
251 gv.set_node_attribute(node,
"color",
"black");
252 gv.set_node_attribute(node,
"style",
"filled");
253 gv.set_node_attribute(
254 node,
"fillcolor", colors[static_cast<size_t>(cp.first) % 4]);
258 for(
size_t n{1}; n < nodes.size(); ++n) {
259 auto * edge = gv.add_edge(nodes[n - 1], nodes[n]);
260 gv.set_edge_attribute(edge,
"penwidth",
"1.5");
265 std::map<control_points_enum, dag> registry_;
271 #endif // FLECSI_ENABLE_GRAPHVIZ Definition: graphviz.hh:91
Definition: point_walker.hh:52
std::string type()
Definition: demangle.hh:44
void visit_type()
Definition: point_walker.hh:135
Definition: point_walker.hh:115
Definition: point_walker.hh:82
size_t colors()
Definition: execution.hh:336
Definition: point_walker.hh:46
Definition: tuple_walker.hh:34
Definition: control.hh:31