xref: /freebsd/contrib/llvm-project/openmp/runtime/src/include/omp.h.var (revision dc318a4ffabcbfa23bb56a33403aad36e6de30af)
1/*
2 * include/omp.h.var
3 */
4
5
6//===----------------------------------------------------------------------===//
7//
8// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
9// See https://llvm.org/LICENSE.txt for license information.
10// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11//
12//===----------------------------------------------------------------------===//
13
14
15#ifndef __OMP_H
16#   define __OMP_H
17
18#   include <stdlib.h>
19#   include <stdint.h>
20
21#   define KMP_VERSION_MAJOR    @LIBOMP_VERSION_MAJOR@
22#   define KMP_VERSION_MINOR    @LIBOMP_VERSION_MINOR@
23#   define KMP_VERSION_BUILD    @LIBOMP_VERSION_BUILD@
24#   define KMP_BUILD_DATE       "@LIBOMP_BUILD_DATE@"
25
26#   ifdef __cplusplus
27    extern "C" {
28#   endif
29
30#   define omp_set_affinity_format   ompc_set_affinity_format
31#   define omp_get_affinity_format   ompc_get_affinity_format
32#   define omp_display_affinity      ompc_display_affinity
33#   define omp_capture_affinity      ompc_capture_affinity
34
35#   if defined(_WIN32)
36#       define __KAI_KMPC_CONVENTION __cdecl
37#       ifndef __KMP_IMP
38#           define __KMP_IMP __declspec(dllimport)
39#       endif
40#   else
41#       define __KAI_KMPC_CONVENTION
42#       ifndef __KMP_IMP
43#           define __KMP_IMP
44#       endif
45#   endif
46
47    /* schedule kind constants */
48    typedef enum omp_sched_t {
49        omp_sched_static  = 1,
50        omp_sched_dynamic = 2,
51        omp_sched_guided  = 3,
52        omp_sched_auto    = 4,
53        omp_sched_monotonic = 0x80000000
54    } omp_sched_t;
55
56    /* set API functions */
57    extern void   __KAI_KMPC_CONVENTION  omp_set_num_threads (int);
58    extern void   __KAI_KMPC_CONVENTION  omp_set_dynamic     (int);
59    extern void   __KAI_KMPC_CONVENTION  omp_set_nested      (int);
60    extern void   __KAI_KMPC_CONVENTION  omp_set_max_active_levels (int);
61    extern void   __KAI_KMPC_CONVENTION  omp_set_schedule          (omp_sched_t, int);
62
63    /* query API functions */
64    extern int    __KAI_KMPC_CONVENTION  omp_get_num_threads  (void);
65    extern int    __KAI_KMPC_CONVENTION  omp_get_dynamic      (void);
66    extern int    __KAI_KMPC_CONVENTION  omp_get_nested       (void);
67    extern int    __KAI_KMPC_CONVENTION  omp_get_max_threads  (void);
68    extern int    __KAI_KMPC_CONVENTION  omp_get_thread_num   (void);
69    extern int    __KAI_KMPC_CONVENTION  omp_get_num_procs    (void);
70    extern int    __KAI_KMPC_CONVENTION  omp_in_parallel      (void);
71    extern int    __KAI_KMPC_CONVENTION  omp_in_final         (void);
72    extern int    __KAI_KMPC_CONVENTION  omp_get_active_level        (void);
73    extern int    __KAI_KMPC_CONVENTION  omp_get_level               (void);
74    extern int    __KAI_KMPC_CONVENTION  omp_get_ancestor_thread_num (int);
75    extern int    __KAI_KMPC_CONVENTION  omp_get_team_size           (int);
76    extern int    __KAI_KMPC_CONVENTION  omp_get_thread_limit        (void);
77    extern int    __KAI_KMPC_CONVENTION  omp_get_max_active_levels   (void);
78    extern void   __KAI_KMPC_CONVENTION  omp_get_schedule            (omp_sched_t *, int *);
79    extern int    __KAI_KMPC_CONVENTION  omp_get_max_task_priority   (void);
80
81    /* lock API functions */
82    typedef struct omp_lock_t {
83        void * _lk;
84    } omp_lock_t;
85
86    extern void   __KAI_KMPC_CONVENTION  omp_init_lock    (omp_lock_t *);
87    extern void   __KAI_KMPC_CONVENTION  omp_set_lock     (omp_lock_t *);
88    extern void   __KAI_KMPC_CONVENTION  omp_unset_lock   (omp_lock_t *);
89    extern void   __KAI_KMPC_CONVENTION  omp_destroy_lock (omp_lock_t *);
90    extern int    __KAI_KMPC_CONVENTION  omp_test_lock    (omp_lock_t *);
91
92    /* nested lock API functions */
93    typedef struct omp_nest_lock_t {
94        void * _lk;
95    } omp_nest_lock_t;
96
97    extern void   __KAI_KMPC_CONVENTION  omp_init_nest_lock    (omp_nest_lock_t *);
98    extern void   __KAI_KMPC_CONVENTION  omp_set_nest_lock     (omp_nest_lock_t *);
99    extern void   __KAI_KMPC_CONVENTION  omp_unset_nest_lock   (omp_nest_lock_t *);
100    extern void   __KAI_KMPC_CONVENTION  omp_destroy_nest_lock (omp_nest_lock_t *);
101    extern int    __KAI_KMPC_CONVENTION  omp_test_nest_lock    (omp_nest_lock_t *);
102
103    /* OpenMP 5.0  Synchronization hints*/
104    typedef enum omp_sync_hint_t {
105        omp_sync_hint_none           = 0,
106        omp_lock_hint_none           = omp_sync_hint_none,
107        omp_sync_hint_uncontended    = 1,
108        omp_lock_hint_uncontended    = omp_sync_hint_uncontended,
109        omp_sync_hint_contended      = (1<<1),
110        omp_lock_hint_contended      = omp_sync_hint_contended,
111        omp_sync_hint_nonspeculative = (1<<2),
112        omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative,
113        omp_sync_hint_speculative    = (1<<3),
114        omp_lock_hint_speculative    = omp_sync_hint_speculative,
115        kmp_lock_hint_hle            = (1<<16),
116        kmp_lock_hint_rtm            = (1<<17),
117        kmp_lock_hint_adaptive       = (1<<18)
118    } omp_sync_hint_t;
119
120    /* lock hint type for dynamic user lock */
121    typedef omp_sync_hint_t omp_lock_hint_t;
122
123    /* hinted lock initializers */
124    extern void __KAI_KMPC_CONVENTION omp_init_lock_with_hint(omp_lock_t *, omp_lock_hint_t);
125    extern void __KAI_KMPC_CONVENTION omp_init_nest_lock_with_hint(omp_nest_lock_t *, omp_lock_hint_t);
126
127    /* time API functions */
128    extern double __KAI_KMPC_CONVENTION  omp_get_wtime (void);
129    extern double __KAI_KMPC_CONVENTION  omp_get_wtick (void);
130
131    /* OpenMP 4.0 */
132    extern int  __KAI_KMPC_CONVENTION  omp_get_default_device (void);
133    extern void __KAI_KMPC_CONVENTION  omp_set_default_device (int);
134    extern int  __KAI_KMPC_CONVENTION  omp_is_initial_device (void);
135    extern int  __KAI_KMPC_CONVENTION  omp_get_num_devices (void);
136    extern int  __KAI_KMPC_CONVENTION  omp_get_num_teams (void);
137    extern int  __KAI_KMPC_CONVENTION  omp_get_team_num (void);
138    extern int  __KAI_KMPC_CONVENTION  omp_get_cancellation (void);
139
140    /* OpenMP 4.5 */
141    extern int   __KAI_KMPC_CONVENTION  omp_get_initial_device (void);
142    extern void* __KAI_KMPC_CONVENTION  omp_target_alloc(size_t, int);
143    extern void  __KAI_KMPC_CONVENTION  omp_target_free(void *, int);
144    extern int   __KAI_KMPC_CONVENTION  omp_target_is_present(void *, int);
145    extern int   __KAI_KMPC_CONVENTION  omp_target_memcpy(void *, void *, size_t, size_t, size_t, int, int);
146    extern int   __KAI_KMPC_CONVENTION  omp_target_memcpy_rect(void *, void *, size_t, int, const size_t *,
147                                            const size_t *, const size_t *, const size_t *, const size_t *, int, int);
148    extern int   __KAI_KMPC_CONVENTION  omp_target_associate_ptr(void *, void *, size_t, size_t, int);
149    extern int   __KAI_KMPC_CONVENTION  omp_target_disassociate_ptr(void *, int);
150
151    /* OpenMP 5.0 */
152    extern int   __KAI_KMPC_CONVENTION  omp_get_device_num (void);
153    typedef void * omp_depend_t;
154
155    /* kmp API functions */
156    extern int    __KAI_KMPC_CONVENTION  kmp_get_stacksize          (void);
157    extern void   __KAI_KMPC_CONVENTION  kmp_set_stacksize          (int);
158    extern size_t __KAI_KMPC_CONVENTION  kmp_get_stacksize_s        (void);
159    extern void   __KAI_KMPC_CONVENTION  kmp_set_stacksize_s        (size_t);
160    extern int    __KAI_KMPC_CONVENTION  kmp_get_blocktime          (void);
161    extern int    __KAI_KMPC_CONVENTION  kmp_get_library            (void);
162    extern void   __KAI_KMPC_CONVENTION  kmp_set_blocktime          (int);
163    extern void   __KAI_KMPC_CONVENTION  kmp_set_library            (int);
164    extern void   __KAI_KMPC_CONVENTION  kmp_set_library_serial     (void);
165    extern void   __KAI_KMPC_CONVENTION  kmp_set_library_turnaround (void);
166    extern void   __KAI_KMPC_CONVENTION  kmp_set_library_throughput (void);
167    extern void   __KAI_KMPC_CONVENTION  kmp_set_defaults           (char const *);
168    extern void   __KAI_KMPC_CONVENTION  kmp_set_disp_num_buffers   (int);
169
170    /* Intel affinity API */
171    typedef void * kmp_affinity_mask_t;
172
173    extern int    __KAI_KMPC_CONVENTION  kmp_set_affinity             (kmp_affinity_mask_t *);
174    extern int    __KAI_KMPC_CONVENTION  kmp_get_affinity             (kmp_affinity_mask_t *);
175    extern int    __KAI_KMPC_CONVENTION  kmp_get_affinity_max_proc    (void);
176    extern void   __KAI_KMPC_CONVENTION  kmp_create_affinity_mask     (kmp_affinity_mask_t *);
177    extern void   __KAI_KMPC_CONVENTION  kmp_destroy_affinity_mask    (kmp_affinity_mask_t *);
178    extern int    __KAI_KMPC_CONVENTION  kmp_set_affinity_mask_proc   (int, kmp_affinity_mask_t *);
179    extern int    __KAI_KMPC_CONVENTION  kmp_unset_affinity_mask_proc (int, kmp_affinity_mask_t *);
180    extern int    __KAI_KMPC_CONVENTION  kmp_get_affinity_mask_proc   (int, kmp_affinity_mask_t *);
181
182    /* OpenMP 4.0 affinity API */
183    typedef enum omp_proc_bind_t {
184        omp_proc_bind_false = 0,
185        omp_proc_bind_true = 1,
186        omp_proc_bind_master = 2,
187        omp_proc_bind_close = 3,
188        omp_proc_bind_spread = 4
189    } omp_proc_bind_t;
190
191    extern omp_proc_bind_t __KAI_KMPC_CONVENTION omp_get_proc_bind (void);
192
193    /* OpenMP 4.5 affinity API */
194    extern int  __KAI_KMPC_CONVENTION omp_get_num_places (void);
195    extern int  __KAI_KMPC_CONVENTION omp_get_place_num_procs (int);
196    extern void __KAI_KMPC_CONVENTION omp_get_place_proc_ids (int, int *);
197    extern int  __KAI_KMPC_CONVENTION omp_get_place_num (void);
198    extern int  __KAI_KMPC_CONVENTION omp_get_partition_num_places (void);
199    extern void __KAI_KMPC_CONVENTION omp_get_partition_place_nums (int *);
200
201    extern void * __KAI_KMPC_CONVENTION  kmp_malloc  (size_t);
202    extern void * __KAI_KMPC_CONVENTION  kmp_aligned_malloc  (size_t, size_t);
203    extern void * __KAI_KMPC_CONVENTION  kmp_calloc  (size_t, size_t);
204    extern void * __KAI_KMPC_CONVENTION  kmp_realloc (void *, size_t);
205    extern void   __KAI_KMPC_CONVENTION  kmp_free    (void *);
206
207    extern void   __KAI_KMPC_CONVENTION  kmp_set_warnings_on(void);
208    extern void   __KAI_KMPC_CONVENTION  kmp_set_warnings_off(void);
209
210    /* OpenMP 5.0 Tool Control */
211    typedef enum omp_control_tool_result_t {
212        omp_control_tool_notool = -2,
213        omp_control_tool_nocallback = -1,
214        omp_control_tool_success = 0,
215        omp_control_tool_ignored = 1
216    } omp_control_tool_result_t;
217
218    typedef enum omp_control_tool_t {
219        omp_control_tool_start = 1,
220        omp_control_tool_pause = 2,
221        omp_control_tool_flush = 3,
222        omp_control_tool_end = 4
223    } omp_control_tool_t;
224
225    extern int __KAI_KMPC_CONVENTION omp_control_tool(int, int, void*);
226
227    /* OpenMP 5.0 Memory Management */
228    typedef uintptr_t omp_uintptr_t;
229
230    typedef enum {
231        omp_atk_threadmodel = 1,
232        omp_atk_alignment = 2,
233        omp_atk_access = 3,
234        omp_atk_pool_size = 4,
235        omp_atk_fallback = 5,
236        omp_atk_fb_data = 6,
237        omp_atk_pinned = 7,
238        omp_atk_partition = 8
239    } omp_alloctrait_key_t;
240
241    typedef enum {
242        omp_atv_false = 0,
243        omp_atv_true = 1,
244        omp_atv_default = 2,
245        omp_atv_contended = 3,
246        omp_atv_uncontended = 4,
247        omp_atv_sequential = 5,
248        omp_atv_private = 6,
249        omp_atv_all = 7,
250        omp_atv_thread = 8,
251        omp_atv_pteam = 9,
252        omp_atv_cgroup = 10,
253        omp_atv_default_mem_fb = 11,
254        omp_atv_null_fb = 12,
255        omp_atv_abort_fb = 13,
256        omp_atv_allocator_fb = 14,
257        omp_atv_environment = 15,
258        omp_atv_nearest = 16,
259        omp_atv_blocked = 17,
260        omp_atv_interleaved = 18
261    } omp_alloctrait_value_t;
262
263    typedef struct {
264        omp_alloctrait_key_t key;
265        omp_uintptr_t value;
266    } omp_alloctrait_t;
267
268#   if defined(_WIN32)
269    // On Windows cl and icl do not support 64-bit enum, let's use integer then.
270    typedef omp_uintptr_t omp_allocator_handle_t;
271    extern __KMP_IMP omp_allocator_handle_t const omp_null_allocator;
272    extern __KMP_IMP omp_allocator_handle_t const omp_default_mem_alloc;
273    extern __KMP_IMP omp_allocator_handle_t const omp_large_cap_mem_alloc;
274    extern __KMP_IMP omp_allocator_handle_t const omp_const_mem_alloc;
275    extern __KMP_IMP omp_allocator_handle_t const omp_high_bw_mem_alloc;
276    extern __KMP_IMP omp_allocator_handle_t const omp_low_lat_mem_alloc;
277    extern __KMP_IMP omp_allocator_handle_t const omp_cgroup_mem_alloc;
278    extern __KMP_IMP omp_allocator_handle_t const omp_pteam_mem_alloc;
279    extern __KMP_IMP omp_allocator_handle_t const omp_thread_mem_alloc;
280    typedef omp_uintptr_t omp_memspace_handle_t;
281    extern __KMP_IMP omp_memspace_handle_t const omp_default_mem_space;
282    extern __KMP_IMP omp_memspace_handle_t const omp_large_cap_mem_space;
283    extern __KMP_IMP omp_memspace_handle_t const omp_const_mem_space;
284    extern __KMP_IMP omp_memspace_handle_t const omp_high_bw_mem_space;
285    extern __KMP_IMP omp_memspace_handle_t const omp_low_lat_mem_space;
286#   else
287#       if __cplusplus >= 201103
288    typedef enum omp_allocator_handle_t : omp_uintptr_t
289#       else
290    typedef enum omp_allocator_handle_t
291#       endif
292    {
293      omp_null_allocator = 0,
294      omp_default_mem_alloc = 1,
295      omp_large_cap_mem_alloc = 2,
296      omp_const_mem_alloc = 3,
297      omp_high_bw_mem_alloc = 4,
298      omp_low_lat_mem_alloc = 5,
299      omp_cgroup_mem_alloc = 6,
300      omp_pteam_mem_alloc = 7,
301      omp_thread_mem_alloc = 8,
302      KMP_ALLOCATOR_MAX_HANDLE = UINTPTR_MAX
303    } omp_allocator_handle_t;
304#       if __cplusplus >= 201103
305    typedef enum omp_memspace_handle_t : omp_uintptr_t
306#       else
307    typedef enum omp_memspace_handle_t
308#       endif
309    {
310      omp_default_mem_space = 0,
311      omp_large_cap_mem_space = 1,
312      omp_const_mem_space = 2,
313      omp_high_bw_mem_space = 3,
314      omp_low_lat_mem_space = 4,
315      KMP_MEMSPACE_MAX_HANDLE = UINTPTR_MAX
316    } omp_memspace_handle_t;
317#   endif
318    extern omp_allocator_handle_t __KAI_KMPC_CONVENTION omp_init_allocator(omp_memspace_handle_t m,
319                                                       int ntraits, omp_alloctrait_t traits[]);
320    extern void __KAI_KMPC_CONVENTION omp_destroy_allocator(omp_allocator_handle_t allocator);
321
322    extern void __KAI_KMPC_CONVENTION omp_set_default_allocator(omp_allocator_handle_t a);
323    extern omp_allocator_handle_t __KAI_KMPC_CONVENTION omp_get_default_allocator(void);
324#   ifdef __cplusplus
325    extern void *__KAI_KMPC_CONVENTION omp_alloc(size_t size, omp_allocator_handle_t a = omp_null_allocator);
326    extern void __KAI_KMPC_CONVENTION omp_free(void * ptr, omp_allocator_handle_t a = omp_null_allocator);
327#   else
328    extern void *__KAI_KMPC_CONVENTION omp_alloc(size_t size, omp_allocator_handle_t a);
329    extern void __KAI_KMPC_CONVENTION omp_free(void *ptr, omp_allocator_handle_t a);
330#   endif
331
332    /* OpenMP 5.0 Affinity Format */
333    extern void __KAI_KMPC_CONVENTION omp_set_affinity_format(char const *);
334    extern size_t __KAI_KMPC_CONVENTION omp_get_affinity_format(char *, size_t);
335    extern void __KAI_KMPC_CONVENTION omp_display_affinity(char const *);
336    extern size_t __KAI_KMPC_CONVENTION omp_capture_affinity(char *, size_t, char const *);
337
338    /* OpenMP 5.0 events */
339#   if defined(_WIN32)
340    // On Windows cl and icl do not support 64-bit enum, let's use integer then.
341    typedef omp_uintptr_t omp_event_handle_t;
342#   else
343    typedef enum omp_event_handle_t { KMP_EVENT_MAX_HANDLE = UINTPTR_MAX } omp_event_handle_t;
344#   endif
345    extern void __KAI_KMPC_CONVENTION omp_fulfill_event ( omp_event_handle_t event );
346
347    /* OpenMP 5.0 Pause Resources */
348    typedef enum omp_pause_resource_t {
349      omp_pause_resume = 0,
350      omp_pause_soft = 1,
351      omp_pause_hard = 2
352    } omp_pause_resource_t;
353    extern int __KAI_KMPC_CONVENTION omp_pause_resource(omp_pause_resource_t, int);
354    extern int __KAI_KMPC_CONVENTION omp_pause_resource_all(omp_pause_resource_t);
355
356    extern int __KAI_KMPC_CONVENTION omp_get_supported_active_levels(void);
357
358    /* OpenMP 5.1 Display Environment */
359    extern void omp_display_env(int verbose);
360
361#   undef __KAI_KMPC_CONVENTION
362#   undef __KMP_IMP
363
364    /* Warning:
365       The following typedefs are not standard, deprecated and will be removed in a future release.
366    */
367    typedef int     omp_int_t;
368    typedef double  omp_wtime_t;
369
370#   ifdef __cplusplus
371    }
372#   endif
373
374#endif /* __OMP_H */
375