1 /* Copyright (C) 2005-2016 Free Software Foundation, Inc.
2 Contributed by Jakub Jelinek <jakub@redhat.com>.
4 This file is part of the GNU Offloading and Multi Processing Library
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)
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
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.
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/>. */
26 /* This file contains Fortran wrapper routines. */
29 #include "libgomp_f.h"
33 #ifdef HAVE_ATTRIBUTE_ALIAS
34 /* Use internal aliases if possible. */
35 # ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
36 ialias_redirect (omp_init_lock
)
37 ialias_redirect (omp_init_nest_lock
)
38 ialias_redirect (omp_destroy_lock
)
39 ialias_redirect (omp_destroy_nest_lock
)
40 ialias_redirect (omp_set_lock
)
41 ialias_redirect (omp_set_nest_lock
)
42 ialias_redirect (omp_unset_lock
)
43 ialias_redirect (omp_unset_nest_lock
)
44 ialias_redirect (omp_test_lock
)
45 ialias_redirect (omp_test_nest_lock
)
47 ialias_redirect (omp_set_dynamic
)
48 ialias_redirect (omp_set_nested
)
49 ialias_redirect (omp_set_num_threads
)
50 ialias_redirect (omp_get_dynamic
)
51 ialias_redirect (omp_get_nested
)
52 ialias_redirect (omp_in_parallel
)
53 ialias_redirect (omp_get_max_threads
)
54 ialias_redirect (omp_get_num_procs
)
55 ialias_redirect (omp_get_num_threads
)
56 ialias_redirect (omp_get_thread_num
)
57 ialias_redirect (omp_get_wtick
)
58 ialias_redirect (omp_get_wtime
)
59 ialias_redirect (omp_set_schedule
)
60 ialias_redirect (omp_get_schedule
)
61 ialias_redirect (omp_get_thread_limit
)
62 ialias_redirect (omp_set_max_active_levels
)
63 ialias_redirect (omp_get_max_active_levels
)
64 ialias_redirect (omp_get_level
)
65 ialias_redirect (omp_get_ancestor_thread_num
)
66 ialias_redirect (omp_get_team_size
)
67 ialias_redirect (omp_get_active_level
)
68 ialias_redirect (omp_in_final
)
69 ialias_redirect (omp_get_cancellation
)
70 ialias_redirect (omp_get_proc_bind
)
71 ialias_redirect (omp_get_num_places
)
72 ialias_redirect (omp_get_place_num_procs
)
73 ialias_redirect (omp_get_place_proc_ids
)
74 ialias_redirect (omp_get_place_num
)
75 ialias_redirect (omp_get_partition_num_places
)
76 ialias_redirect (omp_get_partition_place_nums
)
77 ialias_redirect (omp_set_default_device
)
78 ialias_redirect (omp_get_default_device
)
79 ialias_redirect (omp_get_num_devices
)
80 ialias_redirect (omp_get_num_teams
)
81 ialias_redirect (omp_get_team_num
)
82 ialias_redirect (omp_is_initial_device
)
83 ialias_redirect (omp_get_initial_device
)
84 ialias_redirect (omp_get_max_task_priority
)
87 #ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
88 # define gomp_init_lock__30 omp_init_lock_
89 # define gomp_destroy_lock__30 omp_destroy_lock_
90 # define gomp_set_lock__30 omp_set_lock_
91 # define gomp_unset_lock__30 omp_unset_lock_
92 # define gomp_test_lock__30 omp_test_lock_
93 # define gomp_init_nest_lock__30 omp_init_nest_lock_
94 # define gomp_destroy_nest_lock__30 omp_destroy_nest_lock_
95 # define gomp_set_nest_lock__30 omp_set_nest_lock_
96 # define gomp_unset_nest_lock__30 omp_unset_nest_lock_
97 # define gomp_test_nest_lock__30 omp_test_nest_lock_
101 gomp_init_lock__30 (omp_lock_arg_t lock
)
103 #ifndef OMP_LOCK_DIRECT
104 omp_lock_arg (lock
) = malloc (sizeof (omp_lock_t
));
106 gomp_init_lock_30 (omp_lock_arg (lock
));
110 gomp_init_nest_lock__30 (omp_nest_lock_arg_t lock
)
112 #ifndef OMP_NEST_LOCK_DIRECT
113 omp_nest_lock_arg (lock
) = malloc (sizeof (omp_nest_lock_t
));
115 gomp_init_nest_lock_30 (omp_nest_lock_arg (lock
));
119 gomp_destroy_lock__30 (omp_lock_arg_t lock
)
121 gomp_destroy_lock_30 (omp_lock_arg (lock
));
122 #ifndef OMP_LOCK_DIRECT
123 free (omp_lock_arg (lock
));
124 omp_lock_arg (lock
) = NULL
;
129 gomp_destroy_nest_lock__30 (omp_nest_lock_arg_t lock
)
131 gomp_destroy_nest_lock_30 (omp_nest_lock_arg (lock
));
132 #ifndef OMP_NEST_LOCK_DIRECT
133 free (omp_nest_lock_arg (lock
));
134 omp_nest_lock_arg (lock
) = NULL
;
139 gomp_set_lock__30 (omp_lock_arg_t lock
)
141 gomp_set_lock_30 (omp_lock_arg (lock
));
145 gomp_set_nest_lock__30 (omp_nest_lock_arg_t lock
)
147 gomp_set_nest_lock_30 (omp_nest_lock_arg (lock
));
151 gomp_unset_lock__30 (omp_lock_arg_t lock
)
153 gomp_unset_lock_30 (omp_lock_arg (lock
));
157 gomp_unset_nest_lock__30 (omp_nest_lock_arg_t lock
)
159 gomp_unset_nest_lock_30 (omp_nest_lock_arg (lock
));
163 gomp_test_lock__30 (omp_lock_arg_t lock
)
165 return gomp_test_lock_30 (omp_lock_arg (lock
));
169 gomp_test_nest_lock__30 (omp_nest_lock_arg_t lock
)
171 return gomp_test_nest_lock_30 (omp_nest_lock_arg (lock
));
174 #ifdef LIBGOMP_GNU_SYMBOL_VERSIONING
176 gomp_init_lock__25 (omp_lock_25_arg_t lock
)
178 #ifndef OMP_LOCK_25_DIRECT
179 omp_lock_25_arg (lock
) = malloc (sizeof (omp_lock_25_t
));
181 gomp_init_lock_25 (omp_lock_25_arg (lock
));
185 gomp_init_nest_lock__25 (omp_nest_lock_25_arg_t lock
)
187 #ifndef OMP_NEST_LOCK_25_DIRECT
188 omp_nest_lock_25_arg (lock
) = malloc (sizeof (omp_nest_lock_25_t
));
190 gomp_init_nest_lock_25 (omp_nest_lock_25_arg (lock
));
194 gomp_destroy_lock__25 (omp_lock_25_arg_t lock
)
196 gomp_destroy_lock_25 (omp_lock_25_arg (lock
));
197 #ifndef OMP_LOCK_25_DIRECT
198 free (omp_lock_25_arg (lock
));
199 omp_lock_25_arg (lock
) = NULL
;
204 gomp_destroy_nest_lock__25 (omp_nest_lock_25_arg_t lock
)
206 gomp_destroy_nest_lock_25 (omp_nest_lock_25_arg (lock
));
207 #ifndef OMP_NEST_LOCK_25_DIRECT
208 free (omp_nest_lock_25_arg (lock
));
209 omp_nest_lock_25_arg (lock
) = NULL
;
214 gomp_set_lock__25 (omp_lock_25_arg_t lock
)
216 gomp_set_lock_25 (omp_lock_25_arg (lock
));
220 gomp_set_nest_lock__25 (omp_nest_lock_25_arg_t lock
)
222 gomp_set_nest_lock_25 (omp_nest_lock_25_arg (lock
));
226 gomp_unset_lock__25 (omp_lock_25_arg_t lock
)
228 gomp_unset_lock_25 (omp_lock_25_arg (lock
));
232 gomp_unset_nest_lock__25 (omp_nest_lock_25_arg_t lock
)
234 gomp_unset_nest_lock_25 (omp_nest_lock_25_arg (lock
));
238 gomp_test_lock__25 (omp_lock_25_arg_t lock
)
240 return gomp_test_lock_25 (omp_lock_25_arg (lock
));
244 gomp_test_nest_lock__25 (omp_nest_lock_25_arg_t lock
)
246 return gomp_test_nest_lock_25 (omp_nest_lock_25_arg (lock
));
249 omp_lock_symver (omp_init_lock_
)
250 omp_lock_symver (omp_destroy_lock_
)
251 omp_lock_symver (omp_set_lock_
)
252 omp_lock_symver (omp_unset_lock_
)
253 omp_lock_symver (omp_test_lock_
)
254 omp_lock_symver (omp_init_nest_lock_
)
255 omp_lock_symver (omp_destroy_nest_lock_
)
256 omp_lock_symver (omp_set_nest_lock_
)
257 omp_lock_symver (omp_unset_nest_lock_
)
258 omp_lock_symver (omp_test_nest_lock_
)
261 #define TO_INT(x) ((x) > INT_MIN ? (x) < INT_MAX ? (x) : INT_MAX : INT_MIN)
264 omp_set_dynamic_ (const int32_t *set
)
266 omp_set_dynamic (*set
);
270 omp_set_dynamic_8_ (const int64_t *set
)
272 omp_set_dynamic (!!*set
);
276 omp_set_nested_ (const int32_t *set
)
278 omp_set_nested (*set
);
282 omp_set_nested_8_ (const int64_t *set
)
284 omp_set_nested (!!*set
);
288 omp_set_num_threads_ (const int32_t *set
)
290 omp_set_num_threads (*set
);
294 omp_set_num_threads_8_ (const int64_t *set
)
296 omp_set_num_threads (TO_INT (*set
));
300 omp_get_dynamic_ (void)
302 return omp_get_dynamic ();
306 omp_get_nested_ (void)
308 return omp_get_nested ();
312 omp_in_parallel_ (void)
314 return omp_in_parallel ();
318 omp_get_max_threads_ (void)
320 return omp_get_max_threads ();
324 omp_get_num_procs_ (void)
326 return omp_get_num_procs ();
330 omp_get_num_threads_ (void)
332 return omp_get_num_threads ();
336 omp_get_thread_num_ (void)
338 return omp_get_thread_num ();
342 omp_get_wtick_ (void)
344 return omp_get_wtick ();
348 omp_get_wtime_ (void)
350 return omp_get_wtime ();
354 omp_set_schedule_ (const int32_t *kind
, const int32_t *chunk_size
)
356 omp_set_schedule (*kind
, *chunk_size
);
360 omp_set_schedule_8_ (const int32_t *kind
, const int64_t *chunk_size
)
362 omp_set_schedule (*kind
, TO_INT (*chunk_size
));
366 omp_get_schedule_ (int32_t *kind
, int32_t *chunk_size
)
370 omp_get_schedule (&k
, &cs
);
376 omp_get_schedule_8_ (int32_t *kind
, int64_t *chunk_size
)
380 omp_get_schedule (&k
, &cs
);
386 omp_get_thread_limit_ (void)
388 return omp_get_thread_limit ();
392 omp_set_max_active_levels_ (const int32_t *levels
)
394 omp_set_max_active_levels (*levels
);
398 omp_set_max_active_levels_8_ (const int64_t *levels
)
400 omp_set_max_active_levels (TO_INT (*levels
));
404 omp_get_max_active_levels_ (void)
406 return omp_get_max_active_levels ();
410 omp_get_level_ (void)
412 return omp_get_level ();
416 omp_get_ancestor_thread_num_ (const int32_t *level
)
418 return omp_get_ancestor_thread_num (*level
);
422 omp_get_ancestor_thread_num_8_ (const int64_t *level
)
424 return omp_get_ancestor_thread_num (TO_INT (*level
));
428 omp_get_team_size_ (const int32_t *level
)
430 return omp_get_team_size (*level
);
434 omp_get_team_size_8_ (const int64_t *level
)
436 return omp_get_team_size (TO_INT (*level
));
440 omp_get_active_level_ (void)
442 return omp_get_active_level ();
448 return omp_in_final ();
452 omp_get_cancellation_ (void)
454 return omp_get_cancellation ();
458 omp_get_proc_bind_ (void)
460 return omp_get_proc_bind ();
464 omp_get_num_places_ (void)
466 return omp_get_num_places ();
470 omp_get_place_num_procs_ (const int32_t *place_num
)
472 return omp_get_place_num_procs (*place_num
);
476 omp_get_place_num_procs_8_ (const int64_t *place_num
)
478 return omp_get_place_num_procs (TO_INT (*place_num
));
482 omp_get_place_proc_ids_ (const int32_t *place_num
, int32_t *ids
)
484 omp_get_place_proc_ids (*place_num
, (int *) ids
);
488 omp_get_place_proc_ids_8_ (const int64_t *place_num
, int64_t *ids
)
490 gomp_get_place_proc_ids_8 (TO_INT (*place_num
), ids
);
494 omp_get_place_num_ (void)
496 return omp_get_place_num ();
500 omp_get_partition_num_places_ (void)
502 return omp_get_partition_num_places ();
506 omp_get_partition_place_nums_ (int32_t *place_nums
)
508 omp_get_partition_place_nums ((int *) place_nums
);
512 omp_get_partition_place_nums_8_ (int64_t *place_nums
)
514 if (gomp_places_list
== NULL
)
517 struct gomp_thread
*thr
= gomp_thread ();
519 gomp_init_affinity ();
522 for (i
= 0; i
< thr
->ts
.place_partition_len
; i
++)
523 *place_nums
++ = (int64_t) thr
->ts
.place_partition_off
+ i
;
527 omp_set_default_device_ (const int32_t *device_num
)
529 return omp_set_default_device (*device_num
);
533 omp_set_default_device_8_ (const int64_t *device_num
)
535 return omp_set_default_device (TO_INT (*device_num
));
539 omp_get_default_device_ (void)
541 return omp_get_default_device ();
545 omp_get_num_devices_ (void)
547 return omp_get_num_devices ();
551 omp_get_num_teams_ (void)
553 return omp_get_num_teams ();
557 omp_get_team_num_ (void)
559 return omp_get_team_num ();
563 omp_is_initial_device_ (void)
565 return omp_is_initial_device ();
569 omp_get_initial_device_ (void)
571 return omp_get_initial_device ();
575 omp_get_max_task_priority_ (void)
577 return omp_get_max_task_priority ();