ROSE  0.11.145.0
omp.h
1 #ifndef _OMP_H_DEF
2 #define _OMP_H_DEF
3 
4 #include <stdlib.h> // support size_t
5 
6 /*
7 Updated to support OpenMP 4.5, B.1 page 327
8 
9 Liao 10/10/2016
10 
11 From the specification 3.0, Chapter 3.1, page 108
12 What to put into this file:
13 * The prototypes of all the runtime library routines, with "C" linkage
14 * The type omp_lock_t
15 * The type omp_nest_lock_t
16 * The type omp_sched_t
17 
18 Specification 3.0 page 302
19 D.1 Example of the omp.h Header File
20  * */
21 // This is not correct. omp.h is not required to trigger _OPENMP macro
22 //#define _OPENMP 201511
23 
24 typedef void *omp_lock_t; /* represented as a pointer */
25 typedef void *omp_nest_lock_t; /* represented as a pointer */
26 
27 /*
28 * define the lock hints
29 */
30 typedef enum omp_lock_hint_t
31 {
32  omp_lock_hint_none = 0,
33  omp_lock_hint_uncontended = 1,
34  omp_lock_hint_contended = 2,
35  omp_lock_hint_nonspeculative = 4,
36  omp_lock_hint_speculative = 8
37  /* , Add vendor specific constants for lock hints here,
38  starting from the most-significant bit. */
39 } omp_lock_hint_t;
40 
41 
42 /*
43 * define the schedule kinds
44 */
45 
46 typedef enum omp_sched_t
47 {
48  omp_sched_static = 1,
49  omp_sched_dynamic = 2,
50  omp_sched_guided = 3,
51  omp_sched_auto = 4
52 } omp_sched_t;
53 
54 /*
55 * define the proc bind values
56 */
57 typedef enum omp_proc_bind_t
58 {
59  omp_proc_bind_false = 0,
60  omp_proc_bind_true = 1,
61  omp_proc_bind_master = 2,
62  omp_proc_bind_close = 3,
63  omp_proc_bind_spread = 4
64 } omp_proc_bind_t;
65 
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
71 /*
72  * Execution Environment Functions
73  */
74 extern void omp_set_num_threads(int num);
75 extern int omp_get_num_threads(void);
76 extern int omp_get_max_threads(void);
77 extern int omp_get_thread_num(void);
78 extern int omp_get_num_procs(void);
79 
80 int omp_in_parallel(void);
81 void omp_set_dynamic(int dynamic_thds);
82 int omp_get_dynamic(void);
83 
84 int omp_get_cancellation(void);
85 
86 void omp_set_nested(int n_nested);
87 int omp_get_nested(void);
88 
89 /*
90  * Other internal variables
91  */
92 
93 void omp_set_schedule (omp_sched_t, int);
94 void omp_get_schedule (omp_sched_t *, int *);
95 int omp_get_thread_limit (void);
96 void omp_set_max_active_levels (int);
97 int omp_get_max_active_levels (void);
98 int omp_get_level (void);
99 int omp_get_ancestor_thread_num (int);
100 int omp_get_team_size (int);
101 int omp_get_active_level (void);
102 
103 int omp_in_final(void);
104 omp_proc_bind_t omp_get_proc_bind(void);
105 int omp_get_num_places(void);
106 int omp_get_place_num_procs(int place_num);
107 void omp_get_place_proc_ids(int place_num, int *ids);
108 int omp_get_place_num(void);
109 int omp_get_partition_num_places(void);
110 void omp_get_partition_place_nums(int *place_nums);
111 
112 /*
113  * Support accelerators as target devices
114  */
115 
116 void omp_set_default_device(int device_num);
117 int omp_get_default_device(void);
118 
119 /* find the max number of devices on the system */
120 int omp_get_max_devices(void);
121 /* set number of active devices to be used */
122 void omp_set_num_devices(int);
123 
124 /* get number of available devices */
125 int omp_get_num_devices(void);
126 // GCC 4.0 provides omp_get_num_devices() already, but without supporting GPUs
127 // I have to use another function to bypass it
128 int xomp_get_num_devices(void);
129 
130 int omp_get_num_teams(void);
131 int omp_get_team_num(void);
132 
133 int omp_is_initial_device(void);
134 int omp_get_initial_device(void);
135 int omp_get_max_task_priority(void);
136 
137 /*
138  * Lock Functions
139  */
140 void omp_init_lock(omp_lock_t *lock);
141 void omp_init_lock_with_hint(omp_lock_t *lock,
142  omp_lock_hint_t hint);
143 void omp_destroy_lock(omp_lock_t *lock);
144 void omp_set_lock(omp_lock_t *lock);
145 void omp_unset_lock(omp_lock_t *lock);
146 int omp_test_lock(omp_lock_t *lock);
147 void omp_init_nest_lock(omp_nest_lock_t *lock);
148 void omp_init_nest_lock_with_hint(omp_nest_lock_t *lock,
149  omp_lock_hint_t hint);
150 void omp_destroy_nest_lock(omp_nest_lock_t *lock);
151 void omp_set_nest_lock(omp_nest_lock_t *lock);
152 void omp_unset_nest_lock(omp_nest_lock_t *lock);
153 int omp_test_nest_lock(omp_nest_lock_t *lock);
154 
155 /*
156  * Timer routine
157  */
158 double omp_get_wtime(void);
159 double omp_get_wtick(void);
160 
161 void * omp_target_alloc(size_t _size, int _device_num);
162 void omp_target_free(void * device_ptr, int _device_num);
163 int omp_target_is_present(void * ptr, int _device_num);
164 int omp_target_memcpy(void *dst, void *src, size_t _length,
165  size_t dst_offset, size_t src_offset,
166  int dst_device_num, int src_device_num);
167 
168 int omp_target_memcpy_rect(
169  void *dst, void *src,
170  size_t element_size,
171  int num_dims,
172  const size_t *volume,
173  const size_t *dst_offsets,
174  const size_t *src_offsets,
175  const size_t *dst_dimensions,
176  const size_t *src_dimensions,
177  int dst_device_num, int src_device_num);
178 
179 int omp_target_associate_ptr(void * host_ptr,
180  void * device_ptr,
181  size_t _size,
182  size_t device_offset,
183  int device_num);
184 
185 int omp_target_disassociate_ptr(void * ptr,
186  int device_num);
187 
188 
189 /*
190  * FORTRAN Execution Environment Function Wrappers
191  * Fortran stuff should be handled in omp_lib.h
192 void omp_set_num_threads_(int *num);
193 int omp_get_num_threads_(void);
194 int omp_get_max_threads_(void);
195 int omp_get_thread_num_(void);
196 int omp_get_num_procs_(void);
197 int omp_in_parallel_(void);
198 void omp_set_dynamic_(int *dynamic_thds);
199 int omp_get_dynamic_(void);
200 void omp_set_nested_(int *n_nested);
201 int omp_get_nested_(void);
202 
203  * FORTRAN Lock Function Wrappers
204 typedef unsigned int _omf77Lock_t;
205 void omp_init_lock_(_omf77Lock_t *lock);
206 void omp_init_nest_lock_(_omf77Lock_t *lock);
207 void omp_destroy_lock_(_omf77Lock_t *lock);
208 void omp_destroy_nest_lock_(_omf77Lock_t *lock);
209 void omp_set_lock_(_omf77Lock_t *lock);
210 void omp_set_nest_lock_(_omf77Lock_t *lock);
211 void omp_unset_lock_(_omf77Lock_t *lock);
212 void omp_unset_nest_lock_(_omf77Lock_t *lock);
213 int omp_test_lock_(_omf77Lock_t *lock);
214 int omp_test_nest_lock_(_omf77Lock_t *lock);
215 
216 */
217 #ifdef __cplusplus
218 } /* closing brace for extern "C" */
219 #endif
220 
221 #endif /* _OMP_H_DEF */
222