Skip to content

Commit ec53d6e

Browse files
Tsung-Wei HuangTsung-Wei Huang
authored andcommitted
updated complex example
1 parent cc2ca61 commit ec53d6e

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Cpp-Taskflow lets you quickly build parallel dependency graphs using modern C++1
1212
It is by far faster, more expressive, and easier for drop-in integration than existing libraries such as [OpenMP Tasking][OpenMP Tasking] and
1313
[TBB FlowGraph][TBB FlowGraph].
1414

15+
*"Cpp-Taskflow is the cleanest Task API I've ever seen," Damien*
16+
17+
*"Cpp-Taskflow allows us to explore more parallelism that wouldn't be possible without it," OpenTimer developers*
1518

1619
# Get Started with Cpp-Taskflow
1720

@@ -52,6 +55,38 @@ TaskB <-- concurrent with TaskC
5255
TaskD
5356
```
5457

58+
It is clear now Cpp-Taskflow is powerful in parallelizing tasks with complex dependencies.
59+
The following example demonstrates a concurrent execution of 10 tasks with 15 dependencies.
60+
With Cpp-Taskflow, you only need *15 lines of code*.
61+
62+
<img align="right" src="image/complex.png" width="30%">
63+
64+
```cpp
65+
// source dependencies
66+
S.precede(a0); // S runs before a0
67+
S.precede(b0); // S runs before b0
68+
S.precede(a1); // S runs before a1
69+
70+
// a_ -> others
71+
a0.precede(a1); // a0 runs before a1
72+
a0.precede(b2); // a0 runs before b2
73+
a1.precede(a2); // a1 runs before a2
74+
a1.precede(b3); // a1 runs before b3
75+
a2.precede(a3); // a2 runs before a3
76+
77+
// b_ -> others
78+
b0.precede(b1); // b0 runs before b1
79+
b1.precede(b2); // b1 runs before b2
80+
b2.precede(b3); // b2 runs before b3
81+
b2.precede(a3); // b2 runs before a3
82+
83+
// target dependencies
84+
a3.precede(T); // a3 runs before T
85+
b1.precede(T); // b1 runs before T
86+
b3.precede(T); // b3 runs before T
87+
```
88+
89+
5590
# Create a Taskflow Graph
5691
Cpp-Taskflow has very expressive and neat methods to create dependency graphs.
5792
Most applications are developed through the following three steps.

image/complex.png

57 KB
Loading

0 commit comments

Comments
 (0)