This presentation introduces Taskflow, an open-source C++ library designed to simplify parallel and heterogeneous (CPU/GPU) programming. The speaker addresses the significant challenges developers face with traditional parallel computing tools, particularly for applications with large-scale, irregular task dependencies and complex algorithmic control flows, such as those found in VLSI CAD and machine learning.
Taskflow offers a solution through an expressive task-graph programming model with a unified API. A key innovation is conditional tasking, which allows developers to natively embed dynamic control flows (like loops and branches) into the task graph. This avoids the performance penalties of synchronization and the high memory cost of unrolling graphs, common limitations in other frameworks. The library also features CudaFlow for efficiently managing and offloading GPU workloads using CUDA Graphs, and a dynamic work-stealing scheduler optimized for performance and energy efficiency. Performance benchmarks and real-world use cases demonstrate that Taskflow can significantly outperform comparable libraries like Intel TBB and StarPU in both runtime and memory usage for complex, iterative applications.
Taskflow: A C++ Library for Simplified Parallel and Heterogeneous Computing
0:00:19 The Challenge of Parallel Computing: Writing correct and efficient parallel programs is difficult due to the need to manage concurrency, task dependencies, and data races. Taskflow is an open-source C++ library designed to make this easier.
0:01:37 Core Goal: Taskflow aims to provide C++ developers with a high-productivity, high-performance way to write parallel and heterogeneous (CPU/GPU) programs by abstracting away low-level parallelization details.
0:02:24 Simple and Expressive API: The library uses an intuitive graph description language. A simple example demonstrates creating four tasks (A, B, C, D) and defining their dependencies (e.g., A must run before B and C) in just a few lines of code.
0:05:20 Motivation from Real-World Problems: The project was motivated by the needs of VLSI Computer-Aided Design (CAD), which involves millions of dependent tasks with complex, cyclical, and dynamic control flows that are difficult to express with existing tools like OpenMP or TBB.
0:11:13 Key Task Types: Taskflow provides several types of tasks that can be combined in a single graph:
Dynamic Tasks (Subflows): Allows a task to spawn a new, nested task graph during its execution.
CudaFlow Tasks: Describes a GPU workload as a task graph, including data transfers and kernel launches, which is then efficiently offloaded using CUDA Graphs to reduce overhead.
Conditional Tasks: A powerful and unique feature that enables dynamic control flow (loops, branches) by allowing a task to decide which successor to run next.
0:23:33 Conditional Tasking for Control Flow: Unlike most libraries that require acyclic graphs, Taskflow's conditional tasks allow for building iterative and conditional logic directly into the parallel graph. This avoids unrolling loops (saving significant memory) and eliminates the need for synchronization between iterations.
0:31:16 Two-Level Scheduling Algorithm: Taskflow uses a sophisticated scheduler to manage execution:
Task-level: Manages the task queue, correctly handling control flow from conditional tasks to prevent race conditions.
Worker-level: Uses a work-stealing algorithm to dynamically balance the load across CPU and GPU worker threads, adapting the number of active threads to the available parallelism to maximize performance and energy efficiency.
Microbenchmarks: Show that Taskflow has lower programming complexity and faster task creation overhead compared to OpenMP, TBB, and HPX. It delivers better runtime performance and energy efficiency.
Machine Learning Application: In a deep neural network inference task, Taskflow was 2x faster and used 1.6x less memory than TBB and StarPU, primarily due to its efficient handling of the iterative workload with conditional tasks.
0:46:15 VLSI Placement Application: In another complex optimization problem, Taskflow again demonstrated superior performance and drastically lower memory consumption compared to alternatives that had to unroll the iterative task graph.
0:52:27 Vision for C++ Parallelism: The speaker argues that Taskflow complements existing tools by addressing the critical need for a library that excels at task-graph parallelism with integrated control flow. Future plans include integrating other backends like SYCL and OpenCL.