Skip to content

What is TaskFlow?

Christian Relf edited this page Jun 10, 2025 · 1 revision

Taskflow Wiki Documentation

Introduction to Taskflow

Taskflow is a powerful and versatile general-purpose task-parallel programming system designed for modern C++. It enables developers to efficiently implement parallel and heterogeneous task programs with high performance and productivity. Taskflow is known for being faster, more expressive, requiring fewer lines of code, and being easier to integrate into existing projects compared to many other task programming frameworks.

It excels at handling complex parallel workloads by allowing you to quickly implement task decomposition strategies, incorporating both regular and irregular compute patterns. Taskflow leverages an efficient work-stealing scheduler to optimize multithreaded performance.

Key Advantages:

  • Performance: Optimized for speed and efficiency in parallel execution.
  • Expressiveness: Provides an intuitive way to define complex task dependencies and control flows.
  • Ease of Integration: A header-only library, simplifying setup and compilation.

Core Features

Taskflow offers a rich set of features to express and manage parallel tasks:

  • Static Tasking: Define a fixed task graph at compile time.
  • Subflow Tasking (Dynamic Parallelism): Create new task graphs from within the execution of a task, enabling recursive parallelism.
  • Conditional Tasking: Implement rapid control-flow decisions across dependent tasks, allowing for cycles and conditions within an end-to-end task graph.
  • Composable Task Graphs: Build large parallel graphs by composing modular and reusable blocks, which are easier to optimize individually.
  • Heterogeneous Tasking (CPU-GPU): Accelerate scientific computing applications by offloading tasks to GPUs using Nvidia CUDA Graph.
  • Asynchronous Tasking: Launch tasks asynchronously to dynamically explore task graph parallelism.
  • Standard Parallel Algorithms: Leverage built-in algorithms for common parallel patterns like iterations, transforms, reductions, and sorting.
  • Visualization and Profiling: Includes tools like the Taskflow Profiler for visualizing and analyzing taskflow programs, aiding in performance optimization.

Getting Started

Taskflow is a header-only library, which means there's no complex installation process.

Prerequisites

To use Taskflow, you only need a C++17 compatible compiler. Supported compilers include:

  • GNU C++ Compiler (v8.4 or newer) with -std=c++17
  • Clang C++ Compiler (v6.0 or newer) with -std=c++17
  • Microsoft Visual Studio (v19.14 or newer) with /std:c++17
  • AppleClang Xcode Version (v12.0 or newer) with -std=c++17
  • Nvidia CUDA Toolkit and Compiler (nvcc v11.1 or newer) with -std=c++17 (for GPU tasking)
  • Intel C++ Compiler (v19.0.1 or newer) with -std=c++17
  • Intel DPC++ Clang Compiler (v13.0.0 or newer) with -std=c++17 and SYCL20

Basic Setup

  1. Clone the Taskflow repository:

    git clone https://github.com/taskflow/taskflow.git
  2. Include headers in your project: Simply tell your compiler to include the headers from the cloned taskflow/ directory.

    Example compilation for a simple C++ program (simple.cpp):

    g++ -std=c++20 examples/simple.cpp -I taskflow/ -O2 -pthread -o simple
    ./simple

Example Use Cases

Taskflow has been successfully applied in various domains, including:

  • Computer-aided Design (CAD) Software: Parallelizing CAD algorithms and software that scale to millions of tasks on multi-core CPUs and GPUs.
  • Quantum Computing: Accelerating the simulation of quantum circuits in both static and dynamic environments.
  • Machine Learning: Designing efficient model- and data-parallel algorithms for scaling large-scale machine learning workloads with billions of parameters.

Clone this wiki locally