Skip to content

[OpenMP] New taskgraph runtime implementation - #194047

Closed
jtb20 wants to merge 6 commits into
users/jtb20/spr/main.openmp-new-taskgraph-runtime-implementationfrom
users/jtb20/spr/openmp-new-taskgraph-runtime-implementation
Closed

[OpenMP] New taskgraph runtime implementation#194047
jtb20 wants to merge 6 commits into
users/jtb20/spr/main.openmp-new-taskgraph-runtime-implementationfrom
users/jtb20/spr/openmp-new-taskgraph-runtime-implementation

Conversation

@jtb20

@jtb20 jtb20 commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

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

Created using spr 1.3.5
@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label Apr 24, 2026
@github-actions

github-actions Bot commented Apr 24, 2026

Copy link
Copy Markdown

✅ With the latest revision this PR passed the C/C++ code formatter.

jtb20 added 2 commits April 27, 2026 14:12
Created using spr 1.3.5
Created using spr 1.3.5
Created using spr 1.3.5
@shiltian

shiltian commented May 1, 2026

Copy link
Copy Markdown
Contributor

Is there any way that I can jump between PRs in this stack?

@jtb20

jtb20 commented May 1, 2026

Copy link
Copy Markdown
Contributor Author

#188765 has a list of the first few (they're consecutive), but other than that, not sure! Perhaps that's a drawback of SPR?

@shiltian

shiltian commented May 1, 2026

Copy link
Copy Markdown
Contributor

You might want to consider adding such a list in the description of each PR; otherwise IMHO it is hard to track the order and understand what is going on here.

@jtb20

jtb20 commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Stack as of now:
[OpenMP] Add taskgraph template interaction codegen tests #200409
[OpenMP] Constructor and destructor fixes for tasks cloned for recorded taskgraphs #200408
[Clang][OpenMP] Restrict 'saved' firstprivate modifier to admissible directives #200407
[Clang][OpenMP] Parsing, serialisation and deserialisation for the 'saved' firstprivate modifier #200406
[OpenMP] Extend taskgraph shared-data relocation to taskloop #200405
[OpenMP] Relocate task shared-by-ref captures across taskgraph replay #200404
[OpenMP] Widen taskgraph graph_id to uintptr_t #200403
[OpenMP] Make __kmp_replay_taskgraph static (NFC) #200402
[OpenMP] Add test for concurrent taskgraph re-record sanity check #195077
[OpenMP] Add sanity check for concurrent taskgraph reset #195076
[OpenMP] New runtime tests for graph_id/graph_reset clauses (taskgraph) #195075
[OpenMP] Runtime support for graph_id and graph_reset clauses (for taskgraph) #195074
[OpenMP] OpenMP 6.0 "taskgraph" support, add new tests #194057
[OpenMP] Add libomp_debug feature for tests #194056
[OpenMP] OpenMP 6.0 "taskgraph" support, additional tests from previous implementation #194055
[OpenMP] Add tests for 'replayable' clause #194054
[OpenMP] Add 'replayable' clause (for 'taskgraph' support) #194053
[OpenMP] New Clang tests for 'taskgraph' directive #194052
[OpenMP] Support 'taskgraph' semantics via new libomp API entry points #194051
[OpenMP] Add OpenMP 6.0 taskgraph parsing/trivial semantics #194050
[OpenMP] Add graph_id/graph_reset tests #194049
[OpenMP] Add graph_id and graph_reset clause support (for taskgraph directive) #194048
[OpenMP] New taskgraph runtime implementation #194047
[OpenMP] Mostly remove experimental taskgraph support from runtime #194046

jtb20 added 2 commits May 7, 2026 12:11
Created using spr 1.3.5
Created using spr 1.3.5
@jtb20

jtb20 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

FYI: this one looks like it needs some changes -- the irreducible-graph handling code is likely to radically change. So don't put too much review effort into that part just yet.

Thanks!

jtb20 added a commit that referenced this pull request Jun 23, 2026
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

Pull Request: #194047
@jtb20

jtb20 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

The stacked-PR tool I'm using for this stack did something weird: this one is #216324 now.

@jtb20 jtb20 closed this Aug 14, 2026
@github-actions
github-actions Bot deleted the users/jtb20/spr/openmp-new-taskgraph-runtime-implementation branch August 15, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

openmp:libomp OpenMP host runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants