-
Notifications
You must be signed in to change notification settings - Fork 15k
[NFC][AMDGPU] Add a missing test case about cluster dims #159179
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
|
@llvm/pr-subscribers-backend-amdgpu Author: Shilei Tian (shiltian) ChangesFull diff: https://github.com/llvm/llvm-project/pull/159179.diff 1 Files Affected:
diff --git a/llvm/test/CodeGen/AMDGPU/propagate-amdgpu-cluster-dims.ll b/llvm/test/CodeGen/AMDGPU/propagate-amdgpu-cluster-dims.ll
new file mode 100644
index 0000000000000..e8271220fa66f
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/propagate-amdgpu-cluster-dims.ll
@@ -0,0 +1,182 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --check-globals all --version 5
+; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1250 -passes=amdgpu-attributor %s -o - | FileCheck %s
+
+declare void @unknown()
+
+; fixed_cluster_dims_0 is only used by fixed_cluster_dims_1 that is expected to
+; have fixed dims.
+define internal void @fixed_cluster_dims_before_0() {
+; CHECK-LABEL: define internal void @fixed_cluster_dims_before_0(
+; CHECK-SAME: ) #[[ATTR1:[0-9]+]] {
+; CHECK-NEXT: call void @unknown()
+; CHECK-NEXT: ret void
+;
+ call void @unknown()
+ ret void
+}
+
+; fixed_cluster_dims_1 is used by two kernels with the same cluster dims.
+define internal void @fixed_cluster_dims_1() {
+; CHECK-LABEL: define internal void @fixed_cluster_dims_1(
+; CHECK-SAME: ) #[[ATTR1]] {
+; CHECK-NEXT: call void @fixed_cluster_dims_before_0()
+; CHECK-NEXT: call void @unknown()
+; CHECK-NEXT: ret void
+;
+ call void @fixed_cluster_dims_before_0()
+ call void @unknown()
+ ret void
+}
+
+; no_cluster_dims_0 is only used by no_cluster_dims_1 that is expected to not use
+; cluster.
+define internal void @no_cluster_dims_0() {
+; CHECK-LABEL: define internal void @no_cluster_dims_0(
+; CHECK-SAME: ) #[[ATTR2:[0-9]+]] {
+; CHECK-NEXT: call void @unknown()
+; CHECK-NEXT: ret void
+;
+ call void @unknown()
+ ret void
+}
+
+; no_cluster_dims_1 is used by two kernels that don't use cluster.
+define internal void @no_cluster_dims_1() {
+; CHECK-LABEL: define internal void @no_cluster_dims_1(
+; CHECK-SAME: ) #[[ATTR2]] {
+; CHECK-NEXT: call void @unknown()
+; CHECK-NEXT: call void @no_cluster_dims_0()
+; CHECK-NEXT: ret void
+;
+ call void @unknown()
+ call void @no_cluster_dims_0()
+ ret void
+}
+
+; non_fixed_cluster_dims is used by two kernels with different cluster dims, so
+; it will use cluster but cluster dims is unknown.
+define internal void @non_fixed_cluster_dims() {
+; CHECK-LABEL: define internal void @non_fixed_cluster_dims(
+; CHECK-SAME: ) #[[ATTR3:[0-9]+]] {
+; CHECK-NEXT: call void @unknown()
+; CHECK-NEXT: ret void
+;
+ call void @unknown()
+ ret void
+}
+
+; unknown_cluster_dims is used by a kernel that uses cluster and another one that
+; doesn't use cluster, so it is unknown that whether cluster is used or not.
+define internal void @unknown_cluster_dims() {
+; CHECK-LABEL: define internal void @unknown_cluster_dims(
+; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT: call void @unknown()
+; CHECK-NEXT: ret void
+;
+ call void @unknown()
+ ret void
+}
+
+; unknown_cluster_use is used by a kernel that we don't know whether cluster will
+; be used or not (because it doesn't have any attribute), so it is unknown that
+; whether cluster is used or not.
+define internal void @unknown_cluster_use() {
+; CHECK-LABEL: define internal void @unknown_cluster_use(
+; CHECK-SAME: ) #[[ATTR0]] {
+; CHECK-NEXT: call void @unknown()
+; CHECK-NEXT: ret void
+;
+ call void @unknown()
+ ret void
+}
+
+; unknown_call_site has unknown call site, so it is unknown that whether cluster
+; is used or not.
+define void @unknown_call_site() {
+; CHECK-LABEL: define void @unknown_call_site(
+; CHECK-SAME: ) #[[ATTR0]] {
+; CHECK-NEXT: call void @unknown()
+; CHECK-NEXT: ret void
+;
+ call void @unknown()
+ ret void
+}
+
+define amdgpu_kernel void @cluster_kernel_0() #0 {
+; CHECK-LABEL: define amdgpu_kernel void @cluster_kernel_0(
+; CHECK-SAME: ) #[[ATTR1]] {
+; CHECK-NEXT: call void @fixed_cluster_dims_1()
+; CHECK-NEXT: call void @non_fixed_cluster_dims()
+; CHECK-NEXT: call void @unknown_cluster_dims()
+; CHECK-NEXT: call void @unknown_call_site()
+; CHECK-NEXT: ret void
+;
+ call void @fixed_cluster_dims_1()
+ call void @non_fixed_cluster_dims()
+ call void @unknown_cluster_dims()
+ call void @unknown_call_site()
+ ret void
+}
+
+define amdgpu_kernel void @cluster_kernel_0_1() #0 {
+; CHECK-LABEL: define amdgpu_kernel void @cluster_kernel_0_1(
+; CHECK-SAME: ) #[[ATTR1]] {
+; CHECK-NEXT: call void @fixed_cluster_dims_1()
+; CHECK-NEXT: ret void
+;
+ call void @fixed_cluster_dims_1()
+ ret void
+}
+
+define amdgpu_kernel void @cluster_kernel_1() #1 {
+; CHECK-LABEL: define amdgpu_kernel void @cluster_kernel_1(
+; CHECK-SAME: ) #[[ATTR4:[0-9]+]] {
+; CHECK-NEXT: call void @non_fixed_cluster_dims()
+; CHECK-NEXT: ret void
+;
+ call void @non_fixed_cluster_dims()
+ ret void
+}
+
+define amdgpu_kernel void @no_cluster_kernel() #2 {
+; CHECK-LABEL: define amdgpu_kernel void @no_cluster_kernel(
+; CHECK-SAME: ) #[[ATTR2]] {
+; CHECK-NEXT: call void @no_cluster_dims_1()
+; CHECK-NEXT: call void @unknown_cluster_dims()
+; CHECK-NEXT: ret void
+;
+ call void @no_cluster_dims_1()
+ call void @unknown_cluster_dims()
+ ret void
+}
+
+define amdgpu_kernel void @no_cluster_kernel_1() #2 {
+; CHECK-LABEL: define amdgpu_kernel void @no_cluster_kernel_1(
+; CHECK-SAME: ) #[[ATTR2]] {
+; CHECK-NEXT: call void @no_cluster_dims_1()
+; CHECK-NEXT: ret void
+;
+ call void @no_cluster_dims_1()
+ ret void
+}
+
+define amdgpu_kernel void @unknown_cluster_use_kernel() {
+; CHECK-LABEL: define amdgpu_kernel void @unknown_cluster_use_kernel(
+; CHECK-SAME: ) #[[ATTR0]] {
+; CHECK-NEXT: call void @unknown_cluster_use()
+; CHECK-NEXT: ret void
+;
+ call void @unknown_cluster_use()
+ ret void
+}
+
+attributes #0 = { "amdgpu-cluster-dims"="2,2,2" }
+attributes #1 = { "amdgpu-cluster-dims"="1,2,1" }
+attributes #2 = { "amdgpu-cluster-dims"="0,0,0" }
+;.
+; CHECK: attributes #[[ATTR0]] = { "target-cpu"="gfx1250" "uniform-work-group-size"="false" }
+; CHECK: attributes #[[ATTR1]] = { "amdgpu-cluster-dims"="2,2,2" "target-cpu"="gfx1250" "uniform-work-group-size"="false" }
+; CHECK: attributes #[[ATTR2]] = { "amdgpu-cluster-dims"="0,0,0" "target-cpu"="gfx1250" "uniform-work-group-size"="false" }
+; CHECK: attributes #[[ATTR3]] = { "amdgpu-cluster-dims"="1024,1024,1024" "target-cpu"="gfx1250" "uniform-work-group-size"="false" }
+; CHECK: attributes #[[ATTR4]] = { "amdgpu-cluster-dims"="1,2,1" "target-cpu"="gfx1250" "uniform-work-group-size"="false" }
+;.
|
rampitec
approved these changes
Sep 16, 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.

No description provided.