-
Notifications
You must be signed in to change notification settings - Fork 0
/
icv.c
368 lines (315 loc) · 7.11 KB
/
icv.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
/* Copyright (C) 2005-2017 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>.
This file is part of the GNU Offloading and Multi Processing Library
(libgomp).
Libgomp is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* This file defines the OpenMP API entry points that operate on internal
control variables. */
#include "libgomp.h"
#include "gomp-constants.h"
#include <limits.h>
void
omp_set_num_threads (int n)
{
struct gomp_task_icv *icv = gomp_icv (true);
icv->nthreads_var = (n > 0 ? n : 1);
}
void
omp_set_dynamic (int val)
{
struct gomp_task_icv *icv = gomp_icv (true);
icv->dyn_var = val;
}
int
omp_get_dynamic (void)
{
struct gomp_task_icv *icv = gomp_icv (false);
return icv->dyn_var;
}
void
omp_set_work_first_sched (int val)
{
struct gomp_task_icv *icv = gomp_icv (true);
icv->wf_sched_var = val;
}
int
omp_get_work_first_sched (void)
{
struct gomp_task_icv *icv = gomp_icv (false);
return icv->wf_sched_var;
}
void
omp_set_untied_block (int val)
{
struct gomp_task_icv *icv = gomp_icv (true);
icv->untied_block_var = val;
}
int
omp_get_untied_block (void)
{
struct gomp_task_icv *icv = gomp_icv (false);
return icv->untied_block_var;
}
void
omp_set_ult_threads (int val)
{
struct gomp_task_icv *icv = gomp_icv (true);
icv->ult_var = val;
}
int
omp_get_ult_threads (void)
{
struct gomp_task_icv *icv = gomp_icv (false);
return icv->ult_var;
}
void
omp_set_ult_stack (unsigned long val)
{
struct gomp_task_icv *icv = gomp_icv (true);
icv->ult_stack_size = (val > ULT_STACK_SIZE ? val : ULT_STACK_SIZE);
}
unsigned long
omp_get_ult_stack (void)
{
struct gomp_task_icv *icv = gomp_icv (false);
return icv->ult_stack_size;
}
#if defined HAVE_TLS || defined USE_EMUTLS
void
omp_set_text_section_addresses(void *start, void *end)
{
struct gomp_task_icv *icv = gomp_icv (true);
icv->text_section_start = start;
icv->text_section_end = end;
}
#endif
void
omp_set_nested (int val)
{
struct gomp_task_icv *icv = gomp_icv (true);
icv->nest_var = val;
}
int
omp_get_nested (void)
{
struct gomp_task_icv *icv = gomp_icv (false);
return icv->nest_var;
}
void
omp_set_schedule (omp_sched_t kind, int chunk_size)
{
struct gomp_task_icv *icv = gomp_icv (true);
switch (kind)
{
case omp_sched_static:
if (chunk_size < 1)
chunk_size = 0;
icv->run_sched_chunk_size = chunk_size;
break;
case omp_sched_dynamic:
case omp_sched_guided:
if (chunk_size < 1)
chunk_size = 1;
icv->run_sched_chunk_size = chunk_size;
break;
case omp_sched_auto:
break;
default:
return;
}
icv->run_sched_var = kind;
}
void
omp_get_schedule (omp_sched_t *kind, int *chunk_size)
{
struct gomp_task_icv *icv = gomp_icv (false);
*kind = icv->run_sched_var;
*chunk_size = icv->run_sched_chunk_size;
}
int
omp_get_max_threads (void)
{
struct gomp_task_icv *icv = gomp_icv (false);
return icv->nthreads_var;
}
int
omp_get_thread_limit (void)
{
struct gomp_task_icv *icv = gomp_icv (false);
return icv->thread_limit_var > INT_MAX ? INT_MAX : icv->thread_limit_var;
}
void
omp_set_max_active_levels (int max_levels)
{
if (max_levels >= 0)
gomp_max_active_levels_var = max_levels;
}
int
omp_get_max_active_levels (void)
{
return gomp_max_active_levels_var;
}
int
omp_get_cancellation (void)
{
return gomp_cancel_var;
}
int
omp_get_autocutoff (void)
{
return gomp_auto_cutoff_var;
}
int
omp_get_signal_unblock (void)
{
return gomp_signal_unblock;
}
int
omp_get_ipi (void)
{
return gomp_ipi_var;
}
double
omp_get_ipi_decision_model (void)
{
return gomp_ipi_decision_model;
}
void
omp_set_ipi_priority_gap (unsigned long val)
{
gomp_ipi_priority_gap = val;
}
int
omp_get_ipi_priority_gap (void)
{
return gomp_ipi_priority_gap;
}
void
omp_set_ipi_sending_cap (unsigned long val)
{
gomp_ipi_sending_cap = val;
}
int
omp_get_ipi_sending_cap (void)
{
return gomp_ipi_sending_cap;
}
int
omp_get_ibs_rate (void)
{
return gomp_ibs_rate_var;
}
void
omp_set_queue_policy (unsigned long val)
{
gomp_queue_policy_var = val;
}
int
omp_get_queue_policy (void)
{
return gomp_queue_policy_var;
}
int
omp_get_max_task_priority (void)
{
return gomp_max_task_priority_var;
}
omp_proc_bind_t
omp_get_proc_bind (void)
{
struct gomp_task_icv *icv = gomp_icv (false);
return icv->bind_var;
}
int
omp_get_initial_device (void)
{
return GOMP_DEVICE_HOST_FALLBACK;
}
int
omp_get_num_places (void)
{
return gomp_places_list_len;
}
int
omp_get_place_num (void)
{
if (gomp_places_list == NULL)
return -1;
struct gomp_thread *thr = gomp_thread ();
if (thr->place == 0)
gomp_init_affinity ();
return (int) thr->place - 1;
}
int
omp_get_partition_num_places (void)
{
if (gomp_places_list == NULL)
return 0;
struct gomp_thread *thr = gomp_thread ();
if (thr->place == 0)
gomp_init_affinity ();
return thr->ts.place_partition_len;
}
void
omp_get_partition_place_nums (int *place_nums)
{
if (gomp_places_list == NULL)
return;
struct gomp_thread *thr = gomp_thread ();
if (thr->place == 0)
gomp_init_affinity ();
unsigned int i;
for (i = 0; i < thr->ts.place_partition_len; i++)
*place_nums++ = thr->ts.place_partition_off + i;
}
ialias (omp_set_dynamic)
ialias (omp_set_nested)
ialias (omp_set_work_first_sched)
ialias (omp_get_work_first_sched)
ialias (omp_set_ult_threads)
ialias (omp_set_ult_stack)
ialias (omp_set_text_section_addresses)
ialias (omp_set_num_threads)
ialias (omp_get_dynamic)
ialias (omp_get_nested)
ialias (omp_get_ult_threads)
ialias (omp_get_ult_stack)
ialias (omp_set_schedule)
ialias (omp_get_schedule)
ialias (omp_get_max_threads)
ialias (omp_get_thread_limit)
ialias (omp_set_max_active_levels)
ialias (omp_get_max_active_levels)
ialias (omp_get_cancellation)
ialias (omp_get_autocutoff)
ialias (omp_get_ipi)
ialias (omp_get_ipi_decision_model)
ialias (omp_get_signal_unblock)
ialias (omp_set_ipi_priority_gap)
ialias (omp_get_ipi_priority_gap)
ialias (omp_set_ipi_sending_cap)
ialias (omp_get_ipi_sending_cap)
ialias (omp_get_ibs_rate)
ialias (omp_set_queue_policy)
ialias (omp_get_queue_policy)
ialias (omp_get_proc_bind)
ialias (omp_get_initial_device)
ialias (omp_get_max_task_priority)
ialias (omp_get_num_places)
ialias (omp_get_place_num)
ialias (omp_get_partition_num_places)
ialias (omp_get_partition_place_nums)