
Currently, we use `AAAMDWavesPerEU` to iteratively update values based on attributes from the associated function, potentially propagating user-annotated values, along with `AAAMDFlatWorkGroupSize`. Similarly, we have `AAAMDFlatWorkGroupSize`. However, since the value calculated through the flat workgroup size always dominates the user annotation (i.e., the attribute), running `AAAMDWavesPerEU` iteratively is unnecessary if no user-annotated value exists. This PR completely rewrites how the `amdgpu-waves-per-eu` attribute is handled in `AMDGPUAttributor`. The key changes are as follows: - `AAAMDFlatWorkGroupSize` remains unchanged. - `AAAMDWavesPerEU` now only propagates user-annotated values. - A new function is added to check and update `amdgpu-waves-per-eu` based on the following rules: - No waves per eu, no flat workgroup size: Assume a flat workgroup size of `1,1024` and compute waves per eu based on this. - No waves per eu, flat workgroup size exists: Use the provided flat workgroup size to compute waves-per-eu. - Waves per eu exists, no flat workgroup size: This is a tricky case. In this PR, we assume a flat workgroup size of `1,1024`, but this can be adjusted if a different approach is preferred. Alternatively, we could directly use the user-annotated value. - Both waves per eu and flat workgroup size exist: If there’s a conflict, the value derived from the flat workgroup size takes precedence over waves per eu. This PR also updates the logic for merging two waves per eu pairs. The current implementation, which uses `clampStateAndIndicateChange` to compute a union, might not be ideal. If we think from ensure proper resource allocation perspective, for instance, if one pair specifies a minimum of 2 waves per eu, and another specifies a minimum of 4, we should guarantee that 4 waves per eu can be supported, as failing to do so could result in excessive resource allocation per wave. A similar principle applies to the upper bound. Thus, the PR uses the following approach for merging two pairs, `lo_a,up_a` and `lo_b,up_b`: `max(lo_a, lo_b), max(up_a, up_b)`. This ensures that resource allocation adheres to the stricter constraints from both inputs. Fix #123092.
64 lines
2.6 KiB
LLVM
64 lines
2.6 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals
|
|
; Check that no attributes are added to graphics functions
|
|
; RUN: opt -S -mtriple=amdgcn-amd-amdpal -passes=amdgpu-attributor %s | FileCheck -check-prefixes=ATTRIBUTOR_GCN %s
|
|
|
|
; Check that it doesn't crash
|
|
; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 < %s | FileCheck -check-prefixes=GFX9 %s
|
|
; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1010 < %s | FileCheck -check-prefixes=GFX10 %s
|
|
; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1010 -global-isel < %s | FileCheck -check-prefixes=GFX10 %s
|
|
|
|
define amdgpu_cs void @test_simple_indirect_call() {
|
|
; ATTRIBUTOR_GCN-LABEL: define {{[^@]+}}@test_simple_indirect_call
|
|
; ATTRIBUTOR_GCN-SAME: () #[[ATTR0:[0-9]+]] {
|
|
; ATTRIBUTOR_GCN-NEXT: [[PC:%.*]] = call i64 @llvm.amdgcn.s.getpc()
|
|
; ATTRIBUTOR_GCN-NEXT: [[FUN:%.*]] = inttoptr i64 [[PC]] to ptr
|
|
; ATTRIBUTOR_GCN-NEXT: call amdgpu_gfx void [[FUN]]()
|
|
; ATTRIBUTOR_GCN-NEXT: ret void
|
|
;
|
|
; Attributor adds work-group-size attribute. This should be ok.
|
|
; GFX9-LABEL: test_simple_indirect_call:
|
|
; GFX9: ; %bb.0:
|
|
; GFX9-NEXT: s_getpc_b64 s[8:9]
|
|
; GFX9-NEXT: s_mov_b32 s8, s0
|
|
; GFX9-NEXT: s_load_dwordx4 s[8:11], s[8:9], 0x10
|
|
; GFX9-NEXT: s_getpc_b64 s[4:5]
|
|
; GFX9-NEXT: s_mov_b32 s32, 0
|
|
; GFX9-NEXT: s_waitcnt lgkmcnt(0)
|
|
; GFX9-NEXT: s_add_u32 s8, s8, s0
|
|
; GFX9-NEXT: s_addc_u32 s9, s9, 0
|
|
; GFX9-NEXT: s_mov_b64 s[0:1], s[8:9]
|
|
; GFX9-NEXT: s_mov_b64 s[2:3], s[10:11]
|
|
; GFX9-NEXT: s_swappc_b64 s[30:31], s[4:5]
|
|
; GFX9-NEXT: s_endpgm
|
|
; GFX10-LABEL: test_simple_indirect_call:
|
|
; GFX10: ; %bb.0:
|
|
; GFX10-NEXT: s_getpc_b64 s[8:9]
|
|
; GFX10-NEXT: s_mov_b32 s8, s0
|
|
; GFX10-NEXT: s_getpc_b64 s[4:5]
|
|
; GFX10-NEXT: s_load_dwordx4 s[8:11], s[8:9], 0x10
|
|
; GFX10-NEXT: s_mov_b32 s32, 0
|
|
; GFX10-NEXT: s_waitcnt lgkmcnt(0)
|
|
; GFX10-NEXT: s_bitset0_b32 s11, 21
|
|
; GFX10-NEXT: s_add_u32 s8, s8, s0
|
|
; GFX10-NEXT: s_addc_u32 s9, s9, 0
|
|
; GFX10-NEXT: s_mov_b64 s[0:1], s[8:9]
|
|
; GFX10-NEXT: s_mov_b64 s[2:3], s[10:11]
|
|
; GFX10-NEXT: s_swappc_b64 s[30:31], s[4:5]
|
|
; GFX10-NEXT: s_endpgm
|
|
|
|
|
|
%pc = call i64 @llvm.amdgcn.s.getpc()
|
|
%fun = inttoptr i64 %pc to ptr
|
|
call amdgpu_gfx void %fun()
|
|
ret void
|
|
}
|
|
|
|
; Function Attrs: nounwind readnone speculatable willreturn
|
|
declare i64 @llvm.amdgcn.s.getpc() #0
|
|
|
|
attributes #0 = { nounwind readnone speculatable willreturn }
|
|
;.
|
|
; ATTRIBUTOR_GCN: attributes #[[ATTR0]] = { "amdgpu-waves-per-eu"="4,10" "uniform-work-group-size"="false" }
|
|
; ATTRIBUTOR_GCN: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
|
|
;.
|