[Mlir-commits] [mlir] [mlir][gpu] Add `subgroup_broadcast` op (PR #152808)
Jianhui Li
llvmlistbot at llvm.org
Fri Aug 15 14:17:49 PDT 2025
Jianhui-Li wrote:
>One example is something like [thread ID x] / [whatever I know my subgroup size is].
> This will often lower to something more concrete like reading the first active lane, but allow more transformations before that lowering takes place.
Thanks. The example certainly helps addressing my use case question.
Why the compiler hint has to be part of broadcast OP?
I see alternatives not attaching the hint to broadcast.
Ivan's early propose doesn't have broadcast semantics. [[mlir][amdgpu] Introduce `assume_subgroup_uniform` op by Hardcode84 · Pull Request #152740 · llvm/llvm-project](https://github.com/llvm/llvm-project/pull/152740#issuecomment-3168692683)
Another example of providing compiler hint without using broadcast: There is a "Uniform" SPIR-V decoration: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Decoration
```mlir
Uniform
Apply only to an object. Asserts that, for each [dynamic instance](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#DynamicInstance) of the instruction that computes the result, all invocations in the same [tangle](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Tangle) within the invocation’s Subgroup scope compute the same result value.
```
These alternatives are more straightforward to my eyes.
1. User don't have to understand the broadcast "any_lane" semantics and realize this is just to describe the input value property and nothing to do with the result value.
2. Each HW targets can choose to implement the hint differently. AMD GPU may choose to implement as "readFirstLane". Others may choose another way or simply ignore it. But with the current proposal, each HW target must implement the broadcast semantics because the broadcast semantic (not as a hint) can be used to do something meaningful as shown below.
```mlir
$value = 1
$result = 0
if (lane_id & 0x1)
$result = subgroup.broadcast @any_lane $value
```
https://github.com/llvm/llvm-project/pull/152808
More information about the Mlir-commits
mailing list