Taskflow  2.7.0
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 and Unit Tests

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.

Available CMake Options

You can list a set of available options in the cmake.

~$ cmake -LA
...
TF_BUILD_BENCHMARKS:BOOL=OFF # by default, we don't compile benchmarks
TF_BUILD_CUDA:BOOL=ON # by default, we compile CUDA code
...
... more options

Currently, our CMake script supports the following options:

CMake Option Default Usage
TF_BUILD_BENCHMARKS OFF enable/disable building benchmarks
TF_BUILD_CUDA ON enable/disable building CUDA code
TF_BUILD_EXAMPLES ON enable/disable building examples
TF_BUILD_TESTS ON enable/disable building unit tests

To enable or disable a specific option, use -D in the CMake build. For example:

~$ cmake ../ -DTF_BUILD_CUDA=OFF # disable building CUDA code

Build Benchmarks

We have developed a set of benchmarks comparing Taskflow with OpenMP and Intel Threading Building Blocks (TBB) libraries. 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/.