[Openmp-commits] [PATCH] D102532: [Libomptarget] Introduce new globalization runtime calls

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri May 14 14:00:31 PDT 2021


jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992.
jhuber6 added a project: OpenMP.
jhuber6 requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1.

This patch introduces the new globalization runtime to be used by D97680 <https://reviews.llvm.org/D97680>. These
runtime calls will replace the `__kmpc_data_sharing_push_stack` and
`__kmpc_data_sharing_pop_stack` functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102532

Files:
  openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
  openmp/libomptarget/deviceRTLs/interface.h


Index: openmp/libomptarget/deviceRTLs/interface.h
===================================================================
--- openmp/libomptarget/deviceRTLs/interface.h
+++ openmp/libomptarget/deviceRTLs/interface.h
@@ -462,4 +462,14 @@
 EXTERN void __kmpc_restore_team_static_memory(int16_t isSPMDExecutionMode,
                                               int16_t is_shared);
 
+/// Allocate \p Bytes in "shareable" memory and return the address. Needs to be
+/// called balanced with __kmpc_free_shared like a stack (push/pop). Can be
+/// called by any thread, allocation happens per-thread.
+EXTERN void *__kmpc_alloc_shared(uint64_t Bytes);
+
+/// Deallocate \p Ptr. Needs to be called balanced with __kmpc_alloc_shared like
+/// a stack (push/pop). Can be called by any thread. \p Ptr must be allocated by
+/// __kmpc_alloc_shared by the same thread.
+EXTERN void __kmpc_free_shared(void *Ptr);
+
 #endif
Index: openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
===================================================================
--- openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
+++ openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
@@ -36,6 +36,14 @@
   }
 }
 
+EXTERN void *__kmpc_alloc_shared(size_t DataSize) {
+  return (void *)SafeMalloc(DataSize, "Alloc Shared");
+}
+
+EXTERN void __kmpc_free_shared(void *FrameStart) {
+  SafeFree(FrameStart, "Free Shared");
+}
+
 // Initialize data sharing data structure. This function needs to be called
 // once at the beginning of a data sharing context (coincides with the kernel
 // initialization). This function is called only by the MASTER thread of each


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102532.345555.patch
Type: text/x-patch
Size: 1642 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210514/1ed546f8/attachment.bin>


More information about the Openmp-commits mailing list