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.

Example Brief
Wavefront Parallelism Diagonal sweep parallelism over a 2D grid where each cell depends on its left and top neighbours
Graph Traversal Parallel DAG traversal where task dependencies mirror the input graph structure
Nondeterministic Control Flow Stochastic branching using conditional tasks to express non-deterministic execution paths
Blocked Cholesky Factorization Task-parallel blocked Cholesky decomposition based on a tile dependency graph
Critical Path Scheduling PERT chart executed as a static task graph to identify the critical path
Incremental Build Graph Make-style incremental build system using condition tasks
Speculative Execution Bloom 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.

Example Brief
Fibonacci Number Recursive task parallelism using tf::Runtime and cooperative synchronization via tf::TaskGroup
Async Producer-Consumer Pipeline Overlapping producer, validator, and consumer stages using dependent-async tasks
Divide and Conquer Divide-and-conquer parallelism with tf::TaskGroup, demonstrated on parallel merge sort
Dynamic Dependency Graph Runtime-driven task graph whose topology and dependencies are determined by program data
Traveling Salesman Problem Parallel branch-and-bound solver for the traveling salesman problem
Graph Coloring Problem Parallel 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.

Example Brief
Parallel Breadth-First Search Parallel BFS using stateful frontier iteration with tf::IndexRange and atomic distance claims
Matrix Multiplication Parallel dense matrix multiplication partitioned across CPU workers
K-Means Clustering Parallel k-means clustering with iterative assignment and centroid update steps
3D Stencil Computation Parallel 3D Jacobi stencil over a volumetric grid using tf::IndexRange
Sparse Matrix-Vector Multiplication Parallel SpMV in CSR format demonstrating partitioner selection for irregular workloads
2D Image Convolution Parallel 2D image convolution using tf::IndexRange
Text Processing Pipeline Character frequency analysis expressed as a three-stage parallel pipeline
Graph Processing Pipeline Wavefront pipeline scheduling over a DAG of dependent processing stages
Taskflow Processing Pipeline Nested 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.

Example Brief
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: