[PATCH] D39036: AMDGPU: Fix default range in non-kernel functions
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 17 21:23:45 PDT 2017
arsenm created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng.
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.
https://reviews.llvm.org/D39036
Files:
lib/Target/AMDGPU/AMDGPUSubtarget.cpp
lib/Target/AMDGPU/AMDGPUSubtarget.h
test/CodeGen/AMDGPU/zext-lid.ll
Index: test/CodeGen/AMDGPU/zext-lid.ll
===================================================================
--- test/CodeGen/AMDGPU/zext-lid.ll
+++ test/CodeGen/AMDGPU/zext-lid.ll
@@ -63,6 +63,26 @@
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 #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 @@
; OPT: !3 = !{i32 0, i32 4}
; OPT: !4 = !{i32 0, i32 1}
; OPT: !5 = !{i32 0, i32 512}
+; OPT: !6 = !{i32 0, i32 1024}
Index: lib/Target/AMDGPU/AMDGPUSubtarget.h
===================================================================
--- lib/Target/AMDGPU/AMDGPUSubtarget.h
+++ lib/Target/AMDGPU/AMDGPUSubtarget.h
@@ -587,6 +587,9 @@
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
Index: lib/Target/AMDGPU/AMDGPUSubtarget.cpp
===================================================================
--- lib/Target/AMDGPU/AMDGPUSubtarget.cpp
+++ lib/Target/AMDGPU/AMDGPUSubtarget.cpp
@@ -190,14 +190,31 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39036.119424.patch
Type: text/x-patch
Size: 3625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171018/bd10ebc8/attachment.bin>
More information about the llvm-commits
mailing list