[Openmp-commits] [PATCH] D135444: [OpenMP] Utilize the "non-uniform-workgroup" to simplify DeviceRTL

Johannes Doerfert via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Oct 7 06:36:18 PDT 2022


jdoerfert created this revision.
jdoerfert added reviewers: jhuber6, tianshilei1992.
Herald added subscribers: guansong, bollu, yaxunl.
Herald added a project: All.
jdoerfert requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: OpenMP.

OpenMP offloading always uses uniform workgroups, see
https://reviews.llvm.org/D135374. The runtime doesn't need to handle
non-uniform workgroups at all either.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135444

Files:
  openmp/libomptarget/DeviceRTL/src/Mapping.cpp


Index: openmp/libomptarget/DeviceRTL/src/Mapping.cpp
===================================================================
--- openmp/libomptarget/DeviceRTL/src/Mapping.cpp
+++ openmp/libomptarget/DeviceRTL/src/Mapping.cpp
@@ -26,9 +26,6 @@
 
 // Forward declarations defined to be defined for AMDGCN and NVPTX.
 const llvm::omp::GV &getGridValue();
-uint32_t getGridDim(uint32_t n, uint16_t d);
-uint32_t getWorkgroupDim(uint32_t group_id, uint32_t grid_size,
-                         uint16_t group_size);
 uint32_t getNumHardwareThreadsInBlock();
 LaneMaskTy activemask();
 LaneMaskTy lanemaskLT();
@@ -50,21 +47,8 @@
   return llvm::omp::getAMDGPUGridValues<__AMDGCN_WAVEFRONT_SIZE>();
 }
 
-uint32_t getGridDim(uint32_t n, uint16_t d) {
-  uint32_t q = n / d;
-  return q + (n > q * d);
-}
-
-uint32_t getWorkgroupDim(uint32_t group_id, uint32_t grid_size,
-                         uint16_t group_size) {
-  uint32_t r = grid_size - group_id * group_size;
-  return (r < group_size) ? r : group_size;
-}
-
 uint32_t getNumHardwareThreadsInBlock() {
-  return getWorkgroupDim(__builtin_amdgcn_workgroup_id_x(),
-                         __builtin_amdgcn_grid_size_x(),
-                         __builtin_amdgcn_workgroup_size_x());
+  return __builtin_amdgcn_workgroup_size_x();
 }
 
 LaneMaskTy activemask() { return __builtin_amdgcn_read_exec(); }
@@ -95,10 +79,7 @@
 
 uint32_t getBlockId() { return __builtin_amdgcn_workgroup_id_x(); }
 
-uint32_t getNumberOfBlocks() {
-  return getGridDim(__builtin_amdgcn_grid_size_x(),
-                    __builtin_amdgcn_workgroup_size_x());
-}
+uint32_t getNumberOfBlocks() { return __builtin_amdgcn_grid_size_x(); }
 
 uint32_t getWarpId() {
   return impl::getThreadIdInBlock() / mapping::getWarpSize();
@@ -228,8 +209,8 @@
 uint32_t mapping::getWarpSize() { return impl::getWarpSize(); }
 
 uint32_t mapping::getBlockSize(bool IsSPMD) {
-  uint32_t BlockSize = mapping::getNumberOfProcessorElements() -
-                       (!IsSPMD * impl::getWarpSize());
+  uint32_t BlockSize =
+      mapping::getNumberOfProcessorElements() - (!IsSPMD * impl::getWarpSize());
   return BlockSize;
 }
 uint32_t mapping::getBlockSize() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135444.466063.patch
Type: text/x-patch
Size: 2179 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20221007/f1097b6d/attachment.bin>


More information about the Openmp-commits mailing list