Taskflow helps you quickly write parallel and heterogeneous tasks programs in modern C++
Taskflow is faster, more expressive, and easier for drop-in integration than many of existing task programming frameworks in handling complex parallel workloads.
Taskflow lets you quickly implement task decomposition strategies that incorporate both regular and irregular compute patterns, together with an efficient work-stealing scheduler to optimize your multithreaded performance.
Static Tasking | Dynamic Tasking |
---|---|
Taskflow supports conditional tasking for you to make rapid control-flow decisions across dependent tasks to implement cycles and conditions that were otherwise difficult to do with existing tools.
Conditional Tasking |
---|
Taskflow is composable. You can create large parallel graphs through composition of modular and reusable blocks that are easier to optimize at an individual scope.
Taskflow Composition |
---|
Taskflow supports heterogeneous tasking for you to accelerate a wide range of scientific computing applications by harnessing the power of CPU-GPU collaborative computing.
Concurrent CPU-GPU Tasking |
---|
Taskflow provides visualization and tooling needed for profiling Taskflow programs.
Taskflow Profiler |
---|
We are committed to support trustworthy developments for both academic and industrial research projects in parallel computing. Check out Who is Using Taskflow and what our users say:
- "Taskflow is the cleanest Task API I've ever seen." Damien Hocking @Corelium Inc
- "Taskflow has a very simple and elegant tasking interface. The performance also scales very well." Glen Fraser
- "Taskflow lets me handle parallel processing in a smart way." Hayabusa @Learning
- "Taskflow improves the throughput of our graph engine in just a few hours of coding." Jean-Michaël @KDAB
- "Best poster award for open-source parallel programming library." Cpp Conference 2018
- "Second Prize of Open-source Software Competition." ACM Multimedia Conference 2019
See a quick presentation and visit the documentation to learn more about Taskflow. Technical details can be referred to our IPDPS paper.
The following program (simple.cpp
) creates four tasks
A
, B
, C
, and D
, where A
runs before B
and C
, and D
runs after B
and C
.
When A
finishes, B
and C
can run in parallel.
#include <taskflow/taskflow.hpp> // Taskflow is header-only
int main(){
tf::Executor executor;
tf::Taskflow taskflow;
auto [A, B, C, D] = taskflow.emplace( // create 4 tasks
[] () { std::cout << "TaskA\n"; },
[] () { std::cout << "TaskB\n"; },
[] () { std::cout << "TaskC\n"; },
[] () { std::cout << "TaskD\n"; }
);
A.precede(B, C); // A runs before B and C
D.succeed(B, C); // D runs after B and C
executor.run(taskflow).wait();
return 0;
}
Taskflow is header-only and there is no wrangle with installation. To compile the program, clone the Taskflow project and tell the compiler to include the headers.
~$ git clone https://github.com/taskflow/taskflow.git # clone it only once
~$ g++ -std=c++17 simple.cpp -I taskflow/taskflow -O2 -pthread -o simple
~$ ./simple
TaskA
TaskC
TaskB
TaskD
Taskflow comes with a built-in profiler, TFProf, for you to profile and visualize taskflow programs in an easy-to-use web-based interface.
# run the program with the environment variable TF_ENABLE_PROFILER enabled
~$ TF_ENABLE_PROFILER=simple.json ./simple
~$ cat simple.json
[
{"executor":"0","data":[{"worker":0,"level":0,"data":[{"span":[172,186],"name":"0_0","type":"static"},{"span":[187,189],"name":"0_1","type":"static"}]},{"worker":2,"level":0,"data":[{"span":[93,164],"name":"2_0","type":"static"},{"span":[170,179],"name":"2_1","type":"static"}]}]}
]
# paste the profiling json data to https://taskflow.github.io/tfprof/
In addition to execution diagram, you can dump the graph to a DOT format and visualize it using a number of free GraphViz tools.
// dump the taskflow graph to a DOT format through std::cout
taskflow.dump(std::cout);
To use Taskflow, you only need a compiler that supports C++17:
- GNU C++ Compiler at least v7.0 with -std=c++17
- Clang C++ Compiler at least v6.0 with -std=c++17
- Microsoft Visual Studio at least v19.27 with /std:c++17
- AppleClang Xode Version at least v12.0 with -std=c++17
- Nvidia CUDA Toolkit and Compiler (nvcc) at least v11.1 with -std=c++17
- Intel C++ Compiler (nvcc) at least v19.0.1 with -std=c++17
Taskflow works on Linux, Windows, and Mac OS X.
Visit our project website and documentation to learn more about Taskflow. To get involved:
- See release notes to stay up-to-date with newest versions
- Read the step-by-step tutorial at cookbook
- Submit an issue at GitHub issues
- Find out our technical details at references
- Watch our technical talks at YouTube
CppCon20 Tech Talk | MUC++ Tech Talk |
---|---|
We are committed to support trustworthy developments for both academic and industrial research projects in parallel and heterogeneous computing. At the same time, we appreciate all Taskflow contributors!
Taskflow is licensed with the MIT License. You are completely free to re-distribute your work derived from Taskflow.