Back to Taskflow

Task Graph

docs/Examples.html

4.1.07.1 KB
Original Source

| | Taskflow: A General-purpose Task-parallel Programming System |

Loading...

Searching...

No Matches

Learning from Examples

This page collects self-contained examples that demonstrate Taskflow across a broad range of parallel programming patterns, from classic graph algorithms and numerical computing to dynamic task graphs, async pipelines, and GPU acceleration. Each example is designed to be read independently and includes a problem formulation, a parallel implementation, and a discussion of the key Taskflow features at work.

Task Graph

These examples demonstrate how to express parallelism as a static task dependency graph using tf::Taskflow, including conditional and non-deterministic control flow.

ExampleBrief
Wavefront ParallelismDiagonal sweep parallelism over a 2D grid where each cell depends on its left and top neighbours
Graph TraversalParallel DAG traversal where task dependencies mirror the input graph structure
Nondeterministic Control FlowStochastic branching using conditional tasks to express non-deterministic execution paths
Blocked Cholesky FactorizationTask-parallel blocked Cholesky decomposition based on a tile dependency graph
Critical Path SchedulingPERT chart executed as a static task graph to identify the critical path
Incremental Build GraphMake-style incremental build system using condition tasks
Speculative ExecutionBloom filter simualtion using condition tasks

Links to each example subpage are provided below:

Async Tasking

These examples focus on Taskflow's dynamic task creation capabilities, including async tasks, dependent-async task graphs, cooperative execution, and recursive runtime tasking.

ExampleBrief
Fibonacci NumberRecursive task parallelism using tf::Runtime and cooperative synchronization via tf::TaskGroup
Async Producer-Consumer PipelineOverlapping producer, validator, and consumer stages using dependent-async tasks
Divide and ConquerDivide-and-conquer parallelism with tf::TaskGroup, demonstrated on parallel merge sort
Dynamic Dependency GraphRuntime-driven task graph whose topology and dependencies are determined by program data
Traveling Salesman ProblemParallel branch-and-bound solver for the traveling salesman problem
Graph Coloring ProblemParallel branch-and-bound solver for the graph coloring problem

Links to each example subpage are provided below:

Parallel Algorithms

These examples apply Taskflow's parallel algorithms and pipeline scheduling to classic computational and data-processing problems.

ExampleBrief
Parallel Breadth-First SearchParallel BFS using stateful frontier iteration with tf::IndexRange and atomic distance claims
Matrix MultiplicationParallel dense matrix multiplication partitioned across CPU workers
K-Means ClusteringParallel k-means clustering with iterative assignment and centroid update steps
3D Stencil ComputationParallel 3D Jacobi stencil over a volumetric grid using tf::IndexRanges
Sparse Matrix-Vector MultiplicationParallel SpMV in CSR format demonstrating partitioner selection for irregular workloads
2D Image ConvolutionParallel 2D image convolution using tf::IndexRanges
Text Processing PipelineCharacter frequency analysis expressed as a three-stage parallel pipeline
Graph Processing PipelineWavefront pipeline scheduling over a DAG of dependent processing stages
Taskflow Processing PipelineNested taskflow graphs embedded inside pipeline stages for hierarchical parallelism

Links to each example subpage are provided below:

GPU Task Graph

These examples demonstrate how to offload computation to a CUDA GPU using tf::cudaGraph, coordinated with CPU tasks in a single taskflow.

ExampleBrief
Matrix Multiplication (CUDA)GPU-accelerated dense matrix multiplication using tf::cudaGraph coordinated with CPU tasks
K-Means Clustering (CUDA)GPU-accelerated k-means clustering with CUDA kernels for assignment and centroid update

Links to each example subpage are provided below: