[Openmp-commits] [PATCH] D108698: [libomptarget][amdgpu] Macro for accessing GPU variables from plugin

Jon Chesterfield via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Aug 25 05:59:18 PDT 2021


JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, tianshilei1992, grokos, ronlieb, ye-luo.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, jvesely, kzhuravl.
JonChesterfield requested review of this revision.
Herald added subscribers: openmp-commits, wdng.
Herald added a project: OpenMP.

Lets the amdgpu plugin write to omptarget_device_environment
to enable debugging. Intend to use in the near future to record the
wavesize that a given deviceRTL was compiled with for running on hardware
that supports 32 or 64.

Patch sets all the attributes that are useful. Notably .data means the variable
is set by writing to host memory before copying to the GPU instead of launching
a kernel to update the image. Can simplify the plugin slightly to drop the
code for patching after load if this is used consistently.

NFC on nvptx, cuda plugin seems to work fine without any annotations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108698

Files:
  openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
  openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h


Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
@@ -26,6 +26,7 @@
 #define INLINE inline __attribute__((always_inline))
 #define NOINLINE __attribute__((noinline))
 #define ALIGN(N) __attribute__((aligned(N)))
+#define PLUGIN_ACCESSIBLE /* no annotation needed for cuda plugin */
 
 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
 
Index: openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
===================================================================
--- openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
+++ openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
@@ -19,6 +19,7 @@
 // global device environment
 ////////////////////////////////////////////////////////////////////////////////
 
+PLUGIN_ACCESSIBLE
 omptarget_device_environmentTy omptarget_device_environment;
 
 ////////////////////////////////////////////////////////////////////////////////
Index: openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
===================================================================
--- openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
+++ openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
@@ -30,6 +30,10 @@
 #define INLINE inline
 #define NOINLINE __attribute__((noinline))
 #define ALIGN(N) __attribute__((aligned(N)))
+#define PLUGIN_ACCESSIBLE                                                      \
+  __attribute__((used)) /* Don't discard values the plugin reads */            \
+      __attribute__((visibility("default"))) /* Access via SHT_HASH */         \
+      __attribute__((section(".data"))) /* Not .bss, can write before load */
 
 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108698.368620.patch
Type: text/x-patch
Size: 1836 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210825/c6eda658/attachment.bin>


More information about the Openmp-commits mailing list