// 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
omptarget_nvptx_threadPrivateContext->GetTopLevelTaskDescr(threadId);
nThreads = GetNumberOfThreadsInBlock();
threadLimit = ThreadLimit;
+
+ if (!isSPMDMode())
+ omptarget_nvptx_globalArgs.Init();
+
__kmpc_impl_target_init();
}
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