[Mlir-commits] [mlir] [mlir][gpu] Add 'cluster_stride' attribute to gpu.subgroup_reduce (PR #107142)
Andrea Faulds
llvmlistbot at llvm.org
Wed Sep 4 03:26:36 PDT 2024
================
@@ -1230,27 +1233,38 @@ def GPU_SubgroupReduceOp : GPU_Op<"subgroup_reduce", [SameOperandsAndResultType]
AnyIntegerOrFloatOr1DVector:$value,
GPU_AllReduceOperationAttr:$op,
UnitAttr:$uniform,
- OptionalAttr<I32Attr>:$cluster_size
+ OptionalAttr<I32Attr>:$cluster_size,
+ DefaultValuedAttr<I32Attr,"1">:$cluster_stride
);
let results = (outs AnyIntegerOrFloatOr1DVector:$result);
let builders = [
OpBuilder<(ins "Value":$value,
"::mlir::gpu::AllReduceOperation":$op,
"bool":$uniform), [{
- build($_builder, $_state, value, op, uniform, /*cluster_size=*/ nullptr);
+ build($_builder, $_state, value, op, uniform, std::nullopt);
}]>,
OpBuilder<(ins "Value":$value,
"::mlir::gpu::AllReduceOperation":$op,
"bool":$uniform,
"std::optional<uint32_t>":$cluster_size), [{
- build($_builder, $_state, value, op, uniform, cluster_size ? $_builder.getI32IntegerAttr(*cluster_size) : nullptr);
+ build($_builder, $_state, value, op, uniform,
+ cluster_size ? $_builder.getI32IntegerAttr(*cluster_size) : nullptr);
+ }]>,
+ OpBuilder<(ins "Value":$value,
+ "::mlir::gpu::AllReduceOperation":$op,
+ "bool":$uniform,
+ "std::optional<uint32_t>":$cluster_size,
+ "uint32_t":$cluster_stride), [{
+ build($_builder, $_state, value, op, uniform,
+ cluster_size ? $_builder.getI32IntegerAttr(*cluster_size) : nullptr,
----------------
andfau-amd wrote:
I'm using it in the lowerings that break down a single subgroup reduction into several (the bits higher up in `SubgroupReduceLowering.cpp`), where I want to preserve the original cluster attributes or lack thereof. So it is actually used.
https://github.com/llvm/llvm-project/pull/107142
More information about the Mlir-commits
mailing list