-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[mlir][gpu] Update attribute definitions in gpu::LaunchOp
#152106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-mlir-gpu Author: Longsheng Mou (CoTinker) ChangesThis PR replaces Full diff: https://github.com/llvm/llvm-project/pull/152106.diff 2 Files Affected:
diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
index 99f5c5b0cf139..346cce0f08b74 100644
--- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
@@ -357,7 +357,7 @@ class GpuKernelOutliningPass
SetVector<Value> operands;
std::string kernelFnName;
if (op.getKernelFunc()) {
- kernelFnName = op.getKernelFunc()->getRootReference().str();
+ kernelFnName = op.getKernelFunc()->getLeafReference().str();
} else {
kernelFnName =
Twine(op->getParentOfType<SymbolOpInterface>().getName(),
diff --git a/mlir/test/Dialect/GPU/outlining.mlir b/mlir/test/Dialect/GPU/outlining.mlir
index d48fa054432d1..fda9877f58fe2 100644
--- a/mlir/test/Dialect/GPU/outlining.mlir
+++ b/mlir/test/Dialect/GPU/outlining.mlir
@@ -530,6 +530,24 @@ func.func @testKernelAttributes() {
return
}
+// -----
+
+// This test tests the kernelFunc has nested references.
+
+// CHECK-LABEL: func.func @testKernelAttributesWithNestedFunc
+// CHECK: gpu.launch_func @test_module::@test_kernel_func
+// CHECK: gpu.module @test_module
+// CHECK: gpu.func @test_kernel_func()
+// CHECK-NOT: gpu.func @test_module()
+func.func @testKernelAttributesWithNestedFunc(%arg0 : index) {
+ gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %arg0, %grid_y = %arg0, %grid_z = %arg0)
+ threads(%tx, %ty, %tz) in (%block_x = %arg0, %block_y = %arg0, %block_z = %arg0) {
+ "some_op"(%bx, %tx) : (index, index) -> ()
+ gpu.terminator
+ } {kernelModule = @test_module, kernelFunc = @test_module::@test_kernel_func}
+ return
+}
+
// -----
// This test tests the two optional attributes kernelModule and kernelFunc for gpu.launch, when kernelModule already exists.
|
@llvm/pr-subscribers-mlir Author: Longsheng Mou (CoTinker) ChangesThis PR replaces Full diff: https://github.com/llvm/llvm-project/pull/152106.diff 2 Files Affected:
diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
index 99f5c5b0cf139..346cce0f08b74 100644
--- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
@@ -357,7 +357,7 @@ class GpuKernelOutliningPass
SetVector<Value> operands;
std::string kernelFnName;
if (op.getKernelFunc()) {
- kernelFnName = op.getKernelFunc()->getRootReference().str();
+ kernelFnName = op.getKernelFunc()->getLeafReference().str();
} else {
kernelFnName =
Twine(op->getParentOfType<SymbolOpInterface>().getName(),
diff --git a/mlir/test/Dialect/GPU/outlining.mlir b/mlir/test/Dialect/GPU/outlining.mlir
index d48fa054432d1..fda9877f58fe2 100644
--- a/mlir/test/Dialect/GPU/outlining.mlir
+++ b/mlir/test/Dialect/GPU/outlining.mlir
@@ -530,6 +530,24 @@ func.func @testKernelAttributes() {
return
}
+// -----
+
+// This test tests the kernelFunc has nested references.
+
+// CHECK-LABEL: func.func @testKernelAttributesWithNestedFunc
+// CHECK: gpu.launch_func @test_module::@test_kernel_func
+// CHECK: gpu.module @test_module
+// CHECK: gpu.func @test_kernel_func()
+// CHECK-NOT: gpu.func @test_module()
+func.func @testKernelAttributesWithNestedFunc(%arg0 : index) {
+ gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %arg0, %grid_y = %arg0, %grid_z = %arg0)
+ threads(%tx, %ty, %tz) in (%block_x = %arg0, %block_y = %arg0, %block_z = %arg0) {
+ "some_op"(%bx, %tx) : (index, index) -> ()
+ gpu.terminator
+ } {kernelModule = @test_module, kernelFunc = @test_module::@test_kernel_func}
+ return
+}
+
// -----
// This test tests the two optional attributes kernelModule and kernelFunc for gpu.launch, when kernelModule already exists.
|
gpu::LaunchOp
This PR makes two updates to `gpu.launch`: - Change the attribute type for kernel function and module from `SymbolRefAttr` to `FlatSymbolRefAttr` to avoid nested symbol references. - Rename variables from camel case (kernelFunc, kernelModule) to lower case (function, module).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
gpu::LaunchOp is updated the following way:
SymbolRefAttr
toFlatSymbolRefAttr
to avoid nested symbol references.LaunchOp::build
support passingmodule
andfunction
attributes.