| 1 |
/* Copyright (C) 2005-2025 Free Software Foundation, Inc. |
| 2 |
Contributed by Richard Henderson <[email protected]>. |
| 3 |
|
| 4 |
This file is part of the GNU Offloading and Multi Processing Library |
| 5 |
(libgomp). |
| 6 |
|
| 7 |
Libgomp is free software; you can redistribute it and/or modify it |
| 8 |
under the terms of the GNU General Public License as published by |
| 9 |
the Free Software Foundation; either version 3, or (at your option) |
| 10 |
any later version. |
| 11 |
|
| 12 |
Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 14 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 15 |
more details. |
| 16 |
|
| 17 |
Under Section 7 of GPL version 3, you are granted additional |
| 18 |
permissions described in the GCC Runtime Library Exception, version |
| 19 |
3.1, as published by the Free Software Foundation. |
| 20 |
|
| 21 |
You should have received a copy of the GNU General Public License and |
| 22 |
a copy of the GCC Runtime Library Exception along with this program; |
| 23 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 24 |
<http://www.gnu.org/licenses/>. */ |
| 25 |
|
| 26 |
#ifndef _OMP_H |
| 27 |
#define _OMP_H 1 |
| 28 |
|
| 29 |
#if defined(__GNUC__) && _OPENMP >= 201811 |
| 30 |
# define __GOMP_DEPRECATED_5_0 __attribute__((__deprecated__)) |
| 31 |
#else |
| 32 |
# define __GOMP_DEPRECATED_5_0 |
| 33 |
#endif |
| 34 |
|
| 35 |
#if defined(__GNUC__) && _OPENMP >= 202011 |
| 36 |
# define __GOMP_DEPRECATED_5_1 __attribute__((__deprecated__)) |
| 37 |
#else |
| 38 |
# define __GOMP_DEPRECATED_5_1 |
| 39 |
#endif |
| 40 |
|
| 41 |
#ifndef _LIBGOMP_OMP_LOCK_DEFINED |
| 42 |
#define _LIBGOMP_OMP_LOCK_DEFINED 1 |
| 43 |
/* These two structures get edited by the libgomp build process to |
| 44 |
reflect the shape of the two types. Their internals are private |
| 45 |
to the library. */ |
| 46 |
|
| 47 |
typedef struct |
| 48 |
{ |
| 49 |
unsigned char _x[@OMP_LOCK_SIZE@] |
| 50 |
__attribute__((__aligned__(@OMP_LOCK_ALIGN@))); |
| 51 |
} omp_lock_t; |
| 52 |
|
| 53 |
typedef struct |
| 54 |
{ |
| 55 |
unsigned char _x[@OMP_NEST_LOCK_SIZE@] |
| 56 |
__attribute__((__aligned__(@OMP_NEST_LOCK_ALIGN@))); |
| 57 |
} omp_nest_lock_t; |
| 58 |
#endif |
| 59 |
|
| 60 |
typedef enum omp_sched_t |
| 61 |
{ |
| 62 |
omp_sched_static = 1, |
| 63 |
omp_sched_dynamic = 2, |
| 64 |
omp_sched_guided = 3, |
| 65 |
omp_sched_auto = 4, |
| 66 |
omp_sched_monotonic = 0x80000000U |
| 67 |
} omp_sched_t; |
| 68 |
|
| 69 |
typedef enum omp_proc_bind_t |
| 70 |
{ |
| 71 |
omp_proc_bind_false = 0, |
| 72 |
omp_proc_bind_true = 1, |
| 73 |
omp_proc_bind_primary = 2, |
| 74 |
omp_proc_bind_master __GOMP_DEPRECATED_5_1 |
| 75 |
= omp_proc_bind_primary, |
| 76 |
omp_proc_bind_close = 3, |
| 77 |
omp_proc_bind_spread = 4 |
| 78 |
} omp_proc_bind_t; |
| 79 |
|
| 80 |
typedef enum omp_sync_hint_t |
| 81 |
{ |
| 82 |
omp_sync_hint_none = 0, |
| 83 |
omp_lock_hint_none __GOMP_DEPRECATED_5_0 = omp_sync_hint_none, |
| 84 |
omp_sync_hint_uncontended = 1, |
| 85 |
omp_lock_hint_uncontended __GOMP_DEPRECATED_5_0 = omp_sync_hint_uncontended, |
| 86 |
omp_sync_hint_contended = 2, |
| 87 |
omp_lock_hint_contended __GOMP_DEPRECATED_5_0 = omp_sync_hint_contended, |
| 88 |
omp_sync_hint_nonspeculative = 4, |
| 89 |
omp_lock_hint_nonspeculative __GOMP_DEPRECATED_5_0 |
| 90 |
= omp_sync_hint_nonspeculative, |
| 91 |
omp_sync_hint_speculative = 8, |
| 92 |
omp_lock_hint_speculative __GOMP_DEPRECATED_5_0 = omp_sync_hint_speculative |
| 93 |
} omp_sync_hint_t; |
| 94 |
|
| 95 |
typedef __GOMP_DEPRECATED_5_0 omp_sync_hint_t omp_lock_hint_t; |
| 96 |
|
| 97 |
typedef struct __attribute__((__aligned__ (sizeof (void *)))) omp_depend_t |
| 98 |
{ |
| 99 |
char __omp_depend_t__[2 * sizeof (void *)]; |
| 100 |
} omp_depend_t; |
| 101 |
|
| 102 |
typedef enum omp_pause_resource_t |
| 103 |
{ |
| 104 |
omp_pause_soft = 1, |
| 105 |
omp_pause_hard = 2 |
| 106 |
} omp_pause_resource_t; |
| 107 |
|
| 108 |
typedef __INTPTR_TYPE__ omp_intptr_t; |
| 109 |
typedef __UINTPTR_TYPE__ omp_uintptr_t; |
| 110 |
|
| 111 |
#if __cplusplus >= 201103L |
| 112 |
# define __GOMP_UINTPTR_T_ENUM : omp_uintptr_t |
| 113 |
#else |
| 114 |
# define __GOMP_UINTPTR_T_ENUM |
| 115 |
#endif |
| 116 |
|
| 117 |
typedef enum omp_memspace_handle_t __GOMP_UINTPTR_T_ENUM |
| 118 |
{ |
| 119 |
omp_default_mem_space = 0, |
| 120 |
omp_large_cap_mem_space = 1, |
| 121 |
omp_const_mem_space = 2, |
| 122 |
omp_high_bw_mem_space = 3, |
| 123 |
omp_low_lat_mem_space = 4, |
| 124 |
__omp_memspace_handle_t_max__ = __UINTPTR_MAX__ |
| 125 |
} omp_memspace_handle_t; |
| 126 |
|
| 127 |
typedef enum omp_allocator_handle_t __GOMP_UINTPTR_T_ENUM |
| 128 |
{ |
| 129 |
omp_null_allocator = 0, |
| 130 |
omp_default_mem_alloc = 1, |
| 131 |
omp_large_cap_mem_alloc = 2, |
| 132 |
omp_const_mem_alloc = 3, |
| 133 |
omp_high_bw_mem_alloc = 4, |
| 134 |
omp_low_lat_mem_alloc = 5, |
| 135 |
omp_cgroup_mem_alloc = 6, |
| 136 |
omp_pteam_mem_alloc = 7, |
| 137 |
omp_thread_mem_alloc = 8, |
| 138 |
ompx_gnu_pinned_mem_alloc = 200, |
| 139 |
__omp_allocator_handle_t_max__ = __UINTPTR_MAX__ |
| 140 |
} omp_allocator_handle_t; |
| 141 |
|
| 142 |
typedef enum omp_alloctrait_key_t |
| 143 |
{ |
| 144 |
omp_atk_sync_hint = 1, |
| 145 |
omp_atk_alignment = 2, |
| 146 |
omp_atk_access = 3, |
| 147 |
omp_atk_pool_size = 4, |
| 148 |
omp_atk_fallback = 5, |
| 149 |
omp_atk_fb_data = 6, |
| 150 |
omp_atk_pinned = 7, |
| 151 |
omp_atk_partition = 8 |
| 152 |
} omp_alloctrait_key_t; |
| 153 |
|
| 154 |
typedef enum omp_alloctrait_value_t |
| 155 |
{ |
| 156 |
omp_atv_default = (__UINTPTR_TYPE__) -1, |
| 157 |
omp_atv_false = 0, |
| 158 |
omp_atv_true = 1, |
| 159 |
omp_atv_contended = 3, |
| 160 |
omp_atv_uncontended = 4, |
| 161 |
omp_atv_serialized = 5, |
| 162 |
omp_atv_sequential __GOMP_DEPRECATED_5_1 = omp_atv_serialized, |
| 163 |
omp_atv_private = 6, |
| 164 |
omp_atv_all = 7, |
| 165 |
omp_atv_thread = 8, |
| 166 |
omp_atv_pteam = 9, |
| 167 |
omp_atv_cgroup = 10, |
| 168 |
omp_atv_default_mem_fb = 11, |
| 169 |
omp_atv_null_fb = 12, |
| 170 |
omp_atv_abort_fb = 13, |
| 171 |
omp_atv_allocator_fb = 14, |
| 172 |
omp_atv_environment = 15, |
| 173 |
omp_atv_nearest = 16, |
| 174 |
omp_atv_blocked = 17, |
| 175 |
omp_atv_interleaved = 18 |
| 176 |
} omp_alloctrait_value_t; |
| 177 |
|
| 178 |
typedef struct omp_alloctrait_t |
| 179 |
{ |
| 180 |
omp_alloctrait_key_t key; |
| 181 |
omp_uintptr_t value; |
| 182 |
} omp_alloctrait_t; |
| 183 |
|
| 184 |
typedef enum omp_event_handle_t __GOMP_UINTPTR_T_ENUM |
| 185 |
{ |
| 186 |
__omp_event_handle_t_max__ = __UINTPTR_MAX__ |
| 187 |
} omp_event_handle_t; |
| 188 |
|
| 189 |
enum |
| 190 |
{ |
| 191 |
omp_initial_device = -1, |
| 192 |
omp_invalid_device = -4 |
| 193 |
}; |
| 194 |
|
| 195 |
typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM |
| 196 |
{ |
| 197 |
omp_interop_none = 0, |
| 198 |
__omp_interop_t_max__ = __UINTPTR_MAX__ |
| 199 |
} omp_interop_t; |
| 200 |
|
| 201 |
typedef enum omp_interop_fr_t |
| 202 |
{ |
| 203 |
omp_ifr_cuda = 1, |
| 204 |
omp_ifr_cuda_driver = 2, |
| 205 |
omp_ifr_opencl = 3, |
| 206 |
omp_ifr_sycl = 4, |
| 207 |
omp_ifr_hip = 5, |
| 208 |
omp_ifr_level_zero = 6, |
| 209 |
omp_ifr_hsa = 7, |
| 210 |
omp_ifr_last = omp_ifr_hsa |
| 211 |
} omp_interop_fr_t; |
| 212 |
|
| 213 |
typedef enum omp_interop_property_t |
| 214 |
{ |
| 215 |
omp_ipr_fr_id = -1, |
| 216 |
omp_ipr_fr_name = -2, |
| 217 |
omp_ipr_vendor = -3, |
| 218 |
omp_ipr_vendor_name = -4, |
| 219 |
omp_ipr_device_num = -5, |
| 220 |
omp_ipr_platform = -6, |
| 221 |
omp_ipr_device = -7, |
| 222 |
omp_ipr_device_context = -8, |
| 223 |
omp_ipr_targetsync = -9, |
| 224 |
omp_ipr_first = -9 |
| 225 |
} omp_interop_property_t; |
| 226 |
|
| 227 |
|
| 228 |
typedef enum omp_interop_rc_t |
| 229 |
{ |
| 230 |
omp_irc_no_value = 1, |
| 231 |
omp_irc_success = 0, |
| 232 |
omp_irc_empty = -1, |
| 233 |
omp_irc_out_of_range = -2, |
| 234 |
omp_irc_type_int = -3, |
| 235 |
omp_irc_type_ptr = -4, |
| 236 |
omp_irc_type_str = -5, |
| 237 |
omp_irc_other = -6 |
| 238 |
} omp_interop_rc_t; |
| 239 |
|
| 240 |
#ifdef __cplusplus |
| 241 |
extern "C" { |
| 242 |
# define __GOMP_NOTHROW throw () |
| 243 |
# define __GOMP_DEFAULT_NULL_ALLOCATOR = omp_null_allocator |
| 244 |
# define __GOMP_DEFAULT_NULL = __null |
| 245 |
#else |
| 246 |
# define __GOMP_NOTHROW __attribute__((__nothrow__)) |
| 247 |
# define __GOMP_DEFAULT_NULL_ALLOCATOR |
| 248 |
# define __GOMP_DEFAULT_NULL |
| 249 |
#endif |
| 250 |
|
| 251 |
extern void omp_set_num_threads (int) __GOMP_NOTHROW; |
| 252 |
extern int omp_get_num_threads (void) __GOMP_NOTHROW; |
| 253 |
extern int omp_get_max_threads (void) __GOMP_NOTHROW; |
| 254 |
extern int omp_get_thread_num (void) __GOMP_NOTHROW; |
| 255 |
extern int omp_get_num_procs (void) __GOMP_NOTHROW; |
| 256 |
|
| 257 |
extern int omp_in_parallel (void) __GOMP_NOTHROW; |
| 258 |
|
| 259 |
extern void omp_set_dynamic (int) __GOMP_NOTHROW; |
| 260 |
extern int omp_get_dynamic (void) __GOMP_NOTHROW; |
| 261 |
|
| 262 |
extern void omp_set_nested (int) __GOMP_NOTHROW __GOMP_DEPRECATED_5_0; |
| 263 |
extern int omp_get_nested (void) __GOMP_NOTHROW __GOMP_DEPRECATED_5_0; |
| 264 |
|
| 265 |
extern void omp_init_lock (omp_lock_t *) __GOMP_NOTHROW; |
| 266 |
extern void omp_init_lock_with_hint (omp_lock_t *, omp_sync_hint_t) |
| 267 |
__GOMP_NOTHROW; |
| 268 |
extern void omp_destroy_lock (omp_lock_t *) __GOMP_NOTHROW; |
| 269 |
extern void omp_set_lock (omp_lock_t *) __GOMP_NOTHROW; |
| 270 |
extern void omp_unset_lock (omp_lock_t *) __GOMP_NOTHROW; |
| 271 |
extern int omp_test_lock (omp_lock_t *) __GOMP_NOTHROW; |
| 272 |
|
| 273 |
extern void omp_init_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW; |
| 274 |
extern void omp_init_nest_lock_with_hint (omp_nest_lock_t *, omp_sync_hint_t) |
| 275 |
__GOMP_NOTHROW; |
| 276 |
extern void omp_destroy_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW; |
| 277 |
extern void omp_set_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW; |
| 278 |
extern void omp_unset_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW; |
| 279 |
extern int omp_test_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW; |
| 280 |
|
| 281 |
extern double omp_get_wtime (void) __GOMP_NOTHROW; |
| 282 |
extern double omp_get_wtick (void) __GOMP_NOTHROW; |
| 283 |
|
| 284 |
extern void omp_set_schedule (omp_sched_t, int) __GOMP_NOTHROW; |
| 285 |
extern void omp_get_schedule (omp_sched_t *, int *) __GOMP_NOTHROW; |
| 286 |
extern int omp_get_thread_limit (void) __GOMP_NOTHROW; |
| 287 |
extern void omp_set_max_active_levels (int) __GOMP_NOTHROW; |
| 288 |
extern int omp_get_max_active_levels (void) __GOMP_NOTHROW; |
| 289 |
extern int omp_get_supported_active_levels (void) __GOMP_NOTHROW; |
| 290 |
extern int omp_get_level (void) __GOMP_NOTHROW; |
| 291 |
extern int omp_get_ancestor_thread_num (int) __GOMP_NOTHROW; |
| 292 |
extern int omp_get_team_size (int) __GOMP_NOTHROW; |
| 293 |
extern int omp_get_active_level (void) __GOMP_NOTHROW; |
| 294 |
|
| 295 |
extern int omp_in_final (void) __GOMP_NOTHROW; |
| 296 |
extern int omp_in_explicit_task (void) __GOMP_NOTHROW; |
| 297 |
|
| 298 |
extern int omp_get_cancellation (void) __GOMP_NOTHROW; |
| 299 |
extern omp_proc_bind_t omp_get_proc_bind (void) __GOMP_NOTHROW; |
| 300 |
extern int omp_get_num_places (void) __GOMP_NOTHROW; |
| 301 |
extern int omp_get_place_num_procs (int) __GOMP_NOTHROW; |
| 302 |
extern void omp_get_place_proc_ids (int, int *) __GOMP_NOTHROW; |
| 303 |
extern int omp_get_place_num (void) __GOMP_NOTHROW; |
| 304 |
extern int omp_get_partition_num_places (void) __GOMP_NOTHROW; |
| 305 |
extern void omp_get_partition_place_nums (int *) __GOMP_NOTHROW; |
| 306 |
|
| 307 |
extern void omp_set_default_device (int) __GOMP_NOTHROW; |
| 308 |
extern int omp_get_default_device (void) __GOMP_NOTHROW; |
| 309 |
extern int omp_get_num_devices (void) __GOMP_NOTHROW; |
| 310 |
extern int omp_get_device_num (void) __GOMP_NOTHROW; |
| 311 |
extern int omp_get_num_teams (void) __GOMP_NOTHROW; |
| 312 |
extern int omp_get_team_num (void) __GOMP_NOTHROW; |
| 313 |
|
| 314 |
extern int omp_is_initial_device (void) __GOMP_NOTHROW; |
| 315 |
extern int omp_get_initial_device (void) __GOMP_NOTHROW; |
| 316 |
extern int omp_get_max_task_priority (void) __GOMP_NOTHROW; |
| 317 |
|
| 318 |
extern void omp_fulfill_event (omp_event_handle_t) __GOMP_NOTHROW; |
| 319 |
|
| 320 |
extern void omp_set_num_teams (int) __GOMP_NOTHROW; |
| 321 |
extern int omp_get_max_teams (void) __GOMP_NOTHROW; |
| 322 |
extern void omp_set_teams_thread_limit (int) __GOMP_NOTHROW; |
| 323 |
extern int omp_get_teams_thread_limit (void) __GOMP_NOTHROW; |
| 324 |
|
| 325 |
extern void *omp_target_alloc (__SIZE_TYPE__, int) __GOMP_NOTHROW; |
| 326 |
extern void omp_target_free (void *, int) __GOMP_NOTHROW; |
| 327 |
extern int omp_target_is_present (const void *, int) __GOMP_NOTHROW; |
| 328 |
extern int omp_target_memcpy (void *, const void *, __SIZE_TYPE__, |
| 329 |
__SIZE_TYPE__, __SIZE_TYPE__, int, int) |
| 330 |
__GOMP_NOTHROW; |
| 331 |
extern int omp_target_memcpy_async (void *, const void *, __SIZE_TYPE__, |
| 332 |
__SIZE_TYPE__, __SIZE_TYPE__, int, int, |
| 333 |
int, omp_depend_t * __GOMP_DEFAULT_NULL) |
| 334 |
__GOMP_NOTHROW; |
| 335 |
extern int omp_target_memcpy_rect (void *, const void *, __SIZE_TYPE__, int, |
| 336 |
const __SIZE_TYPE__ *, |
| 337 |
const __SIZE_TYPE__ *, |
| 338 |
const __SIZE_TYPE__ *, |
| 339 |
const __SIZE_TYPE__ *, |
| 340 |
const __SIZE_TYPE__ *, int, int) |
| 341 |
__GOMP_NOTHROW; |
| 342 |
extern int omp_target_memcpy_rect_async (void *, const void *, __SIZE_TYPE__, |
| 343 |
int, const __SIZE_TYPE__ *, |
| 344 |
const __SIZE_TYPE__ *, |
| 345 |
const __SIZE_TYPE__ *, |
| 346 |
const __SIZE_TYPE__ *, |
| 347 |
const __SIZE_TYPE__ *, int, int, int, |
| 348 |
omp_depend_t * __GOMP_DEFAULT_NULL) |
| 349 |
__GOMP_NOTHROW; |
| 350 |
extern int omp_target_associate_ptr (const void *, const void *, __SIZE_TYPE__, |
| 351 |
__SIZE_TYPE__, int) __GOMP_NOTHROW; |
| 352 |
extern int omp_target_disassociate_ptr (const void *, int) __GOMP_NOTHROW; |
| 353 |
extern void *omp_get_mapped_ptr (const void *, int) __GOMP_NOTHROW; |
| 354 |
extern int omp_target_is_accessible (const void *, __SIZE_TYPE__, int) |
| 355 |
__GOMP_NOTHROW; |
| 356 |
|
| 357 |
extern void omp_set_affinity_format (const char *) __GOMP_NOTHROW; |
| 358 |
extern __SIZE_TYPE__ omp_get_affinity_format (char *, __SIZE_TYPE__) |
| 359 |
__GOMP_NOTHROW; |
| 360 |
extern void omp_display_affinity (const char *) __GOMP_NOTHROW; |
| 361 |
extern __SIZE_TYPE__ omp_capture_affinity (char *, __SIZE_TYPE__, const char *) |
| 362 |
__GOMP_NOTHROW; |
| 363 |
|
| 364 |
extern int omp_pause_resource (omp_pause_resource_t, int) __GOMP_NOTHROW; |
| 365 |
extern int omp_pause_resource_all (omp_pause_resource_t) __GOMP_NOTHROW; |
| 366 |
|
| 367 |
extern omp_allocator_handle_t omp_init_allocator (omp_memspace_handle_t, |
| 368 |
int, |
| 369 |
const omp_alloctrait_t []) |
| 370 |
__GOMP_NOTHROW; |
| 371 |
extern void omp_destroy_allocator (omp_allocator_handle_t) __GOMP_NOTHROW; |
| 372 |
extern void omp_set_default_allocator (omp_allocator_handle_t) __GOMP_NOTHROW; |
| 373 |
extern omp_allocator_handle_t omp_get_default_allocator (void) __GOMP_NOTHROW; |
| 374 |
extern void omp_free (void *, |
| 375 |
omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR) |
| 376 |
__GOMP_NOTHROW; |
| 377 |
extern void *omp_alloc (__SIZE_TYPE__, |
| 378 |
omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR) |
| 379 |
__GOMP_NOTHROW __attribute__((__malloc__, __malloc__ (omp_free), |
| 380 |
__alloc_size__ (1))); |
| 381 |
extern void *omp_aligned_alloc (__SIZE_TYPE__, __SIZE_TYPE__, |
| 382 |
omp_allocator_handle_t |
| 383 |
__GOMP_DEFAULT_NULL_ALLOCATOR) |
| 384 |
__GOMP_NOTHROW __attribute__((__malloc__, __malloc__ (omp_free), |
| 385 |
__alloc_size__ (2), __alloc_align__ (1))); |
| 386 |
extern void *omp_calloc (__SIZE_TYPE__, __SIZE_TYPE__, |
| 387 |
omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR) |
| 388 |
__GOMP_NOTHROW __attribute__((__malloc__, __malloc__ (omp_free), |
| 389 |
__alloc_size__ (1, 2))); |
| 390 |
extern void *omp_aligned_calloc (__SIZE_TYPE__, __SIZE_TYPE__, __SIZE_TYPE__, |
| 391 |
omp_allocator_handle_t |
| 392 |
__GOMP_DEFAULT_NULL_ALLOCATOR) |
| 393 |
__GOMP_NOTHROW __attribute__((__malloc__, __malloc__ (omp_free), |
| 394 |
__alloc_size__ (2, 3), __alloc_align__ (1))); |
| 395 |
extern void *omp_realloc (void *, __SIZE_TYPE__, |
| 396 |
omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR, |
| 397 |
omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR) |
| 398 |
__GOMP_NOTHROW __attribute__((__malloc__ (omp_free), __alloc_size__ (2))); |
| 399 |
|
| 400 |
extern void omp_display_env (int) __GOMP_NOTHROW; |
| 401 |
|
| 402 |
extern int omp_get_num_interop_properties (const omp_interop_t) __GOMP_NOTHROW; |
| 403 |
|
| 404 |
extern omp_intptr_t omp_get_interop_int (const omp_interop_t, |
| 405 |
omp_interop_property_t, |
| 406 |
omp_interop_rc_t * __GOMP_DEFAULT_NULL) |
| 407 |
__GOMP_NOTHROW; |
| 408 |
|
| 409 |
extern void *omp_get_interop_ptr (const omp_interop_t, omp_interop_property_t, |
| 410 |
omp_interop_rc_t * __GOMP_DEFAULT_NULL) |
| 411 |
__GOMP_NOTHROW; |
| 412 |
|
| 413 |
extern const char *omp_get_interop_str (const omp_interop_t, |
| 414 |
omp_interop_property_t, |
| 415 |
omp_interop_rc_t * __GOMP_DEFAULT_NULL) |
| 416 |
__GOMP_NOTHROW; |
| 417 |
|
| 418 |
extern const char *omp_get_interop_name (const omp_interop_t, |
| 419 |
omp_interop_property_t) __GOMP_NOTHROW; |
| 420 |
|
| 421 |
extern const char *omp_get_interop_type_desc (const omp_interop_t, |
| 422 |
omp_interop_property_t) |
| 423 |
__GOMP_NOTHROW; |
| 424 |
|
| 425 |
extern const char *omp_get_interop_rc_desc (const omp_interop_t, |
| 426 |
omp_interop_rc_t) __GOMP_NOTHROW; |
| 427 |
|
| 428 |
extern int omp_get_device_from_uid (const char *) __GOMP_NOTHROW; |
| 429 |
extern const char *omp_get_uid_from_device (int) __GOMP_NOTHROW; |
| 430 |
|
| 431 |
#ifdef __cplusplus |
| 432 |
} |
| 433 |
#endif |
| 434 |
|
| 435 |
#if __cplusplus >= 201103L |
| 436 |
|
| 437 |
/* std::__throw_bad_alloc and std::__throw_bad_array_new_length. */ |
| 438 |
#include <bits/functexcept.h> |
| 439 |
|
| 440 |
namespace omp |
| 441 |
{ |
| 442 |
namespace allocator |
| 443 |
{ |
| 444 |
|
| 445 |
namespace __detail |
| 446 |
{ |
| 447 |
|
| 448 |
template<typename __T, omp_allocator_handle_t __Handle> |
| 449 |
struct __allocator_templ |
| 450 |
{ |
| 451 |
using value_type = __T; |
| 452 |
using pointer = __T*; |
| 453 |
using const_pointer = const __T*; |
| 454 |
using size_type = __SIZE_TYPE__; |
| 455 |
using difference_type = __PTRDIFF_TYPE__; |
| 456 |
|
| 457 |
__T* |
| 458 |
allocate (size_type __n) |
| 459 |
{ |
| 460 |
if (__SIZE_MAX__ / sizeof(__T) < __n) |
| 461 |
std::__throw_bad_array_new_length (); |
| 462 |
void *__p = omp_aligned_alloc (alignof(__T), __n * sizeof(__T), __Handle); |
| 463 |
if (!__p) |
| 464 |
std::__throw_bad_alloc (); |
| 465 |
return static_cast<__T*>(__p); |
| 466 |
} |
| 467 |
|
| 468 |
void |
| 469 |
deallocate (__T *__p, size_type) __GOMP_NOTHROW |
| 470 |
{ |
| 471 |
omp_free (static_cast<void*>(__p), __Handle); |
| 472 |
} |
| 473 |
}; |
| 474 |
|
| 475 |
template<typename __T, typename __U, omp_allocator_handle_t __Handle> |
| 476 |
constexpr bool |
| 477 |
operator== (const __allocator_templ<__T, __Handle>&, |
| 478 |
const __allocator_templ<__U, __Handle>&) __GOMP_NOTHROW |
| 479 |
{ |
| 480 |
return true; |
| 481 |
} |
| 482 |
|
| 483 |
template<typename __T, omp_allocator_handle_t __Handle, |
| 484 |
typename __U, omp_allocator_handle_t __UHandle> |
| 485 |
constexpr bool |
| 486 |
operator== (const __allocator_templ<__T, __Handle>&, |
| 487 |
const __allocator_templ<__U, __UHandle>&) __GOMP_NOTHROW |
| 488 |
{ |
| 489 |
return false; |
| 490 |
} |
| 491 |
|
| 492 |
template<typename __T, typename __U, omp_allocator_handle_t __Handle> |
| 493 |
constexpr bool |
| 494 |
operator!= (const __allocator_templ<__T, __Handle>&, |
| 495 |
const __allocator_templ<__U, __Handle>&) __GOMP_NOTHROW |
| 496 |
{ |
| 497 |
return false; |
| 498 |
} |
| 499 |
|
| 500 |
template<typename __T, omp_allocator_handle_t __Handle, |
| 501 |
typename __U, omp_allocator_handle_t __UHandle> |
| 502 |
constexpr bool |
| 503 |
operator!= (const __allocator_templ<__T, __Handle>&, |
| 504 |
const __allocator_templ<__U, __UHandle>&) __GOMP_NOTHROW |
| 505 |
{ |
| 506 |
return true; |
| 507 |
} |
| 508 |
|
| 509 |
} /* namespace __detail */ |
| 510 |
|
| 511 |
template<typename __T> |
| 512 |
struct null_allocator |
| 513 |
: __detail::__allocator_templ<__T, omp_null_allocator> {}; |
| 514 |
|
| 515 |
template<typename __T> |
| 516 |
struct default_mem |
| 517 |
: __detail::__allocator_templ<__T, omp_default_mem_alloc> {}; |
| 518 |
|
| 519 |
template<typename __T> |
| 520 |
struct large_cap_mem |
| 521 |
: __detail::__allocator_templ<__T, omp_large_cap_mem_alloc> {}; |
| 522 |
|
| 523 |
template<typename __T> |
| 524 |
struct const_mem |
| 525 |
: __detail::__allocator_templ<__T, omp_const_mem_alloc> {}; |
| 526 |
|
| 527 |
template<typename __T> |
| 528 |
struct high_bw_mem |
| 529 |
: __detail::__allocator_templ<__T, omp_high_bw_mem_alloc> {}; |
| 530 |
|
| 531 |
template<typename __T> |
| 532 |
struct low_lat_mem |
| 533 |
: __detail::__allocator_templ<__T, omp_low_lat_mem_alloc> {}; |
| 534 |
|
| 535 |
template<typename __T> |
| 536 |
struct cgroup_mem |
| 537 |
: __detail::__allocator_templ<__T, omp_cgroup_mem_alloc> {}; |
| 538 |
|
| 539 |
template<typename __T> |
| 540 |
struct pteam_mem |
| 541 |
: __detail::__allocator_templ<__T, omp_pteam_mem_alloc> {}; |
| 542 |
|
| 543 |
template<typename __T> |
| 544 |
struct thread_mem |
| 545 |
: __detail::__allocator_templ<__T, omp_thread_mem_alloc> {}; |
| 546 |
|
| 547 |
} /* namespace allocator */ |
| 548 |
|
| 549 |
} /* namespace omp */ |
| 550 |
|
| 551 |
namespace ompx |
| 552 |
{ |
| 553 |
|
| 554 |
namespace allocator |
| 555 |
{ |
| 556 |
|
| 557 |
template<typename __T> |
| 558 |
struct gnu_pinned_mem |
| 559 |
: omp::allocator::__detail::__allocator_templ<__T, ompx_gnu_pinned_mem_alloc> {}; |
| 560 |
|
| 561 |
} /* namespace allocator */ |
| 562 |
|
| 563 |
} /* namespace ompx */ |
| 564 |
|
| 565 |
#endif /* __cplusplus */ |
| 566 |
|
| 567 |
#endif /* _OMP_H */ |