5 #include "flow_builder.hpp" 6 #include "topology.hpp" 20 friend class Topology;
125 assert(_topologies.empty());
135 return _graph.size();
140 return _graph.empty();
155 template <
typename V>
157 for(
size_t i=0; i<_graph._nodes.size(); ++i) {
158 visitor(
Task(_graph._nodes[i]));
171 os <<
"digraph Taskflow {\n";
185 while(!stack.empty()) {
187 auto f = stack.top();
190 os <<
"subgraph cluster_p" << f <<
" {\nlabel=\"Taskflow: ";
191 if(f->_name.empty()) os <<
'p' << f;
194 _dump(os, f->_graph, stack, visited);
200 inline void Taskflow::_dump(
207 os <<
'p' << node <<
"[label=\"";
208 if(node->_name.empty()) os <<
'p' << node;
209 else os << node->_name;
213 if(node->_handle.index() == Node::CONDITION_WORK) {
214 os <<
" shape=diamond color=black fillcolor=aquamarine style=filled";
219 for(
size_t s=0; s<node->_successors.size(); ++s) {
220 if(node->_handle.index() == Node::CONDITION_WORK) {
222 os <<
'p' << node <<
" -> p" << node->_successors[s]
223 <<
" [style=dashed label=\"" << s <<
"\"];\n";
226 os <<
'p' << node <<
" -> p" << node->_successors[s] <<
";\n";
231 if(node->_parent && node->_successors.size() == 0) {
232 os <<
'p' << node <<
" -> p" << node->_parent <<
";\n";
235 if(node->_handle.index() == Node::DYNAMIC_WORK) {
237 auto& sbg = nstd::get<Node::DynamicWork>(node->_handle).subgraph;
242 os <<
"subgraph cluster_p" << node <<
" {\nlabel=\"Subflow: ";
243 if(node->_name.empty()) os <<
'p' << node;
244 else os << node->_name;
246 os <<
"\";\n" <<
"color=blue\n";
247 _dump(os, sbg, stack, visited);
254 inline void Taskflow::_dump(
261 for(
const auto& n : graph._nodes) {
264 if(n->_handle.index() != Node::MODULE_WORK) {
265 _dump(os, n, stack, visited);
270 auto module = nstd::get<Node::ModuleWork>(n->_handle).module;
272 os <<
'p' << n <<
"[shape=box, color=blue, label=\"";
273 if(n->_name.empty()) os << n;
275 os <<
" [Taskflow: ";
276 if(module->_name.empty()) os <<
'p' << module;
277 else os << module->_name;
280 if(visited.find(module) == visited.end()) {
281 visited.insert(module);
285 for(
const auto s : n->_successors) {
286 os <<
'p' << n <<
"->" <<
'p' << s <<
";\n";
Taskflow()
constructs a taskflow
Definition: core/taskflow.hpp:120
Definition: taskflow.hpp:5
void for_each_task(V &&visitor) const
applies an visitor callable to each task in the taskflow
Definition: core/taskflow.hpp:156
const std::string & name() const
queries the name of the taskflow
Definition: core/taskflow.hpp:150
void clear()
clears the associated task dependency graph
Definition: core/taskflow.hpp:129
the class to create a task dependency graph
Definition: core/taskflow.hpp:18
bool empty() const
queries the emptiness of the taskflow
Definition: core/taskflow.hpp:139
std::string dump() const
dumps the taskflow in DOT format to a std::string
Definition: core/taskflow.hpp:163
Building blocks of a task dependency graph.
Definition: flow_builder.hpp:13
task handle to a node in a task dependency graph
Definition: task.hpp:51
The executor class to run a taskflow graph.
Definition: executor.hpp:33
size_t num_tasks() const
queries the number of tasks in the taskflow
Definition: core/taskflow.hpp:134
virtual ~Taskflow()
destroy the taskflow (virtual call)
Definition: core/taskflow.hpp:124