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