mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
AMDGPU: Fix default range in non-kernel functions
The range should be assumed to be the hardware maximum if a workitem intrinsic is used in a callable function which does not know the restricted limit of the calling kernel. llvm-svn: 316346
This commit is contained in:
parent
2002419a4c
commit
a23dd86c65
@ -190,14 +190,31 @@ unsigned AMDGPUSubtarget::getOccupancyWithLocalMemSize(uint32_t Bytes,
|
||||
return NumWaves;
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned>
|
||||
AMDGPUSubtarget::getDefaultFlatWorkGroupSize(CallingConv::ID CC) const {
|
||||
switch (CC) {
|
||||
case CallingConv::AMDGPU_CS:
|
||||
case CallingConv::AMDGPU_KERNEL:
|
||||
case CallingConv::SPIR_KERNEL:
|
||||
return std::make_pair(getWavefrontSize() * 2, getWavefrontSize() * 4);
|
||||
case CallingConv::AMDGPU_VS:
|
||||
case CallingConv::AMDGPU_LS:
|
||||
case CallingConv::AMDGPU_HS:
|
||||
case CallingConv::AMDGPU_ES:
|
||||
case CallingConv::AMDGPU_GS:
|
||||
case CallingConv::AMDGPU_PS:
|
||||
return std::make_pair(1, getWavefrontSize());
|
||||
default:
|
||||
return std::make_pair(1, 16 * getWavefrontSize());
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned> AMDGPUSubtarget::getFlatWorkGroupSizes(
|
||||
const Function &F) const {
|
||||
// FIXME: 1024 if function.
|
||||
// Default minimum/maximum flat work group sizes.
|
||||
std::pair<unsigned, unsigned> Default =
|
||||
AMDGPU::isCompute(F.getCallingConv()) ?
|
||||
std::pair<unsigned, unsigned>(getWavefrontSize() * 2,
|
||||
getWavefrontSize() * 4) :
|
||||
std::pair<unsigned, unsigned>(1, getWavefrontSize());
|
||||
getDefaultFlatWorkGroupSize(F.getCallingConv());
|
||||
|
||||
// TODO: Do not process "amdgpu-max-work-group-size" attribute once mesa
|
||||
// starts using "amdgpu-flat-work-group-size" attribute.
|
||||
|
@ -587,6 +587,9 @@ public:
|
||||
FlatWorkGroupSize);
|
||||
}
|
||||
|
||||
/// \returns Default range flat work group size for a calling convention.
|
||||
std::pair<unsigned, unsigned> getDefaultFlatWorkGroupSize(CallingConv::ID CC) const;
|
||||
|
||||
/// \returns Subtarget's default pair of minimum/maximum flat work group sizes
|
||||
/// for function \p F, or minimum/maximum flat work group sizes explicitly
|
||||
/// requested using "amdgpu-flat-work-group-size" attribute attached to
|
||||
|
@ -63,6 +63,26 @@ bb:
|
||||
ret void
|
||||
}
|
||||
|
||||
; OPT-LABEL: @func_test_workitem_id_x_known_max_range(
|
||||
; OPT: tail call i32 @llvm.amdgcn.workitem.id.x(), !range !0
|
||||
define void @func_test_workitem_id_x_known_max_range(i32 addrspace(1)* nocapture %out) #0 {
|
||||
entry:
|
||||
%id = tail call i32 @llvm.amdgcn.workitem.id.x()
|
||||
%and = and i32 %id, 1023
|
||||
store i32 %and, i32 addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; OPT-LABEL: @func_test_workitem_id_x_default_range(
|
||||
; OPT: tail call i32 @llvm.amdgcn.workitem.id.x(), !range !6
|
||||
define void @func_test_workitem_id_x_default_range(i32 addrspace(1)* nocapture %out) #4 {
|
||||
entry:
|
||||
%id = tail call i32 @llvm.amdgcn.workitem.id.x()
|
||||
%and = and i32 %id, 1023
|
||||
store i32 %and, i32 addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i32 @llvm.amdgcn.workitem.id.x() #2
|
||||
|
||||
declare i32 @llvm.amdgcn.workitem.id.y() #2
|
||||
@ -73,6 +93,7 @@ attributes #0 = { nounwind "amdgpu-flat-work-group-size"="64,128" }
|
||||
attributes #1 = { nounwind "amdgpu-flat-work-group-size"="512,512" }
|
||||
attributes #2 = { nounwind readnone speculatable }
|
||||
attributes #3 = { nounwind readnone }
|
||||
attributes #4 = { nounwind }
|
||||
|
||||
!0 = !{i32 32, i32 4, i32 1}
|
||||
|
||||
@ -82,3 +103,4 @@ attributes #3 = { nounwind readnone }
|
||||
; OPT: !3 = !{i32 0, i32 4}
|
||||
; OPT: !4 = !{i32 0, i32 1}
|
||||
; OPT: !5 = !{i32 0, i32 512}
|
||||
; OPT: !6 = !{i32 0, i32 1024}
|
||||
|
Loading…
Reference in New Issue
Block a user