forked from taskflow/taskflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuickStart.dox
More file actions
100 lines (70 loc) · 4.05 KB
/
Copy pathQuickStart.dox
File metadata and controls
100 lines (70 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
namespace tf {
/** @mainpage Quick Start
@section ModernCppParallelTaskProgrammingLibrary Modern C++ Parallel Task Programming Library
Cpp-Taskflow is by far faster, more expressive, fewer lines of code, and easier for drop-in integration
than existing parallel task programming libraries such as <a href="http://www.nersc.gov/users/software/programming-models/openmp/openmp-tasking/">OpenMP Tasking</a> and Intel <a href="https://www.threadingbuildingblocks.org/tutorial-intel-tbb-flow-graph">Thread Building Block (TBB) FlowGraph</a>.
@image html image/performance.jpg width=95%
Cpp-Taskflow is committed to support both academic and industry research projects,
making it reliable and cost-effective for long-term and large-scale developments.
Our users say:
@li \"<em>Cpp-Taskflow has the cleanest task API I've ever seen.</em>\" <a href="https://github.com/damienhocking">Damien Hocking</a>
@li \"<em>Cpp-Taskflow has a very simple and elegant tasking interface. The performance also scales very well.</em>\" <a href="https://github.com/totalgee">Glen Fraser</a>
@li \"<em>Best poster award for the open-source parallel programming library.</em>\" <a href="https://github.com/CppCon/CppCon2018">Cpp Conference 2018</a>
See a quick <a href="https://cpp-taskflow.github.io/">presentation</a> and visit our <a href="https://github.com/cpp-taskflow/cpp-taskflow">GitHub</a> to learn more about Cpp-Taskflow.
@section HowToInstallCppTaskflow How to Install Cpp-Taskflow?
Cpp-Taskflow is *header-only* and there is no need for installation.
Simply download the source and copy the headers under the @c taskflow subdirectory to your project.
@code{.sh}
~$ git clone https://github.com/cpp-taskflow/cpp-taskflow.git
~$ cd cpp-taskflow/
~$ cp -r taskflow myproject/include/
@endcode
@section ASimpleFirstProgram A Simple First Program
Here is a rather simple program to get you started.
@code{.cpp}
#include <taskflow/taskflow.hpp> // Cpp-Taskflow is header-only
int main(){
tf::Taskflow taskflow;
auto [A, B, C, D] = taskflow.silent_emplace(
[] () { std::cout << "TaskA\n"; }, // task dependency graph
[] () { std::cout << "TaskB\n"; }, //
[] () { std::cout << "TaskC\n"; }, // +---+
[] () { std::cout << "TaskD\n"; } // +---->| B |-----+
); // | +---+ |
// +---+ +-v-+
A.precede(B); // A runs before B // | A | | D |
A.precede(C); // A runs before C // +---+ +-^-+
B.precede(D); // B runs before D // | +---+ |
C.precede(D); // C runs before D // +---->| C |-----+
// +---+
taskflow.wait_for_all(); // block until finish
return 0;
}
@endcode
The program creates four tasks A, B, C, and D.
The dependency constraints force A to run before B and C, and D to run after B and C.
The maximum concurrency is this example is two, where B and C can run at the same time.
@section CompileAndRunYourFirstProgram Compile and Run Your First Program
Cpp-Taskflow is written in C++17 and is built on top of C++ standardized threading libraries.
To compile the above program, you need to tell the compiler
where to find the Cpp-Taskflow header files.
For example, with gcc you need the `-I` option.
@code{.sh}
~$ g++ simple.cpp -I myproject/include/ -std=c++17 -O2 -pthread -o simple
~$ ./simple
TaskA
TaskC
TaskB
TaskD
@endcode
The execution order of B and C might differ as they can run concurrently.
@section SupportedCompilers Supported Compilers
To use Cpp-Taskflow, you only need a compiler that supports C++17:
@li GNU C++ Compiler v7.3 with -std=c++17
@li Clang C++ Compiler v6.0 with -std=c++17
@li Microsoft Visual Studio Version 15.7 (MSVC++ 19.14)
Cpp-Taskflow works on Linux, Windows, and OSX.
@section License License
Cpp-Taskflow is open-source under permissive MIT license.
*/
}