75 friend class Topology;
252 template <
typename V>
298 _topologies =
std::move(rhs._topologies);
299 _satellite = rhs._satellite;
301 rhs._satellite.reset();
310 _topologies =
std::move(rhs._topologies);
311 _satellite = rhs._satellite;
312 rhs._satellite.reset();
324 return _graph.
size();
329 return _graph.
empty();
350 for(
size_t i=0; i<_graph._nodes.size(); ++i) {
351 visitor(
Task(_graph._nodes[i]));
364 os <<
"digraph Taskflow {\n";
375 dumper.stack.push({
nullptr, top});
376 dumper.visited[top] = dumper.id++;
378 while(!dumper.stack.empty()) {
380 auto [p, f] = dumper.stack.top();
383 os <<
"subgraph cluster_p" << f <<
" {\nlabel=\"";
387 os <<
'm' << dumper.visited[f];
392 if(_name.empty()) os <<
'p' <<
this;
398 _dump(os, f, dumper);
404inline void Taskflow::_dump(
408 os <<
'p' << node <<
"[label=\"";
409 if(node->_name.empty()) os <<
'p' << node;
410 else os << node->_name;
414 switch(node->_handle.index()) {
416 case Node::CONDITION:
417 case Node::MULTI_CONDITION:
418 os <<
"shape=diamond color=black fillcolor=aquamarine style=filled";
422 os <<
"shape=component";
426 os <<
" style=\"filled\""
427 <<
" color=\"black\" fillcolor=\"purple\""
428 <<
" fontcolor=\"white\""
429 <<
" shape=\"folder\"";
433 os <<
" style=\"filled\""
434 <<
" color=\"black\" fillcolor=\"red\""
435 <<
" fontcolor=\"white\""
436 <<
" shape=\"folder\"";
445 for(
size_t s=0; s<node->_successors.size(); ++s) {
446 if(node->_is_conditioner()) {
448 os <<
'p' << node <<
" -> p" << node->_successors[s]
449 <<
" [style=dashed label=\"" << s <<
"\"];\n";
451 os <<
'p' << node <<
" -> p" << node->_successors[s] <<
";\n";
456 if(node->_parent && node->_parent->_handle.index() == Node::DYNAMIC &&
457 node->_successors.size() == 0
459 os <<
'p' << node <<
" -> p" << node->_parent <<
";\n";
463 switch(node->_handle.index()) {
465 case Node::DYNAMIC: {
468 os <<
"subgraph cluster_p" << node <<
" {\nlabel=\"Subflow: ";
469 if(node->_name.empty()) os <<
'p' << node;
470 else os << node->_name;
472 os <<
"\";\n" <<
"color=blue\n";
473 _dump(os, &sbg, dumper);
479 case Node::CUDAFLOW: {
481 os, node, node->_name
486 case Node::SYCLFLOW: {
488 os, node, node->_name
499inline void Taskflow::_dump(
503 for(
const auto& n :
graph->_nodes) {
506 if(n->_handle.index() != Node::MODULE) {
507 _dump(os, n, dumper);
512 auto module = &(std::get_if<Node::Module>(&n->_handle)->graph);
514 os <<
'p' << n <<
"[shape=box3d, color=blue, label=\"";
515 if(n->_name.empty()) os <<
'p' << n;
518 if(dumper.visited.find(module) == dumper.visited.end()) {
519 dumper.visited[module] = dumper.id++;
520 dumper.stack.push({n,
module});
523 os <<
" [m" << dumper.visited[module] <<
"]\"];\n";
525 for(
const auto s : n->_successors) {
526 os <<
'p' << n <<
"->" <<
'p' << s <<
";\n";
581 constexpr static auto ASYNC = get_index_v<std::weak_ptr<AsyncTopology>, handle_t>;
582 constexpr static auto TASKFLOW = get_index_v<std::weak_ptr<Topology>, handle_t>;
629 template <
typename P>
649 auto ptr = arg.lock();
class to create an executor for running a taskflow graph
Definition executor.hpp:50
class to build a task dependency graph
Definition flow_builder.hpp:21
class to access the result of an execution
Definition core/taskflow.hpp:571
bool cancel()
cancels the execution of the running taskflow associated with this future object
Definition core/taskflow.hpp:642
Future()=default
default constructor
Future(const Future &)=delete
disabled copy constructor
Future(Future &&)=default
default move constructor
class to create a graph object
Definition graph.hpp:56
bool empty() const
queries if the graph is empty
Definition graph.hpp:770
size_t size() const
queries the number of nodes in the graph
Definition graph.hpp:765
class to construct a subflow graph from the execution of a dynamic task
Definition flow_builder.hpp:889
class to create a task handle over a node in a taskflow graph
Definition task.hpp:187
class to create a taskflow object
Definition core/taskflow.hpp:73
void clear()
clears the associated task dependency graph
Definition core/taskflow.hpp:318
bool empty() const
queries the emptiness of the taskflow
Definition core/taskflow.hpp:328
void for_each_task(V &&visitor) const
applies a visitor to each task in the taskflow
Definition core/taskflow.hpp:349
Graph & graph()
returns a reference to the underlying graph object
Definition core/taskflow.hpp:343
const std::string & name() const
queries the name of the taskflow
Definition core/taskflow.hpp:338
std::string dump() const
dumps the taskflow to a std::string of DOT format
Definition core/taskflow.hpp:356
Taskflow & operator=(Taskflow &&rhs)
move assignment operator
Definition core/taskflow.hpp:305
~Taskflow()=default
default destructor
Taskflow()
constructs a taskflow
Definition core/taskflow.hpp:288
size_t num_tasks() const
queries the number of tasks
Definition core/taskflow.hpp:323
flow builder include file
taskflow namespace
Definition small_vector.hpp:27
@ ASYNC
asynchronous task type