[PATCH] D106033: Folding threadLimit and numThreads when single value in kernels

Jose Manuel Monsalve Diaz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 14 20:05:26 PDT 2021


josemonsalve2 created this revision.
josemonsalve2 added reviewers: jdoerfert, JonChesterfield, ggeorgakoudis, jhuber6, baziotis, sstefan1, uenoku, tianshilei1992.
Herald added subscribers: ormris, hiraditya, jvesely.
josemonsalve2 requested review of this revision.
Herald added subscribers: llvm-commits, openmp-commits, bbn.
Herald added projects: OpenMP, LLVM.

The device runtime contains several calls to `__kmpc_get_hardware_num_threads_in_block`
and `__kmpc_get_hardware_num_blocks`. If the thread_limit and the num_teams are constant,
these calls can be folded to the constant value.

In this patch we use the already introduced `AAFoldRuntimeCall` and the `NumTeams` and
`NumThreads` kernel attributes (to be introduced in a different patch) to fold these functions.
The code checks all the kernels, and if their attributes match, the functions are folded.

In the future we will explore specializing for multiple values of NumThreads and NumTeams.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106033

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
  openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.hip
  openmp/libomptarget/deviceRTLs/common/src/libcall.cu
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/common/src/reduction.cu
  openmp/libomptarget/deviceRTLs/common/src/support.cu
  openmp/libomptarget/deviceRTLs/common/support.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
  openmp/libomptarget/deviceRTLs/target_interface.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106033.358830.patch
Type: text/x-patch
Size: 19799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210715/f4569447/attachment.bin>


More information about the llvm-commits mailing list