Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 24, 2026·3 min de lecture

Taskflow — General-Purpose Parallel Programming for C++

Taskflow is a C++ library for writing parallel and heterogeneous task programs. It provides an intuitive task graph API that simplifies complex dependency patterns across CPU and GPU workloads.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Taskflow
Commande d'installation directe
npx -y tokrepo@latest install c57e2bfc-87a1-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

Taskflow is a header-only C++ library that lets developers express parallel workloads as directed task graphs. It handles scheduling, work stealing, and GPU offloading so you can focus on the structure of your computation rather than low-level threading details.

What Taskflow Does

  • Expresses complex parallel workflows as directed acyclic task graphs
  • Schedules tasks across CPU cores using an efficient work-stealing executor
  • Supports heterogeneous computing with CUDA and SYCL GPU task graphs
  • Provides composable subflow graphs for modular task decomposition
  • Handles dynamic control flow with conditional and looping constructs inside graphs

Architecture Overview

Taskflow uses a lightweight work-stealing scheduler that maps task graphs onto a thread pool. Tasks are nodes in a DAG with explicit dependencies. The executor traverses the graph, dispatching ready tasks to worker threads. For GPU work, CUDA tasks are embedded in the same graph and offloaded transparently.

Self-Hosting & Configuration

  • Header-only: add the include path and compile with C++17 or later
  • Available via vcpkg, Conan, Homebrew, and Conda
  • Enable CUDA support with -DCMAKE_CUDA_COMPILER and linking cudart
  • Control thread count via tf::Executor(N) constructor
  • Profile task graphs using the built-in TFProf timeline visualizer

Key Features

  • Header-only design with zero external dependencies
  • Work-stealing scheduler that scales linearly with core count
  • Built-in profiler that exports Chrome-tracing-compatible timelines
  • Composable subflows allow reusing graph fragments across projects
  • Benchmarks faster than OpenMP and TBB on many workloads

Comparison with Similar Tools

  • OpenMP — OpenMP uses pragma-based parallelism; Taskflow uses explicit task graphs for more flexible dependency modeling
  • Intel TBB (oneTBB) — TBB provides building blocks like parallel_for; Taskflow focuses on graph-based workflows with GPU support
  • HPX — HPX targets distributed computing; Taskflow is single-node with lower overhead
  • std::async — std::async lacks dependency control; Taskflow manages complex DAGs efficiently

FAQ

Q: Does Taskflow require C++17? A: Yes. Taskflow uses C++17 features such as std::optional, structured bindings, and if-constexpr.

Q: Can Taskflow run GPU tasks? A: Yes. Taskflow supports CUDA task graphs natively, allowing GPU kernels to participate in the same DAG as CPU tasks.

Q: How does Taskflow handle dynamic parallelism? A: Subflows can spawn new tasks at runtime, and conditional tasking allows branches and loops inside the graph.

Q: Is Taskflow thread-safe? A: The executor is thread-safe for concurrent graph submissions. Individual task graph construction is single-threaded by design.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires