-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[MLIR][ROCDL] Add permlane16.swap and permanlane32.swap #153804
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
Merged
Merged
Conversation
This file contains hidden or 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
Member
|
@llvm/pr-subscribers-mlir-llvm @llvm/pr-subscribers-mlir Author: Tim Gymnich (tgymnich) Changesadd rocdl.permlane16.swap and rocdl.permanlane32.swap Full diff: https://github.com/llvm/llvm-project/pull/153804.diff 2 Files Affected:
diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
index d6761f4da21ff..98a9a5b4f4b37 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
@@ -780,6 +780,40 @@ def ROCDL_PermlaneX16Op : ROCDL_IntrOp<"permlanex16", [], [0],
}];
}
+class ROCDL_ConcretePair<Type elem> :
+ Type<CPred<"::llvm::isa<::mlir::LLVM::LLVMStructType>($_self)">, "LLVM pair type">,
+ BuildableType<"::mlir::LLVM::LLVMStructType::getLiteral($_builder.getContext(), {" # elem.builderCall # ", " # elem.builderCall # "})">;
+
+// Permlane16 swap intrinsic operation
+def ROCDL_Permlane16SwapOp : ROCDL_IntrOp<"permlane16.swap", [], [],
+ [], 1, 0, 0, 0,
+ [2, 3], ["fi", "boundControl"]>,
+ Arguments<(ins I32:$old, I32:$src, I1Attr:$fi, I1Attr:$boundControl)> {
+ let results = (outs ROCDL_ConcretePair<I32>:$res);
+ let assemblyFormat = [{
+ attr-dict $old `,` $src `,` $fi `,` $boundControl `:` `(` type($old) `,` type($src) `)` `->` type($res)
+ }];
+ let description = [{
+ Performs a `permlane16.swap` operation with the given operands, applying the
+ permutation specified by $fi to the provided inputs.
+ }];
+}
+
+// Permlane32 swap intrinsic operation
+def ROCDL_Permlane32SwapOp : ROCDL_IntrOp<"permlane32.swap", [], [],
+ [], 1, 0, 0, 0,
+ [2, 3], ["fi", "boundControl"]>,
+ Arguments<(ins I32:$old, I32:$src, I1Attr:$fi, I1Attr:$boundControl)> {
+ let results = (outs ROCDL_ConcretePair<I32>:$res);
+ let assemblyFormat = [{
+ attr-dict $old `,` $src `,` $fi `,` $boundControl `:` `(` type($old) `,` type($src) `)` `->` type($res)
+ }];
+ let description = [{
+ Performs a `permlane32.swap` operation with the given operands, applying the
+ permutation specified by $fi to the provided inputs.
+ }];
+}
+
class ROCDL_ConcreteVector<Type elem, int length> :
FixedVectorOfLengthAndType<[length], [elem]>,
BuildableType<
diff --git a/mlir/test/Dialect/LLVMIR/rocdl.mlir b/mlir/test/Dialect/LLVMIR/rocdl.mlir
index db5271c57f573..782ef4e154440 100644
--- a/mlir/test/Dialect/LLVMIR/rocdl.mlir
+++ b/mlir/test/Dialect/LLVMIR/rocdl.mlir
@@ -1009,6 +1009,22 @@ llvm.func @rocdl.permlanex16(%src : f32) -> f32 {
// -----
+llvm.func @rocdl.permlane16.swap(%src : i32) -> !llvm.struct<(i32, i32)> {
+ // CHECK-LABEL: rocdl.permlane16.swap
+ // CHECK: rocdl.permlane16.swap %{{.*}} %{{.*}}
+ %res = rocdl.permlane16.swap %src, %src, 0, -1 : (i32, i32) -> !llvm.struct<(i32, i32)>
+ llvm.return %res : !llvm.struct<(i32, i32)>
+}
+
+llvm.func @rocdl.permlane32.swap(%src : i32) -> !llvm.struct<(i32, i32)> {
+ // CHECK-LABEL: rocdl.permlane32.swap
+ // CHECK: rocdl.permlane32.swap %{{.*}} %{{.*}}
+ %res = rocdl.permlane32.swap %src, %src, 0, -1 : (i32, i32) -> !llvm.struct<(i32, i32)>
+ llvm.return %res : !llvm.struct<(i32, i32)>
+}
+
+// -----
+
// expected-error@below {{attribute attached to unexpected op}}
func.func private @expected_llvm_func() attributes { rocdl.kernel }
|
Contributor
|
Please add to https://github.com/llvm/llvm-project/blob/main/mlir/test/Target/LLVMIR/rocdl.mlir as well |
2802ec4 to
9246b5e
Compare
9246b5e to
aef7a6e
Compare
Member
Author
|
@Hardcode84 done |
kuhar
approved these changes
Aug 15, 2025
Hardcode84
approved these changes
Aug 15, 2025
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.
add rocdl.permlane16.swap and rocdl.permanlane32.swap