[llvm-branch-commits] [OpenMP] New taskgraph runtime implementation (PR #194047)

Julian Brown via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Apr 24 13:54:03 PDT 2026


https://github.com/jtb20 created https://github.com/llvm/llvm-project/pull/194047

This patch contains the bulk of the new runtime support for taskgraph
record/replay.

Key points are as follows.

The task/taskdata structures and the dependencies between them are
duplicated whilst recording a taskgraph, keeping the existing runtime
dependency handling unaffected by the taskgraph implementation --
e.g. during runtime execution, it is valid for output dependencies can
be dropped as soon as the producing task completes. This separation
is intended to eliminate a class of race conditions, where tasks which
complete unpredictably might or might not be marked as having a subsequent
task depending on them.

The dependencies between tasks in a taskgraph are processed by static
analysis: the high-level process is akin to turning data dependencies
between tasks into control-flow dependencies. This is done by building
a set of successors and predecessors for each recorded task, then
decomposing the resulting DAG into parallel and sequential regions. In the
(presumed relatively unlikely, in real-world code) case that the graph
is irreducible, a further set of analyses and transformations is done,
and the parallel-sequential decomposition is run again.

The output of this process is a set of nested kmp_taskgraph_region
structures -- parallel or sequential (with some number of children),
or nodes representing a single task. The two phases alternate until we
obtain a single, top-level region.

Replaying a taskgraph processed in this way on the CPU involves another
set of linked structures, of type kmp_taskgraph_exec_descr. These form
a kind of trace of a traversal over the kmp_taskgraph_region structure,
so that a pointer to a kmp_taskgraph_exec_descr is somewhat equivalent
to a "program counter".

Recorded taskgraphs are located directly by using a handle passed in
from the user's compiled program, rather than using a linked list or
hashtable to find taskgraph records to replay keyed by an index.

commit-id:47e383a2





More information about the llvm-branch-commits mailing list