Taskflow  2.4-master-branch
Quick Start

Modern C++ Parallel Task Programming

Taskflow helps you quickly write parallel task programs with high performance scalability and simultaneous high productivity. It is faster, more expressive, fewer lines of code, and easier for drop-in integration than many of existing task programming frameworks.

performance.png

Taskflow is committed to support both academic and industry research projects, making it reliable and cost-efficient to develop large-scale parallel applications. Our users say:

  • "Taskflow has 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 helps improve the throughput of our graph processing engine in just a few hours of coding." Jean-MichaĆ«l @KDAB
  • "Best poster award for the open-source parallel programming library." 2018 Cpp Conference
  • "Second Place in Open Source Software Competition." 2019 ACM Multimedia Conference

See a quick presentation and visit our GitHub to learn more about Taskflow.

Static and Dynamic Tasking

Taskflow has a unified interface for both static tasking and dynamic tasking, allowing users to quickly master our parallel task programming model in a natural idiom.

Static Tasking Dynamic Tasking
static_graph.svg
dynamic_graph.svg

Conditional Tasking

Taskflow supports conditional tasking for you to implement cyclic and dynamic control flows that are otherwise difficult to do with existing task programming frameworks.

condition.svg

Composable 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.

framework.svg

Concurrent CPU-GPU Tasking

Taskflow supports heterogeneous tasking for you to accelerate a wide range of scientific computing applications by harnessing the power of CPU-GPU collaborative computing.

cudaflow.svg

Taskflow provides visualization and tooling (tfprof) needed for profiling Taskflow programs.

tfprof.png

How to Install Taskflow?

Taskflow is header-only and there is no need for installation. Simply download the source and copy the headers under the directory taskflow/ to your project.

~$ git clone https://github.com/taskflow/taskflow.git
~$ cd taskflow/
~$ cp -r taskflow myproject/include/

A Simple First Program

Here is a rather simple program to get you started.

#include <taskflow/taskflow.hpp> // Taskflow is header-only
int main(){
tf::Executor executor;
tf::Taskflow taskflow;
auto [A, B, C, D] = taskflow.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 |-----+
// +---+
executor.run(taskflow).wait();
return 0;
}

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.

simple.svg

Compile and Run Your First Program

Taskflow is written in C++14 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 Taskflow header files. For example, with gcc you need the -I option.

~$ g++ simple.cpp -I myproject/include/ -O2 -pthread -o simple
~$ ./simple
TaskA
TaskC
TaskB
TaskD

The execution order of B and C might differ as they can run concurrently.

Supported Compilers

To use Taskflow, you only need a compiler that supports C++14:

  • GNU C++ Compiler at least v5.0 with -std=c++14
  • Clang C++ Compiler at least v4.0 with -std=c++14
  • Microsoft Visual Studio at least v15.7 (MSVC++ 19.14)
  • AppleClang Xode Version at least v8
  • Nvidia CUDA Toolkit and Compiler (nvcc) at least v10.0 with -std=c++14

Taskflow works on Linux, Windows, and Mac OS X.

License

Taskflow is open-source under permissive MIT license.