10
10
//
11
11
//===----------------------------------------------------------------------===//
12
12
13
+ #ifndef OMPTARGET_SUPPORT_H
14
+ #define OMPTARGET_SUPPORT_H
15
+
16
+ #include "interface.h"
13
17
#include "target_impl.h"
18
+
14
19
////////////////////////////////////////////////////////////////////////////////
15
20
// Execution Parameters
16
21
////////////////////////////////////////////////////////////////////////////////
@@ -26,58 +31,70 @@ enum RuntimeMode {
26
31
RuntimeMask = 0x02u ,
27
32
};
28
33
29
- INLINE void setExecutionParameters (ExecutionMode EMode , RuntimeMode RMode );
30
- INLINE bool isGenericMode ();
31
- INLINE bool isSPMDMode ();
32
- INLINE bool isRuntimeUninitialized ();
33
- INLINE bool isRuntimeInitialized ();
34
+ DEVICE void setExecutionParameters (ExecutionMode EMode , RuntimeMode RMode );
35
+ DEVICE bool isGenericMode ();
36
+ DEVICE bool isSPMDMode ();
37
+ DEVICE bool isRuntimeUninitialized ();
38
+ DEVICE bool isRuntimeInitialized ();
39
+
40
+ ////////////////////////////////////////////////////////////////////////////////
41
+ // Execution Modes based on location parameter fields
42
+ ////////////////////////////////////////////////////////////////////////////////
43
+
44
+ DEVICE bool checkSPMDMode (kmp_Ident * loc );
45
+
46
+ DEVICE bool checkGenericMode (kmp_Ident * loc );
47
+
48
+ DEVICE bool checkRuntimeUninitialized (kmp_Ident * loc );
49
+
50
+ DEVICE bool checkRuntimeInitialized (kmp_Ident * loc );
34
51
35
52
////////////////////////////////////////////////////////////////////////////////
36
53
// get info from machine
37
54
////////////////////////////////////////////////////////////////////////////////
38
55
39
56
// get low level ids of resources
40
- INLINE int GetThreadIdInBlock ();
41
- INLINE int GetBlockIdInKernel ();
42
- INLINE int GetNumberOfBlocksInKernel ();
43
- INLINE int GetNumberOfThreadsInBlock ();
44
- INLINE unsigned GetWarpId ();
45
- INLINE unsigned GetLaneId ();
57
+ DEVICE int GetThreadIdInBlock ();
58
+ DEVICE int GetBlockIdInKernel ();
59
+ DEVICE int GetNumberOfBlocksInKernel ();
60
+ DEVICE int GetNumberOfThreadsInBlock ();
61
+ DEVICE unsigned GetWarpId ();
62
+ DEVICE unsigned GetLaneId ();
46
63
47
64
// get global ids to locate tread/team info (constant regardless of OMP)
48
- INLINE int GetLogicalThreadIdInBlock (bool isSPMDExecutionMode );
49
- INLINE int GetMasterThreadID ();
50
- INLINE int GetNumberOfWorkersInTeam ();
65
+ DEVICE int GetLogicalThreadIdInBlock (bool isSPMDExecutionMode );
66
+ DEVICE int GetMasterThreadID ();
67
+ DEVICE int GetNumberOfWorkersInTeam ();
51
68
52
69
// get OpenMP thread and team ids
53
- INLINE int GetOmpThreadId (int threadId ,
70
+ DEVICE int GetOmpThreadId (int threadId ,
54
71
bool isSPMDExecutionMode ); // omp_thread_num
55
- INLINE int GetOmpTeamId (); // omp_team_num
72
+ DEVICE int GetOmpTeamId (); // omp_team_num
56
73
57
74
// get OpenMP number of threads and team
58
- INLINE int GetNumberOfOmpThreads (bool isSPMDExecutionMode ); // omp_num_threads
59
- INLINE int GetNumberOfOmpTeams (); // omp_num_teams
75
+ DEVICE int GetNumberOfOmpThreads (bool isSPMDExecutionMode ); // omp_num_threads
76
+ DEVICE int GetNumberOfOmpTeams (); // omp_num_teams
60
77
61
78
// get OpenMP number of procs
62
- INLINE int GetNumberOfProcsInTeam (bool isSPMDExecutionMode );
63
- INLINE int GetNumberOfProcsInDevice (bool isSPMDExecutionMode );
79
+ DEVICE int GetNumberOfProcsInTeam (bool isSPMDExecutionMode );
80
+ DEVICE int GetNumberOfProcsInDevice (bool isSPMDExecutionMode );
64
81
65
82
// masters
66
- INLINE int IsTeamMaster (int ompThreadId );
83
+ DEVICE int IsTeamMaster (int ompThreadId );
67
84
68
85
// Parallel level
69
- INLINE void IncParallelLevel (bool ActiveParallel , __kmpc_impl_lanemask_t Mask );
70
- INLINE void DecParallelLevel (bool ActiveParallel , __kmpc_impl_lanemask_t Mask );
86
+ DEVICE void IncParallelLevel (bool ActiveParallel , __kmpc_impl_lanemask_t Mask );
87
+ DEVICE void DecParallelLevel (bool ActiveParallel , __kmpc_impl_lanemask_t Mask );
71
88
72
89
////////////////////////////////////////////////////////////////////////////////
73
90
// Memory
74
91
////////////////////////////////////////////////////////////////////////////////
75
92
76
93
// safe alloc and free
77
- INLINE void * SafeMalloc (size_t size , const char * msg ); // check if success
78
- INLINE void * SafeFree (void * ptr , const char * msg );
94
+ DEVICE void * SafeMalloc (size_t size , const char * msg ); // check if success
95
+ DEVICE void * SafeFree (void * ptr , const char * msg );
79
96
// pad to a alignment (power of 2 only)
80
- INLINE unsigned long PadBytes (unsigned long size , unsigned long alignment );
97
+ DEVICE unsigned long PadBytes (unsigned long size , unsigned long alignment );
81
98
#define ADD_BYTES (_addr , _bytes ) \
82
99
((void *)((char *)((void *)(_addr)) + (_bytes)))
83
100
#define SUB_BYTES (_addr , _bytes ) \
@@ -86,6 +103,8 @@ INLINE unsigned long PadBytes(unsigned long size, unsigned long alignment);
86
103
////////////////////////////////////////////////////////////////////////////////
87
104
// Teams Reduction Scratchpad Helpers
88
105
////////////////////////////////////////////////////////////////////////////////
89
- INLINE unsigned int * GetTeamsReductionTimestamp ();
90
- INLINE char * GetTeamsReductionScratchpad ();
91
- INLINE void SetTeamsReductionScratchpadPtr (void * ScratchpadPtr );
106
+ DEVICE unsigned int * GetTeamsReductionTimestamp ();
107
+ DEVICE char * GetTeamsReductionScratchpad ();
108
+ DEVICE void SetTeamsReductionScratchpadPtr (void * ScratchpadPtr );
109
+
110
+ #endif
0 commit comments