Debian Codegraph @

libgomp/fortran.c

raw
1 /* Copyright (C) 2005-2025 Free Software Foundation, Inc.
2 Contributed by Jakub Jelinek <[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 /* This file contains Fortran wrapper routines. */
27
28 #include "libgomp.h"
29 #include "libgomp_f.h"
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <string.h>
33 #include <limits.h>
34
35 #ifdef HAVE_ATTRIBUTE_ALIAS
36 /* Use internal aliases if possible. */
37 # ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
38 ialias_redirect (omp_init_lock)
39 ialias_redirect (omp_init_nest_lock)
40 ialias_redirect (omp_destroy_lock)
41 ialias_redirect (omp_destroy_nest_lock)
42 ialias_redirect (omp_set_lock)
43 ialias_redirect (omp_set_nest_lock)
44 ialias_redirect (omp_unset_lock)
45 ialias_redirect (omp_unset_nest_lock)
46 ialias_redirect (omp_test_lock)
47 ialias_redirect (omp_test_nest_lock)
48 # endif
49 ialias_redirect (omp_set_dynamic)
50 ialias_redirect (omp_get_dynamic)
51 #pragma GCC diagnostic push
52 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
53 ialias_redirect (omp_set_nested)
54 ialias_redirect (omp_get_nested)
55 #pragma GCC diagnostic pop
56 ialias_redirect (omp_set_num_threads)
57 ialias_redirect (omp_in_parallel)
58 ialias_redirect (omp_get_max_threads)
59 ialias_redirect (omp_get_num_procs)
60 ialias_redirect (omp_get_num_threads)
61 ialias_redirect (omp_get_thread_num)
62 ialias_redirect (omp_get_wtick)
63 ialias_redirect (omp_get_wtime)
64 ialias_redirect (omp_set_schedule)
65 ialias_redirect (omp_get_schedule)
66 ialias_redirect (omp_get_thread_limit)
67 ialias_redirect (omp_set_max_active_levels)
68 ialias_redirect (omp_get_max_active_levels)
69 ialias_redirect (omp_get_supported_active_levels)
70 ialias_redirect (omp_set_num_teams)
71 ialias_redirect (omp_get_max_teams)
72 ialias_redirect (omp_set_teams_thread_limit)
73 ialias_redirect (omp_get_teams_thread_limit)
74 ialias_redirect (omp_get_level)
75 ialias_redirect (omp_get_ancestor_thread_num)
76 ialias_redirect (omp_get_team_size)
77 ialias_redirect (omp_get_active_level)
78 ialias_redirect (omp_in_final)
79 ialias_redirect (omp_in_explicit_task)
80 ialias_redirect (omp_get_cancellation)
81 ialias_redirect (omp_get_proc_bind)
82 ialias_redirect (omp_get_num_places)
83 ialias_redirect (omp_get_place_num_procs)
84 ialias_redirect (omp_get_place_proc_ids)
85 ialias_redirect (omp_get_place_num)
86 ialias_redirect (omp_get_partition_num_places)
87 ialias_redirect (omp_get_partition_place_nums)
88 ialias_redirect (omp_set_default_device)
89 ialias_redirect (omp_get_default_device)
90 ialias_redirect (omp_get_num_devices)
91 ialias_redirect (omp_get_device_num)
92 ialias_redirect (omp_get_num_teams)
93 ialias_redirect (omp_get_team_num)
94 ialias_redirect (omp_is_initial_device)
95 ialias_redirect (omp_get_initial_device)
96 ialias_redirect (omp_get_max_task_priority)
97 ialias_redirect (omp_pause_resource)
98 ialias_redirect (omp_pause_resource_all)
99 ialias_redirect (omp_init_allocator)
100 ialias_redirect (omp_destroy_allocator)
101 ialias_redirect (omp_set_default_allocator)
102 ialias_redirect (omp_get_default_allocator)
103 ialias_redirect (omp_display_env)
104 ialias_redirect (omp_fulfill_event)
105 ialias_redirect (omp_get_interop_str)
106 ialias_redirect (omp_get_interop_name)
107 ialias_redirect (omp_get_interop_type_desc)
108 ialias_redirect (omp_get_interop_rc_desc)
109 #endif
110
111 #ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
112 # define gomp_init_lock__30 omp_init_lock_
113 # define gomp_destroy_lock__30 omp_destroy_lock_
114 # define gomp_set_lock__30 omp_set_lock_
115 # define gomp_unset_lock__30 omp_unset_lock_
116 # define gomp_test_lock__30 omp_test_lock_
117 # define gomp_init_nest_lock__30 omp_init_nest_lock_
118 # define gomp_destroy_nest_lock__30 omp_destroy_nest_lock_
119 # define gomp_set_nest_lock__30 omp_set_nest_lock_
120 # define gomp_unset_nest_lock__30 omp_unset_nest_lock_
121 # define gomp_test_nest_lock__30 omp_test_nest_lock_
122 #endif
123
124 void
125 gomp_init_lock__30 (omp_lock_arg_t lock)
126 {
127 #ifndef OMP_LOCK_DIRECT
128 omp_lock_arg (lock) = malloc (sizeof (omp_lock_t));
129 #endif
130 gomp_init_lock_30 (omp_lock_arg (lock));
131 }
132
133 void
134 gomp_init_nest_lock__30 (omp_nest_lock_arg_t lock)
135 {
136 #ifndef OMP_NEST_LOCK_DIRECT
137 omp_nest_lock_arg (lock) = malloc (sizeof (omp_nest_lock_t));
138 #endif
139 gomp_init_nest_lock_30 (omp_nest_lock_arg (lock));
140 }
141
142 void
143 gomp_destroy_lock__30 (omp_lock_arg_t lock)
144 {
145 gomp_destroy_lock_30 (omp_lock_arg (lock));
146 #ifndef OMP_LOCK_DIRECT
147 free (omp_lock_arg (lock));
148 omp_lock_arg (lock) = NULL;
149 #endif
150 }
151
152 void
153 gomp_destroy_nest_lock__30 (omp_nest_lock_arg_t lock)
154 {
155 gomp_destroy_nest_lock_30 (omp_nest_lock_arg (lock));
156 #ifndef OMP_NEST_LOCK_DIRECT
157 free (omp_nest_lock_arg (lock));
158 omp_nest_lock_arg (lock) = NULL;
159 #endif
160 }
161
162 void
163 gomp_set_lock__30 (omp_lock_arg_t lock)
164 {
165 gomp_set_lock_30 (omp_lock_arg (lock));
166 }
167
168 void
169 gomp_set_nest_lock__30 (omp_nest_lock_arg_t lock)
170 {
171 gomp_set_nest_lock_30 (omp_nest_lock_arg (lock));
172 }
173
174 void
175 gomp_unset_lock__30 (omp_lock_arg_t lock)
176 {
177 gomp_unset_lock_30 (omp_lock_arg (lock));
178 }
179
180 void
181 gomp_unset_nest_lock__30 (omp_nest_lock_arg_t lock)
182 {
183 gomp_unset_nest_lock_30 (omp_nest_lock_arg (lock));
184 }
185
186 int32_t
187 gomp_test_lock__30 (omp_lock_arg_t lock)
188 {
189 return gomp_test_lock_30 (omp_lock_arg (lock));
190 }
191
192 int32_t
193 gomp_test_nest_lock__30 (omp_nest_lock_arg_t lock)
194 {
195 return gomp_test_nest_lock_30 (omp_nest_lock_arg (lock));
196 }
197
198 #ifdef LIBGOMP_GNU_SYMBOL_VERSIONING
199 void
200 gomp_init_lock__25 (omp_lock_25_arg_t lock)
201 {
202 #ifndef OMP_LOCK_25_DIRECT
203 omp_lock_25_arg (lock) = malloc (sizeof (omp_lock_25_t));
204 #endif
205 gomp_init_lock_25 (omp_lock_25_arg (lock));
206 }
207
208 void
209 gomp_init_nest_lock__25 (omp_nest_lock_25_arg_t lock)
210 {
211 #ifndef OMP_NEST_LOCK_25_DIRECT
212 omp_nest_lock_25_arg (lock) = malloc (sizeof (omp_nest_lock_25_t));
213 #endif
214 gomp_init_nest_lock_25 (omp_nest_lock_25_arg (lock));
215 }
216
217 void
218 gomp_destroy_lock__25 (omp_lock_25_arg_t lock)
219 {
220 gomp_destroy_lock_25 (omp_lock_25_arg (lock));
221 #ifndef OMP_LOCK_25_DIRECT
222 free (omp_lock_25_arg (lock));
223 omp_lock_25_arg (lock) = NULL;
224 #endif
225 }
226
227 void
228 gomp_destroy_nest_lock__25 (omp_nest_lock_25_arg_t lock)
229 {
230 gomp_destroy_nest_lock_25 (omp_nest_lock_25_arg (lock));
231 #ifndef OMP_NEST_LOCK_25_DIRECT
232 free (omp_nest_lock_25_arg (lock));
233 omp_nest_lock_25_arg (lock) = NULL;
234 #endif
235 }
236
237 void
238 gomp_set_lock__25 (omp_lock_25_arg_t lock)
239 {
240 gomp_set_lock_25 (omp_lock_25_arg (lock));
241 }
242
243 void
244 gomp_set_nest_lock__25 (omp_nest_lock_25_arg_t lock)
245 {
246 gomp_set_nest_lock_25 (omp_nest_lock_25_arg (lock));
247 }
248
249 void
250 gomp_unset_lock__25 (omp_lock_25_arg_t lock)
251 {
252 gomp_unset_lock_25 (omp_lock_25_arg (lock));
253 }
254
255 void
256 gomp_unset_nest_lock__25 (omp_nest_lock_25_arg_t lock)
257 {
258 gomp_unset_nest_lock_25 (omp_nest_lock_25_arg (lock));
259 }
260
261 int32_t
262 gomp_test_lock__25 (omp_lock_25_arg_t lock)
263 {
264 return gomp_test_lock_25 (omp_lock_25_arg (lock));
265 }
266
267 int32_t
268 gomp_test_nest_lock__25 (omp_nest_lock_25_arg_t lock)
269 {
270 return gomp_test_nest_lock_25 (omp_nest_lock_25_arg (lock));
271 }
272
273 omp_lock_symver (omp_init_lock_)
274 omp_lock_symver (omp_destroy_lock_)
275 omp_lock_symver (omp_set_lock_)
276 omp_lock_symver (omp_unset_lock_)
277 omp_lock_symver (omp_test_lock_)
278 omp_lock_symver (omp_init_nest_lock_)
279 omp_lock_symver (omp_destroy_nest_lock_)
280 omp_lock_symver (omp_set_nest_lock_)
281 omp_lock_symver (omp_unset_nest_lock_)
282 omp_lock_symver (omp_test_nest_lock_)
283 #endif
284
285 #define TO_INT(x) ((x) > INT_MIN ? (x) < INT_MAX ? (x) : INT_MAX : INT_MIN)
286
287 void
288 omp_set_dynamic_ (const int32_t *set)
289 {
290 omp_set_dynamic (*set);
291 }
292
293 void
294 omp_set_dynamic_8_ (const int64_t *set)
295 {
296 omp_set_dynamic (!!*set);
297 }
298
299 #pragma GCC diagnostic push
300 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
301 void
302 omp_set_nested_ (const int32_t *set)
303 {
304 omp_set_nested (*set);
305 }
306
307 void
308 omp_set_nested_8_ (const int64_t *set)
309 {
310 omp_set_nested (!!*set);
311 }
312 #pragma GCC diagnostic pop
313
314 void
315 omp_set_num_threads_ (const int32_t *set)
316 {
317 omp_set_num_threads (*set);
318 }
319
320 void
321 omp_set_num_threads_8_ (const int64_t *set)
322 {
323 omp_set_num_threads (TO_INT (*set));
324 }
325
326 int32_t
327 omp_get_dynamic_ (void)
328 {
329 return omp_get_dynamic ();
330 }
331
332 #pragma GCC diagnostic push
333 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
334 int32_t
335 omp_get_nested_ (void)
336 {
337 return omp_get_nested ();
338 }
339 #pragma GCC diagnostic pop
340
341 int32_t
342 omp_in_parallel_ (void)
343 {
344 return omp_in_parallel ();
345 }
346
347 int32_t
348 omp_get_max_threads_ (void)
349 {
350 return omp_get_max_threads ();
351 }
352
353 int32_t
354 omp_get_num_procs_ (void)
355 {
356 return omp_get_num_procs ();
357 }
358
359 int32_t
360 omp_get_num_threads_ (void)
361 {
362 return omp_get_num_threads ();
363 }
364
365 int32_t
366 omp_get_thread_num_ (void)
367 {
368 return omp_get_thread_num ();
369 }
370
371 double
372 omp_get_wtick_ (void)
373 {
374 return omp_get_wtick ();
375 }
376
377 double
378 omp_get_wtime_ (void)
379 {
380 return omp_get_wtime ();
381 }
382
383 void
384 omp_set_schedule_ (const int32_t *kind, const int32_t *chunk_size)
385 {
386 omp_set_schedule (*kind, *chunk_size);
387 }
388
389 void
390 omp_set_schedule_8_ (const int32_t *kind, const int64_t *chunk_size)
391 {
392 omp_set_schedule (*kind, TO_INT (*chunk_size));
393 }
394
395 void
396 omp_get_schedule_ (int32_t *kind, int32_t *chunk_size)
397 {
398 omp_sched_t k;
399 int cs;
400 omp_get_schedule (&k, &cs);
401 /* For now mask off GFS_MONOTONIC, because OpenMP 4.5 code will not
402 expect to see it. */
403 *kind = k & ~GFS_MONOTONIC;
404 *chunk_size = cs;
405 }
406
407 void
408 omp_get_schedule_8_ (int32_t *kind, int64_t *chunk_size)
409 {
410 omp_sched_t k;
411 int cs;
412 omp_get_schedule (&k, &cs);
413 /* See above. */
414 *kind = k & ~GFS_MONOTONIC;
415 *chunk_size = cs;
416 }
417
418 int32_t
419 omp_get_thread_limit_ (void)
420 {
421 return omp_get_thread_limit ();
422 }
423
424 void
425 omp_set_max_active_levels_ (const int32_t *levels)
426 {
427 omp_set_max_active_levels (*levels);
428 }
429
430 void
431 omp_set_max_active_levels_8_ (const int64_t *levels)
432 {
433 omp_set_max_active_levels (TO_INT (*levels));
434 }
435
436 int32_t
437 omp_get_max_active_levels_ (void)
438 {
439 return omp_get_max_active_levels ();
440 }
441
442 int32_t
443 omp_get_supported_active_levels_ (void)
444 {
445 return omp_get_supported_active_levels ();
446 }
447
448 int32_t
449 omp_get_level_ (void)
450 {
451 return omp_get_level ();
452 }
453
454 int32_t
455 omp_get_ancestor_thread_num_ (const int32_t *level)
456 {
457 return omp_get_ancestor_thread_num (*level);
458 }
459
460 int32_t
461 omp_get_ancestor_thread_num_8_ (const int64_t *level)
462 {
463 return omp_get_ancestor_thread_num (TO_INT (*level));
464 }
465
466 int32_t
467 omp_get_team_size_ (const int32_t *level)
468 {
469 return omp_get_team_size (*level);
470 }
471
472 int32_t
473 omp_get_team_size_8_ (const int64_t *level)
474 {
475 return omp_get_team_size (TO_INT (*level));
476 }
477
478 int32_t
479 omp_get_active_level_ (void)
480 {
481 return omp_get_active_level ();
482 }
483
484 int32_t
485 omp_in_final_ (void)
486 {
487 return omp_in_final ();
488 }
489
490 int32_t
491 omp_in_explicit_task_ (void)
492 {
493 return omp_in_explicit_task ();
494 }
495
496 void
497 omp_set_num_teams_ (const int32_t *num_teams)
498 {
499 omp_set_num_teams (*num_teams);
500 }
501
502 void
503 omp_set_num_teams_8_ (const int64_t *num_teams)
504 {
505 omp_set_num_teams (TO_INT (*num_teams));
506 }
507
508 int32_t
509 omp_get_max_teams_ (void)
510 {
511 return omp_get_max_teams ();
512 }
513
514 void
515 omp_set_teams_thread_limit_ (const int32_t *thread_limit)
516 {
517 omp_set_teams_thread_limit (*thread_limit);
518 }
519
520 void
521 omp_set_teams_thread_limit_8_ (const int64_t *thread_limit)
522 {
523 omp_set_teams_thread_limit (TO_INT (*thread_limit));
524 }
525
526 int32_t
527 omp_get_teams_thread_limit_ (void)
528 {
529 return omp_get_teams_thread_limit ();
530 }
531
532 int32_t
533 omp_get_cancellation_ (void)
534 {
535 return omp_get_cancellation ();
536 }
537
538 int32_t
539 omp_get_proc_bind_ (void)
540 {
541 return omp_get_proc_bind ();
542 }
543
544 int32_t
545 omp_get_num_places_ (void)
546 {
547 return omp_get_num_places ();
548 }
549
550 int32_t
551 omp_get_place_num_procs_ (const int32_t *place_num)
552 {
553 return omp_get_place_num_procs (*place_num);
554 }
555
556 int32_t
557 omp_get_place_num_procs_8_ (const int64_t *place_num)
558 {
559 return omp_get_place_num_procs (TO_INT (*place_num));
560 }
561
562 void
563 omp_get_place_proc_ids_ (const int32_t *place_num, int32_t *ids)
564 {
565 omp_get_place_proc_ids (*place_num, (int *) ids);
566 }
567
568 void
569 omp_get_place_proc_ids_8_ (const int64_t *place_num, int64_t *ids)
570 {
571 gomp_get_place_proc_ids_8 (TO_INT (*place_num), ids);
572 }
573
574 int32_t
575 omp_get_place_num_ (void)
576 {
577 return omp_get_place_num ();
578 }
579
580 int32_t
581 omp_get_partition_num_places_ (void)
582 {
583 return omp_get_partition_num_places ();
584 }
585
586 void
587 omp_get_partition_place_nums_ (int32_t *place_nums)
588 {
589 omp_get_partition_place_nums ((int *) place_nums);
590 }
591
592 void
593 omp_get_partition_place_nums_8_ (int64_t *place_nums)
594 {
595 if (gomp_places_list == NULL)
596 return;
597
598 struct gomp_thread *thr = gomp_thread ();
599 if (thr->place == 0)
600 gomp_init_affinity ();
601
602 unsigned int i;
603 for (i = 0; i < thr->ts.place_partition_len; i++)
604 *place_nums++ = (int64_t) thr->ts.place_partition_off + i;
605 }
606
607 void
608 omp_set_default_device_ (const int32_t *device_num)
609 {
610 return omp_set_default_device (*device_num);
611 }
612
613 void
614 omp_set_default_device_8_ (const int64_t *device_num)
615 {
616 return omp_set_default_device (TO_INT (*device_num));
617 }
618
619 int32_t
620 omp_get_default_device_ (void)
621 {
622 return omp_get_default_device ();
623 }
624
625 int32_t
626 omp_get_num_devices_ (void)
627 {
628 return omp_get_num_devices ();
629 }
630
631 int32_t
632 omp_get_num_teams_ (void)
633 {
634 return omp_get_num_teams ();
635 }
636
637 int32_t
638 omp_get_team_num_ (void)
639 {
640 return omp_get_team_num ();
641 }
642
643 int32_t
644 omp_is_initial_device_ (void)
645 {
646 return omp_is_initial_device ();
647 }
648
649 int32_t
650 omp_get_initial_device_ (void)
651 {
652 return omp_get_initial_device ();
653 }
654
655 int32_t
656 omp_get_device_num_ (void)
657 {
658 return omp_get_device_num ();
659 }
660
661 int32_t
662 omp_get_max_task_priority_ (void)
663 {
664 return omp_get_max_task_priority ();
665 }
666
667 void
668 omp_fulfill_event_ (intptr_t event)
669 {
670 omp_fulfill_event ((omp_event_handle_t) event);
671 }
672
673 void
674 omp_set_affinity_format_ (const char *format, size_t format_len)
675 {
676 gomp_set_affinity_format (format, format_len);
677 }
678
679 int32_t
680 omp_get_affinity_format_ (char *buffer, size_t buffer_len)
681 {
682 size_t len = strlen (gomp_affinity_format_var);
683 if (buffer_len)
684 {
685 if (len < buffer_len)
686 {
687 memcpy (buffer, gomp_affinity_format_var, len);
688 memset (buffer + len, ' ', buffer_len - len);
689 }
690 else
691 memcpy (buffer, gomp_affinity_format_var, buffer_len);
692 }
693 return len;
694 }
695
696 void
697 omp_display_affinity_ (const char *format, size_t format_len)
698 {
699 char *fmt = NULL, fmt_buf[256];
700 char buf[512];
701 if (format_len)
702 {
703 fmt = format_len < 256 ? fmt_buf : gomp_malloc (format_len + 1);
704 memcpy (fmt, format, format_len);
705 fmt[format_len] = '\0';
706 }
707 struct gomp_thread *thr = gomp_thread ();
708 size_t ret
709 = gomp_display_affinity (buf, sizeof buf,
710 format_len ? fmt : gomp_affinity_format_var,
711 gomp_thread_self (), &thr->ts, thr->place);
712 if (ret < sizeof buf)
713 {
714 buf[ret] = '\n';
715 gomp_print_string (buf, ret + 1);
716 }
717 else
718 {
719 char *b = gomp_malloc (ret + 1);
720 gomp_display_affinity (buf, sizeof buf,
721 format_len ? fmt : gomp_affinity_format_var,
722 gomp_thread_self (), &thr->ts, thr->place);
723 b[ret] = '\n';
724 gomp_print_string (b, ret + 1);
725 free (b);
726 }
727 if (fmt && fmt != fmt_buf)
728 free (fmt);
729 }
730
731 int32_t
732 omp_capture_affinity_ (char *buffer, const char *format,
733 size_t buffer_len, size_t format_len)
734 {
735 char *fmt = NULL, fmt_buf[256];
736 if (format_len)
737 {
738 fmt = format_len < 256 ? fmt_buf : gomp_malloc (format_len + 1);
739 memcpy (fmt, format, format_len);
740 fmt[format_len] = '\0';
741 }
742 struct gomp_thread *thr = gomp_thread ();
743 size_t ret
744 = gomp_display_affinity (buffer, buffer_len,
745 format_len ? fmt : gomp_affinity_format_var,
746 gomp_thread_self (), &thr->ts, thr->place);
747 if (fmt && fmt != fmt_buf)
748 free (fmt);
749 if (ret < buffer_len)
750 memset (buffer + ret, ' ', buffer_len - ret);
751 return ret;
752 }
753
754 int32_t
755 omp_pause_resource_ (const int32_t *kind, const int32_t *device_num)
756 {
757 return omp_pause_resource (*kind, *device_num);
758 }
759
760 int32_t
761 omp_pause_resource_all_ (const int32_t *kind)
762 {
763 return omp_pause_resource_all (*kind);
764 }
765
766 intptr_t
767 omp_init_allocator_ (const intptr_t *memspace, const int32_t *ntraits,
768 const omp_alloctrait_t *traits)
769 {
770 return (intptr_t) omp_init_allocator ((omp_memspace_handle_t) *memspace,
771 (int) *ntraits, traits);
772 }
773
774 intptr_t
775 omp_init_allocator_8_ (const intptr_t *memspace, const int64_t *ntraits,
776 const omp_alloctrait_t *traits)
777 {
778 return (intptr_t) omp_init_allocator ((omp_memspace_handle_t) *memspace,
779 (int) *ntraits, traits);
780 }
781
782 void
783 omp_destroy_allocator_ (const intptr_t *allocator)
784 {
785 omp_destroy_allocator ((omp_allocator_handle_t) *allocator);
786 }
787
788 void
789 omp_set_default_allocator_ (const intptr_t *allocator)
790 {
791 omp_set_default_allocator ((omp_allocator_handle_t) *allocator);
792 }
793
794 intptr_t
795 omp_get_default_allocator_ ()
796 {
797 return (intptr_t) omp_get_default_allocator ();
798 }
799
800 void
801 omp_get_interop_str_ (const char **res, size_t *res_len,
802 const omp_interop_t interop,
803 omp_interop_property_t property_id,
804 omp_interop_rc_t *ret_code)
805 {
806 *res = omp_get_interop_str (interop, property_id, ret_code);
807 *res_len = *res ? strlen (*res) : 0;
808 }
809
810 void
811 omp_get_interop_name_ (const char **res, size_t *res_len,
812 const omp_interop_t interop,
813 omp_interop_property_t property_id)
814 {
815 *res = omp_get_interop_name (interop, property_id);
816 *res_len = *res ? strlen (*res) : 0;
817 }
818
819 void
820 omp_get_interop_type_desc_ (const char **res, size_t *res_len,
821 const omp_interop_t interop,
822 omp_interop_property_t property_id)
823 {
824 *res = omp_get_interop_type_desc (interop, property_id);
825 *res_len = *res ? strlen (*res) : 0;
826 }
827
828 void
829 omp_get_interop_rc_desc_ (const char **res, size_t *res_len,
830 const omp_interop_t interop,
831 omp_interop_rc_t ret_code)
832 {
833 *res = omp_get_interop_rc_desc (interop, ret_code);
834 *res_len = *res ? strlen (*res) : 0;
835 }
836
837 int
838 omp_get_device_from_uid_ (const char *uid, size_t uid_len)
839 {
840 #ifndef LIBGOMP_OFFLOADED_ONLY
841 char *str = __builtin_alloca ((uid_len + 1) * sizeof (char));
842 memcpy (str, uid, uid_len * sizeof (char));
843 str[uid_len] = '\0';
844 return omp_get_device_from_uid (str);
845 #else
846 /* Inside the target region, invoking this routine is undefined
847 behavior; thus, resolve it already here - instead of inside
848 libgomp/config/.../target.c.
849 This also circumvents issues due to not all nvptx configurations
850 supporting 'alloca'. */
851 return omp_invalid_device;
852 #endif
853 }
854
855 void
856 omp_get_uid_from_device_ (const char **res, size_t *res_len,
857 int32_t device_num)
858 {
859 *res = omp_get_uid_from_device (device_num);
860 *res_len = *res ? strlen (*res) : 0;
861 }
862
863 void
864 omp_get_uid_from_device_8_ (const char **res, size_t *res_len,
865 int64_t device_num)
866 {
867 omp_get_uid_from_device_ (res, res_len, (int32_t) device_num);
868 }
869
870 #ifndef LIBGOMP_OFFLOADED_ONLY
871
872 void
873 omp_display_env_ (const int32_t *verbose)
874 {
875 omp_display_env (*verbose);
876 }
877
878 void
879 omp_display_env_8_ (const int64_t *verbose)
880 {
881 omp_display_env (!!*verbose);
882 }
883
884 #endif /* LIBGOMP_OFFLOADED_ONLY */