ROSE 0.11.145.147
omp.h
1#ifndef _OMP_H_DEF
2#define _OMP_H_DEF
3
4#include <stdlib.h> // support size_t
5
6/*
7Updated to support OpenMP 4.5, B.1 page 327
8
9Liao 10/10/2016
10
11From the specification 3.0, Chapter 3.1, page 108
12What 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
18Specification 3.0 page 302
19D.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
24typedef void *omp_lock_t; /* represented as a pointer */
25typedef void *omp_nest_lock_t; /* represented as a pointer */
26
27/*
28* define the lock hints
29*/
30typedef 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
46typedef 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*/
57typedef 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
68extern "C" {
69#endif
70
71/*
72 * Execution Environment Functions
73 */
74extern void omp_set_num_threads(int num);
75extern int omp_get_num_threads(void);
76extern int omp_get_max_threads(void);
77extern int omp_get_thread_num(void);
78extern int omp_get_num_procs(void);
79
80int omp_in_parallel(void);
81void omp_set_dynamic(int dynamic_thds);
82int omp_get_dynamic(void);
83
84int omp_get_cancellation(void);
85
86void omp_set_nested(int n_nested);
87int omp_get_nested(void);
88
89/*
90 * Other internal variables
91 */
92
93void omp_set_schedule (omp_sched_t, int);
94void omp_get_schedule (omp_sched_t *, int *);
95int omp_get_thread_limit (void);
96void omp_set_max_active_levels (int);
97int omp_get_max_active_levels (void);
98int omp_get_level (void);
99int omp_get_ancestor_thread_num (int);
100int omp_get_team_size (int);
101int omp_get_active_level (void);
102
103int omp_in_final(void);
104omp_proc_bind_t omp_get_proc_bind(void);
105int omp_get_num_places(void);
106int omp_get_place_num_procs(int place_num);
107void omp_get_place_proc_ids(int place_num, int *ids);
108int omp_get_place_num(void);
109int omp_get_partition_num_places(void);
110void omp_get_partition_place_nums(int *place_nums);
111
112/*
113 * Support accelerators as target devices
114 */
115
116void omp_set_default_device(int device_num);
117int omp_get_default_device(void);
118
119/* find the max number of devices on the system */
120int omp_get_max_devices(void);
121/* set number of active devices to be used */
122void omp_set_num_devices(int);
123
124/* get number of available devices */
125int 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
128int xomp_get_num_devices(void);
129
130int omp_get_num_teams(void);
131int omp_get_team_num(void);
132
133int omp_is_initial_device(void);
134int omp_get_initial_device(void);
135int omp_get_max_task_priority(void);
136
137/*
138 * Lock Functions
139 */
140void omp_init_lock(omp_lock_t *lock);
141void omp_init_lock_with_hint(omp_lock_t *lock,
142 omp_lock_hint_t hint);
143void omp_destroy_lock(omp_lock_t *lock);
144void omp_set_lock(omp_lock_t *lock);
145void omp_unset_lock(omp_lock_t *lock);
146int omp_test_lock(omp_lock_t *lock);
147void omp_init_nest_lock(omp_nest_lock_t *lock);
148void omp_init_nest_lock_with_hint(omp_nest_lock_t *lock,
149 omp_lock_hint_t hint);
150void omp_destroy_nest_lock(omp_nest_lock_t *lock);
151void omp_set_nest_lock(omp_nest_lock_t *lock);
152void omp_unset_nest_lock(omp_nest_lock_t *lock);
153int omp_test_nest_lock(omp_nest_lock_t *lock);
154
155/*
156 * Timer routine
157 */
158double omp_get_wtime(void);
159double omp_get_wtick(void);
160
161void * omp_target_alloc(size_t _size, int _device_num);
162void omp_target_free(void * device_ptr, int _device_num);
163int omp_target_is_present(void * ptr, int _device_num);
164int 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
168int 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
179int 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
185int 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
192void omp_set_num_threads_(int *num);
193int omp_get_num_threads_(void);
194int omp_get_max_threads_(void);
195int omp_get_thread_num_(void);
196int omp_get_num_procs_(void);
197int omp_in_parallel_(void);
198void omp_set_dynamic_(int *dynamic_thds);
199int omp_get_dynamic_(void);
200void omp_set_nested_(int *n_nested);
201int omp_get_nested_(void);
202
203 * FORTRAN Lock Function Wrappers
204typedef unsigned int _omf77Lock_t;
205void omp_init_lock_(_omf77Lock_t *lock);
206void omp_init_nest_lock_(_omf77Lock_t *lock);
207void omp_destroy_lock_(_omf77Lock_t *lock);
208void omp_destroy_nest_lock_(_omf77Lock_t *lock);
209void omp_set_lock_(_omf77Lock_t *lock);
210void omp_set_nest_lock_(_omf77Lock_t *lock);
211void omp_unset_lock_(_omf77Lock_t *lock);
212void omp_unset_nest_lock_(_omf77Lock_t *lock);
213int omp_test_lock_(_omf77Lock_t *lock);
214int 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