blob: 80db92d367900fa2c21ca16ac3137a7c85dbe962 [file] [log] [blame]
Jim Cownie5e8470a2013-09-27 10:38:44 +00001/*
2 * kmp_ftn_entry.h -- Fortran entry linkage support for OpenMP.
Jim Cownie5e8470a2013-09-27 10:38:44 +00003 */
4
Jim Cownie5e8470a2013-09-27 10:38:44 +00005//===----------------------------------------------------------------------===//
6//
7// The LLVM Compiler Infrastructure
8//
9// This file is dual licensed under the MIT and the University of Illinois Open
10// Source Licenses. See LICENSE.txt for details.
11//
12//===----------------------------------------------------------------------===//
13
Jim Cownie5e8470a2013-09-27 10:38:44 +000014#ifndef FTN_STDCALL
Jonathan Peyton30419822017-05-12 18:01:32 +000015#error The support file kmp_ftn_entry.h should not be compiled by itself.
Jim Cownie5e8470a2013-09-27 10:38:44 +000016#endif
17
18#ifdef KMP_STUB
Jonathan Peyton30419822017-05-12 18:01:32 +000019#include "kmp_stub.h"
Jim Cownie5e8470a2013-09-27 10:38:44 +000020#endif
21
22#include "kmp_i18n.h"
23
Joachim Protze82e94a52017-11-01 10:08:30 +000024#if OMPT_SUPPORT
25#include "ompt-specific.h"
26#endif
27
Jim Cownie5e8470a2013-09-27 10:38:44 +000028#ifdef __cplusplus
Jonathan Peyton30419822017-05-12 18:01:32 +000029extern "C" {
Jim Cownie5e8470a2013-09-27 10:38:44 +000030#endif // __cplusplus
31
Jonathan Peyton30419822017-05-12 18:01:32 +000032/* For compatibility with the Gnu/MS Open MP codegen, omp_set_num_threads(),
Jim Cownie5e8470a2013-09-27 10:38:44 +000033 * omp_set_nested(), and omp_set_dynamic() [in lowercase on MS, and w/o
34 * a trailing underscore on Linux* OS] take call by value integer arguments.
35 * + omp_set_max_active_levels()
36 * + omp_set_schedule()
37 *
Alp Toker8f2d3f02014-02-24 10:40:15 +000038 * For backward compatibility with 9.1 and previous Intel compiler, these
Jonathan Peyton30419822017-05-12 18:01:32 +000039 * entry points take call by reference integer arguments. */
Jim Cownie5e8470a2013-09-27 10:38:44 +000040#ifdef KMP_GOMP_COMPAT
Jonathan Peyton30419822017-05-12 18:01:32 +000041#if (KMP_FTN_ENTRIES == KMP_FTN_PLAIN) || (KMP_FTN_ENTRIES == KMP_FTN_UPPER)
42#define PASS_ARGS_BY_VALUE 1
43#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +000044#endif
45#if KMP_OS_WINDOWS
Jonathan Peyton30419822017-05-12 18:01:32 +000046#if (KMP_FTN_ENTRIES == KMP_FTN_PLAIN) || (KMP_FTN_ENTRIES == KMP_FTN_APPEND)
47#define PASS_ARGS_BY_VALUE 1
48#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +000049#endif
50
51// This macro helps to reduce code duplication.
52#ifdef PASS_ARGS_BY_VALUE
Jonathan Peyton30419822017-05-12 18:01:32 +000053#define KMP_DEREF
Jim Cownie5e8470a2013-09-27 10:38:44 +000054#else
Jonathan Peyton30419822017-05-12 18:01:32 +000055#define KMP_DEREF *
Jim Cownie5e8470a2013-09-27 10:38:44 +000056#endif
57
Jonathan Peyton30419822017-05-12 18:01:32 +000058void FTN_STDCALL FTN_SET_STACKSIZE(int KMP_DEREF arg) {
59#ifdef KMP_STUB
60 __kmps_set_stacksize(KMP_DEREF arg);
61#else
62 // __kmp_aux_set_stacksize initializes the library if needed
63 __kmp_aux_set_stacksize((size_t)KMP_DEREF arg);
64#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +000065}
66
Jonathan Peyton30419822017-05-12 18:01:32 +000067void FTN_STDCALL FTN_SET_STACKSIZE_S(size_t KMP_DEREF arg) {
68#ifdef KMP_STUB
69 __kmps_set_stacksize(KMP_DEREF arg);
70#else
71 // __kmp_aux_set_stacksize initializes the library if needed
72 __kmp_aux_set_stacksize(KMP_DEREF arg);
73#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +000074}
75
Jonathan Peyton30419822017-05-12 18:01:32 +000076int FTN_STDCALL FTN_GET_STACKSIZE(void) {
77#ifdef KMP_STUB
78 return __kmps_get_stacksize();
79#else
80 if (!__kmp_init_serial) {
81 __kmp_serial_initialize();
Jonathan Peytonbd3a7632017-09-27 20:36:27 +000082 }
Jonathan Peyton30419822017-05-12 18:01:32 +000083 return (int)__kmp_stksize;
84#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +000085}
86
Jonathan Peyton30419822017-05-12 18:01:32 +000087size_t FTN_STDCALL FTN_GET_STACKSIZE_S(void) {
88#ifdef KMP_STUB
89 return __kmps_get_stacksize();
90#else
91 if (!__kmp_init_serial) {
92 __kmp_serial_initialize();
Jonathan Peytonbd3a7632017-09-27 20:36:27 +000093 }
Jonathan Peyton30419822017-05-12 18:01:32 +000094 return __kmp_stksize;
95#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +000096}
97
Jonathan Peyton30419822017-05-12 18:01:32 +000098void FTN_STDCALL FTN_SET_BLOCKTIME(int KMP_DEREF arg) {
99#ifdef KMP_STUB
100 __kmps_set_blocktime(KMP_DEREF arg);
101#else
102 int gtid, tid;
103 kmp_info_t *thread;
Jim Cownie5e8470a2013-09-27 10:38:44 +0000104
Jonathan Peyton30419822017-05-12 18:01:32 +0000105 gtid = __kmp_entry_gtid();
106 tid = __kmp_tid_from_gtid(gtid);
107 thread = __kmp_thread_from_gtid(gtid);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000108
Jonathan Peyton30419822017-05-12 18:01:32 +0000109 __kmp_aux_set_blocktime(KMP_DEREF arg, thread, tid);
110#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000111}
112
Jonathan Peyton30419822017-05-12 18:01:32 +0000113int FTN_STDCALL FTN_GET_BLOCKTIME(void) {
114#ifdef KMP_STUB
115 return __kmps_get_blocktime();
116#else
117 int gtid, tid;
118 kmp_info_t *thread;
119 kmp_team_p *team;
Jim Cownie5e8470a2013-09-27 10:38:44 +0000120
Jonathan Peyton30419822017-05-12 18:01:32 +0000121 gtid = __kmp_entry_gtid();
122 tid = __kmp_tid_from_gtid(gtid);
123 thread = __kmp_thread_from_gtid(gtid);
124 team = __kmp_threads[gtid]->th.th_team;
Jim Cownie5e8470a2013-09-27 10:38:44 +0000125
Jonathan Peyton30419822017-05-12 18:01:32 +0000126 /* These must match the settings used in __kmp_wait_sleep() */
127 if (__kmp_dflt_blocktime == KMP_MAX_BLOCKTIME) {
128 KF_TRACE(10, ("kmp_get_blocktime: T#%d(%d:%d), blocktime=%d\n", gtid,
129 team->t.t_id, tid, KMP_MAX_BLOCKTIME));
130 return KMP_MAX_BLOCKTIME;
131 }
Jim Cownie5e8470a2013-09-27 10:38:44 +0000132#ifdef KMP_ADJUST_BLOCKTIME
Jonathan Peyton30419822017-05-12 18:01:32 +0000133 else if (__kmp_zero_bt && !get__bt_set(team, tid)) {
134 KF_TRACE(10, ("kmp_get_blocktime: T#%d(%d:%d), blocktime=%d\n", gtid,
135 team->t.t_id, tid, 0));
136 return 0;
137 }
Jim Cownie5e8470a2013-09-27 10:38:44 +0000138#endif /* KMP_ADJUST_BLOCKTIME */
Jonathan Peyton30419822017-05-12 18:01:32 +0000139 else {
140 KF_TRACE(10, ("kmp_get_blocktime: T#%d(%d:%d), blocktime=%d\n", gtid,
141 team->t.t_id, tid, get__blocktime(team, tid)));
142 return get__blocktime(team, tid);
Jonathan Peytonbd3a7632017-09-27 20:36:27 +0000143 }
Jonathan Peyton30419822017-05-12 18:01:32 +0000144#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000145}
146
Jonathan Peyton30419822017-05-12 18:01:32 +0000147void FTN_STDCALL FTN_SET_LIBRARY_SERIAL(void) {
148#ifdef KMP_STUB
149 __kmps_set_library(library_serial);
150#else
151 // __kmp_user_set_library initializes the library if needed
152 __kmp_user_set_library(library_serial);
153#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000154}
155
Jonathan Peyton30419822017-05-12 18:01:32 +0000156void FTN_STDCALL FTN_SET_LIBRARY_TURNAROUND(void) {
157#ifdef KMP_STUB
158 __kmps_set_library(library_turnaround);
159#else
160 // __kmp_user_set_library initializes the library if needed
161 __kmp_user_set_library(library_turnaround);
162#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000163}
164
Jonathan Peyton30419822017-05-12 18:01:32 +0000165void FTN_STDCALL FTN_SET_LIBRARY_THROUGHPUT(void) {
166#ifdef KMP_STUB
167 __kmps_set_library(library_throughput);
168#else
169 // __kmp_user_set_library initializes the library if needed
170 __kmp_user_set_library(library_throughput);
171#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000172}
173
Jonathan Peyton30419822017-05-12 18:01:32 +0000174void FTN_STDCALL FTN_SET_LIBRARY(int KMP_DEREF arg) {
175#ifdef KMP_STUB
176 __kmps_set_library(KMP_DEREF arg);
177#else
178 enum library_type lib;
179 lib = (enum library_type)KMP_DEREF arg;
180 // __kmp_user_set_library initializes the library if needed
181 __kmp_user_set_library(lib);
182#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000183}
184
Jonathan Peyton30419822017-05-12 18:01:32 +0000185int FTN_STDCALL FTN_GET_LIBRARY(void) {
186#ifdef KMP_STUB
187 return __kmps_get_library();
188#else
189 if (!__kmp_init_serial) {
190 __kmp_serial_initialize();
191 }
192 return ((int)__kmp_library);
193#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000194}
195
Jonathan Peyton30419822017-05-12 18:01:32 +0000196void FTN_STDCALL FTN_SET_DISP_NUM_BUFFERS(int KMP_DEREF arg) {
197#ifdef KMP_STUB
198 ; // empty routine
199#else
200 // ignore after initialization because some teams have already
201 // allocated dispatch buffers
202 if (__kmp_init_serial == 0 && (KMP_DEREF arg) > 0)
203 __kmp_dispatch_num_buffers = KMP_DEREF arg;
204#endif
Jonathan Peyton067325f2016-05-31 19:01:15 +0000205}
206
Jonathan Peyton30419822017-05-12 18:01:32 +0000207int FTN_STDCALL FTN_SET_AFFINITY(void **mask) {
208#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
209 return -1;
210#else
211 if (!TCR_4(__kmp_init_middle)) {
212 __kmp_middle_initialize();
213 }
214 return __kmp_aux_set_affinity(mask);
215#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000216}
217
Jonathan Peyton30419822017-05-12 18:01:32 +0000218int FTN_STDCALL FTN_GET_AFFINITY(void **mask) {
219#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
220 return -1;
221#else
222 if (!TCR_4(__kmp_init_middle)) {
223 __kmp_middle_initialize();
224 }
225 return __kmp_aux_get_affinity(mask);
226#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000227}
228
Jonathan Peyton30419822017-05-12 18:01:32 +0000229int FTN_STDCALL FTN_GET_AFFINITY_MAX_PROC(void) {
230#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
231 return 0;
232#else
233 // We really only NEED serial initialization here.
234 if (!TCR_4(__kmp_init_middle)) {
235 __kmp_middle_initialize();
236 }
237 return __kmp_aux_get_affinity_max_proc();
238#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000239}
240
Jonathan Peyton30419822017-05-12 18:01:32 +0000241void FTN_STDCALL FTN_CREATE_AFFINITY_MASK(void **mask) {
242#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
243 *mask = NULL;
244#else
245 // We really only NEED serial initialization here.
246 kmp_affin_mask_t *mask_internals;
247 if (!TCR_4(__kmp_init_middle)) {
248 __kmp_middle_initialize();
249 }
250 mask_internals = __kmp_affinity_dispatch->allocate_mask();
251 KMP_CPU_ZERO(mask_internals);
252 *mask = mask_internals;
253#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000254}
255
Jonathan Peyton30419822017-05-12 18:01:32 +0000256void FTN_STDCALL FTN_DESTROY_AFFINITY_MASK(void **mask) {
257#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
258// Nothing
259#else
260 // We really only NEED serial initialization here.
261 kmp_affin_mask_t *mask_internals;
262 if (!TCR_4(__kmp_init_middle)) {
263 __kmp_middle_initialize();
264 }
265 if (__kmp_env_consistency_check) {
266 if (*mask == NULL) {
267 KMP_FATAL(AffinityInvalidMask, "kmp_destroy_affinity_mask");
268 }
269 }
270 mask_internals = (kmp_affin_mask_t *)(*mask);
271 __kmp_affinity_dispatch->deallocate_mask(mask_internals);
272 *mask = NULL;
273#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000274}
275
Jonathan Peyton30419822017-05-12 18:01:32 +0000276int FTN_STDCALL FTN_SET_AFFINITY_MASK_PROC(int KMP_DEREF proc, void **mask) {
277#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
278 return -1;
279#else
280 if (!TCR_4(__kmp_init_middle)) {
281 __kmp_middle_initialize();
282 }
283 return __kmp_aux_set_affinity_mask_proc(KMP_DEREF proc, mask);
284#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000285}
286
Jonathan Peyton30419822017-05-12 18:01:32 +0000287int FTN_STDCALL FTN_UNSET_AFFINITY_MASK_PROC(int KMP_DEREF proc, void **mask) {
288#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
289 return -1;
290#else
291 if (!TCR_4(__kmp_init_middle)) {
292 __kmp_middle_initialize();
293 }
294 return __kmp_aux_unset_affinity_mask_proc(KMP_DEREF proc, mask);
295#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000296}
297
Jonathan Peyton30419822017-05-12 18:01:32 +0000298int FTN_STDCALL FTN_GET_AFFINITY_MASK_PROC(int KMP_DEREF proc, void **mask) {
299#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
300 return -1;
301#else
302 if (!TCR_4(__kmp_init_middle)) {
303 __kmp_middle_initialize();
304 }
305 return __kmp_aux_get_affinity_mask_proc(KMP_DEREF proc, mask);
306#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000307}
308
Jim Cownie5e8470a2013-09-27 10:38:44 +0000309/* ------------------------------------------------------------------------ */
310
311/* sets the requested number of threads for the next parallel region */
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000312void FTN_STDCALL KMP_EXPAND_NAME(FTN_SET_NUM_THREADS)(int KMP_DEREF arg) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000313#ifdef KMP_STUB
314// Nothing.
315#else
316 __kmp_set_num_threads(KMP_DEREF arg, __kmp_entry_gtid());
317#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000318}
319
Jim Cownie5e8470a2013-09-27 10:38:44 +0000320/* returns the number of threads in current team */
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000321int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NUM_THREADS)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000322#ifdef KMP_STUB
323 return 1;
324#else
325 // __kmpc_bound_num_threads initializes the library if needed
326 return __kmpc_bound_num_threads(NULL);
327#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000328}
329
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000330int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_MAX_THREADS)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000331#ifdef KMP_STUB
332 return 1;
333#else
334 int gtid;
335 kmp_info_t *thread;
336 if (!TCR_4(__kmp_init_middle)) {
337 __kmp_middle_initialize();
338 }
339 gtid = __kmp_entry_gtid();
340 thread = __kmp_threads[gtid];
341 // return thread -> th.th_team -> t.t_current_task[
342 // thread->th.th_info.ds.ds_tid ] -> icvs.nproc;
343 return thread->th.th_current_task->td_icvs.nproc;
344#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000345}
346
Joachim Protze82e94a52017-11-01 10:08:30 +0000347#if OMP_50_ENABLED
Joachim Protzeb0e4f872018-02-17 09:54:10 +0000348int FTN_STDCALL FTN_CONTROL_TOOL(int command, int modifier, void *arg) {
Joachim Protze82e94a52017-11-01 10:08:30 +0000349#if defined(KMP_STUB) || !OMPT_SUPPORT
350 return -2;
351#else
352 OMPT_STORE_RETURN_ADDRESS(__kmp_entry_gtid());
353 if (!TCR_4(__kmp_init_middle)) {
354 return -2;
355 }
356 kmp_info_t *this_thr = __kmp_threads[__kmp_entry_gtid()];
357 ompt_task_info_t *parent_task_info = OMPT_CUR_TASK_INFO(this_thr);
Joachim Protzec255ca72017-11-05 14:11:10 +0000358 parent_task_info->frame.enter_frame = OMPT_GET_FRAME_ADDRESS(1);
Joachim Protze82e94a52017-11-01 10:08:30 +0000359 int ret = __kmp_control_tool(command, modifier, arg);
Joachim Protzec255ca72017-11-05 14:11:10 +0000360 parent_task_info->frame.enter_frame = 0;
Joachim Protze82e94a52017-11-01 10:08:30 +0000361 return ret;
362#endif
363}
364#endif
365
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000366int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_THREAD_NUM)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000367#ifdef KMP_STUB
368 return 0;
369#else
370 int gtid;
Jim Cownie5e8470a2013-09-27 10:38:44 +0000371
Jonathan Peyton30419822017-05-12 18:01:32 +0000372#if KMP_OS_DARWIN || KMP_OS_FREEBSD || KMP_OS_NETBSD
373 gtid = __kmp_entry_gtid();
374#elif KMP_OS_WINDOWS
375 if (!__kmp_init_parallel ||
376 (gtid = (int)((kmp_intptr_t)TlsGetValue(__kmp_gtid_threadprivate_key))) ==
377 0) {
378 // Either library isn't initialized or thread is not registered
379 // 0 is the correct TID in this case
380 return 0;
381 }
382 --gtid; // We keep (gtid+1) in TLS
383#elif KMP_OS_LINUX
384#ifdef KMP_TDATA_GTID
385 if (__kmp_gtid_mode >= 3) {
386 if ((gtid = __kmp_gtid) == KMP_GTID_DNE) {
387 return 0;
388 }
389 } else {
390#endif
391 if (!__kmp_init_parallel ||
392 (gtid = (kmp_intptr_t)(
393 pthread_getspecific(__kmp_gtid_threadprivate_key))) == 0) {
394 return 0;
395 }
396 --gtid;
397#ifdef KMP_TDATA_GTID
398 }
399#endif
400#else
401#error Unknown or unsupported OS
402#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000403
Jonathan Peyton30419822017-05-12 18:01:32 +0000404 return __kmp_tid_from_gtid(gtid);
405#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000406}
407
Jonathan Peyton30419822017-05-12 18:01:32 +0000408int FTN_STDCALL FTN_GET_NUM_KNOWN_THREADS(void) {
409#ifdef KMP_STUB
410 return 1;
411#else
412 if (!__kmp_init_serial) {
413 __kmp_serial_initialize();
414 }
415 /* NOTE: this is not syncronized, so it can change at any moment */
416 /* NOTE: this number also includes threads preallocated in hot-teams */
417 return TCR_4(__kmp_nth);
418#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000419}
420
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000421int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NUM_PROCS)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000422#ifdef KMP_STUB
423 return 1;
424#else
425 if (!TCR_4(__kmp_init_middle)) {
426 __kmp_middle_initialize();
427 }
428 return __kmp_avail_proc;
429#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000430}
431
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000432void FTN_STDCALL KMP_EXPAND_NAME(FTN_SET_NESTED)(int KMP_DEREF flag) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000433#ifdef KMP_STUB
434 __kmps_set_nested(KMP_DEREF flag);
435#else
436 kmp_info_t *thread;
437 /* For the thread-private internal controls implementation */
438 thread = __kmp_entry_thread();
439 __kmp_save_internal_controls(thread);
440 set__nested(thread, ((KMP_DEREF flag) ? TRUE : FALSE));
441#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000442}
443
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000444int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NESTED)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000445#ifdef KMP_STUB
446 return __kmps_get_nested();
447#else
448 kmp_info_t *thread;
449 thread = __kmp_entry_thread();
450 return get__nested(thread);
451#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000452}
453
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000454void FTN_STDCALL KMP_EXPAND_NAME(FTN_SET_DYNAMIC)(int KMP_DEREF flag) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000455#ifdef KMP_STUB
456 __kmps_set_dynamic(KMP_DEREF flag ? TRUE : FALSE);
457#else
458 kmp_info_t *thread;
459 /* For the thread-private implementation of the internal controls */
460 thread = __kmp_entry_thread();
461 // !!! What if foreign thread calls it?
462 __kmp_save_internal_controls(thread);
463 set__dynamic(thread, KMP_DEREF flag ? TRUE : FALSE);
464#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000465}
466
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000467int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_DYNAMIC)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000468#ifdef KMP_STUB
469 return __kmps_get_dynamic();
470#else
471 kmp_info_t *thread;
472 thread = __kmp_entry_thread();
473 return get__dynamic(thread);
474#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000475}
476
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000477int FTN_STDCALL KMP_EXPAND_NAME(FTN_IN_PARALLEL)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000478#ifdef KMP_STUB
479 return 0;
480#else
481 kmp_info_t *th = __kmp_entry_thread();
Jim Cownie5e8470a2013-09-27 10:38:44 +0000482#if OMP_40_ENABLED
Jonathan Peyton30419822017-05-12 18:01:32 +0000483 if (th->th.th_teams_microtask) {
484 // AC: r_in_parallel does not work inside teams construct where real
485 // parallel is inactive, but all threads have same root, so setting it in
486 // one team affects other teams.
487 // The solution is to use per-team nesting level
488 return (th->th.th_team->t.t_active_level ? 1 : 0);
489 } else
Jim Cownie5e8470a2013-09-27 10:38:44 +0000490#endif /* OMP_40_ENABLED */
Jonathan Peyton30419822017-05-12 18:01:32 +0000491 return (th->th.th_root->r.r_in_parallel ? FTN_TRUE : FTN_FALSE);
492#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000493}
494
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000495void FTN_STDCALL KMP_EXPAND_NAME(FTN_SET_SCHEDULE)(kmp_sched_t KMP_DEREF kind,
496 int KMP_DEREF modifier) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000497#ifdef KMP_STUB
498 __kmps_set_schedule(KMP_DEREF kind, KMP_DEREF modifier);
499#else
500 /* TO DO: For the per-task implementation of the internal controls */
501 __kmp_set_schedule(__kmp_entry_gtid(), KMP_DEREF kind, KMP_DEREF modifier);
502#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000503}
504
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000505void FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_SCHEDULE)(kmp_sched_t *kind,
506 int *modifier) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000507#ifdef KMP_STUB
508 __kmps_get_schedule(kind, modifier);
509#else
510 /* TO DO: For the per-task implementation of the internal controls */
511 __kmp_get_schedule(__kmp_entry_gtid(), kind, modifier);
512#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000513}
514
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000515void FTN_STDCALL KMP_EXPAND_NAME(FTN_SET_MAX_ACTIVE_LEVELS)(int KMP_DEREF arg) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000516#ifdef KMP_STUB
517// Nothing.
518#else
519 /* TO DO: We want per-task implementation of this internal control */
520 __kmp_set_max_active_levels(__kmp_entry_gtid(), KMP_DEREF arg);
521#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000522}
523
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000524int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_MAX_ACTIVE_LEVELS)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000525#ifdef KMP_STUB
526 return 0;
527#else
528 /* TO DO: We want per-task implementation of this internal control */
529 return __kmp_get_max_active_levels(__kmp_entry_gtid());
530#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000531}
532
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000533int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_ACTIVE_LEVEL)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000534#ifdef KMP_STUB
535 return 0; // returns 0 if it is called from the sequential part of the program
536#else
537 /* TO DO: For the per-task implementation of the internal controls */
538 return __kmp_entry_thread()->th.th_team->t.t_active_level;
539#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000540}
541
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000542int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_LEVEL)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000543#ifdef KMP_STUB
544 return 0; // returns 0 if it is called from the sequential part of the program
545#else
546 /* TO DO: For the per-task implementation of the internal controls */
547 return __kmp_entry_thread()->th.th_team->t.t_level;
548#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000549}
550
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000551int FTN_STDCALL
552 KMP_EXPAND_NAME(FTN_GET_ANCESTOR_THREAD_NUM)(int KMP_DEREF level) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000553#ifdef KMP_STUB
554 return (KMP_DEREF level) ? (-1) : (0);
555#else
556 return __kmp_get_ancestor_thread_num(__kmp_entry_gtid(), KMP_DEREF level);
557#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000558}
559
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000560int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_TEAM_SIZE)(int KMP_DEREF level) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000561#ifdef KMP_STUB
562 return (KMP_DEREF level) ? (-1) : (1);
563#else
564 return __kmp_get_team_size(__kmp_entry_gtid(), KMP_DEREF level);
565#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000566}
567
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000568int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_THREAD_LIMIT)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000569#ifdef KMP_STUB
570 return 1; // TO DO: clarify whether it returns 1 or 0?
571#else
572 if (!__kmp_init_serial) {
573 __kmp_serial_initialize();
Jonathan Peytonbd3a7632017-09-27 20:36:27 +0000574 }
Jonathan Peyton30419822017-05-12 18:01:32 +0000575 /* global ICV */
Jonathan Peytonf4392462017-07-27 20:58:41 +0000576 return __kmp_cg_max_nth;
Jonathan Peyton30419822017-05-12 18:01:32 +0000577#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000578}
579
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000580int FTN_STDCALL KMP_EXPAND_NAME(FTN_IN_FINAL)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000581#ifdef KMP_STUB
582 return 0; // TO DO: clarify whether it returns 1 or 0?
583#else
584 if (!TCR_4(__kmp_init_parallel)) {
585 return 0;
586 }
587 return __kmp_entry_thread()->th.th_current_task->td_flags.final;
588#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000589}
590
Jim Cownie5e8470a2013-09-27 10:38:44 +0000591#if OMP_40_ENABLED
592
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000593kmp_proc_bind_t FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_PROC_BIND)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000594#ifdef KMP_STUB
595 return __kmps_get_proc_bind();
596#else
597 return get__proc_bind(__kmp_entry_thread());
598#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000599}
600
Jonathan Peytondf6818b2016-06-14 17:57:47 +0000601#if OMP_45_ENABLED
Jonathan Peyton284fab12018-07-30 17:50:35 +0000602int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NUM_PLACES)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000603#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
604 return 0;
605#else
606 if (!TCR_4(__kmp_init_middle)) {
607 __kmp_middle_initialize();
608 }
609 if (!KMP_AFFINITY_CAPABLE())
610 return 0;
611 return __kmp_affinity_num_masks;
612#endif
Jonathan Peyton2f7c0772016-02-25 18:49:52 +0000613}
614
Jonathan Peyton284fab12018-07-30 17:50:35 +0000615int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_PLACE_NUM_PROCS)(int place_num) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000616#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
617 return 0;
618#else
619 int i;
620 int retval = 0;
621 if (!TCR_4(__kmp_init_middle)) {
622 __kmp_middle_initialize();
623 }
624 if (!KMP_AFFINITY_CAPABLE())
625 return 0;
626 if (place_num < 0 || place_num >= (int)__kmp_affinity_num_masks)
627 return 0;
628 kmp_affin_mask_t *mask = KMP_CPU_INDEX(__kmp_affinity_masks, place_num);
629 KMP_CPU_SET_ITERATE(i, mask) {
630 if ((!KMP_CPU_ISSET(i, __kmp_affin_fullMask)) ||
631 (!KMP_CPU_ISSET(i, mask))) {
632 continue;
633 }
634 ++retval;
635 }
636 return retval;
637#endif
Jonathan Peyton2f7c0772016-02-25 18:49:52 +0000638}
639
Jonathan Peyton284fab12018-07-30 17:50:35 +0000640void FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_PLACE_PROC_IDS)(int place_num,
641 int *ids) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000642#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
643// Nothing.
644#else
645 int i, j;
646 if (!TCR_4(__kmp_init_middle)) {
647 __kmp_middle_initialize();
648 }
649 if (!KMP_AFFINITY_CAPABLE())
650 return;
651 if (place_num < 0 || place_num >= (int)__kmp_affinity_num_masks)
652 return;
653 kmp_affin_mask_t *mask = KMP_CPU_INDEX(__kmp_affinity_masks, place_num);
654 j = 0;
655 KMP_CPU_SET_ITERATE(i, mask) {
656 if ((!KMP_CPU_ISSET(i, __kmp_affin_fullMask)) ||
657 (!KMP_CPU_ISSET(i, mask))) {
658 continue;
659 }
660 ids[j++] = i;
661 }
662#endif
Jonathan Peyton2f7c0772016-02-25 18:49:52 +0000663}
664
Jonathan Peyton284fab12018-07-30 17:50:35 +0000665int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_PLACE_NUM)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000666#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
667 return -1;
668#else
669 int gtid;
670 kmp_info_t *thread;
671 if (!TCR_4(__kmp_init_middle)) {
672 __kmp_middle_initialize();
673 }
674 if (!KMP_AFFINITY_CAPABLE())
675 return -1;
676 gtid = __kmp_entry_gtid();
677 thread = __kmp_thread_from_gtid(gtid);
678 if (thread->th.th_current_place < 0)
679 return -1;
680 return thread->th.th_current_place;
681#endif
Jonathan Peyton2f7c0772016-02-25 18:49:52 +0000682}
683
Jonathan Peyton284fab12018-07-30 17:50:35 +0000684int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_PARTITION_NUM_PLACES)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000685#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
686 return 0;
687#else
688 int gtid, num_places, first_place, last_place;
689 kmp_info_t *thread;
690 if (!TCR_4(__kmp_init_middle)) {
691 __kmp_middle_initialize();
692 }
693 if (!KMP_AFFINITY_CAPABLE())
694 return 0;
Jonathan Peyton1482db92018-04-18 19:25:48 +0000695 if (KMP_AFFINITY_NON_PROC_BIND) {
696 return 1;
697 }
Jonathan Peyton30419822017-05-12 18:01:32 +0000698 gtid = __kmp_entry_gtid();
699 thread = __kmp_thread_from_gtid(gtid);
700 first_place = thread->th.th_first_place;
701 last_place = thread->th.th_last_place;
702 if (first_place < 0 || last_place < 0)
703 return 0;
704 if (first_place <= last_place)
705 num_places = last_place - first_place + 1;
706 else
707 num_places = __kmp_affinity_num_masks - first_place + last_place + 1;
708 return num_places;
709#endif
Jonathan Peyton2f7c0772016-02-25 18:49:52 +0000710}
711
Jonathan Peyton284fab12018-07-30 17:50:35 +0000712void
713 FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_PARTITION_PLACE_NUMS)(int *place_nums) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000714#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
715// Nothing.
716#else
717 int i, gtid, place_num, first_place, last_place, start, end;
718 kmp_info_t *thread;
719 if (!TCR_4(__kmp_init_middle)) {
720 __kmp_middle_initialize();
721 }
722 if (!KMP_AFFINITY_CAPABLE())
723 return;
724 gtid = __kmp_entry_gtid();
725 thread = __kmp_thread_from_gtid(gtid);
Jonathan Peyton1482db92018-04-18 19:25:48 +0000726 if (KMP_AFFINITY_NON_PROC_BIND) {
727 place_nums[0] = thread->th.th_current_place;
728 return;
729 }
Jonathan Peyton30419822017-05-12 18:01:32 +0000730 first_place = thread->th.th_first_place;
731 last_place = thread->th.th_last_place;
732 if (first_place < 0 || last_place < 0)
733 return;
734 if (first_place <= last_place) {
735 start = first_place;
736 end = last_place;
737 } else {
738 start = last_place;
739 end = first_place;
740 }
741 for (i = 0, place_num = start; place_num <= end; ++place_num, ++i) {
742 place_nums[i] = place_num;
743 }
744#endif
Jonathan Peyton2f7c0772016-02-25 18:49:52 +0000745}
746#endif
747
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000748int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NUM_TEAMS)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000749#ifdef KMP_STUB
750 return 1;
751#else
752 kmp_info_t *thr = __kmp_entry_thread();
753 if (thr->th.th_teams_microtask) {
754 kmp_team_t *team = thr->th.th_team;
755 int tlevel = thr->th.th_teams_level;
756 int ii = team->t.t_level; // the level of the teams construct
757 int dd = team->t.t_serialized;
758 int level = tlevel + 1;
759 KMP_DEBUG_ASSERT(ii >= tlevel);
760 while (ii > level) {
761 for (dd = team->t.t_serialized; (dd > 0) && (ii > level); dd--, ii--) {
762 }
763 if (team->t.t_serialized && (!dd)) {
764 team = team->t.t_parent;
765 continue;
766 }
767 if (ii > level) {
768 team = team->t.t_parent;
769 ii--;
770 }
771 }
772 if (dd > 1) {
773 return 1; // teams region is serialized ( 1 team of 1 thread ).
774 } else {
775 return team->t.t_parent->t.t_nproc;
776 }
777 } else {
778 return 1;
779 }
780#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000781}
782
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000783int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_TEAM_NUM)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000784#ifdef KMP_STUB
785 return 0;
786#else
787 kmp_info_t *thr = __kmp_entry_thread();
788 if (thr->th.th_teams_microtask) {
789 kmp_team_t *team = thr->th.th_team;
790 int tlevel = thr->th.th_teams_level; // the level of the teams construct
791 int ii = team->t.t_level;
792 int dd = team->t.t_serialized;
793 int level = tlevel + 1;
794 KMP_DEBUG_ASSERT(ii >= tlevel);
795 while (ii > level) {
796 for (dd = team->t.t_serialized; (dd > 0) && (ii > level); dd--, ii--) {
797 }
798 if (team->t.t_serialized && (!dd)) {
799 team = team->t.t_parent;
800 continue;
801 }
802 if (ii > level) {
803 team = team->t.t_parent;
804 ii--;
805 }
806 }
807 if (dd > 1) {
808 return 0; // teams region is serialized ( 1 team of 1 thread ).
809 } else {
810 return team->t.t_master_tid;
811 }
812 } else {
813 return 0;
814 }
815#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000816}
817
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000818int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_DEFAULT_DEVICE)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000819#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
820 return 0;
821#else
822 return __kmp_entry_thread()->th.th_current_task->td_icvs.default_device;
823#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000824}
825
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000826void FTN_STDCALL KMP_EXPAND_NAME(FTN_SET_DEFAULT_DEVICE)(int KMP_DEREF arg) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000827#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
828// Nothing.
829#else
830 __kmp_entry_thread()->th.th_current_task->td_icvs.default_device =
831 KMP_DEREF arg;
832#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000833}
834
George Rokos28f31b42016-09-09 17:55:26 +0000835#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
836
Jonathan Peyton30419822017-05-12 18:01:32 +0000837int FTN_STDCALL FTN_GET_NUM_DEVICES(void) { return 0; }
Jim Cownie5e8470a2013-09-27 10:38:44 +0000838
Jonathan Peyton50eae7f2016-05-27 15:51:14 +0000839#endif // KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000840
Jonathan Peyton30419822017-05-12 18:01:32 +0000841#if !KMP_OS_LINUX
Andrey Churbanov851563f2015-02-10 19:47:09 +0000842
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000843int FTN_STDCALL KMP_EXPAND_NAME(FTN_IS_INITIAL_DEVICE)(void) { return 1; }
Andrey Churbanov851563f2015-02-10 19:47:09 +0000844
845#else
846
847// This internal function is used when the entry from the offload library
848// is not found.
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000849int _Offload_get_device_number(void) KMP_WEAK_ATTRIBUTE;
Andrey Churbanov851563f2015-02-10 19:47:09 +0000850
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000851int FTN_STDCALL KMP_EXPAND_NAME(FTN_IS_INITIAL_DEVICE)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000852 if (_Offload_get_device_number) {
853 return _Offload_get_device_number() == -1;
854 } else {
855 return 1;
856 }
Andrey Churbanov851563f2015-02-10 19:47:09 +0000857}
858
859#endif // ! KMP_OS_LINUX
860
Jim Cownie5e8470a2013-09-27 10:38:44 +0000861#endif // OMP_40_ENABLED
862
Jonathan Peytondf6818b2016-06-14 17:57:47 +0000863#if OMP_45_ENABLED && defined(KMP_STUB)
Jonathan Peyton50eae7f2016-05-27 15:51:14 +0000864// OpenMP 4.5 entries for stubs library
865
Jonathan Peyton30419822017-05-12 18:01:32 +0000866int FTN_STDCALL FTN_GET_INITIAL_DEVICE(void) { return -1; }
Jonathan Peyton50eae7f2016-05-27 15:51:14 +0000867
868// As all *target* functions are C-only parameters always passed by value
Jonathan Peyton30419822017-05-12 18:01:32 +0000869void *FTN_STDCALL FTN_TARGET_ALLOC(size_t size, int device_num) { return 0; }
870
871void FTN_STDCALL FTN_TARGET_FREE(void *device_ptr, int device_num) {}
872
873int FTN_STDCALL FTN_TARGET_IS_PRESENT(void *ptr, int device_num) { return 0; }
874
875int FTN_STDCALL FTN_TARGET_MEMCPY(void *dst, void *src, size_t length,
876 size_t dst_offset, size_t src_offset,
877 int dst_device, int src_device) {
878 return -1;
Jonathan Peyton50eae7f2016-05-27 15:51:14 +0000879}
880
Jonathan Peyton30419822017-05-12 18:01:32 +0000881int FTN_STDCALL FTN_TARGET_MEMCPY_RECT(
882 void *dst, void *src, size_t element_size, int num_dims,
883 const size_t *volume, const size_t *dst_offsets, const size_t *src_offsets,
884 const size_t *dst_dimensions, const size_t *src_dimensions, int dst_device,
885 int src_device) {
886 return -1;
Jonathan Peyton50eae7f2016-05-27 15:51:14 +0000887}
888
Jonathan Peyton30419822017-05-12 18:01:32 +0000889int FTN_STDCALL FTN_TARGET_ASSOCIATE_PTR(void *host_ptr, void *device_ptr,
890 size_t size, size_t device_offset,
891 int device_num) {
892 return -1;
Jonathan Peyton50eae7f2016-05-27 15:51:14 +0000893}
894
Jonathan Peyton30419822017-05-12 18:01:32 +0000895int FTN_STDCALL FTN_TARGET_DISASSOCIATE_PTR(void *host_ptr, int device_num) {
896 return -1;
Jonathan Peyton50eae7f2016-05-27 15:51:14 +0000897}
Jonathan Peytondf6818b2016-06-14 17:57:47 +0000898#endif // OMP_45_ENABLED && defined(KMP_STUB)
Jonathan Peyton50eae7f2016-05-27 15:51:14 +0000899
Jim Cownie5e8470a2013-09-27 10:38:44 +0000900#ifdef KMP_STUB
901typedef enum { UNINIT = -1, UNLOCKED, LOCKED } kmp_stub_lock_t;
902#endif /* KMP_STUB */
903
Andrey Churbanov5c56fb52015-02-20 18:05:17 +0000904#if KMP_USE_DYNAMIC_LOCK
Jonathan Peyton30419822017-05-12 18:01:32 +0000905void FTN_STDCALL FTN_INIT_LOCK_WITH_HINT(void **user_lock,
906 uintptr_t KMP_DEREF hint) {
907#ifdef KMP_STUB
908 *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
909#else
Joachim Protze82e94a52017-11-01 10:08:30 +0000910 int gtid = __kmp_entry_gtid();
911#if OMPT_SUPPORT && OMPT_OPTIONAL
912 OMPT_STORE_RETURN_ADDRESS(gtid);
913#endif
914 __kmpc_init_lock_with_hint(NULL, gtid, user_lock, KMP_DEREF hint);
Jonathan Peyton30419822017-05-12 18:01:32 +0000915#endif
Andrey Churbanov5c56fb52015-02-20 18:05:17 +0000916}
917
Jonathan Peyton30419822017-05-12 18:01:32 +0000918void FTN_STDCALL FTN_INIT_NEST_LOCK_WITH_HINT(void **user_lock,
919 uintptr_t KMP_DEREF hint) {
920#ifdef KMP_STUB
921 *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
922#else
Joachim Protze82e94a52017-11-01 10:08:30 +0000923 int gtid = __kmp_entry_gtid();
924#if OMPT_SUPPORT && OMPT_OPTIONAL
925 OMPT_STORE_RETURN_ADDRESS(gtid);
926#endif
927 __kmpc_init_nest_lock_with_hint(NULL, gtid, user_lock, KMP_DEREF hint);
Jonathan Peyton30419822017-05-12 18:01:32 +0000928#endif
Andrey Churbanov5c56fb52015-02-20 18:05:17 +0000929}
930#endif
931
Jim Cownie5e8470a2013-09-27 10:38:44 +0000932/* initialize the lock */
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000933void FTN_STDCALL KMP_EXPAND_NAME(FTN_INIT_LOCK)(void **user_lock) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000934#ifdef KMP_STUB
935 *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
936#else
Joachim Protze82e94a52017-11-01 10:08:30 +0000937 int gtid = __kmp_entry_gtid();
938#if OMPT_SUPPORT && OMPT_OPTIONAL
939 OMPT_STORE_RETURN_ADDRESS(gtid);
940#endif
941 __kmpc_init_lock(NULL, gtid, user_lock);
Jonathan Peyton30419822017-05-12 18:01:32 +0000942#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000943}
944
945/* initialize the lock */
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000946void FTN_STDCALL KMP_EXPAND_NAME(FTN_INIT_NEST_LOCK)(void **user_lock) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000947#ifdef KMP_STUB
948 *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
949#else
Joachim Protze82e94a52017-11-01 10:08:30 +0000950 int gtid = __kmp_entry_gtid();
951#if OMPT_SUPPORT && OMPT_OPTIONAL
952 OMPT_STORE_RETURN_ADDRESS(gtid);
953#endif
954 __kmpc_init_nest_lock(NULL, gtid, user_lock);
Jonathan Peyton30419822017-05-12 18:01:32 +0000955#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000956}
957
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000958void FTN_STDCALL KMP_EXPAND_NAME(FTN_DESTROY_LOCK)(void **user_lock) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000959#ifdef KMP_STUB
960 *((kmp_stub_lock_t *)user_lock) = UNINIT;
961#else
Joachim Protze82e94a52017-11-01 10:08:30 +0000962 int gtid = __kmp_entry_gtid();
963#if OMPT_SUPPORT && OMPT_OPTIONAL
964 OMPT_STORE_RETURN_ADDRESS(gtid);
965#endif
966 __kmpc_destroy_lock(NULL, gtid, user_lock);
Jonathan Peyton30419822017-05-12 18:01:32 +0000967#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000968}
969
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000970void FTN_STDCALL KMP_EXPAND_NAME(FTN_DESTROY_NEST_LOCK)(void **user_lock) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000971#ifdef KMP_STUB
972 *((kmp_stub_lock_t *)user_lock) = UNINIT;
973#else
Joachim Protze82e94a52017-11-01 10:08:30 +0000974 int gtid = __kmp_entry_gtid();
975#if OMPT_SUPPORT && OMPT_OPTIONAL
976 OMPT_STORE_RETURN_ADDRESS(gtid);
977#endif
978 __kmpc_destroy_nest_lock(NULL, gtid, user_lock);
Jonathan Peyton30419822017-05-12 18:01:32 +0000979#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000980}
981
Jonathan Peyton40039ac2017-11-07 23:32:13 +0000982void FTN_STDCALL KMP_EXPAND_NAME(FTN_SET_LOCK)(void **user_lock) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000983#ifdef KMP_STUB
984 if (*((kmp_stub_lock_t *)user_lock) == UNINIT) {
985 // TODO: Issue an error.
Jonathan Peytonbd3a7632017-09-27 20:36:27 +0000986 }
Jonathan Peyton30419822017-05-12 18:01:32 +0000987 if (*((kmp_stub_lock_t *)user_lock) != UNLOCKED) {
988 // TODO: Issue an error.
Jonathan Peytonbd3a7632017-09-27 20:36:27 +0000989 }
Jonathan Peyton30419822017-05-12 18:01:32 +0000990 *((kmp_stub_lock_t *)user_lock) = LOCKED;
991#else
Joachim Protze82e94a52017-11-01 10:08:30 +0000992 int gtid = __kmp_entry_gtid();
993#if OMPT_SUPPORT && OMPT_OPTIONAL
994 OMPT_STORE_RETURN_ADDRESS(gtid);
995#endif
996 __kmpc_set_lock(NULL, gtid, user_lock);
Jonathan Peyton30419822017-05-12 18:01:32 +0000997#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000998}
999
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001000void FTN_STDCALL KMP_EXPAND_NAME(FTN_SET_NEST_LOCK)(void **user_lock) {
Jonathan Peyton30419822017-05-12 18:01:32 +00001001#ifdef KMP_STUB
1002 if (*((kmp_stub_lock_t *)user_lock) == UNINIT) {
1003 // TODO: Issue an error.
Jonathan Peytonbd3a7632017-09-27 20:36:27 +00001004 }
Jonathan Peyton30419822017-05-12 18:01:32 +00001005 (*((int *)user_lock))++;
1006#else
Joachim Protze82e94a52017-11-01 10:08:30 +00001007 int gtid = __kmp_entry_gtid();
1008#if OMPT_SUPPORT && OMPT_OPTIONAL
1009 OMPT_STORE_RETURN_ADDRESS(gtid);
1010#endif
1011 __kmpc_set_nest_lock(NULL, gtid, user_lock);
Jonathan Peyton30419822017-05-12 18:01:32 +00001012#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +00001013}
1014
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001015void FTN_STDCALL KMP_EXPAND_NAME(FTN_UNSET_LOCK)(void **user_lock) {
Jonathan Peyton30419822017-05-12 18:01:32 +00001016#ifdef KMP_STUB
1017 if (*((kmp_stub_lock_t *)user_lock) == UNINIT) {
1018 // TODO: Issue an error.
Jonathan Peytonbd3a7632017-09-27 20:36:27 +00001019 }
Jonathan Peyton30419822017-05-12 18:01:32 +00001020 if (*((kmp_stub_lock_t *)user_lock) == UNLOCKED) {
1021 // TODO: Issue an error.
Jonathan Peytonbd3a7632017-09-27 20:36:27 +00001022 }
Jonathan Peyton30419822017-05-12 18:01:32 +00001023 *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
1024#else
Joachim Protze82e94a52017-11-01 10:08:30 +00001025 int gtid = __kmp_entry_gtid();
1026#if OMPT_SUPPORT && OMPT_OPTIONAL
1027 OMPT_STORE_RETURN_ADDRESS(gtid);
1028#endif
1029 __kmpc_unset_lock(NULL, gtid, user_lock);
Jonathan Peyton30419822017-05-12 18:01:32 +00001030#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +00001031}
1032
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001033void FTN_STDCALL KMP_EXPAND_NAME(FTN_UNSET_NEST_LOCK)(void **user_lock) {
Jonathan Peyton30419822017-05-12 18:01:32 +00001034#ifdef KMP_STUB
1035 if (*((kmp_stub_lock_t *)user_lock) == UNINIT) {
1036 // TODO: Issue an error.
Jonathan Peytonbd3a7632017-09-27 20:36:27 +00001037 }
Jonathan Peyton30419822017-05-12 18:01:32 +00001038 if (*((kmp_stub_lock_t *)user_lock) == UNLOCKED) {
1039 // TODO: Issue an error.
Jonathan Peytonbd3a7632017-09-27 20:36:27 +00001040 }
Jonathan Peyton30419822017-05-12 18:01:32 +00001041 (*((int *)user_lock))--;
1042#else
Joachim Protze82e94a52017-11-01 10:08:30 +00001043 int gtid = __kmp_entry_gtid();
1044#if OMPT_SUPPORT && OMPT_OPTIONAL
1045 OMPT_STORE_RETURN_ADDRESS(gtid);
1046#endif
1047 __kmpc_unset_nest_lock(NULL, gtid, user_lock);
Jonathan Peyton30419822017-05-12 18:01:32 +00001048#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +00001049}
1050
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001051int FTN_STDCALL KMP_EXPAND_NAME(FTN_TEST_LOCK)(void **user_lock) {
Jonathan Peyton30419822017-05-12 18:01:32 +00001052#ifdef KMP_STUB
1053 if (*((kmp_stub_lock_t *)user_lock) == UNINIT) {
1054 // TODO: Issue an error.
Jonathan Peytonbd3a7632017-09-27 20:36:27 +00001055 }
Jonathan Peyton30419822017-05-12 18:01:32 +00001056 if (*((kmp_stub_lock_t *)user_lock) == LOCKED) {
1057 return 0;
Jonathan Peytonbd3a7632017-09-27 20:36:27 +00001058 }
Jonathan Peyton30419822017-05-12 18:01:32 +00001059 *((kmp_stub_lock_t *)user_lock) = LOCKED;
1060 return 1;
1061#else
Joachim Protze82e94a52017-11-01 10:08:30 +00001062 int gtid = __kmp_entry_gtid();
1063#if OMPT_SUPPORT && OMPT_OPTIONAL
1064 OMPT_STORE_RETURN_ADDRESS(gtid);
1065#endif
1066 return __kmpc_test_lock(NULL, gtid, user_lock);
Jonathan Peyton30419822017-05-12 18:01:32 +00001067#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +00001068}
1069
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001070int FTN_STDCALL KMP_EXPAND_NAME(FTN_TEST_NEST_LOCK)(void **user_lock) {
Jonathan Peyton30419822017-05-12 18:01:32 +00001071#ifdef KMP_STUB
1072 if (*((kmp_stub_lock_t *)user_lock) == UNINIT) {
1073 // TODO: Issue an error.
Jonathan Peytonbd3a7632017-09-27 20:36:27 +00001074 }
Jonathan Peyton30419822017-05-12 18:01:32 +00001075 return ++(*((int *)user_lock));
1076#else
Joachim Protze82e94a52017-11-01 10:08:30 +00001077 int gtid = __kmp_entry_gtid();
1078#if OMPT_SUPPORT && OMPT_OPTIONAL
1079 OMPT_STORE_RETURN_ADDRESS(gtid);
1080#endif
1081 return __kmpc_test_nest_lock(NULL, gtid, user_lock);
Jonathan Peyton30419822017-05-12 18:01:32 +00001082#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +00001083}
1084
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001085double FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_WTIME)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +00001086#ifdef KMP_STUB
1087 return __kmps_get_wtime();
1088#else
1089 double data;
1090#if !KMP_OS_LINUX
1091 // We don't need library initialization to get the time on Linux* OS. The
1092 // routine can be used to measure library initialization time on Linux* OS now
1093 if (!__kmp_init_serial) {
1094 __kmp_serial_initialize();
Jonathan Peytonbd3a7632017-09-27 20:36:27 +00001095 }
Jonathan Peyton30419822017-05-12 18:01:32 +00001096#endif
1097 __kmp_elapsed(&data);
1098 return data;
1099#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +00001100}
1101
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001102double FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_WTICK)(void) {
Jonathan Peyton30419822017-05-12 18:01:32 +00001103#ifdef KMP_STUB
1104 return __kmps_get_wtick();
1105#else
1106 double data;
1107 if (!__kmp_init_serial) {
1108 __kmp_serial_initialize();
Jonathan Peytonbd3a7632017-09-27 20:36:27 +00001109 }
Jonathan Peyton30419822017-05-12 18:01:32 +00001110 __kmp_elapsed_tick(&data);
1111 return data;
1112#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +00001113}
1114
1115/* ------------------------------------------------------------------------ */
1116
Jonathan Peyton30419822017-05-12 18:01:32 +00001117void *FTN_STDCALL FTN_MALLOC(size_t KMP_DEREF size) {
1118 // kmpc_malloc initializes the library if needed
1119 return kmpc_malloc(KMP_DEREF size);
Jim Cownie5e8470a2013-09-27 10:38:44 +00001120}
1121
Jonathan Peyton30419822017-05-12 18:01:32 +00001122void *FTN_STDCALL FTN_ALIGNED_MALLOC(size_t KMP_DEREF size,
1123 size_t KMP_DEREF alignment) {
1124 // kmpc_aligned_malloc initializes the library if needed
1125 return kmpc_aligned_malloc(KMP_DEREF size, KMP_DEREF alignment);
Jonathan Peytonf83ae312016-05-12 22:00:37 +00001126}
1127
Jonathan Peyton30419822017-05-12 18:01:32 +00001128void *FTN_STDCALL FTN_CALLOC(size_t KMP_DEREF nelem, size_t KMP_DEREF elsize) {
1129 // kmpc_calloc initializes the library if needed
1130 return kmpc_calloc(KMP_DEREF nelem, KMP_DEREF elsize);
Jim Cownie5e8470a2013-09-27 10:38:44 +00001131}
1132
Jonathan Peyton30419822017-05-12 18:01:32 +00001133void *FTN_STDCALL FTN_REALLOC(void *KMP_DEREF ptr, size_t KMP_DEREF size) {
1134 // kmpc_realloc initializes the library if needed
1135 return kmpc_realloc(KMP_DEREF ptr, KMP_DEREF size);
Jim Cownie5e8470a2013-09-27 10:38:44 +00001136}
1137
Jonathan Peyton30419822017-05-12 18:01:32 +00001138void FTN_STDCALL FTN_FREE(void *KMP_DEREF ptr) {
1139 // does nothing if the library is not initialized
1140 kmpc_free(KMP_DEREF ptr);
Jim Cownie5e8470a2013-09-27 10:38:44 +00001141}
1142
Jonathan Peyton30419822017-05-12 18:01:32 +00001143void FTN_STDCALL FTN_SET_WARNINGS_ON(void) {
1144#ifndef KMP_STUB
1145 __kmp_generate_warnings = kmp_warnings_explicit;
1146#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +00001147}
1148
Jonathan Peyton30419822017-05-12 18:01:32 +00001149void FTN_STDCALL FTN_SET_WARNINGS_OFF(void) {
1150#ifndef KMP_STUB
1151 __kmp_generate_warnings = FALSE;
1152#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +00001153}
1154
Jonathan Peyton30419822017-05-12 18:01:32 +00001155void FTN_STDCALL FTN_SET_DEFAULTS(char const *str
1156#ifndef PASS_ARGS_BY_VALUE
1157 ,
1158 int len
1159#endif
1160 ) {
1161#ifndef KMP_STUB
1162#ifdef PASS_ARGS_BY_VALUE
1163 int len = (int)KMP_STRLEN(str);
1164#endif
1165 __kmp_aux_set_defaults(str, len);
1166#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +00001167}
1168
1169/* ------------------------------------------------------------------------ */
1170
Jim Cownie181b4bb2013-12-23 17:28:57 +00001171#if OMP_40_ENABLED
1172/* returns the status of cancellation */
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001173int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_CANCELLATION)(void) {
Jim Cownie181b4bb2013-12-23 17:28:57 +00001174#ifdef KMP_STUB
Jonathan Peyton30419822017-05-12 18:01:32 +00001175 return 0 /* false */;
Jim Cownie181b4bb2013-12-23 17:28:57 +00001176#else
Jonathan Peyton30419822017-05-12 18:01:32 +00001177 // initialize the library if needed
1178 if (!__kmp_init_serial) {
1179 __kmp_serial_initialize();
1180 }
1181 return __kmp_omp_cancellation;
Jim Cownie181b4bb2013-12-23 17:28:57 +00001182#endif
1183}
1184
Jonathan Peyton30419822017-05-12 18:01:32 +00001185int FTN_STDCALL FTN_GET_CANCELLATION_STATUS(int cancel_kind) {
Jim Cownie181b4bb2013-12-23 17:28:57 +00001186#ifdef KMP_STUB
Jonathan Peyton30419822017-05-12 18:01:32 +00001187 return 0 /* false */;
Jim Cownie181b4bb2013-12-23 17:28:57 +00001188#else
Jonathan Peyton30419822017-05-12 18:01:32 +00001189 return __kmp_get_cancellation_status(cancel_kind);
Jim Cownie181b4bb2013-12-23 17:28:57 +00001190#endif
1191}
1192
1193#endif // OMP_40_ENABLED
1194
Jonathan Peytondf6818b2016-06-14 17:57:47 +00001195#if OMP_45_ENABLED
Jonathan Peyton28510722016-02-25 18:04:09 +00001196/* returns the maximum allowed task priority */
Jonathan Peyton284fab12018-07-30 17:50:35 +00001197int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_MAX_TASK_PRIORITY)(void) {
Jonathan Peyton28510722016-02-25 18:04:09 +00001198#ifdef KMP_STUB
Jonathan Peyton30419822017-05-12 18:01:32 +00001199 return 0;
Jonathan Peyton28510722016-02-25 18:04:09 +00001200#else
Jonathan Peyton30419822017-05-12 18:01:32 +00001201 if (!__kmp_init_serial) {
1202 __kmp_serial_initialize();
1203 }
1204 return __kmp_max_task_priority;
Jonathan Peyton28510722016-02-25 18:04:09 +00001205#endif
1206}
1207#endif
1208
Jim Cownie181b4bb2013-12-23 17:28:57 +00001209// GCC compatibility (versioned symbols)
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001210#ifdef KMP_USE_VERSION_SYMBOLS
Jim Cownie181b4bb2013-12-23 17:28:57 +00001211
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001212/* These following sections create versioned symbols for the
1213 omp_* routines. The KMP_VERSION_SYMBOL macro expands the API name and
1214 then maps it to a versioned symbol.
Jonathan Peyton30419822017-05-12 18:01:32 +00001215 libgomp ``versions'' its symbols (OMP_1.0, OMP_2.0, OMP_3.0, ...) while also
1216 retaining the default version which libomp uses: VERSION (defined in
1217 exports_so.txt). If you want to see the versioned symbols for libgomp.so.1
1218 then just type:
Jim Cownie181b4bb2013-12-23 17:28:57 +00001219
Jonathan Peyton30419822017-05-12 18:01:32 +00001220 objdump -T /path/to/libgomp.so.1 | grep omp_
Jim Cownie181b4bb2013-12-23 17:28:57 +00001221
Jonathan Peyton30419822017-05-12 18:01:32 +00001222 Example:
1223 Step 1) Create __kmp_api_omp_set_num_threads_10_alias which is alias of
1224 __kmp_api_omp_set_num_threads
1225 Step 2) Set __kmp_api_omp_set_num_threads_10_alias to version:
1226 omp_set_num_threads@OMP_1.0
1227 Step 2B) Set __kmp_api_omp_set_num_threads to default version:
1228 omp_set_num_threads@@VERSION
Jim Cownie181b4bb2013-12-23 17:28:57 +00001229*/
1230
Jim Cownie181b4bb2013-12-23 17:28:57 +00001231// OMP_1.0 versioned symbols
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001232KMP_VERSION_SYMBOL(FTN_SET_NUM_THREADS, 10, "OMP_1.0");
1233KMP_VERSION_SYMBOL(FTN_GET_NUM_THREADS, 10, "OMP_1.0");
1234KMP_VERSION_SYMBOL(FTN_GET_MAX_THREADS, 10, "OMP_1.0");
1235KMP_VERSION_SYMBOL(FTN_GET_THREAD_NUM, 10, "OMP_1.0");
1236KMP_VERSION_SYMBOL(FTN_GET_NUM_PROCS, 10, "OMP_1.0");
1237KMP_VERSION_SYMBOL(FTN_IN_PARALLEL, 10, "OMP_1.0");
1238KMP_VERSION_SYMBOL(FTN_SET_DYNAMIC, 10, "OMP_1.0");
1239KMP_VERSION_SYMBOL(FTN_GET_DYNAMIC, 10, "OMP_1.0");
1240KMP_VERSION_SYMBOL(FTN_SET_NESTED, 10, "OMP_1.0");
1241KMP_VERSION_SYMBOL(FTN_GET_NESTED, 10, "OMP_1.0");
1242KMP_VERSION_SYMBOL(FTN_INIT_LOCK, 10, "OMP_1.0");
1243KMP_VERSION_SYMBOL(FTN_INIT_NEST_LOCK, 10, "OMP_1.0");
1244KMP_VERSION_SYMBOL(FTN_DESTROY_LOCK, 10, "OMP_1.0");
1245KMP_VERSION_SYMBOL(FTN_DESTROY_NEST_LOCK, 10, "OMP_1.0");
1246KMP_VERSION_SYMBOL(FTN_SET_LOCK, 10, "OMP_1.0");
1247KMP_VERSION_SYMBOL(FTN_SET_NEST_LOCK, 10, "OMP_1.0");
1248KMP_VERSION_SYMBOL(FTN_UNSET_LOCK, 10, "OMP_1.0");
1249KMP_VERSION_SYMBOL(FTN_UNSET_NEST_LOCK, 10, "OMP_1.0");
1250KMP_VERSION_SYMBOL(FTN_TEST_LOCK, 10, "OMP_1.0");
1251KMP_VERSION_SYMBOL(FTN_TEST_NEST_LOCK, 10, "OMP_1.0");
Jim Cownie181b4bb2013-12-23 17:28:57 +00001252
1253// OMP_2.0 versioned symbols
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001254KMP_VERSION_SYMBOL(FTN_GET_WTICK, 20, "OMP_2.0");
1255KMP_VERSION_SYMBOL(FTN_GET_WTIME, 20, "OMP_2.0");
Jim Cownie181b4bb2013-12-23 17:28:57 +00001256
Jim Cownie181b4bb2013-12-23 17:28:57 +00001257// OMP_3.0 versioned symbols
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001258KMP_VERSION_SYMBOL(FTN_SET_SCHEDULE, 30, "OMP_3.0");
1259KMP_VERSION_SYMBOL(FTN_GET_SCHEDULE, 30, "OMP_3.0");
1260KMP_VERSION_SYMBOL(FTN_GET_THREAD_LIMIT, 30, "OMP_3.0");
1261KMP_VERSION_SYMBOL(FTN_SET_MAX_ACTIVE_LEVELS, 30, "OMP_3.0");
1262KMP_VERSION_SYMBOL(FTN_GET_MAX_ACTIVE_LEVELS, 30, "OMP_3.0");
1263KMP_VERSION_SYMBOL(FTN_GET_ANCESTOR_THREAD_NUM, 30, "OMP_3.0");
1264KMP_VERSION_SYMBOL(FTN_GET_LEVEL, 30, "OMP_3.0");
1265KMP_VERSION_SYMBOL(FTN_GET_TEAM_SIZE, 30, "OMP_3.0");
1266KMP_VERSION_SYMBOL(FTN_GET_ACTIVE_LEVEL, 30, "OMP_3.0");
Jim Cownie181b4bb2013-12-23 17:28:57 +00001267
1268// the lock routines have a 1.0 and 3.0 version
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001269KMP_VERSION_SYMBOL(FTN_INIT_LOCK, 30, "OMP_3.0");
1270KMP_VERSION_SYMBOL(FTN_INIT_NEST_LOCK, 30, "OMP_3.0");
1271KMP_VERSION_SYMBOL(FTN_DESTROY_LOCK, 30, "OMP_3.0");
1272KMP_VERSION_SYMBOL(FTN_DESTROY_NEST_LOCK, 30, "OMP_3.0");
1273KMP_VERSION_SYMBOL(FTN_SET_LOCK, 30, "OMP_3.0");
1274KMP_VERSION_SYMBOL(FTN_SET_NEST_LOCK, 30, "OMP_3.0");
1275KMP_VERSION_SYMBOL(FTN_UNSET_LOCK, 30, "OMP_3.0");
1276KMP_VERSION_SYMBOL(FTN_UNSET_NEST_LOCK, 30, "OMP_3.0");
1277KMP_VERSION_SYMBOL(FTN_TEST_LOCK, 30, "OMP_3.0");
1278KMP_VERSION_SYMBOL(FTN_TEST_NEST_LOCK, 30, "OMP_3.0");
Jim Cownie181b4bb2013-12-23 17:28:57 +00001279
1280// OMP_3.1 versioned symbol
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001281KMP_VERSION_SYMBOL(FTN_IN_FINAL, 31, "OMP_3.1");
Jim Cownie181b4bb2013-12-23 17:28:57 +00001282
1283#if OMP_40_ENABLED
1284// OMP_4.0 versioned symbols
Jonathan Peyton40039ac2017-11-07 23:32:13 +00001285KMP_VERSION_SYMBOL(FTN_GET_PROC_BIND, 40, "OMP_4.0");
1286KMP_VERSION_SYMBOL(FTN_GET_NUM_TEAMS, 40, "OMP_4.0");
1287KMP_VERSION_SYMBOL(FTN_GET_TEAM_NUM, 40, "OMP_4.0");
1288KMP_VERSION_SYMBOL(FTN_GET_CANCELLATION, 40, "OMP_4.0");
1289KMP_VERSION_SYMBOL(FTN_GET_DEFAULT_DEVICE, 40, "OMP_4.0");
1290KMP_VERSION_SYMBOL(FTN_SET_DEFAULT_DEVICE, 40, "OMP_4.0");
1291KMP_VERSION_SYMBOL(FTN_IS_INITIAL_DEVICE, 40, "OMP_4.0");
Jim Cownie181b4bb2013-12-23 17:28:57 +00001292#endif /* OMP_40_ENABLED */
1293
Jonathan Peytondf6818b2016-06-14 17:57:47 +00001294#if OMP_45_ENABLED
1295// OMP_4.5 versioned symbols
Jonathan Peyton284fab12018-07-30 17:50:35 +00001296KMP_VERSION_SYMBOL(FTN_GET_MAX_TASK_PRIORITY, 45, "OMP_4.5");
1297KMP_VERSION_SYMBOL(FTN_GET_NUM_PLACES, 45, "OMP_4.5");
1298KMP_VERSION_SYMBOL(FTN_GET_PLACE_NUM_PROCS, 45, "OMP_4.5");
1299KMP_VERSION_SYMBOL(FTN_GET_PLACE_PROC_IDS, 45, "OMP_4.5");
1300KMP_VERSION_SYMBOL(FTN_GET_PLACE_NUM, 45, "OMP_4.5");
1301KMP_VERSION_SYMBOL(FTN_GET_PARTITION_NUM_PLACES, 45, "OMP_4.5");
1302KMP_VERSION_SYMBOL(FTN_GET_PARTITION_PLACE_NUMS, 45, "OMP_4.5");
Jim Cownie181b4bb2013-12-23 17:28:57 +00001303#endif
1304
1305#if OMP_50_ENABLED
1306// OMP_5.0 versioned symbols
1307#endif
1308
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001309#endif // KMP_USE_VERSION_SYMBOLS
Jim Cownie181b4bb2013-12-23 17:28:57 +00001310
Jim Cownie5e8470a2013-09-27 10:38:44 +00001311#ifdef __cplusplus
Jonathan Peyton30419822017-05-12 18:01:32 +00001312} // extern "C"
Jim Cownie5e8470a2013-09-27 10:38:44 +00001313#endif // __cplusplus
1314
1315// end of file //