[nfc][libomptarget] Reorganise support header
Summary: [nfc][libomptarget] Reorganise support header All functions defined in support implementation are now declared in support.h Reordered functions in support implementation to match the sequence in support.h Added include guards to support.h Added #include interface to support.h to provide kmp_Ident declaration Move supporti.h to support.cu and s/INLINE/EXTERN/g Add remaining includes to support.cu A minor side effect is to change the name mangling of the support functions to extern "C". If this matters another macro along the lines of INLINE/EXTERN can be added - perhaps DEVICE as that's the obvious implementation. Reviewers: jdoerfert, ABataev, grokos Reviewed By: jdoerfert Subscribers: mgorny, jfb, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D69652
This commit is contained in:
		
							parent
							
								
									a2240f57e7
								
							
						
					
					
						commit
						764c8420e4
					
				| 
						 | 
					@ -55,6 +55,7 @@ if(LIBOMPTARGET_DEP_CUDA_FOUND)
 | 
				
			||||||
      src/omptarget-nvptx.cu
 | 
					      src/omptarget-nvptx.cu
 | 
				
			||||||
      src/parallel.cu
 | 
					      src/parallel.cu
 | 
				
			||||||
      src/reduction.cu
 | 
					      src/reduction.cu
 | 
				
			||||||
 | 
					      src/support.cu
 | 
				
			||||||
      src/sync.cu
 | 
					      src/sync.cu
 | 
				
			||||||
      src/task.cu
 | 
					      src/task.cu
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -385,6 +385,5 @@ INLINE omptarget_nvptx_TaskDescr *getMyTopTaskDescriptor(int globalThreadId);
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "omptarget-nvptxi.h"
 | 
					#include "omptarget-nvptxi.h"
 | 
				
			||||||
#include "supporti.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
//===--------- supporti.h - NVPTX OpenMP support functions ------- CUDA -*-===//
 | 
					//===--------- support.cu - NVPTX OpenMP support functions ------- CUDA -*-===//
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 | 
					// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 | 
				
			||||||
// See https://llvm.org/LICENSE.txt for license information.
 | 
					// See https://llvm.org/LICENSE.txt for license information.
 | 
				
			||||||
| 
						 | 
					@ -10,12 +10,14 @@
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//===----------------------------------------------------------------------===//
 | 
					//===----------------------------------------------------------------------===//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "support.h"
 | 
				
			||||||
 | 
					#include "debug.h"
 | 
				
			||||||
 | 
					#include "omptarget-nvptx.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
