1 /* Copyright (C) 2005-2017 Free Software Foundation, Inc.
2 Contributed by Richard Henderson <rth@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 defines the OpenMP API entry points that operate on internal
30 #include "gomp-constants.h"
34 omp_set_num_threads (int n
)
36 struct gomp_task_icv
*icv
= gomp_icv (true);
37 icv
->nthreads_var
= (n
> 0 ? n
: 1);
41 omp_set_dynamic (int val
)
43 struct gomp_task_icv
*icv
= gomp_icv (true);
48 omp_get_dynamic (void)
50 struct gomp_task_icv
*icv
= gomp_icv (false);
55 omp_set_nested (int val
)
57 struct gomp_task_icv
*icv
= gomp_icv (true);
64 struct gomp_task_icv
*icv
= gomp_icv (false);
69 omp_set_schedule (omp_sched_t kind
, int chunk_size
)
71 struct gomp_task_icv
*icv
= gomp_icv (true);
74 case omp_sched_static
:
77 icv
->run_sched_chunk_size
= chunk_size
;
79 case omp_sched_dynamic
:
80 case omp_sched_guided
:
83 icv
->run_sched_chunk_size
= chunk_size
;
90 icv
->run_sched_var
= kind
;
94 omp_get_schedule (omp_sched_t
*kind
, int *chunk_size
)
96 struct gomp_task_icv
*icv
= gomp_icv (false);
97 *kind
= icv
->run_sched_var
;
98 *chunk_size
= icv
->run_sched_chunk_size
;
102 omp_get_max_threads (void)
104 struct gomp_task_icv
*icv
= gomp_icv (false);
105 return icv
->nthreads_var
;
109 omp_get_thread_limit (void)
111 struct gomp_task_icv
*icv
= gomp_icv (false);
112 return icv
->thread_limit_var
> INT_MAX
? INT_MAX
: icv
->thread_limit_var
;
116 omp_set_max_active_levels (int max_levels
)
119 gomp_max_active_levels_var
= max_levels
;
123 omp_get_max_active_levels (void)
125 return gomp_max_active_levels_var
;
129 omp_get_cancellation (void)
131 return gomp_cancel_var
;
135 omp_get_max_task_priority (void)
137 return gomp_max_task_priority_var
;
141 omp_get_proc_bind (void)
143 struct gomp_task_icv
*icv
= gomp_icv (false);
144 return icv
->bind_var
;
148 omp_get_initial_device (void)
150 return GOMP_DEVICE_HOST_FALLBACK
;
154 omp_get_num_places (void)
156 return gomp_places_list_len
;
160 omp_get_place_num (void)
162 if (gomp_places_list
== NULL
)
165 struct gomp_thread
*thr
= gomp_thread ();
167 gomp_init_affinity ();
169 return (int) thr
->place
- 1;
173 omp_get_partition_num_places (void)
175 if (gomp_places_list
== NULL
)
178 struct gomp_thread
*thr
= gomp_thread ();
180 gomp_init_affinity ();
182 return thr
->ts
.place_partition_len
;
186 omp_get_partition_place_nums (int *place_nums
)
188 if (gomp_places_list
== NULL
)
191 struct gomp_thread
*thr
= gomp_thread ();
193 gomp_init_affinity ();
196 for (i
= 0; i
< thr
->ts
.place_partition_len
; i
++)
197 *place_nums
++ = thr
->ts
.place_partition_off
+ i
;
200 ialias (omp_set_dynamic
)
201 ialias (omp_set_nested
)
202 ialias (omp_set_num_threads
)
203 ialias (omp_get_dynamic
)
204 ialias (omp_get_nested
)
205 ialias (omp_set_schedule
)
206 ialias (omp_get_schedule
)
207 ialias (omp_get_max_threads
)
208 ialias (omp_get_thread_limit
)
209 ialias (omp_set_max_active_levels
)
210 ialias (omp_get_max_active_levels
)
211 ialias (omp_get_cancellation
)
212 ialias (omp_get_proc_bind
)
213 ialias (omp_get_initial_device
)
214 ialias (omp_get_max_task_priority
)
215 ialias (omp_get_num_places
)
216 ialias (omp_get_place_num
)
217 ialias (omp_get_partition_num_places
)
218 ialias (omp_get_partition_place_nums
)