[llvm] r316346 - AMDGPU: Fix default range in non-kernel functions
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 23 10:09:35 PDT 2017
Author: arsenm
Date: Mon Oct 23 10:09:35 2017
New Revision: 316346
URL: http://llvm.org/viewvc/llvm-project?rev=316346&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h
llvm/trunk/test/CodeGen/AMDGPU/zext-lid.ll
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp?rev=316346&r1=316345&r2=316346&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp Mon Oct 23 10:09:35 2017
@@ -190,14 +190,31 @@ unsigned AMDGPUSubtarget::getOccupancyWi
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.
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h?rev=316346&r1=316345&r2=316346&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h Mon Oct 23 10:09:35 2017
@@ -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
Modified: llvm/trunk/test/CodeGen/AMDGPU/zext-lid.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/zext-lid.ll?rev=316346&r1=316345&r2=316346&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/zext-lid.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/zext-lid.ll Mon Oct 23 10:09:35 2017
@@ -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-
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}
More information about the llvm-commits
mailing list