-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
[mlir][gpu] Add builder to gpu.launch_func
#95541
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-mlir-gpu @llvm/pr-subscribers-mlir Author: Fabian Mora (fabianmcg) ChangesThis patch adds a builder to Full diff: https://github.com/llvm/llvm-project/pull/95541.diff 2 Files Affected:
diff --git a/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td b/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
index 9c5f7ecd8cbe8..5943de103beba 100644
--- a/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
+++ b/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
@@ -653,6 +653,12 @@ def GPU_LaunchFuncOp :GPU_Op<"launch_func", [
CArg<"Type", "nullptr">:$asyncTokenType,
CArg<"ValueRange", "{}">:$asyncDependencies,
CArg<"std::optional<KernelDim3>", "std::nullopt">:$clusterSize)>,
+ OpBuilder<(ins "SymbolRefAttr":$kernel, "KernelDim3":$gridSize,
+ "KernelDim3":$blockSize, "Value":$dynamicSharedMemorySize,
+ "ValueRange":$kernelOperands,
+ "Type":$asyncTokenType,
+ CArg<"ValueRange", "{}">:$asyncDependencies,
+ CArg<"std::optional<KernelDim3>", "std::nullopt">:$clusterSize)>,
OpBuilder<(ins "SymbolRefAttr":$kernel, "KernelDim3":$gridSize,
"KernelDim3":$blockSize, "Value":$dynamicSharedMemorySize,
"ValueRange":$kernelOperands,
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index d8e29da6512d4..17bf254b64b4d 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -1081,11 +1081,13 @@ BlockArgument LaunchOp::addPrivateAttribution(Type type, Location loc) {
//===----------------------------------------------------------------------===//
void LaunchFuncOp::build(OpBuilder &builder, OperationState &result,
- GPUFuncOp kernelFunc, KernelDim3 gridSize,
+ SymbolRefAttr kernelSymbol, KernelDim3 gridSize,
KernelDim3 getBlockSize, Value dynamicSharedMemorySize,
ValueRange kernelOperands, Type asyncTokenType,
ValueRange asyncDependencies,
std::optional<KernelDim3> clusterSize) {
+ assert(kernelSymbol.getNestedReferences().size() == 1 &&
+ "expected a symbol reference with a single nested reference");
result.addOperands(asyncDependencies);
if (asyncTokenType)
result.types.push_back(builder.getType<AsyncTokenType>());
@@ -1098,10 +1100,6 @@ void LaunchFuncOp::build(OpBuilder &builder, OperationState &result,
if (dynamicSharedMemorySize)
result.addOperands(dynamicSharedMemorySize);
result.addOperands(kernelOperands);
- auto kernelModule = kernelFunc->getParentOfType<GPUModuleOp>();
- auto kernelSymbol =
- SymbolRefAttr::get(kernelModule.getNameAttr(),
- {SymbolRefAttr::get(kernelFunc.getNameAttr())});
Properties &prop = result.getOrAddProperties<Properties>();
prop.kernel = kernelSymbol;
@@ -1122,6 +1120,21 @@ void LaunchFuncOp::build(OpBuilder &builder, OperationState &result,
prop.operandSegmentSizes[segmentSizesLen - 1] = 0;
}
+void LaunchFuncOp::build(OpBuilder &builder, OperationState &result,
+ GPUFuncOp kernelFunc, KernelDim3 gridSize,
+ KernelDim3 getBlockSize, Value dynamicSharedMemorySize,
+ ValueRange kernelOperands, Type asyncTokenType,
+ ValueRange asyncDependencies,
+ std::optional<KernelDim3> clusterSize) {
+ auto kernelModule = kernelFunc->getParentOfType<GPUModuleOp>();
+ auto kernelSymbol =
+ SymbolRefAttr::get(kernelModule.getNameAttr(),
+ {SymbolRefAttr::get(kernelFunc.getNameAttr())});
+ build(builder, result, kernelSymbol, gridSize, getBlockSize,
+ dynamicSharedMemorySize, kernelOperands, asyncTokenType,
+ asyncDependencies, clusterSize);
+}
+
void LaunchFuncOp::build(OpBuilder &builder, OperationState &result,
SymbolRefAttr kernel, KernelDim3 gridSize,
KernelDim3 getBlockSize, Value dynamicSharedMemorySize,
|
joker-eph
approved these changes
Jun 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch adds a builder to
gpu.launch_func
allowing it to be created usingSymbolRefAttr
instead ofGPUFuncOp
. This allows creatinglaunch_func
when only agpu.binary
is present, instead of the fullgpu.module {...}
.