You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `composed_of` method returns a *module task* and you can use the `precede` and `gather`
526
-
methods to define its dependencies. A framework can be used to compose multiple
527
-
frameworks and a framework can compose the resulting frameworks to achieve nested composition.
528
-
529
508
509
+
The `composed_of` method returns a *module task* and you can use the `precede` and `gather`
510
+
methods to define its dependencies.
511
+
You can compose a framework from multiple frameworks and use the resulting framework
512
+
to compose another larger ones and so on so forth.
530
513
531
514
532
515
# Debug a Taskflow Graph
@@ -625,11 +608,10 @@ auto [f1A, f1B, f1C] = f1.emplace(
625
608
[]() { std::cout << "Task f1B\n"; },
626
609
[]() { std::cout << "Task f1C\n"; }
627
610
);
611
+
628
612
f1A.precede(f1B, f1C).name("f1A");
629
613
f1B.name("f1B");
630
614
f1C.name("f1C");
631
-
632
-
// Name the framework
633
615
f1.name("f1");
634
616
635
617
tf::Framework f2;
@@ -639,45 +621,40 @@ auto [f2A, f2B, f2C] = f2.emplace(
639
621
[]() { std::cout << "Task f2B\n"; },
640
622
[]() { std::cout << "Task f2C\n"; }
641
623
);
642
-
// Compose framework f1
624
+
643
625
auto f1_module_task = f2.composed_of(f1);
644
626
f2A.precede(f1_module_task).name("f2A");
645
627
f2B.precede(f1_module_task).name("f2B");
646
628
f1_module_task.precede(f2C).name("module_f1");
647
-
f2C.name("f2C");
648
629
649
-
// Name the framework
630
+
f2C.name("f2C");
650
631
f2.name("f2");
651
632
652
-
// Dump the framework
653
-
f2.dump(std::cout);
633
+
f2.dump(std::cout); // dump the framework
654
634
```
655
635
656
-
657
-
658
-
659
-
660
636
# API Reference
661
637
638
+
The official [documentation][wiki] explains the complete list of
639
+
Cpp-Taskflow API.
640
+
In section, we highlight a short list of commonly used methods.
641
+
662
642
## Taskflow API
663
643
664
644
The class `tf::Taskflow` is the main place to create and execute task dependency graph.
665
645
The table below summarizes a list of commonly used methods.
666
-
Visit [documentation][wiki] to see the complete list.
646
+
667
647
668
648
| Method | Argument | Return | Description |
669
649
| -------- | --------- | ------- | ----------- |
670
-
| Taskflow | none | none | construct a taskflow with the worker count equal to max hardware concurrency |
671
650
| Taskflow | size | none | construct a taskflow with a given number of workers |
672
651
| emplace | callables | tasks | create a task with a given callable(s) |
673
652
| placeholder | none | task | insert a node without any work; work can be assigned later |
674
-
| linearize | task list | none | create a linear dependency in the given task list |
675
653
| parallel_for | beg, end, callable, group | task pair | apply the callable in parallel and group-by-group to the result of dereferencing every iterator in the range |
676
654
| parallel_for | beg, end, step, callable, group | task pair | apply the callable in parallel and group-by-group to a index-based range |
677
655
| reduce | beg, end, res, bop | task pair | reduce a range of elements to a single result through a binary operator |
678
656
| transform_reduce | beg, end, res, bop, uop | task pair | apply a unary operator to each element in the range and reduce them to a single result through a binary operator |
679
657
| dispatch | none | future | dispatch the current graph and return a shared future to block on completion |
680
-
| silent_dispatch | none | none | dispatch the current graph |
681
658
| wait_for_all | none | none | dispatch the current graph and block until all graphs finish, including all previously dispatched ones, and then clear all graphs |
682
659
| wait_for_topologies | none | none | block until all dispatched graphs (topologies) finish, and then clear these graphs |
683
660
| num_nodes | none | size | query the number of nodes in the current graph |
@@ -708,17 +685,6 @@ A.precede(B);
708
685
B.work([](){ /* do something */ });
709
686
```
710
687
711
-
### *linearize*
712
-
713
-
The method `linearize` lets you add a linear dependency between each adjacent pair of a task sequence.
0 commit comments