18 #include <flecsi-config.h> 35 #if defined(FLECSI_ENABLE_GRAPHVIZ) 38 "Output a dot file of the control model. This can be processed into a pdf " 39 "using the dot command, like:\n\033[0;36m$ dot -Tpdf input.dot > " 41 {{flecsi::option_implicit,
true}, {flecsi::option_zero}});
44 "control-model-sorted",
45 "Output a dot file of the sorted control model actions.",
46 {{flecsi::option_implicit,
true}, {flecsi::option_zero}});
55 template<bool (*Predicate)(),
typename... ControlPoints>
73 template<
typename ControlPolicy>
76 using target_type = int (*)();
81 using control_points =
typename ControlPolicy::control_points;
82 using control_points_enum =
typename ControlPolicy::control_points_enum;
83 using node_policy =
typename ControlPolicy::node_policy;
91 #if defined(FLECSI_ENABLE_GRAPHVIZ) 92 using point_writer = ctrl_impl::point_writer<control<ControlPolicy>>;
100 struct control_node : node_policy {
102 template<
typename... Args>
103 control_node(target_type target, Args &&... args)
104 : node_policy(std::forward<Args>(args)...), target_(target) {}
127 init_walker(registry_).template walk_types<control_points>();
145 registry_.try_emplace(cp, *cp);
146 return registry_[cp];
153 std::map<control_points_enum, std::vector<node_type const *>> sort() {
154 std::map<control_points_enum, std::vector<node_type const *>> sorted;
155 for(
auto & d : registry_) {
156 sorted.try_emplace(d.first, d.second.sort());
166 int status{flecsi::run::status::success};
167 point_walker(sort(), status).template walk_types<control_points>();
175 #if defined(FLECSI_ENABLE_GRAPHVIZ) 178 point_writer(registry_, gv).template walk_types<control_points>();
179 std::string file =
program() +
"-control-model.dot";
181 return flecsi::run::status::control;
186 point_writer::write_sorted(sort(), gv);
187 std::string file =
program() +
"-control-model-sorted.dot";
189 return flecsi::run::status::control;
193 std::map<control_points_enum, util::dag<control_node>> registry_;
205 template<target_type Target, control_po
ints_enum ControlPo
int>
208 template<target_type U, control_po
ints_enum V>
221 template<
typename... Args>
223 : node_(util::symbol<*Target>(), Target, std::forward<Args>(args)...) {
224 instance().control_point_dag(ControlPoint).push_back(&node_);
243 template<target_type U, control_po
ints_enum V>
245 static_assert(ControlPoint == V,
246 "you cannot add dependencies between actions under different control " 248 node_.push_back(&from.node_);
255 template<target_type F>
257 node_.push_back(&from.node_);
271 return instance().run();
279 int retval{flecsi::run::status::success};
280 #if defined(FLECSI_ENABLE_GRAPHVIZ) 281 if(control_model_option.has_value()) {
282 retval |= instance().write();
284 if(control_model_sorted_option.has_value()) {
285 retval |= instance().write_sorted();
action(Args &&... args)
Definition: control.hh:222
Definition: graphviz.hh:91
static int execute()
Definition: control.hh:270
Definition: control.hh:206
Definition: control.hh:231
dependency add(action< U, V > const &from)
Definition: control.hh:244
Definition: constant.hh:22
std::string const & program()
Definition: execution.hh:276
decltype(auto) execute(ARGS &&... args)
Definition: execution.hh:382
static int check_options()
Definition: control.hh:278
Definition: execution.hh:117
Definition: point_walker.hh:115
Definition: control.hh:74
Definition: point_walker.hh:82
Definition: point_walker.hh:46
Definition: control.hh:31