[Openmp-commits] [openmp] a5f4074 - [libomptarget][amdgpu] Macro for accessing GPU variables from plugin

Jon Chesterfield via Openmp-commits openmp-commits at lists.llvm.org
Thu Aug 26 09:28:30 PDT 2021


Author: Jon Chesterfield
Date: 2021-08-26T17:28:18+01:00
New Revision: a5f4074d85bd7633c6d2cd3abaa7ac169430b32c

URL: https://github.com/llvm/llvm-project/commit/a5f4074d85bd7633c6d2cd3abaa7ac169430b32c
DIFF: https://github.com/llvm/llvm-project/commit/a5f4074d85bd7633c6d2cd3abaa7ac169430b32c.diff

LOG: [libomptarget][amdgpu] Macro for accessing GPU variables from plugin

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.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D108698

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h b/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
index 6921f9bc63483..5396590d46e00 100644
--- a/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
+++ b/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
@@ -30,6 +30,10 @@ typedef uint64_t __kmpc_impl_lanemask_t;
 #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"
 

diff  --git a/openmp/libomptarget/deviceRTLs/common/src/omp_data.cu b/openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
index 6c728751393f3..e31217e1df80a 100644
--- a/openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
+++ b/openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
@@ -19,6 +19,7 @@
 // global device environment
 ////////////////////////////////////////////////////////////////////////////////
 
+PLUGIN_ACCESSIBLE
 omptarget_device_environmentTy omptarget_device_environment;
 
 ////////////////////////////////////////////////////////////////////////////////

diff  --git a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
index 1f64bb99afb5e..ab471e3116327 100644
--- a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
+++ b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
@@ -26,6 +26,7 @@ typedef uint32_t __kmpc_impl_lanemask_t;
 #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"
 


        


More information about the Openmp-commits mailing list