diff options
author | Tom Stellard <tstellar@redhat.com> | 2018-12-15 04:32:11 +0000 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2018-12-15 04:32:11 +0000 |
commit | 17721c5ed149d81546e092560ca2ba28331f7270 (patch) | |
tree | 07778fe8f0038268045ce4b1050cd53bbedbc838 /final/libomptarget/deviceRTLs/nvptx/src/support.h | |
parent | 9a6752f4a72f56ba2a27195e34043eebe82b5155 (diff) |
Creating release candidate final from release_701 branchsvn-tags/RELEASE_701
git-svn-id: https://llvm.org/svn/llvm-project/openmp/tags/RELEASE_701@349248 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'final/libomptarget/deviceRTLs/nvptx/src/support.h')
-rw-r--r-- | final/libomptarget/deviceRTLs/nvptx/src/support.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/final/libomptarget/deviceRTLs/nvptx/src/support.h b/final/libomptarget/deviceRTLs/nvptx/src/support.h new file mode 100644 index 0000000..44298f4 --- /dev/null +++ b/final/libomptarget/deviceRTLs/nvptx/src/support.h @@ -0,0 +1,92 @@ +//===--------- support.h - NVPTX OpenMP support functions -------- CUDA -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.txt for details. +// +//===----------------------------------------------------------------------===// +// +// Wrapper to some functions natively supported by the GPU. +// +//===----------------------------------------------------------------------===// + +//////////////////////////////////////////////////////////////////////////////// +// Execution Parameters +//////////////////////////////////////////////////////////////////////////////// +enum ExecutionMode { + Generic = 0x00u, + Spmd = 0x01u, + ModeMask = 0x01u, +}; + +enum RuntimeMode { + RuntimeInitialized = 0x00u, + RuntimeUninitialized = 0x02u, + RuntimeMask = 0x02u, +}; + +INLINE void setExecutionParameters(ExecutionMode EMode, RuntimeMode RMode); +INLINE bool isGenericMode(); +INLINE bool isSPMDMode(); +INLINE bool isRuntimeUninitialized(); +INLINE bool isRuntimeInitialized(); + +//////////////////////////////////////////////////////////////////////////////// +// get info from machine +//////////////////////////////////////////////////////////////////////////////// + +// get low level ids of resources +INLINE int GetThreadIdInBlock(); +INLINE int GetBlockIdInKernel(); +INLINE int GetNumberOfBlocksInKernel(); +INLINE int GetNumberOfThreadsInBlock(); + +// get global ids to locate tread/team info (constant regardless of OMP) +INLINE int GetLogicalThreadIdInBlock(); +INLINE int GetMasterThreadID(); +INLINE int GetNumberOfWorkersInTeam(); + +// get OpenMP thread and team ids +INLINE int GetOmpThreadId(int threadId, bool isSPMDExecutionMode, + bool isRuntimeUninitialized); // omp_thread_num +INLINE int GetOmpTeamId(); // omp_team_num + +// get OpenMP number of threads and team +INLINE int +GetNumberOfOmpThreads(int threadId, bool isSPMDExecutionMode, + bool isRuntimeUninitialized); // omp_num_threads +INLINE int GetNumberOfOmpTeams(); // omp_num_teams + +// get OpenMP number of procs +INLINE int GetNumberOfProcsInTeam(); +INLINE int GetNumberOfProcsInDevice(); + +// masters +INLINE int IsTeamMaster(int ompThreadId); + +//////////////////////////////////////////////////////////////////////////////// +// Memory +//////////////////////////////////////////////////////////////////////////////// + +// safe alloc and free +INLINE void *SafeMalloc(size_t size, const char *msg); // check if success +INLINE void *SafeFree(void *ptr, const char *msg); +// pad to a alignment (power of 2 only) +INLINE unsigned long PadBytes(unsigned long size, unsigned long alignment); +#define ADD_BYTES(_addr, _bytes) \ + ((void *)((char *)((void *)(_addr)) + (_bytes))) +#define SUB_BYTES(_addr, _bytes) \ + ((void *)((char *)((void *)(_addr)) - (_bytes))) + +//////////////////////////////////////////////////////////////////////////////// +// Named Barrier Routines +//////////////////////////////////////////////////////////////////////////////// +INLINE void named_sync(const int barrier, const int num_threads); + +//////////////////////////////////////////////////////////////////////////////// +// Teams Reduction Scratchpad Helpers +//////////////////////////////////////////////////////////////////////////////// +INLINE unsigned int *GetTeamsReductionTimestamp(); +INLINE char *GetTeamsReductionScratchpad(); +INLINE void SetTeamsReductionScratchpadPtr(void *ScratchpadPtr); |