-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU] Add dynamic LDS size implicit kernel argument to CO-v5 #65273
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
124 changes: 124 additions & 0 deletions
124
llvm/test/CodeGen/AMDGPU/hsa-metadata-dynlds-func-hidden-args-v5.ll
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 -filetype=obj -o - < %s | llvm-readelf --notes - | FileCheck --check-prefix=CHECK %s | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj -o - < %s | llvm-readelf --notes - | FileCheck --check-prefix=CHECK %s | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -filetype=obj -o - < %s | llvm-readelf --notes - | FileCheck --check-prefix=CHECK %s | ||
|
||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 < %s | FileCheck --check-prefix=CHECK %s | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx803 < %s | FileCheck --check-prefix=CHECK %s | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 < %s | FileCheck --check-prefix=CHECK %s | ||
|
||
|
||
; CHECK: amdhsa.kernels: | ||
; CHECK-NEXT: - .args: | ||
; CHECK-NEXT: - .address_space: global | ||
; CHECK-NEXT: .name: r | ||
; CHECK-NEXT: .offset: 0 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: global_buffer | ||
; CHECK-NEXT: - .address_space: global | ||
; CHECK-NEXT: .name: a | ||
; CHECK-NEXT: .offset: 8 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: global_buffer | ||
; CHECK-NEXT: - .address_space: global | ||
; CHECK-NEXT: .name: b | ||
; CHECK-NEXT: .offset: 16 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: global_buffer | ||
; CHECK-NEXT: - .offset: 24 | ||
; CHECK-NEXT: .size: 4 | ||
; CHECK-NEXT: .value_kind: hidden_block_count_x | ||
; CHECK-NEXT: - .offset: 28 | ||
; CHECK-NEXT: .size: 4 | ||
; CHECK-NEXT: .value_kind: hidden_block_count_y | ||
; CHECK-NEXT: - .offset: 32 | ||
; CHECK-NEXT: .size: 4 | ||
; CHECK-NEXT: .value_kind: hidden_block_count_z | ||
; CHECK-NEXT: - .offset: 36 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_group_size_x | ||
; CHECK-NEXT: - .offset: 38 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_group_size_y | ||
; CHECK-NEXT: - .offset: 40 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_group_size_z | ||
; CHECK-NEXT: - .offset: 42 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_remainder_x | ||
; CHECK-NEXT: - .offset: 44 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_remainder_y | ||
; CHECK-NEXT: - .offset: 46 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_remainder_z | ||
; CHECK-NEXT: - .offset: 64 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_global_offset_x | ||
; CHECK-NEXT: - .offset: 72 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_global_offset_y | ||
; CHECK-NEXT: - .offset: 80 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_global_offset_z | ||
; CHECK-NEXT: - .offset: 88 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_grid_dims | ||
; CHECK-NEXT: - .offset: 96 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_printf_buffer | ||
; CHECK-NEXT: - .offset: 104 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_hostcall_buffer | ||
; CHECK-NEXT: - .offset: 112 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_multigrid_sync_arg | ||
; CHECK-NEXT: - .offset: 120 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_heap_v1 | ||
; CHECK-NEXT: - .offset: 128 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_default_queue | ||
; CHECK-NEXT: - .offset: 136 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_completion_action | ||
; CHECK: - .offset: 144 | ||
; CHECK-NEXT: .size: 4 | ||
; CHECK-NEXT: .value_kind: hidden_dynamic_lds_size | ||
; CHECK: - .offset: 224 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_queue_ptr | ||
|
||
; CHECK: .name: test_v5 | ||
; CHECK: .symbol: test_v5.kd | ||
|
||
; CHECK: amdhsa.version: | ||
; CHECK-NEXT: - 1 | ||
; CHECK-NEXT: - 2 | ||
@lds = external hidden addrspace(3) global [0 x i32], align 4 | ||
|
||
define void @funcs_dyn_lds() { | ||
store i32 1234, ptr addrspacecast (ptr addrspace(3) @lds to ptr), align 4 | ||
ret void | ||
} | ||
|
||
define amdgpu_kernel void @test_v5( | ||
ptr addrspace(1) %r, | ||
ptr addrspace(1) %a, | ||
ptr addrspace(1) %b) #0 { | ||
entry: | ||
%a.val = load half, ptr addrspace(1) %a | ||
%b.val = load half, ptr addrspace(1) %b | ||
%r.val = fadd half %a.val, %b.val | ||
store half %r.val, ptr addrspace(1) %r | ||
call void @funcs_dyn_lds() | ||
ret void | ||
} | ||
|
||
!llvm.module.flags = !{!0} | ||
!0 = !{i32 1, !"amdgpu_code_object_version", i32 500} | ||
!llvm.printf.fmts = !{!1, !2} | ||
!1 = !{!"1:1:4:%d\5Cn"} | ||
!2 = !{!"2:1:8:%g\5Cn"} | ||
|
||
attributes #0 = { optnone noinline } | ||
|
124 changes: 124 additions & 0 deletions
124
llvm/test/CodeGen/AMDGPU/hsa-metadata-dynlds-funcarg-hidden-args-v5.ll
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 -filetype=obj -o - < %s | llvm-readelf --notes - | FileCheck --check-prefix=CHECK %s | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj -o - < %s | llvm-readelf --notes - | FileCheck --check-prefix=CHECK %s | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -filetype=obj -o - < %s | llvm-readelf --notes - | FileCheck --check-prefix=CHECK %s | ||
|
||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 < %s | FileCheck --check-prefix=CHECK %s | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx803 < %s | FileCheck --check-prefix=CHECK %s | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 < %s | FileCheck --check-prefix=CHECK %s | ||
|
||
|
||
; CHECK: amdhsa.kernels: | ||
; CHECK-NEXT: - .args: | ||
; CHECK-NEXT: - .address_space: global | ||
; CHECK-NEXT: .name: r | ||
; CHECK-NEXT: .offset: 0 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: global_buffer | ||
; CHECK-NEXT: - .address_space: global | ||
; CHECK-NEXT: .name: a | ||
; CHECK-NEXT: .offset: 8 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: global_buffer | ||
; CHECK-NEXT: - .address_space: global | ||
; CHECK-NEXT: .name: b | ||
; CHECK-NEXT: .offset: 16 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: global_buffer | ||
; CHECK-NEXT: - .offset: 24 | ||
; CHECK-NEXT: .size: 4 | ||
; CHECK-NEXT: .value_kind: hidden_block_count_x | ||
; CHECK-NEXT: - .offset: 28 | ||
; CHECK-NEXT: .size: 4 | ||
; CHECK-NEXT: .value_kind: hidden_block_count_y | ||
; CHECK-NEXT: - .offset: 32 | ||
; CHECK-NEXT: .size: 4 | ||
; CHECK-NEXT: .value_kind: hidden_block_count_z | ||
; CHECK-NEXT: - .offset: 36 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_group_size_x | ||
; CHECK-NEXT: - .offset: 38 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_group_size_y | ||
; CHECK-NEXT: - .offset: 40 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_group_size_z | ||
; CHECK-NEXT: - .offset: 42 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_remainder_x | ||
; CHECK-NEXT: - .offset: 44 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_remainder_y | ||
; CHECK-NEXT: - .offset: 46 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_remainder_z | ||
; CHECK-NEXT: - .offset: 64 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_global_offset_x | ||
; CHECK-NEXT: - .offset: 72 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_global_offset_y | ||
; CHECK-NEXT: - .offset: 80 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_global_offset_z | ||
; CHECK-NEXT: - .offset: 88 | ||
; CHECK-NEXT: .size: 2 | ||
; CHECK-NEXT: .value_kind: hidden_grid_dims | ||
; CHECK-NEXT: - .offset: 96 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_printf_buffer | ||
; CHECK-NEXT: - .offset: 104 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_hostcall_buffer | ||
; CHECK-NEXT: - .offset: 112 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_multigrid_sync_arg | ||
; CHECK-NEXT: - .offset: 120 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_heap_v1 | ||
; CHECK-NEXT: - .offset: 128 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_default_queue | ||
; CHECK-NEXT: - .offset: 136 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_completion_action | ||
; CHECK: - .offset: 144 | ||
; CHECK-NEXT: .size: 4 | ||
; CHECK-NEXT: .value_kind: hidden_dynamic_lds_size | ||
; CHECK: - .offset: 224 | ||
; CHECK-NEXT: .size: 8 | ||
; CHECK-NEXT: .value_kind: hidden_queue_ptr | ||
|
||
; CHECK: .name: test_v5 | ||
; CHECK: .symbol: test_v5.kd | ||
|
||
; CHECK: amdhsa.version: | ||
; CHECK-NEXT: - 1 | ||
; CHECK-NEXT: - 2 | ||
@lds = external hidden addrspace(3) global [0 x i32], align 4 | ||
|
||
define void @funcs_dyn_lds(ptr addrspace(3) %lds_ptr) { | ||
store i32 1234, ptr addrspace(3) %lds_ptr, align 4 | ||
ret void | ||
} | ||
|
||
define amdgpu_kernel void @test_v5( | ||
ptr addrspace(1) %r, | ||
ptr addrspace(1) %a, | ||
ptr addrspace(1) %b) #0 { | ||
entry: | ||
%a.val = load half, ptr addrspace(1) %a | ||
%b.val = load half, ptr addrspace(1) %b | ||
%r.val = fadd half %a.val, %b.val | ||
store half %r.val, ptr addrspace(1) %r | ||
call void @funcs_dyn_lds(ptr addrspace(3) @lds) | ||
ret void | ||
} | ||
|
||
!llvm.module.flags = !{!0} | ||
!0 = !{i32 1, !"amdgpu_code_object_version", i32 500} | ||
!llvm.printf.fmts = !{!1, !2} | ||
!1 = !{!"1:1:4:%d\5Cn"} | ||
!2 = !{!"2:1:8:%g\5Cn"} | ||
|
||
attributes #0 = { optnone noinline } | ||
|
Oops, something went wrong.
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.
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.
This won't work if the dynamic LDS reference only appears in a called function and not in the parent kernel. Is that possible with the current module LDS lowering?
You also should set this if a kernel argument is an LDS pointer
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.
Thanks for suggestions @arsenm. Have updated the patch to identify below cases: