[Openmp-commits] [PATCH] D103093: [libomptarget][nfc][amdgpu] Refactor uses of KernelInfoTable

Jon Chesterfield via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue May 25 08:49:55 PDT 2021


JonChesterfield created this revision.
JonChesterfield added a reviewer: dhruvachak.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
JonChesterfield requested review of this revision.
Herald added subscribers: openmp-commits, wdng.
Herald added a project: OpenMP.

[libomptarget][nfc][amdgpu] Refactor uses of KernelInfoTable

Suggested in D103059 <https://reviews.llvm.org/D103059>. Use a single lookup instead of two, more const, less mutation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103093

Files:
  openmp/libomptarget/plugins/amdgpu/src/rtl.cpp


Index: openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
===================================================================
--- openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -1788,17 +1788,15 @@
     return OFFLOAD_FAIL;
   }
 
-  uint32_t group_segment_size;
-  uint32_t sgpr_count, vgpr_count, sgpr_spill_count, vgpr_spill_count;
+  const atl_kernel_info_t KernelInfoEntry =
+      KernelInfoTable[device_id][kernel_name];
+  const uint32_t group_segment_size = KernelInfoEntry.group_segment_size;
+  const uint32_t sgpr_count = KernelInfoEntry.sgpr_count;
+  const uint32_t vgpr_count = KernelInfoEntry.vgpr_count;
+  const uint32_t sgpr_spill_count = KernelInfoEntry.sgpr_spill_count;
+  const uint32_t vgpr_spill_count = KernelInfoEntry.vgpr_spill_count;
 
-  {
-    auto it = KernelInfoTable[device_id][kernel_name];
-    group_segment_size = it.group_segment_size;
-    sgpr_count = it.sgpr_count;
-    vgpr_count = it.vgpr_count;
-    sgpr_spill_count = it.sgpr_spill_count;
-    vgpr_spill_count = it.vgpr_spill_count;
-  }
+  assert(arg_num == (int)KernelInfoEntry.num_args);
 
   /*
    * Set limit based on ThreadsPerGroup and GroupsPerDevice
@@ -1851,21 +1849,13 @@
     packet->grid_size_x = num_groups * threadsPerGroup;
     packet->grid_size_y = 1;
     packet->grid_size_z = 1;
-    packet->private_segment_size = 0;
-    packet->group_segment_size = 0;
-    packet->kernel_object = 0;
+    packet->private_segment_size = KernelInfoEntry.private_segment_size;
+    packet->group_segment_size = KernelInfoEntry.group_segment_size;
+    packet->kernel_object = KernelInfoEntry.kernel_object;
     packet->kernarg_address = 0;     // use the block allocator
     packet->reserved2 = 0;           // atmi writes id_ here
     packet->completion_signal = {0}; // may want a pool of signals
 
-    {
-      auto it = KernelInfoTable[device_id][kernel_name];
-      packet->kernel_object = it.kernel_object;
-      packet->private_segment_size = it.private_segment_size;
-      packet->group_segment_size = it.group_segment_size;
-      assert(arg_num == (int)it.num_args);
-    }
-
     KernelArgPool *ArgPool = nullptr;
     {
       auto it = KernelArgPoolMap.find(std::string(KernelInfo->Name));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103093.347697.patch
Type: text/x-patch
Size: 2264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210525/23faced4/attachment-0001.bin>


More information about the Openmp-commits mailing list