[PATCH] D148525: [OpenMP][AMDGPU] Refactor setting uniform work group size attribute

Dominik Adamski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 17 06:19:01 PDT 2023


domada created this revision.
domada added reviewers: jsjodin, ronlieb, dpalermo, JonChesterfield, agozillon, gregrodgers, skatrak, raghavendhra, RogerV-AMD, saiislam.
domada added projects: OpenMP, AMDGPU.
Herald added subscribers: sunshaoce, kosarev, guansong, hiraditya, tpr, dstuttard, yaxunl, kzhuravl.
Herald added a project: All.
domada requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jplehr, sstefan1, wdng.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, LLVM.

Work group size attribute was set in Clang specific class. That's why we cannot reuse this code in Flang.

If we move setting of this attribute to OpenMPIRBuilder, then we can reuse this code in Flang and Clang. Function `createOffloadEntry` from OpenMPIRBuilder is already used by Clang (via `OpenMPIRBuilder::createOffloadEntriesAndInfoMetadata` function).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148525

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===================================================================
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4892,6 +4892,8 @@
 
   // Add a function attribute for the kernel.
   Fn->addFnAttr(Attribute::get(Ctx, "kernel"));
+  if (Triple(M.getTargetTriple()).isAMDGCN())
+    Fn->addFnAttr("uniform-work-group-size", "true");
 }
 
 // We only generate metadata for function that contain target regions.
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9588,12 +9588,9 @@
 
   const bool IsHIPKernel =
       M.getLangOpts().HIP && FD && FD->hasAttr<CUDAGlobalAttr>();
-  const bool IsOpenMPkernel =
-      M.getLangOpts().OpenMPIsDevice &&
-      (F->getCallingConv() == llvm::CallingConv::AMDGPU_KERNEL);
 
   // TODO: This should be moved to language specific attributes instead.
-  if (IsHIPKernel || IsOpenMPkernel)
+  if (IsHIPKernel)
     F->addFnAttr("uniform-work-group-size", "true");
 
   if (M.getContext().getTargetInfo().allowAMDGPUUnsafeFPAtomics())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148525.514185.patch
Type: text/x-patch
Size: 1206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230417/fc58e59d/attachment-0001.bin>


More information about the cfe-commits mailing list