xref: /freebsd/contrib/llvm-project/openmp/runtime/src/include/omp.h.var (revision b1879975794772ee51f0b4865753364c7d7626c3)
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 <stddef.h>
19#   include <stdlib.h>
20#   include <stdint.h>
21
22#   define KMP_VERSION_MAJOR    @LIBOMP_VERSION_MAJOR@
23#   define KMP_VERSION_MINOR    @LIBOMP_VERSION_MINOR@
24#   define KMP_VERSION_BUILD    @LIBOMP_VERSION_BUILD@
25#   define KMP_BUILD_DATE       "@LIBOMP_BUILD_DATE@"
26
27#   ifdef __cplusplus
28    extern "C" {
29#   endif
30
31#   define omp_set_affinity_format   ompc_set_affinity_format
32#   define omp_get_affinity_format   ompc_get_affinity_format
33#   define omp_display_affinity      ompc_display_affinity
34#   define omp_capture_affinity      ompc_capture_affinity
35
36#   if defined(_WIN32)
37#       define __KAI_KMPC_CONVENTION __cdecl
38#       ifndef __KMP_IMP
39#           define __KMP_IMP __declspec(dllimport)
40#       endif
41#   else
42#       define __KAI_KMPC_CONVENTION
43#       ifndef __KMP_IMP
44#           define __KMP_IMP
45#       endif
46#   endif
47
48    /* schedule kind constants */
49    typedef enum omp_sched_t {
50        omp_sched_static  = 1,
51        omp_sched_dynamic = 2,
52        omp_sched_guided  = 3,
53        omp_sched_auto    = 4,
54        omp_sched_monotonic = 0x80000000
55    } omp_sched_t;
56
57    /* set API functions */
58    extern void   __KAI_KMPC_CONVENTION  omp_set_num_threads (int);
59    extern void   __KAI_KMPC_CONVENTION  omp_set_dynamic     (int);
60    extern void   __KAI_KMPC_CONVENTION  omp_set_nested      (int);
61    extern void   __KAI_KMPC_CONVENTION  omp_set_max_active_levels (int);
62    extern void   __KAI_KMPC_CONVENTION  omp_set_schedule          (omp_sched_t, int);
63
64    /* query API functions */
65    extern int    __KAI_KMPC_CONVENTION  omp_get_num_threads  (void);
66    extern int    __KAI_KMPC_CONVENTION  omp_get_dynamic      (void);
67    extern int    __KAI_KMPC_CONVENTION  omp_get_nested       (void);
68    extern int    __KAI_KMPC_CONVENTION  omp_get_max_threads  (void);
69    extern int    __KAI_KMPC_CONVENTION  omp_get_thread_num   (void);
70    extern int    __KAI_KMPC_CONVENTION  omp_get_num_procs    (void);
71    extern int    __KAI_KMPC_CONVENTION  omp_in_parallel      (void);
72    extern int    __KAI_KMPC_CONVENTION  omp_in_final         (void);
73    extern int    __KAI_KMPC_CONVENTION  omp_get_active_level        (void);
74    extern int    __KAI_KMPC_CONVENTION  omp_get_level               (void);
75    extern int    __KAI_KMPC_CONVENTION  omp_get_ancestor_thread_num (int);
76    extern int    __KAI_KMPC_CONVENTION  omp_get_team_size           (int);
77    extern int    __KAI_KMPC_CONVENTION  omp_get_thread_limit        (void);
78    extern int    __KAI_KMPC_CONVENTION  omp_get_max_active_levels   (void);
79    extern void   __KAI_KMPC_CONVENTION  omp_get_schedule            (omp_sched_t *, int *);
80    extern int    __KAI_KMPC_CONVENTION  omp_get_max_task_priority   (void);
81
82    /* lock API functions */
83    typedef struct omp_lock_t {
84        void * _lk;
85    } omp_lock_t;
86
87    extern void   __KAI_KMPC_CONVENTION  omp_init_lock    (omp_lock_t *);
88    extern void   __KAI_KMPC_CONVENTION  omp_set_lock     (omp_lock_t *);
89    extern void   __KAI_KMPC_CONVENTION  omp_unset_lock   (omp_lock_t *);
90    extern void   __KAI_KMPC_CONVENTION  omp_destroy_lock (omp_lock_t *);
91    extern int    __KAI_KMPC_CONVENTION  omp_test_lock    (omp_lock_t *);
92
93    /* nested lock API functions */
94    typedef struct omp_nest_lock_t {
95        void * _lk;
96    } omp_nest_lock_t;
97
98    extern void   __KAI_KMPC_CONVENTION  omp_init_nest_lock    (omp_nest_lock_t *);
99    extern void   __KAI_KMPC_CONVENTION  omp_set_nest_lock     (omp_nest_lock_t *);
100    extern void   __KAI_KMPC_CONVENTION  omp_unset_nest_lock   (omp_nest_lock_t *);
101    extern void   __KAI_KMPC_CONVENTION  omp_destroy_nest_lock (omp_nest_lock_t *);
102    extern int    __KAI_KMPC_CONVENTION  omp_test_nest_lock    (omp_nest_lock_t *);
103
104    /* OpenMP 5.0  Synchronization hints*/
105    typedef enum omp_sync_hint_t {
106        omp_sync_hint_none           = 0,
107        omp_lock_hint_none           = omp_sync_hint_none,
108        omp_sync_hint_uncontended    = 1,
109        omp_lock_hint_uncontended    = omp_sync_hint_uncontended,
110        omp_sync_hint_contended      = (1<<1),
111        omp_lock_hint_contended      = omp_sync_hint_contended,
112        omp_sync_hint_nonspeculative = (1<<2),
113        omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative,
114        omp_sync_hint_speculative    = (1<<3),
115        omp_lock_hint_speculative    = omp_sync_hint_speculative,
116        kmp_lock_hint_hle            = (1<<16),
117        kmp_lock_hint_rtm            = (1<<17),
118        kmp_lock_hint_adaptive       = (1<<18)
119    } omp_sync_hint_t;
120
121    /* lock hint type for dynamic user lock */
122    typedef omp_sync_hint_t omp_lock_hint_t;
123
124    /* hinted lock initializers */
125    extern void __KAI_KMPC_CONVENTION omp_init_lock_with_hint(omp_lock_t *, omp_lock_hint_t);
126    extern void __KAI_KMPC_CONVENTION omp_init_nest_lock_with_hint(omp_nest_lock_t *, omp_lock_hint_t);
127
128    /* time API functions */
129    extern double __KAI_KMPC_CONVENTION  omp_get_wtime (void);
130    extern double __KAI_KMPC_CONVENTION  omp_get_wtick (void);
131
132    /* OpenMP 4.0 */
133    extern int  __KAI_KMPC_CONVENTION  omp_get_default_device (void);
134    extern void __KAI_KMPC_CONVENTION  omp_set_default_device (int);
135    extern int  __KAI_KMPC_CONVENTION  omp_is_initial_device (void);
136    extern int  __KAI_KMPC_CONVENTION  omp_get_num_devices (void);
137    extern int  __KAI_KMPC_CONVENTION  omp_get_num_teams (void);
138    extern int  __KAI_KMPC_CONVENTION  omp_get_team_num (void);
139    extern int  __KAI_KMPC_CONVENTION  omp_get_cancellation (void);
140
141    /* OpenMP 4.5 */
142    extern int   __KAI_KMPC_CONVENTION  omp_get_initial_device (void);
143    extern void* __KAI_KMPC_CONVENTION  omp_target_alloc(size_t, int);
144    extern void  __KAI_KMPC_CONVENTION  omp_target_free(void *, int);
145    extern int   __KAI_KMPC_CONVENTION  omp_target_is_present(const void *, int);
146    extern int   __KAI_KMPC_CONVENTION  omp_target_memcpy(void *, const void *, size_t, size_t, size_t, int, int);
147    extern int   __KAI_KMPC_CONVENTION  omp_target_memcpy_rect(void *, const void *, size_t, int, const size_t *,
148                                            const size_t *, const size_t *, const size_t *, const size_t *, int, int);
149    extern int   __KAI_KMPC_CONVENTION  omp_target_associate_ptr(const void *, const void *, size_t, size_t, int);
150    extern int   __KAI_KMPC_CONVENTION  omp_target_disassociate_ptr(const void *, int);
151
152    /* OpenMP 5.0 */
153    extern int   __KAI_KMPC_CONVENTION  omp_get_device_num (void);
154    typedef void * omp_depend_t;
155
156    /* OpenMP 5.1 interop */
157    typedef intptr_t omp_intptr_t;
158
159    extern void __KAI_KMPC_CONVENTION ompx_dump_mapping_tables(void);
160
161    /* 0..omp_get_num_interop_properties()-1 are reserved for implementation-defined properties */
162    typedef enum omp_interop_property {
163        omp_ipr_fr_id = -1,
164        omp_ipr_fr_name = -2,
165        omp_ipr_vendor = -3,
166        omp_ipr_vendor_name = -4,
167        omp_ipr_device_num = -5,
168        omp_ipr_platform = -6,
169        omp_ipr_device = -7,
170        omp_ipr_device_context = -8,
171        omp_ipr_targetsync = -9,
172        omp_ipr_first = -9
173    } omp_interop_property_t;
174
175    #define omp_interop_none 0
176
177    typedef enum omp_interop_rc {
178        omp_irc_no_value = 1,
179        omp_irc_success = 0,
180        omp_irc_empty = -1,
181        omp_irc_out_of_range = -2,
182        omp_irc_type_int = -3,
183        omp_irc_type_ptr = -4,
184        omp_irc_type_str = -5,
185        omp_irc_other = -6
186    } omp_interop_rc_t;
187
188    typedef enum omp_interop_fr {
189        omp_ifr_cuda = 1,
190        omp_ifr_cuda_driver = 2,
191        omp_ifr_opencl = 3,
192        omp_ifr_sycl = 4,
193        omp_ifr_hip = 5,
194        omp_ifr_level_zero = 6,
195        omp_ifr_last = 7
196    } omp_interop_fr_t;
197
198    typedef void * omp_interop_t;
199
200    /*!
201     * The `omp_get_num_interop_properties` routine retrieves the number of implementation-defined properties available for an `omp_interop_t` object.
202     */
203    extern int          __KAI_KMPC_CONVENTION  omp_get_num_interop_properties(const omp_interop_t);
204    /*!
205     * The `omp_get_interop_int` routine retrieves an integer property from an `omp_interop_t` object.
206     */
207    extern omp_intptr_t __KAI_KMPC_CONVENTION  omp_get_interop_int(const omp_interop_t, omp_interop_property_t, int *);
208    /*!
209     * The `omp_get_interop_ptr` routine retrieves a pointer property from an `omp_interop_t` object.
210     */
211    extern void *       __KAI_KMPC_CONVENTION  omp_get_interop_ptr(const omp_interop_t, omp_interop_property_t, int *);
212    /*!
213     * The `omp_get_interop_str` routine retrieves a string property from an `omp_interop_t` object.
214     */
215    extern const char * __KAI_KMPC_CONVENTION  omp_get_interop_str(const omp_interop_t, omp_interop_property_t, int *);
216    /*!
217     * The `omp_get_interop_name` routine retrieves a property name from an `omp_interop_t` object.
218     */
219    extern const char * __KAI_KMPC_CONVENTION  omp_get_interop_name(const omp_interop_t, omp_interop_property_t);
220    /*!
221     * The `omp_get_interop_type_desc` routine retrieves a description of the type of a property associated with an `omp_interop_t` object.
222     */
223    extern const char * __KAI_KMPC_CONVENTION  omp_get_interop_type_desc(const omp_interop_t, omp_interop_property_t);
224    /*!
225     * The `omp_get_interop_rc_desc` routine retrieves a description of the return code associated with an `omp_interop_t` object.
226     */
227    extern const char * __KAI_KMPC_CONVENTION  omp_get_interop_rc_desc(const omp_interop_t, omp_interop_rc_t);
228
229    /* OpenMP 5.1 device memory routines */
230
231    /*!
232     * The `omp_target_memcpy_async` routine asynchronously performs a copy between any combination of host and device pointers.
233     */
234    extern int    __KAI_KMPC_CONVENTION  omp_target_memcpy_async(void *, const void *, size_t, size_t, size_t, int,
235                                             int, int, omp_depend_t *);
236    /*!
237     * The `omp_target_memcpy_rect_async` routine asynchronously performs a copy between any combination of host and device pointers.
238     */
239    extern int    __KAI_KMPC_CONVENTION  omp_target_memcpy_rect_async(void *, const void *, size_t, int, const size_t *,
240                                             const size_t *, const size_t *, const size_t *, const size_t *, int, int,
241                                             int, omp_depend_t *);
242
243    /* OpenMP 6.0 device memory routines */
244    extern void * __KAI_KMPC_CONVENTION omp_target_memset(void *, int, size_t, int);
245    extern void * __KAI_KMPC_CONVENTION omp_target_memset_async(void *, int, size_t, int, int, omp_depend_t *);
246
247    /*!
248     * The `omp_get_mapped_ptr` routine returns the device pointer that is associated with a host pointer for a given device.
249     */
250    extern void * __KAI_KMPC_CONVENTION  omp_get_mapped_ptr(const void *, int);
251    extern int    __KAI_KMPC_CONVENTION  omp_target_is_accessible(const void *, size_t, int);
252
253    /* kmp API functions */
254    extern int    __KAI_KMPC_CONVENTION  kmp_get_stacksize          (void);
255    extern void   __KAI_KMPC_CONVENTION  kmp_set_stacksize          (int);
256    extern size_t __KAI_KMPC_CONVENTION  kmp_get_stacksize_s        (void);
257    extern void   __KAI_KMPC_CONVENTION  kmp_set_stacksize_s        (size_t);
258    extern int    __KAI_KMPC_CONVENTION  kmp_get_blocktime          (void);
259    extern int    __KAI_KMPC_CONVENTION  kmp_get_library            (void);
260    extern void   __KAI_KMPC_CONVENTION  kmp_set_blocktime          (int);
261    extern void   __KAI_KMPC_CONVENTION  kmp_set_library            (int);
262    extern void   __KAI_KMPC_CONVENTION  kmp_set_library_serial     (void);
263    extern void   __KAI_KMPC_CONVENTION  kmp_set_library_turnaround (void);
264    extern void   __KAI_KMPC_CONVENTION  kmp_set_library_throughput (void);
265    extern void   __KAI_KMPC_CONVENTION  kmp_set_defaults           (char const *);
266    extern void   __KAI_KMPC_CONVENTION  kmp_set_disp_num_buffers   (int);
267
268    /* Intel affinity API */
269    typedef void * kmp_affinity_mask_t;
270
271    extern int    __KAI_KMPC_CONVENTION  kmp_set_affinity             (kmp_affinity_mask_t *);
272    extern int    __KAI_KMPC_CONVENTION  kmp_get_affinity             (kmp_affinity_mask_t *);
273    extern int    __KAI_KMPC_CONVENTION  kmp_get_affinity_max_proc    (void);
274    extern void   __KAI_KMPC_CONVENTION  kmp_create_affinity_mask     (kmp_affinity_mask_t *);
275    extern void   __KAI_KMPC_CONVENTION  kmp_destroy_affinity_mask    (kmp_affinity_mask_t *);
276    extern int    __KAI_KMPC_CONVENTION  kmp_set_affinity_mask_proc   (int, kmp_affinity_mask_t *);
277    extern int    __KAI_KMPC_CONVENTION  kmp_unset_affinity_mask_proc (int, kmp_affinity_mask_t *);
278    extern int    __KAI_KMPC_CONVENTION  kmp_get_affinity_mask_proc   (int, kmp_affinity_mask_t *);
279
280    /* OpenMP 4.0 affinity API */
281    typedef enum omp_proc_bind_t {
282        omp_proc_bind_false = 0,
283        omp_proc_bind_true = 1,
284        omp_proc_bind_master = 2,
285        omp_proc_bind_close = 3,
286        omp_proc_bind_spread = 4
287    } omp_proc_bind_t;
288
289    extern omp_proc_bind_t __KAI_KMPC_CONVENTION omp_get_proc_bind (void);
290
291    /* OpenMP 4.5 affinity API */
292    extern int  __KAI_KMPC_CONVENTION omp_get_num_places (void);
293    extern int  __KAI_KMPC_CONVENTION omp_get_place_num_procs (int);
294    extern void __KAI_KMPC_CONVENTION omp_get_place_proc_ids (int, int *);
295    extern int  __KAI_KMPC_CONVENTION omp_get_place_num (void);
296    extern int  __KAI_KMPC_CONVENTION omp_get_partition_num_places (void);
297    extern void __KAI_KMPC_CONVENTION omp_get_partition_place_nums (int *);
298
299    extern void * __KAI_KMPC_CONVENTION  kmp_malloc  (size_t);
300    extern void * __KAI_KMPC_CONVENTION  kmp_aligned_malloc  (size_t, size_t);
301    extern void * __KAI_KMPC_CONVENTION  kmp_calloc  (size_t, size_t);
302    extern void * __KAI_KMPC_CONVENTION  kmp_realloc (void *, size_t);
303    extern void   __KAI_KMPC_CONVENTION  kmp_free    (void *);
304
305    extern void   __KAI_KMPC_CONVENTION  kmp_set_warnings_on(void);
306    extern void   __KAI_KMPC_CONVENTION  kmp_set_warnings_off(void);
307
308    /* OpenMP 5.0 Tool Control */
309    typedef enum omp_control_tool_result_t {
310        omp_control_tool_notool = -2,
311        omp_control_tool_nocallback = -1,
312        omp_control_tool_success = 0,
313        omp_control_tool_ignored = 1
314    } omp_control_tool_result_t;
315
316    typedef enum omp_control_tool_t {
317        omp_control_tool_start = 1,
318        omp_control_tool_pause = 2,
319        omp_control_tool_flush = 3,
320        omp_control_tool_end = 4
321    } omp_control_tool_t;
322
323    extern int __KAI_KMPC_CONVENTION omp_control_tool(int, int, void*);
324
325    /* OpenMP 5.0 Memory Management */
326    typedef uintptr_t omp_uintptr_t;
327
328    typedef enum {
329        omp_atk_sync_hint = 1,
330        omp_atk_alignment = 2,
331        omp_atk_access = 3,
332        omp_atk_pool_size = 4,
333        omp_atk_fallback = 5,
334        omp_atk_fb_data = 6,
335        omp_atk_pinned = 7,
336        omp_atk_partition = 8
337    } omp_alloctrait_key_t;
338
339    typedef enum {
340        omp_atv_false = 0,
341        omp_atv_true = 1,
342        omp_atv_contended = 3,
343        omp_atv_uncontended = 4,
344        omp_atv_serialized = 5,
345        omp_atv_sequential = omp_atv_serialized, // (deprecated)
346        omp_atv_private = 6,
347        omp_atv_all = 7,
348        omp_atv_thread = 8,
349        omp_atv_pteam = 9,
350        omp_atv_cgroup = 10,
351        omp_atv_default_mem_fb = 11,
352        omp_atv_null_fb = 12,
353        omp_atv_abort_fb = 13,
354        omp_atv_allocator_fb = 14,
355        omp_atv_environment = 15,
356        omp_atv_nearest = 16,
357        omp_atv_blocked = 17,
358        omp_atv_interleaved = 18
359    } omp_alloctrait_value_t;
360    #define omp_atv_default ((omp_uintptr_t)-1)
361
362    typedef struct {
363        omp_alloctrait_key_t key;
364        omp_uintptr_t value;
365    } omp_alloctrait_t;
366
367#   if defined(_WIN32)
368    // On Windows cl and icl do not support 64-bit enum, let's use integer then.
369    typedef omp_uintptr_t omp_allocator_handle_t;
370    extern __KMP_IMP omp_allocator_handle_t const omp_null_allocator;
371    extern __KMP_IMP omp_allocator_handle_t const omp_default_mem_alloc;
372    extern __KMP_IMP omp_allocator_handle_t const omp_large_cap_mem_alloc;
373    extern __KMP_IMP omp_allocator_handle_t const omp_const_mem_alloc;
374    extern __KMP_IMP omp_allocator_handle_t const omp_high_bw_mem_alloc;
375    extern __KMP_IMP omp_allocator_handle_t const omp_low_lat_mem_alloc;
376    extern __KMP_IMP omp_allocator_handle_t const omp_cgroup_mem_alloc;
377    extern __KMP_IMP omp_allocator_handle_t const omp_pteam_mem_alloc;
378    extern __KMP_IMP omp_allocator_handle_t const omp_thread_mem_alloc;
379    extern __KMP_IMP omp_allocator_handle_t const llvm_omp_target_host_mem_alloc;
380    extern __KMP_IMP omp_allocator_handle_t const llvm_omp_target_shared_mem_alloc;
381    extern __KMP_IMP omp_allocator_handle_t const llvm_omp_target_device_mem_alloc;
382
383    typedef omp_uintptr_t omp_memspace_handle_t;
384    extern __KMP_IMP omp_memspace_handle_t const omp_default_mem_space;
385    extern __KMP_IMP omp_memspace_handle_t const omp_large_cap_mem_space;
386    extern __KMP_IMP omp_memspace_handle_t const omp_const_mem_space;
387    extern __KMP_IMP omp_memspace_handle_t const omp_high_bw_mem_space;
388    extern __KMP_IMP omp_memspace_handle_t const omp_low_lat_mem_space;
389    extern __KMP_IMP omp_memspace_handle_t const llvm_omp_target_host_mem_space;
390    extern __KMP_IMP omp_memspace_handle_t const llvm_omp_target_shared_mem_space;
391    extern __KMP_IMP omp_memspace_handle_t const llvm_omp_target_device_mem_space;
392#   else
393#       if __cplusplus >= 201103
394    typedef enum omp_allocator_handle_t : omp_uintptr_t
395#       else
396    typedef enum omp_allocator_handle_t
397#       endif
398    {
399      omp_null_allocator = 0,
400      omp_default_mem_alloc = 1,
401      omp_large_cap_mem_alloc = 2,
402      omp_const_mem_alloc = 3,
403      omp_high_bw_mem_alloc = 4,
404      omp_low_lat_mem_alloc = 5,
405      omp_cgroup_mem_alloc = 6,
406      omp_pteam_mem_alloc = 7,
407      omp_thread_mem_alloc = 8,
408      llvm_omp_target_host_mem_alloc = 100,
409      llvm_omp_target_shared_mem_alloc = 101,
410      llvm_omp_target_device_mem_alloc = 102,
411      KMP_ALLOCATOR_MAX_HANDLE = UINTPTR_MAX
412    } omp_allocator_handle_t;
413#       if __cplusplus >= 201103
414    typedef enum omp_memspace_handle_t : omp_uintptr_t
415#       else
416    typedef enum omp_memspace_handle_t
417#       endif
418    {
419      omp_default_mem_space = 0,
420      omp_large_cap_mem_space = 1,
421      omp_const_mem_space = 2,
422      omp_high_bw_mem_space = 3,
423      omp_low_lat_mem_space = 4,
424      llvm_omp_target_host_mem_space = 100,
425      llvm_omp_target_shared_mem_space = 101,
426      llvm_omp_target_device_mem_space = 102,
427      KMP_MEMSPACE_MAX_HANDLE = UINTPTR_MAX
428    } omp_memspace_handle_t;
429#   endif
430    extern omp_allocator_handle_t __KAI_KMPC_CONVENTION omp_init_allocator(omp_memspace_handle_t m,
431                                                       int ntraits, omp_alloctrait_t traits[]);
432    extern void __KAI_KMPC_CONVENTION omp_destroy_allocator(omp_allocator_handle_t allocator);
433
434    extern void __KAI_KMPC_CONVENTION omp_set_default_allocator(omp_allocator_handle_t a);
435    extern omp_allocator_handle_t __KAI_KMPC_CONVENTION omp_get_default_allocator(void);
436#   ifdef __cplusplus
437    extern void *__KAI_KMPC_CONVENTION omp_alloc(size_t size, omp_allocator_handle_t a = omp_null_allocator);
438    extern void *__KAI_KMPC_CONVENTION omp_aligned_alloc(size_t align, size_t size,
439                                                         omp_allocator_handle_t a = omp_null_allocator);
440    extern void *__KAI_KMPC_CONVENTION omp_calloc(size_t nmemb, size_t size,
441                                                  omp_allocator_handle_t a = omp_null_allocator);
442    extern void *__KAI_KMPC_CONVENTION omp_aligned_calloc(size_t align, size_t nmemb, size_t size,
443                                                          omp_allocator_handle_t a = omp_null_allocator);
444    extern void *__KAI_KMPC_CONVENTION omp_realloc(void *ptr, size_t size,
445                                                   omp_allocator_handle_t allocator = omp_null_allocator,
446                                                   omp_allocator_handle_t free_allocator = omp_null_allocator);
447    extern void __KAI_KMPC_CONVENTION omp_free(void * ptr, omp_allocator_handle_t a = omp_null_allocator);
448#   else
449    extern void *__KAI_KMPC_CONVENTION omp_alloc(size_t size, omp_allocator_handle_t a);
450    extern void *__KAI_KMPC_CONVENTION omp_aligned_alloc(size_t align, size_t size,
451                                                         omp_allocator_handle_t a);
452    extern void *__KAI_KMPC_CONVENTION omp_calloc(size_t nmemb, size_t size, omp_allocator_handle_t a);
453    extern void *__KAI_KMPC_CONVENTION omp_aligned_calloc(size_t align, size_t nmemb, size_t size,
454                                                          omp_allocator_handle_t a);
455    extern void *__KAI_KMPC_CONVENTION omp_realloc(void *ptr, size_t size, omp_allocator_handle_t allocator,
456                                                   omp_allocator_handle_t free_allocator);
457    extern void __KAI_KMPC_CONVENTION omp_free(void *ptr, omp_allocator_handle_t a);
458#   endif
459
460    /* OpenMP 5.0 Affinity Format */
461    extern void __KAI_KMPC_CONVENTION omp_set_affinity_format(char const *);
462    extern size_t __KAI_KMPC_CONVENTION omp_get_affinity_format(char *, size_t);
463    extern void __KAI_KMPC_CONVENTION omp_display_affinity(char const *);
464    extern size_t __KAI_KMPC_CONVENTION omp_capture_affinity(char *, size_t, char const *);
465
466    /* OpenMP 5.0 events */
467#   if defined(_WIN32)
468    // On Windows cl and icl do not support 64-bit enum, let's use integer then.
469    typedef omp_uintptr_t omp_event_handle_t;
470#   else
471    typedef enum omp_event_handle_t { KMP_EVENT_MAX_HANDLE = UINTPTR_MAX } omp_event_handle_t;
472#   endif
473    extern void __KAI_KMPC_CONVENTION omp_fulfill_event ( omp_event_handle_t event );
474
475    /* OpenMP 5.0 Pause Resources */
476    typedef enum omp_pause_resource_t {
477      omp_pause_resume = 0,
478      omp_pause_soft = 1,
479      omp_pause_hard = 2
480    } omp_pause_resource_t;
481    extern int __KAI_KMPC_CONVENTION omp_pause_resource(omp_pause_resource_t, int);
482    extern int __KAI_KMPC_CONVENTION omp_pause_resource_all(omp_pause_resource_t);
483
484    extern int __KAI_KMPC_CONVENTION omp_get_supported_active_levels(void);
485
486    /* OpenMP 5.1 */
487    extern void __KAI_KMPC_CONVENTION omp_set_num_teams(int num_teams);
488    extern int __KAI_KMPC_CONVENTION omp_get_max_teams(void);
489    extern void __KAI_KMPC_CONVENTION omp_set_teams_thread_limit(int limit);
490    extern int __KAI_KMPC_CONVENTION omp_get_teams_thread_limit(void);
491
492    /* OpenMP 5.1 Display Environment */
493    extern void omp_display_env(int verbose);
494
495#   if defined(_OPENMP) && _OPENMP >= 201811
496    #pragma omp begin declare variant match(device={kind(host)})
497    static inline int omp_is_initial_device(void) { return 1; }
498    #pragma omp end declare variant
499    #pragma omp begin declare variant match(device={kind(nohost)})
500    static inline int omp_is_initial_device(void) { return 0; }
501    #pragma omp end declare variant
502#   endif
503
504    /* OpenMP 5.2 */
505    extern int __KAI_KMPC_CONVENTION omp_in_explicit_task(void);
506
507    /* LLVM Extensions */
508    extern void *llvm_omp_target_dynamic_shared_alloc(void);
509
510#   undef __KAI_KMPC_CONVENTION
511#   undef __KMP_IMP
512
513    /* Warning:
514       The following typedefs are not standard, deprecated and will be removed in a future release.
515    */
516    typedef int     omp_int_t;
517    typedef double  omp_wtime_t;
518
519#   ifdef __cplusplus
520    }
521#   endif
522
523#endif /* __OMP_H */
524