// Execution Parameters
 | 
					// Execution Parameters
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "target_impl.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
INLINE void setExecutionParameters(ExecutionMode EMode, RuntimeMode RMode) {
 | 
					INLINE void setExecutionParameters(ExecutionMode EMode, RuntimeMode RMode) {
 | 
				
			||||||
  execution_param = EMode;
 | 
					  execution_param = EMode;
 | 
				
			||||||
  execution_param |= RMode;
 | 
					  execution_param |= RMode;
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,12 @@
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//===----------------------------------------------------------------------===//
 | 
					//===----------------------------------------------------------------------===//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef OMPTARGET_SUPPORT_H
 | 
				
			||||||
 | 
					#define OMPTARGET_SUPPORT_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "interface.h"
 | 
				
			||||||
#include "target_impl.h"
 | 
					#include "target_impl.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
// Execution Parameters
 | 
					// Execution Parameters
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
| 
						 | 
					@ -26,58 +31,70 @@ enum RuntimeMode {
 | 
				
			||||||
  RuntimeMask = 0x02u,
 | 
					  RuntimeMask = 0x02u,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
INLINE void setExecutionParameters(ExecutionMode EMode, RuntimeMode RMode);
 | 
					DEVICE void setExecutionParameters(ExecutionMode EMode, RuntimeMode RMode);
 | 
				
			||||||
INLINE bool isGenericMode();
 | 
					DEVICE bool isGenericMode();
 | 
				
			||||||
INLINE bool isSPMDMode();
 | 
					DEVICE bool isSPMDMode();
 | 
				
			||||||
INLINE bool isRuntimeUninitialized();
 | 
					DEVICE bool isRuntimeUninitialized();
 | 
				
			||||||
INLINE bool isRuntimeInitialized();
 | 
					DEVICE bool isRuntimeInitialized();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// Execution Modes based on location parameter fields
 | 
				
			||||||
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEVICE bool checkSPMDMode(kmp_Ident *loc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEVICE bool checkGenericMode(kmp_Ident *loc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEVICE bool checkRuntimeUninitialized(kmp_Ident *loc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEVICE bool checkRuntimeInitialized(kmp_Ident *loc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
// get info from machine
 | 
					// get info from machine
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// get low level ids of resources
 | 
					// get low level ids of resources
 | 
				
			||||||
INLINE int GetThreadIdInBlock();
 | 
					DEVICE int GetThreadIdInBlock();
 | 
				
			||||||
INLINE int GetBlockIdInKernel();
 | 
					DEVICE int GetBlockIdInKernel();
 | 
				
			||||||
INLINE int GetNumberOfBlocksInKernel();
 | 
					DEVICE int GetNumberOfBlocksInKernel();
 | 
				
			||||||
INLINE int GetNumberOfThreadsInBlock();
 | 
					DEVICE int GetNumberOfThreadsInBlock();
 | 
				
			||||||
INLINE unsigned GetWarpId();
 | 
					DEVICE unsigned GetWarpId();
 | 
				
			||||||
INLINE unsigned GetLaneId();
 | 
					DEVICE unsigned GetLaneId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// get global ids to locate tread/team info (constant regardless of OMP)
 | 
					// get global ids to locate tread/team info (constant regardless of OMP)
 | 
				
			||||||
INLINE int GetLogicalThreadIdInBlock(bool isSPMDExecutionMode);
 | 
					DEVICE int GetLogicalThreadIdInBlock(bool isSPMDExecutionMode);
 | 
				
			||||||
INLINE int GetMasterThreadID();
 | 
					DEVICE int GetMasterThreadID();
 | 
				
			||||||
INLINE int GetNumberOfWorkersInTeam();
 | 
					DEVICE int GetNumberOfWorkersInTeam();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// get OpenMP thread and team ids
 | 
					// get OpenMP thread and team ids
 | 
				
			||||||
INLINE int GetOmpThreadId(int threadId,
 | 
					DEVICE int GetOmpThreadId(int threadId,
 | 
				
			||||||
                          bool isSPMDExecutionMode);    // omp_thread_num
 | 
					                          bool isSPMDExecutionMode);    // omp_thread_num
 | 
				
			||||||
INLINE int GetOmpTeamId();                              // omp_team_num
 | 
					DEVICE int GetOmpTeamId();                              // omp_team_num
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// get OpenMP number of threads and team
 | 
					// get OpenMP number of threads and team
 | 
				
			||||||
INLINE int GetNumberOfOmpThreads(bool isSPMDExecutionMode); // omp_num_threads
 | 
					DEVICE int GetNumberOfOmpThreads(bool isSPMDExecutionMode); // omp_num_threads
 | 
				
			||||||
INLINE int GetNumberOfOmpTeams();                           // omp_num_teams
 | 
					DEVICE int GetNumberOfOmpTeams();                           // omp_num_teams
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// get OpenMP number of procs
 | 
					// get OpenMP number of procs
 | 
				
			||||||
INLINE int GetNumberOfProcsInTeam(bool isSPMDExecutionMode);
 | 
					DEVICE int GetNumberOfProcsInTeam(bool isSPMDExecutionMode);
 | 
				
			||||||
INLINE int GetNumberOfProcsInDevice(bool isSPMDExecutionMode);
 | 
					DEVICE int GetNumberOfProcsInDevice(bool isSPMDExecutionMode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// masters
 | 
					// masters
 | 
				
			||||||
INLINE int IsTeamMaster(int ompThreadId);
 | 
					DEVICE int IsTeamMaster(int ompThreadId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Parallel level
 | 
					// Parallel level
 | 
				
			||||||
INLINE void IncParallelLevel(bool ActiveParallel, __kmpc_impl_lanemask_t Mask);
 | 
					DEVICE void IncParallelLevel(bool ActiveParallel, __kmpc_impl_lanemask_t Mask);
 | 
				
			||||||
INLINE void DecParallelLevel(bool ActiveParallel, __kmpc_impl_lanemask_t Mask);
 | 
					DEVICE void DecParallelLevel(bool ActiveParallel, __kmpc_impl_lanemask_t Mask);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
// Memory
 | 
					// Memory
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// safe alloc and free
 | 
					// safe alloc and free
 | 
				
			||||||
INLINE void *SafeMalloc(size_t size, const char *msg); // check if success
 | 
					DEVICE void *SafeMalloc(size_t size, const char *msg); // check if success
 | 
				
			||||||
INLINE void *SafeFree(void *ptr, const char *msg);
 | 
					DEVICE void *SafeFree(void *ptr, const char *msg);
 | 
				
			||||||
// pad to a alignment (power of 2 only)
 | 
					// pad to a alignment (power of 2 only)
 | 
				
			||||||
INLINE unsigned long PadBytes(unsigned long size, unsigned long alignment);
 | 
					DEVICE unsigned long PadBytes(unsigned long size, unsigned long alignment);
 | 
				
			||||||
#define ADD_BYTES(_addr, _bytes)                                               \
 | 
					#define ADD_BYTES(_addr, _bytes)                                               \
 | 
				
			||||||
  ((void *)((char *)((void *)(_addr)) + (_bytes)))
 | 
					  ((void *)((char *)((void *)(_addr)) + (_bytes)))
 | 
				
			||||||
#define SUB_BYTES(_addr, _bytes)                                               \
 | 
					#define SUB_BYTES(_addr, _bytes)                                               \
 | 
				
			||||||
| 
						 | 
					@ -86,6 +103,8 @@ INLINE unsigned long PadBytes(unsigned long size, unsigned long alignment);
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
// Teams Reduction Scratchpad Helpers
 | 
					// Teams Reduction Scratchpad Helpers
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
INLINE unsigned int *GetTeamsReductionTimestamp();
 | 
					DEVICE unsigned int *GetTeamsReductionTimestamp();
 | 
				
			||||||
INLINE char *GetTeamsReductionScratchpad();
 | 
					DEVICE char *GetTeamsReductionScratchpad();
 | 
				
			||||||
INLINE void SetTeamsReductionScratchpadPtr(void *ScratchpadPtr);
 | 
					DEVICE void SetTeamsReductionScratchpadPtr(void *ScratchpadPtr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,8 +15,9 @@
 | 
				
			||||||
#include <cuda.h>
 | 
					#include <cuda.h>
 | 
				
			||||||
#include "nvptx_interface.h"
 | 
					#include "nvptx_interface.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define INLINE __forceinline__ __device__
 | 
					#define DEVICE __device__
 | 
				
			||||||
#define NOINLINE __noinline__ __device__
 | 
					#define INLINE __forceinline__ DEVICE
 | 
				
			||||||
 | 
					#define NOINLINE __noinline__ DEVICE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
// Kernel options
 | 
					// Kernel options
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,5 +21,6 @@
 | 
				
			||||||
#include "src/omptarget-nvptx.cu"
 | 
					#include "src/omptarget-nvptx.cu"
 | 
				
			||||||
#include "src/parallel.cu"
 | 
					#include "src/parallel.cu"
 | 
				
			||||||
#include "src/reduction.cu"
 | 
					#include "src/reduction.cu"
 | 
				
			||||||
 | 
					#include "src/support.cu"
 | 
				
			||||||
#include "src/sync.cu"
 | 
					#include "src/sync.cu"
 | 
				
			||||||
#include "src/task.cu"
 | 
					#include "src/task.cu"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue