[clang] [llvm] [mlir] [AMDGPU] Implement AsyncMark Stages (PR #220442)
Sameer Sahasrabuddhe via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 25 22:20:00 PDT 2026
================
@@ -219,44 +348,49 @@ examined at `Y`.
```c++
void bar() {
- asyncmark(); // B
- asyncmark(); // C
- ... // no asyncmark()
- wait.asyncmark(0); // Y
+ asyncmark(0); // B
+ asyncmark(0); // C
+ ... // no asyncmark()
+ wait.asyncmark(0, 0); // Y
...
- wait.asyncmark(1); // D
+ wait.asyncmark(1, 0); // D
}
```
After inlining, both `B` and `C` are *completed-at* `Y`.
### Optimization
-The implementation may eliminate asyncmark/wait intrinsics in the following
-cases. These are just examples and not meant to be an exhaustive list.
+The implementation may eliminate/modify asyncmark/wait intrinsics in the
+following cases. These are just examples and not meant to be an exhaustive list.
-1. An `asyncmark` operation which remains in the current sequence along every
+1. An `asyncmark` operation which remains in a current sequence along every
path that reaches the function exit.
```c++
void foo() {
...
- asyncmark(); // X
- ... // no wait.asyncmark()
+ asyncmark(0); // X
+ ... // no wait.asyncmark()
}
```
- Here, `X` can be eliminated.
+ Here, the zero mask names every stage, and each independent mark remains, so
+ the entire mark `X` can be eliminated. If only some sequences qualified, then
+ the `asyncmark` operation could be modified to remove just those stages from
+ its mask.
2. A `wait.asyncmark` which sees an empty sequence of asyncmarks along every
path that reaches it.
```c++
void foo() {
- ... // no asyncmark()
- wait.asyncmark(0); // Y
+ ... // no asyncmark()
+ wait.asyncmark(0, 0); // Y
...
}
```
- Here, `Y` can be eliminated.
+ Here, as with `X` above, every sequence qualifies, so `Y` can be eliminated.
+ If only some sequences qualified, the `wait.asyncmark` could be modified to
+ only wait for the relevant stages.
----------------
ssahasra wrote:
In general, the proposed note is simply saying that such a removal of bits is *possible*, i.e., under the right conditions it can improve code-gen without breaking semantics. Details like function boundaries can be worked out when we actually try to do it.
https://github.com/llvm/llvm-project/pull/220442
More information about the cfe-commits
mailing list