Taskflow  2.4-master-branch
Building and Installing

This page describes how to set up Taskflow in your project. We will also go through the building process of unit tests and examples.

Setting Up 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/

Compile and Link Flags

Taskflow is written in C++14 and is built on top of C++ standardized threading libraries to improve portability. To compile a Taskflow program, say simple.cpp, you need to tell the compiler where to find the Taskflow header files and link it through the system thread library (usually POSIX threads in Linux-like systems). Take gcc for an example:

~$ g++ simple.cpp -I myproject/include/ -O2 -pthread -o simple

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.

Build Examples, Tests, and Benchmarks

Taskflow uses CMake to build examples and unit tests. We recommend using out-of-source build.

~$ cd path/to/taskflow
~$ mkdir build
~$ cd build
~$ cmake ../
~$ make # compile all examples and unittests
~$ make test
Running tests...
/usr/bin/ctest --force-new-ctest-process
Test project /home/tsung-wei/Code/taskflow/build
Start 1: passive_vector
1/254 Test #1: passive_vector ................... Passed 0.04 sec
Start 2: function_traits
2/254 Test #2: function_traits .................. Passed 0.00 sec
Start 3: object_pool.sequential
3/254 Test #3: object_pool.sequential ........... Passed 0.10 sec
...
Start 253: cuda_kmeans.1000.8C8G
253/254 Test #253: cuda_kmeans.1000.8C8G ............ Passed 0.19 sec
Start 254: cuda_kmeans.1000.16C16G
254/254 Test #254: cuda_kmeans.1000.16C16G .......... Passed 0.24 sec
100% tests passed, 0 tests failed out of 254
Total Test time (real) = 29.67 sec

When the building completes, you can find the executables for examples and tests under the two folders, examples/ and unittests/. By default, our CMake script automatically detects the existence of a CUDA compiler and compiles all GPU tests and examples if one is available. You may list a set of available options in the cmake.

~$ cmake -LA
...
TF_BUILD_BENCHMARKS:BOOL=OFF # by default, we don't compile benchmarks due to long compilation time

We have developed a set of micro-benchmarks comparing Taskflow with OpenMP Task Dependency Clause and Intel TBB FlowGraph. To build these benchmarks, you need to configure the option TF_BUILD_BENCHMARKS to ON.

~$ cmake ../ -DTF_BUILD_BENCHMARKS=ON
~$ make

You can find the binary of each benchmark under the folder benchmarks/.