[PATCH] D29741: [AMDGPU] Calculate number of available SGPRs/VGPRs for WavesPerEU instead of using switch statement

Konstantin Zhuravlyov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 8 17:28:04 PST 2017


kzhuravl created this revision.
Herald added a reviewer: tstellarAMD.
Herald added subscribers: tpr, yaxunl, nhaehnle, wdng.

https://reviews.llvm.org/D29741

Files:
  lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp


Index: lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
===================================================================
--- lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
+++ lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
@@ -235,26 +235,12 @@
 unsigned getMaxNumSGPRs(const FeatureBitset &Features, unsigned WavesPerEU,
                         bool Addressable) {
   IsaVersion Version = getIsaVersion(Features);
-  if (Version.Major >= 8) {
-    switch (WavesPerEU) {
-      case 0:  return 80;
-      case 10: return 80;
-      case 9:  return 80;
-      case 8:  return 96;
-      default: return Addressable ? getAddressableNumSGPRs(Features) : 112;
-    }
-  } else {
-    switch (WavesPerEU) {
-      case 0:  return 48;
-      case 10: return 48;
-      case 9:  return 56;
-      case 8:  return 64;
-      case 7:  return 72;
-      case 6:  return 80;
-      case 5:  return 96;
-      default: return getAddressableNumSGPRs(Features);
-    }
-  }
+  unsigned MaxNumSGPRs = alignDown(getTotalNumSGPRs(Features) / WavesPerEU,
+                                   getSGPRAllocGranule(Features));
+  unsigned AddressableNumSGPRs = getAddressableNumSGPRs(Features);
+  if (Version.Major >= 8 && !Addressable)
+    AddressableNumSGPRs = 112;
+  return std::min(MaxNumSGPRs, AddressableNumSGPRs);
 }
 
 unsigned getVGPRAllocGranule(const FeatureBitset &Features) {
@@ -290,19 +276,10 @@
 }
 
 unsigned getMaxNumVGPRs(const FeatureBitset &Features, unsigned WavesPerEU) {
-  switch (WavesPerEU) {
-    case 0:  return 24;
-    case 10: return 24;
-    case 9:  return 28;
-    case 8:  return 32;
-    case 7:  return 36;
-    case 6:  return 40;
-    case 5:  return 48;
-    case 4:  return 64;
-    case 3:  return 84;
-    case 2:  return 128;
-    default: return getTotalNumVGPRs(Features);
-  }
+  unsigned MaxNumVGPRs = alignDown(getTotalNumVGPRs(Features) / WavesPerEU,
+                                   getVGPRAllocGranule(Features));
+  unsigned AddressableNumVGPRs = getAddressableNumVGPRs(Features);
+  return std::min(MaxNumVGPRs, AddressableNumVGPRs);
 }
 
 } // namespace IsaInfo


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29741.87740.patch
Type: text/x-patch
Size: 2092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170209/89ecd474/attachment.bin>


More information about the llvm-commits mailing list