Abstract
Taskflow aims to streamline the building of parallel and heterogeneous applications using a lightweight task graph-based approach. Taskflow introduces an expressive task graph programming model to assist developers in the implementation of parallel and heterogeneous decomposition strategies on a heterogeneous computing platform. Our programming model distinguishes itself as a very general class of task graph parallelism with in-graph control flow to enable end-to-end parallel optimization. To support our model with high performance, we design an efficient system runtime that solves many of the new scheduling challenges arising out of our models and optimizes the performance across latency, energy efficiency, and throughput. We have demonstrated the promising performance of Taskflow in real-world applications. As an example, Taskflow solves a large-scale machine learning workload up to 29% faster, 1.5× less memory, and 1.9× higher throughput than the industrial system, oneTBB, on a machine of 40 CPUs and 4 GPUs. We have opened the source of Taskflow and deployed it to large numbers of users in the open-source community.
Introduction
Parallel programming is often a tug-of-war between performance and programmability. While Task Graph Computing Systems (TGCS) have helped developers manage complex dependencies, they have historically struggled with two primary challenges: integrating "if-else" control logic and managing heterogeneous hardware (CPUs vs. GPUs). Most existing frameworks rely on Directed Acyclic Graphs (DAGs). However, real-world algorithms frequently involve loops and conditional branches. Currently, developers must either "unroll" these loops—creating massive, memory-intensive graphs—or synchronize with the main thread, which introduces significant synchronization overhead and "gaps" in parallelism.
The Taskflow Programming Model
Taskflow addresses these limitations by introducing a lightweight C++ library that allows developers to build complex, heterogeneous task graphs with native control flow. The model supports four distinct task types:
- Static Tasks: Standard functions or lambdas.
- Dynamic Tasks: Tasks that can spawn additional sub-tasks during execution.
- Module Tasks: Reusable graph components for modular design.
- Condition Tasks: The core innovation for control flow.
Condition tasks act as decision-makers within the graph. Instead of simply completing, a condition task returns an integer that directs the scheduler to the next successor task. This enables the native implementation of complex branching logic directly within the graph structure.
In-Graph Control Flow and Looping
By distinguishing between strong dependencies (precedence constraints) and weak dependencies (conditional jumps), Taskflow can safely handle cycles and loops without causing task races. This "in-graph" approach allows the scheduler to maintain a global view of the workload, overlapping condition checks with other independent tasks to hide latency.
For heterogeneous workloads, Taskflow introduces cudaFlow, which describes GPU tasks as graphs that the runtime maps to native CUDA Graphs. This reduces the overhead associated with launching numerous small GPU kernels.
Performance Evaluation
Taskflow was benchmarked against industry standards including Intel oneTBB, StarPU, and OpenMP across several domains:
- Machine Learning: On the LSDNN workload (40 CPUs, 4 GPUs), Taskflow achieved 29% faster execution and 1.5× lower memory usage than oneTBB.
- CAD Tools: In VLSI incremental timing analysis, Taskflow demonstrated superior scalability as iteration counts increased.
- System Overhead: Taskflow recorded a task creation overhead of only 61ns, making it highly efficient for fine-grained parallelism.
- Energy Efficiency: An adaptive work-stealing algorithm using a two-phase commit protocol minimizes "busy-waiting," leading to lower total energy consumption compared to competitors.
Conclusion
Taskflow provides a powerful, lightweight solution for modern parallel computing by integrating control flow directly into task graphs. While currently focused on single-node performance, future work includes extending the model to distributed environments and integrating with SYCL for broader accelerator support.
Summary updated