[Openmp-commits] [openmp] 952a0f2 - [Libomptarget] Introduce new globalization runtime calls

via Openmp-commits openmp-commits at lists.llvm.org
Tue Jun 22 07:08:32 PDT 2021


Author: Joseph Huber
Date: 2021-06-22T10:05:42-04:00
New Revision: 952a0f23852ce9448b10458449b0aa39061ffee5

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

LOG: [Libomptarget] Introduce new globalization runtime calls

Summary:
This patch introduces the new globalization runtime to be used by D97680. These
runtime calls will replace the __kmpc_data_sharing_push_stack and
__kmpc_data_sharing_pop_stack functions.

Reviewed By: tianshilei1992

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu b/openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
index e80211dd8f23b..97348972663af 100644
--- a/openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
+++ b/openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
@@ -46,7 +46,14 @@ EXTERN void __kmpc_data_sharing_init_stack() {
   // statically allocated shared memory slots. The size of a shared memory
   // slot is pre-determined to be 256 bytes.
   data_sharing_init_stack_common();
-  omptarget_nvptx_globalArgs.Init();
+}
+
+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

diff  --git a/openmp/libomptarget/deviceRTLs/common/src/omptarget.cu b/openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
index e19d67affc2b7..f0dab1be6df89 100644
--- a/openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
+++ b/openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
@@ -64,6 +64,10 @@ EXTERN void __kmpc_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime) {
       omptarget_nvptx_threadPrivateContext->GetTopLevelTaskDescr(threadId);
   nThreads = GetNumberOfThreadsInBlock();
   threadLimit = ThreadLimit;
+
+  if (!isSPMDMode())
+    omptarget_nvptx_globalArgs.Init();
+
   __kmpc_impl_target_init();
 }
 

diff  --git a/openmp/libomptarget/deviceRTLs/interface.h b/openmp/libomptarget/deviceRTLs/interface.h
index 8fb4089166a52..4c8f710ae6a33 100644
--- a/openmp/libomptarget/deviceRTLs/interface.h
+++ b/openmp/libomptarget/deviceRTLs/interface.h
@@ -462,4 +462,14 @@ EXTERN void __kmpc_get_team_static_memory(int16_t isSPMDExecutionMode,
 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


        


More information about the Openmp-commits mailing list