[Mlir-commits] [mlir] 69f7647 - [mlir][GPU] Add ShuffleOp builder for constant offset/width
Matthias Springer
llvmlistbot at llvm.org
Wed Feb 9 09:55:56 PST 2022
Author: Matthias Springer
Date: 2022-02-10T02:55:44+09:00
New Revision: 69f764715823c38a06e1d21dbd5309e3fce9ba6f
URL: https://github.com/llvm/llvm-project/commit/69f764715823c38a06e1d21dbd5309e3fce9ba6f
DIFF: https://github.com/llvm/llvm-project/commit/69f764715823c38a06e1d21dbd5309e3fce9ba6f.diff
LOG: [mlir][GPU] Add ShuffleOp builder for constant offset/width
Differential Revision: https://reviews.llvm.org/D119345
Added:
Modified:
mlir/include/mlir/Dialect/GPU/GPUOps.td
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td
index a07f73eaa4328..877e20cd8931a 100644
--- a/mlir/include/mlir/Dialect/GPU/GPUOps.td
+++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td
@@ -724,6 +724,11 @@ def GPU_ShuffleOp : GPU_Op<
in the shuffle. Exactly the first `width` invocations of a subgroup need to
execute this op in convergence.
}];
+ let builders = [
+ // Helper function that creates a shuffle with constant offset/width.
+ OpBuilder<(ins "Value":$value, "int32_t":$offset, "int32_t":$width,
+ "ShuffleMode":$mode)>
+ ];
let assemblyFormat = "$mode $value `,` $offset `,` $width attr-dict `:` type($value)";
}
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index 013ab7d313096..a75724421d7a7 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -691,6 +691,22 @@ static void printLaunchFuncOperands(OpAsmPrinter &printer, Operation *,
printer << ")";
}
+//
+
+//===----------------------------------------------------------------------===//
+// ShuffleOp
+//===----------------------------------------------------------------------===//
+
+void ShuffleOp::build(OpBuilder &builder, OperationState &result, Value value,
+ int32_t offset, int32_t width, ShuffleMode mode) {
+ build(builder, result, value,
+ builder.create<arith::ConstantOp>(result.location,
+ builder.getI32IntegerAttr(offset)),
+ builder.create<arith::ConstantOp>(result.location,
+ builder.getI32IntegerAttr(width)),
+ mode);
+}
+
//===----------------------------------------------------------------------===//
// GPUFuncOp
//===----------------------------------------------------------------------===//
More information about the Mlir-commits
mailing list