blob: 3e4d996a2a516f6fe84f60f1d66603965cde212c [file] [log] [blame]
Jim Cownie5e8470a2013-09-27 10:38:44 +00001/*
2 * kmp_gsupport.c
Jim Cownie5e8470a2013-09-27 10:38:44 +00003 */
4
5
6//===----------------------------------------------------------------------===//
7//
8// The LLVM Compiler Infrastructure
9//
10// This file is dual licensed under the MIT and the University of Illinois Open
11// Source Licenses. See LICENSE.txt for details.
12//
13//===----------------------------------------------------------------------===//
14
15
Andrey Churbanovcbda8682015-01-13 14:43:35 +000016#if defined(__x86_64) || defined (__powerpc64__) || defined(__aarch64__)
Jim Cownie5e8470a2013-09-27 10:38:44 +000017# define KMP_I8
18#endif
19#include "kmp.h"
20#include "kmp_atomic.h"
21
Andrey Churbanovd7d088f2015-04-29 16:42:24 +000022#if OMPT_SUPPORT
23#include "ompt-specific.h"
24#endif
25
Jim Cownie5e8470a2013-09-27 10:38:44 +000026#ifdef __cplusplus
27 extern "C" {
28#endif // __cplusplus
29
30#define MKLOC(loc,routine) \
31 static ident_t (loc) = {0, KMP_IDENT_KMPC, 0, 0, ";unknown;unknown;0;0;;" };
32
Jim Cownie181b4bb2013-12-23 17:28:57 +000033#include "kmp_ftn_os.h"
Jim Cownie5e8470a2013-09-27 10:38:44 +000034
35void
Jim Cownie181b4bb2013-12-23 17:28:57 +000036xexpand(KMP_API_NAME_GOMP_BARRIER)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +000037{
38 int gtid = __kmp_entry_gtid();
39 MKLOC(loc, "GOMP_barrier");
40 KA_TRACE(20, ("GOMP_barrier: T#%d\n", gtid));
41 __kmpc_barrier(&loc, gtid);
42}
43
44
Jim Cownie5e8470a2013-09-27 10:38:44 +000045//
46// Mutual exclusion
47//
48
49//
50// The symbol that icc/ifort generates for unnamed for unnamed critical
51// sections - .gomp_critical_user_ - is defined using .comm in any objects
52// reference it. We can't reference it directly here in C code, as the
53// symbol contains a ".".
54//
55// The RTL contains an assembly language definition of .gomp_critical_user_
56// with another symbol __kmp_unnamed_critical_addr initialized with it's
57// address.
58//
59extern kmp_critical_name *__kmp_unnamed_critical_addr;
60
61
62void
Jim Cownie181b4bb2013-12-23 17:28:57 +000063xexpand(KMP_API_NAME_GOMP_CRITICAL_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +000064{
65 int gtid = __kmp_entry_gtid();
66 MKLOC(loc, "GOMP_critical_start");
67 KA_TRACE(20, ("GOMP_critical_start: T#%d\n", gtid));
68 __kmpc_critical(&loc, gtid, __kmp_unnamed_critical_addr);
69}
70
71
72void
Jim Cownie181b4bb2013-12-23 17:28:57 +000073xexpand(KMP_API_NAME_GOMP_CRITICAL_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +000074{
75 int gtid = __kmp_get_gtid();
76 MKLOC(loc, "GOMP_critical_end");
77 KA_TRACE(20, ("GOMP_critical_end: T#%d\n", gtid));
78 __kmpc_end_critical(&loc, gtid, __kmp_unnamed_critical_addr);
79}
80
81
82void
Jim Cownie181b4bb2013-12-23 17:28:57 +000083xexpand(KMP_API_NAME_GOMP_CRITICAL_NAME_START)(void **pptr)
Jim Cownie5e8470a2013-09-27 10:38:44 +000084{
85 int gtid = __kmp_entry_gtid();
86 MKLOC(loc, "GOMP_critical_name_start");
87 KA_TRACE(20, ("GOMP_critical_name_start: T#%d\n", gtid));
88 __kmpc_critical(&loc, gtid, (kmp_critical_name *)pptr);
89}
90
91
92void
Jim Cownie181b4bb2013-12-23 17:28:57 +000093xexpand(KMP_API_NAME_GOMP_CRITICAL_NAME_END)(void **pptr)
Jim Cownie5e8470a2013-09-27 10:38:44 +000094{
95 int gtid = __kmp_get_gtid();
96 MKLOC(loc, "GOMP_critical_name_end");
97 KA_TRACE(20, ("GOMP_critical_name_end: T#%d\n", gtid));
98 __kmpc_end_critical(&loc, gtid, (kmp_critical_name *)pptr);
99}
100
101
102//
103// The Gnu codegen tries to use locked operations to perform atomic updates
104// inline. If it can't, then it calls GOMP_atomic_start() before performing
105// the update and GOMP_atomic_end() afterward, regardless of the data type.
106//
107
108void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000109xexpand(KMP_API_NAME_GOMP_ATOMIC_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000110{
111 int gtid = __kmp_entry_gtid();
112 KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000113
114#if OMPT_SUPPORT
115 __ompt_thread_assign_wait_id(0);
116#endif
117
Jim Cownie5e8470a2013-09-27 10:38:44 +0000118 __kmp_acquire_atomic_lock(&__kmp_atomic_lock, gtid);
119}
120
121
122void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000123xexpand(KMP_API_NAME_GOMP_ATOMIC_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000124{
125 int gtid = __kmp_get_gtid();
126 KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
127 __kmp_release_atomic_lock(&__kmp_atomic_lock, gtid);
128}
129
130
131int
Jim Cownie181b4bb2013-12-23 17:28:57 +0000132xexpand(KMP_API_NAME_GOMP_SINGLE_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000133{
134 int gtid = __kmp_entry_gtid();
135 MKLOC(loc, "GOMP_single_start");
136 KA_TRACE(20, ("GOMP_single_start: T#%d\n", gtid));
137
138 if (! TCR_4(__kmp_init_parallel))
139 __kmp_parallel_initialize();
140
141 //
142 // 3rd parameter == FALSE prevents kmp_enter_single from pushing a
143 // workshare when USE_CHECKS is defined. We need to avoid the push,
144 // as there is no corresponding GOMP_single_end() call.
145 //
146 return __kmp_enter_single(gtid, &loc, FALSE);
147}
148
149
150void *
Jim Cownie181b4bb2013-12-23 17:28:57 +0000151xexpand(KMP_API_NAME_GOMP_SINGLE_COPY_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000152{
153 void *retval;
154 int gtid = __kmp_entry_gtid();
155 MKLOC(loc, "GOMP_single_copy_start");
156 KA_TRACE(20, ("GOMP_single_copy_start: T#%d\n", gtid));
157
158 if (! TCR_4(__kmp_init_parallel))
159 __kmp_parallel_initialize();
160
161 //
162 // If this is the first thread to enter, return NULL. The generated
163 // code will then call GOMP_single_copy_end() for this thread only,
164 // with the copyprivate data pointer as an argument.
165 //
166 if (__kmp_enter_single(gtid, &loc, FALSE))
167 return NULL;
168
169 //
170 // Wait for the first thread to set the copyprivate data pointer,
171 // and for all other threads to reach this point.
172 //
173 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
174
175 //
176 // Retrieve the value of the copyprivate data point, and wait for all
177 // threads to do likewise, then return.
178 //
179 retval = __kmp_team_from_gtid(gtid)->t.t_copypriv_data;
180 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
181 return retval;
182}
183
184
185void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000186xexpand(KMP_API_NAME_GOMP_SINGLE_COPY_END)(void *data)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000187{
188 int gtid = __kmp_get_gtid();
Jim Cownie5e8470a2013-09-27 10:38:44 +0000189 KA_TRACE(20, ("GOMP_single_copy_end: T#%d\n", gtid));
190
191 //
192 // Set the copyprivate data pointer fo the team, then hit the barrier
193 // so that the other threads will continue on and read it. Hit another
194 // barrier before continuing, so that the know that the copyprivate
195 // data pointer has been propagated to all threads before trying to
196 // reuse the t_copypriv_data field.
197 //
198 __kmp_team_from_gtid(gtid)->t.t_copypriv_data = data;
199 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
200 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
201}
202
203
204void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000205xexpand(KMP_API_NAME_GOMP_ORDERED_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000206{
207 int gtid = __kmp_entry_gtid();
208 MKLOC(loc, "GOMP_ordered_start");
209 KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
210 __kmpc_ordered(&loc, gtid);
211}
212
213
214void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000215xexpand(KMP_API_NAME_GOMP_ORDERED_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000216{
217 int gtid = __kmp_get_gtid();
218 MKLOC(loc, "GOMP_ordered_end");
219 KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
220 __kmpc_end_ordered(&loc, gtid);
221}
222
223
Jim Cownie5e8470a2013-09-27 10:38:44 +0000224//
225// Dispatch macro defs
226//
227// They come in two flavors: 64-bit unsigned, and either 32-bit signed
228// (IA-32 architecture) or 64-bit signed (Intel(R) 64).
229//
230
Jim Cownie181b4bb2013-12-23 17:28:57 +0000231#if KMP_ARCH_X86 || KMP_ARCH_ARM
Jim Cownie5e8470a2013-09-27 10:38:44 +0000232# define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_4
233# define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_4
234# define KMP_DISPATCH_NEXT __kmpc_dispatch_next_4
235#else
236# define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_8
237# define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_8
238# define KMP_DISPATCH_NEXT __kmpc_dispatch_next_8
239#endif /* KMP_ARCH_X86 */
240
241# define KMP_DISPATCH_INIT_ULL __kmp_aux_dispatch_init_8u
242# define KMP_DISPATCH_FINI_CHUNK_ULL __kmp_aux_dispatch_fini_chunk_8u
243# define KMP_DISPATCH_NEXT_ULL __kmpc_dispatch_next_8u
244
245
Jim Cownie5e8470a2013-09-27 10:38:44 +0000246//
247// The parallel contruct
248//
249
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000250#ifndef KMP_DEBUG
Jim Cownie5e8470a2013-09-27 10:38:44 +0000251static
252#endif /* KMP_DEBUG */
253void
254__kmp_GOMP_microtask_wrapper(int *gtid, int *npr, void (*task)(void *),
255 void *data)
256{
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000257#if OMPT_SUPPORT
258 kmp_info_t *thr;
259 ompt_frame_t *ompt_frame;
260 ompt_state_t enclosing_state;
261
262 if (ompt_status & ompt_status_track) {
263 // get pointer to thread data structure
264 thr = __kmp_threads[*gtid];
265
266 // save enclosing task state; set current state for task
267 enclosing_state = thr->th.ompt_thread_info.state;
268 thr->th.ompt_thread_info.state = ompt_state_work_parallel;
269
270 // set task frame
271 ompt_frame = __ompt_get_task_frame_internal(0);
272 ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
273 }
274#endif
275
Jim Cownie5e8470a2013-09-27 10:38:44 +0000276 task(data);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000277
278#if OMPT_SUPPORT
279 if (ompt_status & ompt_status_track) {
280 // clear task frame
281 ompt_frame->exit_runtime_frame = NULL;
282
283 // restore enclosing state
284 thr->th.ompt_thread_info.state = enclosing_state;
285 }
286#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000287}
288
289
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000290#ifndef KMP_DEBUG
Jim Cownie5e8470a2013-09-27 10:38:44 +0000291static
292#endif /* KMP_DEBUG */
293void
294__kmp_GOMP_parallel_microtask_wrapper(int *gtid, int *npr,
295 void (*task)(void *), void *data, unsigned num_threads, ident_t *loc,
296 enum sched_type schedule, long start, long end, long incr, long chunk_size)
297{
298 //
299 // Intialize the loop worksharing construct.
300 //
301 KMP_DISPATCH_INIT(loc, *gtid, schedule, start, end, incr, chunk_size,
302 schedule != kmp_sch_static);
303
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000304#if OMPT_SUPPORT
305 kmp_info_t *thr;
306 ompt_frame_t *ompt_frame;
307 ompt_state_t enclosing_state;
308
309 if (ompt_status & ompt_status_track) {
310 thr = __kmp_threads[*gtid];
311 // save enclosing task state; set current state for task
312 enclosing_state = thr->th.ompt_thread_info.state;
313 thr->th.ompt_thread_info.state = ompt_state_work_parallel;
314
315 // set task frame
316 ompt_frame = __ompt_get_task_frame_internal(0);
317 ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
318 }
319#endif
320
Jim Cownie5e8470a2013-09-27 10:38:44 +0000321 //
322 // Now invoke the microtask.
323 //
324 task(data);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000325
326#if OMPT_SUPPORT
327 if (ompt_status & ompt_status_track) {
328 // clear task frame
329 ompt_frame->exit_runtime_frame = NULL;
330
331 // reset enclosing state
332 thr->th.ompt_thread_info.state = enclosing_state;
333 }
334#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000335}
336
337
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000338#ifndef KMP_DEBUG
Jim Cownie5e8470a2013-09-27 10:38:44 +0000339static
340#endif /* KMP_DEBUG */
341void
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000342__kmp_GOMP_fork_call(ident_t *loc, int gtid, void (*unwrapped_task)(void *), microtask_t wrapper, int argc,...)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000343{
344 int rc;
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000345 kmp_info_t *thr = __kmp_threads[gtid];
346 kmp_team_t *team = thr->th.th_team;
347 int tid = __kmp_tid_from_gtid(gtid);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000348
349 va_list ap;
350 va_start(ap, argc);
351
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000352#if OMPT_SUPPORT
353 team->t.t_implicit_task_taskdata[tid].
354 ompt_task_info.frame.reenter_runtime_frame = NULL;
355#endif
356
357 rc = __kmp_fork_call(loc, gtid, fork_context_gnu, argc,
358#if OMPT_SUPPORT
359 VOLATILE_CAST(void *) unwrapped_task,
360#endif
361 wrapper, __kmp_invoke_task_func,
Andrey Churbanovcbda8682015-01-13 14:43:35 +0000362#if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
Jim Cownie5e8470a2013-09-27 10:38:44 +0000363 &ap
364#else
365 ap
366#endif
367 );
368
369 va_end(ap);
370
371 if (rc) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000372 __kmp_run_before_invoked_task(gtid, tid, thr, team);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000373 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000374
375#if OMPT_SUPPORT && OMPT_TRACE
376 if (ompt_status & ompt_status_track) {
377 ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
378 ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
379
380 // implicit task callback
381 if ((ompt_status == ompt_status_track_callback) &&
382 ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)) {
383 ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)(
384 team_info->parallel_id, task_info->task_id);
385 }
386 thr->th.ompt_thread_info.state = ompt_state_work_parallel;
387 }
388#endif
389}
390
391static void
392__kmp_GOMP_serialized_parallel(ident_t *loc, kmp_int32 gtid, void (*task)(void *))
393{
394 __kmp_serialized_parallel(loc, gtid);
395
396#if OMPT_SUPPORT
397 if (ompt_status & ompt_status_track) {
398 ompt_task_id_t ompt_task_id = __ompt_get_task_id_internal(0);
399 ompt_frame_t *ompt_frame = __ompt_get_task_frame_internal(0);
400 kmp_info_t *thr = __kmp_threads[gtid];
401
402 ompt_parallel_id_t ompt_parallel_id = __ompt_parallel_id_new(gtid);
403 ompt_task_id_t my_ompt_task_id = __ompt_task_id_new(gtid);
404
405 ompt_frame->exit_runtime_frame = NULL;
406
407 // parallel region callback
408 if ((ompt_status == ompt_status_track_callback) &&
409 ompt_callbacks.ompt_callback(ompt_event_parallel_begin)) {
410 int team_size = 1;
411 ompt_callbacks.ompt_callback(ompt_event_parallel_begin)(
412 ompt_task_id, ompt_frame, ompt_parallel_id,
413 team_size, (void *) task);
414 }
415
416 // set up lightweight task
417 ompt_lw_taskteam_t *lwt = (ompt_lw_taskteam_t *)
418 __kmp_allocate(sizeof(ompt_lw_taskteam_t));
419 __ompt_lw_taskteam_init(lwt, thr, gtid, (void *) task, ompt_parallel_id);
420 lwt->ompt_task_info.task_id = my_ompt_task_id;
421 lwt->ompt_task_info.frame.exit_runtime_frame = 0;
422 __ompt_lw_taskteam_link(lwt, thr);
423
424#if OMPT_TRACE
425 // implicit task callback
426 if ((ompt_status == ompt_status_track_callback) &&
427 ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)) {
428 ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)(
429 ompt_parallel_id, my_ompt_task_id);
430 }
431 thr->th.ompt_thread_info.state = ompt_state_work_parallel;
432#endif
433 }
434#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000435}
436
437
438void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000439xexpand(KMP_API_NAME_GOMP_PARALLEL_START)(void (*task)(void *), void *data, unsigned num_threads)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000440{
441 int gtid = __kmp_entry_gtid();
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000442
443#if OMPT_SUPPORT
444 ompt_frame_t *parent_frame;
445
446 if (ompt_status & ompt_status_track) {
447 parent_frame = __ompt_get_task_frame_internal(0);
448 parent_frame->reenter_runtime_frame = __builtin_frame_address(0);
449 }
450#endif
451
Jim Cownie5e8470a2013-09-27 10:38:44 +0000452 MKLOC(loc, "GOMP_parallel_start");
453 KA_TRACE(20, ("GOMP_parallel_start: T#%d\n", gtid));
454
455 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
456 if (num_threads != 0) {
457 __kmp_push_num_threads(&loc, gtid, num_threads);
458 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000459 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie5e8470a2013-09-27 10:38:44 +0000460 (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task, data);
461 }
462 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000463 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000464 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000465
466#if OMPT_SUPPORT
467 if (ompt_status & ompt_status_track) {
468 parent_frame->reenter_runtime_frame = NULL;
469 }
470#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000471}
472
473
474void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000475xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000476{
477 int gtid = __kmp_get_gtid();
Jonathan Peytone8104ad2015-06-08 18:56:33 +0000478 kmp_info_t *thr;
479
480 thr = __kmp_threads[gtid];
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000481
Jim Cownie5e8470a2013-09-27 10:38:44 +0000482 MKLOC(loc, "GOMP_parallel_end");
483 KA_TRACE(20, ("GOMP_parallel_end: T#%d\n", gtid));
484
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000485
486#if OMPT_SUPPORT
487 ompt_parallel_id_t parallel_id;
488 ompt_frame_t *ompt_frame = NULL;
489
490 if (ompt_status & ompt_status_track) {
491 ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
492 parallel_id = team_info->parallel_id;
493
494 ompt_frame = __ompt_get_task_frame_internal(0);
495 ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
496
497#if OMPT_TRACE
498 if ((ompt_status == ompt_status_track_callback) &&
499 ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)) {
500 ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
501 ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)(
502 parallel_id, task_info->task_id);
503 }
504#endif
505
506 // unlink if necessary. no-op if there is not a lightweight task.
507 ompt_lw_taskteam_t *lwt = __ompt_lw_taskteam_unlink(thr);
508 // GOMP allocates/frees lwt since it can't be kept on the stack
509 if (lwt) __kmp_free(lwt);
510 }
511#endif
512
Jim Cownie5e8470a2013-09-27 10:38:44 +0000513 if (! __kmp_threads[gtid]->th.th_team->t.t_serialized) {
514 kmp_info_t *thr = __kmp_threads[gtid];
515 __kmp_run_after_invoked_task(gtid, __kmp_tid_from_gtid(gtid), thr,
516 thr->th.th_team);
517 __kmp_join_call(&loc, gtid);
518 }
519 else {
520 __kmpc_end_serialized_parallel(&loc, gtid);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000521
522#if OMPT_SUPPORT
523 if (ompt_status & ompt_status_track) {
524 if ((ompt_status == ompt_status_track_callback) &&
525 ompt_callbacks.ompt_callback(ompt_event_parallel_end)) {
526 ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
527 ompt_callbacks.ompt_callback(ompt_event_parallel_end)(
528 parallel_id, task_info->task_id);
529 }
530
531 thr->th.ompt_thread_info.state =
532 (((thr->th.th_team)->t.t_serialized) ?
533 ompt_state_work_serial : ompt_state_work_parallel);
534 }
535#endif
536
Jim Cownie5e8470a2013-09-27 10:38:44 +0000537 }
538}
539
540
Jim Cownie5e8470a2013-09-27 10:38:44 +0000541//
542// Loop worksharing constructs
543//
544
545//
546// The Gnu codegen passes in an exclusive upper bound for the overall range,
547// but the libguide dispatch code expects an inclusive upper bound, hence the
548// "end - incr" 5th argument to KMP_DISPATCH_INIT (and the " ub - str" 11th
549// argument to __kmp_GOMP_fork_call).
550//
551// Conversely, KMP_DISPATCH_NEXT returns and inclusive upper bound in *p_ub,
552// but the Gnu codegen expects an excluside upper bound, so the adjustment
553// "*p_ub += stride" compenstates for the discrepancy.
554//
555// Correction: the gnu codegen always adjusts the upper bound by +-1, not the
556// stride value. We adjust the dispatch parameters accordingly (by +-1), but
557// we still adjust p_ub by the actual stride value.
558//
559// The "runtime" versions do not take a chunk_sz parameter.
560//
561// The profile lib cannot support construct checking of unordered loops that
562// are predetermined by the compiler to be statically scheduled, as the gcc
563// codegen will not always emit calls to GOMP_loop_static_next() to get the
564// next iteration. Instead, it emits inline code to call omp_get_thread_num()
565// num and calculate the iteration space using the result. It doesn't do this
566// with ordered static loop, so they can be checked.
567//
568
569#define LOOP_START(func,schedule) \
570 int func (long lb, long ub, long str, long chunk_sz, long *p_lb, \
571 long *p_ub) \
572 { \
573 int status; \
574 long stride; \
575 int gtid = __kmp_entry_gtid(); \
576 MKLOC(loc, #func); \
577 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
578 gtid, lb, ub, str, chunk_sz )); \
579 \
580 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
581 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
582 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
583 (schedule) != kmp_sch_static); \
584 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
585 (kmp_int *)p_ub, (kmp_int *)&stride); \
586 if (status) { \
587 KMP_DEBUG_ASSERT(stride == str); \
588 *p_ub += (str > 0) ? 1 : -1; \
589 } \
590 } \
591 else { \
592 status = 0; \
593 } \
594 \
595 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
596 gtid, *p_lb, *p_ub, status)); \
597 return status; \
598 }
599
600
601#define LOOP_RUNTIME_START(func,schedule) \
602 int func (long lb, long ub, long str, long *p_lb, long *p_ub) \
603 { \
604 int status; \
605 long stride; \
606 long chunk_sz = 0; \
607 int gtid = __kmp_entry_gtid(); \
608 MKLOC(loc, #func); \
609 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n", \
610 gtid, lb, ub, str, chunk_sz )); \
611 \
612 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
613 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
614 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, TRUE); \
615 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
616 (kmp_int *)p_ub, (kmp_int *)&stride); \
617 if (status) { \
618 KMP_DEBUG_ASSERT(stride == str); \
619 *p_ub += (str > 0) ? 1 : -1; \
620 } \
621 } \
622 else { \
623 status = 0; \
624 } \
625 \
626 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
627 gtid, *p_lb, *p_ub, status)); \
628 return status; \
629 }
630
631
632#define LOOP_NEXT(func,fini_code) \
633 int func(long *p_lb, long *p_ub) \
634 { \
635 int status; \
636 long stride; \
637 int gtid = __kmp_get_gtid(); \
638 MKLOC(loc, #func); \
639 KA_TRACE(20, ( #func ": T#%d\n", gtid)); \
640 \
641 fini_code \
642 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
643 (kmp_int *)p_ub, (kmp_int *)&stride); \
644 if (status) { \
645 *p_ub += (stride > 0) ? 1 : -1; \
646 } \
647 \
648 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, stride 0x%lx, " \
649 "returning %d\n", gtid, *p_lb, *p_ub, stride, status)); \
650 return status; \
651 }
652
653
Jim Cownie181b4bb2013-12-23 17:28:57 +0000654LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_STATIC_START), kmp_sch_static)
655LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT), {})
656LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START), kmp_sch_dynamic_chunked)
657LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT), {})
658LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_GUIDED_START), kmp_sch_guided_chunked)
659LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT), {})
660LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_START), kmp_sch_runtime)
661LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT), {})
Jim Cownie5e8470a2013-09-27 10:38:44 +0000662
Jim Cownie181b4bb2013-12-23 17:28:57 +0000663LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START), kmp_ord_static)
664LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000665 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000666LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START), kmp_ord_dynamic_chunked)
667LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000668 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000669LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START), kmp_ord_guided_chunked)
670LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000671 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000672LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START), kmp_ord_runtime)
673LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000674 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
675
676
677void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000678xexpand(KMP_API_NAME_GOMP_LOOP_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000679{
680 int gtid = __kmp_get_gtid();
681 KA_TRACE(20, ("GOMP_loop_end: T#%d\n", gtid))
682
683 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
684
685 KA_TRACE(20, ("GOMP_loop_end exit: T#%d\n", gtid))
686}
687
688
689void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000690xexpand(KMP_API_NAME_GOMP_LOOP_END_NOWAIT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000691{
692 KA_TRACE(20, ("GOMP_loop_end_nowait: T#%d\n", __kmp_get_gtid()))
693}
694
695
Jim Cownie5e8470a2013-09-27 10:38:44 +0000696//
697// Unsigned long long loop worksharing constructs
698//
699// These are new with gcc 4.4
700//
701
702#define LOOP_START_ULL(func,schedule) \
703 int func (int up, unsigned long long lb, unsigned long long ub, \
704 unsigned long long str, unsigned long long chunk_sz, \
705 unsigned long long *p_lb, unsigned long long *p_ub) \
706 { \
707 int status; \
708 long long str2 = up ? ((long long)str) : -((long long)str); \
709 long long stride; \
710 int gtid = __kmp_entry_gtid(); \
711 MKLOC(loc, #func); \
712 \
713 KA_TRACE(20, ( #func ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
714 gtid, up, lb, ub, str, chunk_sz )); \
715 \
716 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
717 KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
718 (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, \
719 (schedule) != kmp_sch_static); \
720 status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, \
721 (kmp_uint64 *)p_lb, (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
722 if (status) { \
723 KMP_DEBUG_ASSERT(stride == str2); \
724 *p_ub += (str > 0) ? 1 : -1; \
725 } \
726 } \
727 else { \
728 status = 0; \
729 } \
730 \
731 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
732 gtid, *p_lb, *p_ub, status)); \
733 return status; \
734 }
735
736
737#define LOOP_RUNTIME_START_ULL(func,schedule) \
738 int func (int up, unsigned long long lb, unsigned long long ub, \
739 unsigned long long str, unsigned long long *p_lb, \
740 unsigned long long *p_ub) \
741 { \
742 int status; \
743 long long str2 = up ? ((long long)str) : -((long long)str); \
744 unsigned long long stride; \
745 unsigned long long chunk_sz = 0; \
746 int gtid = __kmp_entry_gtid(); \
747 MKLOC(loc, #func); \
748 \
749 KA_TRACE(20, ( #func ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
750 gtid, up, lb, ub, str, chunk_sz )); \
751 \
752 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
753 KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
754 (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, TRUE); \
755 status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, \
756 (kmp_uint64 *)p_lb, (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
757 if (status) { \
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000758 KMP_DEBUG_ASSERT((long long)stride == str2); \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000759 *p_ub += (str > 0) ? 1 : -1; \
760 } \
761 } \
762 else { \
763 status = 0; \
764 } \
765 \
766 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
767 gtid, *p_lb, *p_ub, status)); \
768 return status; \
769 }
770
771
772#define LOOP_NEXT_ULL(func,fini_code) \
773 int func(unsigned long long *p_lb, unsigned long long *p_ub) \
774 { \
775 int status; \
776 long long stride; \
777 int gtid = __kmp_get_gtid(); \
778 MKLOC(loc, #func); \
779 KA_TRACE(20, ( #func ": T#%d\n", gtid)); \
780 \
781 fini_code \
782 status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
783 (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
784 if (status) { \
785 *p_ub += (stride > 0) ? 1 : -1; \
786 } \
787 \
788 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, stride 0x%llx, " \
789 "returning %d\n", gtid, *p_lb, *p_ub, stride, status)); \
790 return status; \
791 }
792
793
Jim Cownie181b4bb2013-12-23 17:28:57 +0000794LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START), kmp_sch_static)
795LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT), {})
796LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START), kmp_sch_dynamic_chunked)
797LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT), {})
798LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START), kmp_sch_guided_chunked)
799LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT), {})
800LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START), kmp_sch_runtime)
801LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT), {})
Jim Cownie5e8470a2013-09-27 10:38:44 +0000802
Jim Cownie181b4bb2013-12-23 17:28:57 +0000803LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START), kmp_ord_static)
804LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000805 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000806LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START), kmp_ord_dynamic_chunked)
807LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000808 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000809LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START), kmp_ord_guided_chunked)
810LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000811 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000812LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START), kmp_ord_runtime)
813LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000814 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
815
816
Jim Cownie5e8470a2013-09-27 10:38:44 +0000817//
818// Combined parallel / loop worksharing constructs
819//
820// There are no ull versions (yet).
821//
822
823#define PARALLEL_LOOP_START(func, schedule) \
824 void func (void (*task) (void *), void *data, unsigned num_threads, \
825 long lb, long ub, long str, long chunk_sz) \
826 { \
827 int gtid = __kmp_entry_gtid(); \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000828 MKLOC(loc, #func); \
829 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
830 gtid, lb, ub, str, chunk_sz )); \
831 \
832 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) { \
833 if (num_threads != 0) { \
834 __kmp_push_num_threads(&loc, gtid, num_threads); \
835 } \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000836 __kmp_GOMP_fork_call(&loc, gtid, task, \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000837 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, \
838 task, data, num_threads, &loc, (schedule), lb, \
839 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz); \
840 } \
841 else { \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000842 __kmp_GOMP_serialized_parallel(&loc, gtid, task); \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000843 } \
844 \
845 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
846 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
847 (schedule) != kmp_sch_static); \
848 \
849 KA_TRACE(20, ( #func " exit: T#%d\n", gtid)); \
850 }
851
852
Jim Cownie181b4bb2013-12-23 17:28:57 +0000853PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START), kmp_sch_static)
854PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START), kmp_sch_dynamic_chunked)
855PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START), kmp_sch_guided_chunked)
856PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START), kmp_sch_runtime)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000857
858
Jim Cownie5e8470a2013-09-27 10:38:44 +0000859//
860// Tasking constructs
861//
862
863void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000864xexpand(KMP_API_NAME_GOMP_TASK)(void (*func)(void *), void *data, void (*copy_func)(void *, void *),
Jim Cownie5e8470a2013-09-27 10:38:44 +0000865 long arg_size, long arg_align, int if_cond, unsigned gomp_flags)
866{
867 MKLOC(loc, "GOMP_task");
868 int gtid = __kmp_entry_gtid();
869 kmp_int32 flags = 0;
870 kmp_tasking_flags_t *input_flags = (kmp_tasking_flags_t *) & flags;
871
872 KA_TRACE(20, ("GOMP_task: T#%d\n", gtid));
873
874 // The low-order bit is the "tied" flag
875 if (gomp_flags & 1) {
876 input_flags->tiedness = 1;
877 }
878 input_flags->native = 1;
879 // __kmp_task_alloc() sets up all other flags
880
881 if (! if_cond) {
882 arg_size = 0;
883 }
884
885 kmp_task_t *task = __kmp_task_alloc(&loc, gtid, input_flags,
886 sizeof(kmp_task_t), arg_size ? arg_size + arg_align - 1 : 0,
887 (kmp_routine_entry_t)func);
888
889 if (arg_size > 0) {
890 if (arg_align > 0) {
891 task->shareds = (void *)((((size_t)task->shareds)
892 + arg_align - 1) / arg_align * arg_align);
893 }
894 //else error??
895
896 if (copy_func) {
897 (*copy_func)(task->shareds, data);
898 }
899 else {
Andrey Churbanov74bf17b2015-04-02 13:27:08 +0000900 KMP_MEMCPY(task->shareds, data, arg_size);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000901 }
902 }
903
904 if (if_cond) {
905 __kmpc_omp_task(&loc, gtid, task);
906 }
907 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000908#if OMPT_SUPPORT
909 ompt_thread_info_t oldInfo;
910 kmp_info_t *thread;
911 kmp_taskdata_t *taskdata;
912 if (ompt_status & ompt_status_track) {
913 // Store the threads states and restore them after the task
914 thread = __kmp_threads[ gtid ];
915 taskdata = KMP_TASK_TO_TASKDATA(task);
916 oldInfo = thread->th.ompt_thread_info;
917 thread->th.ompt_thread_info.wait_id = 0;
918 thread->th.ompt_thread_info.state = ompt_state_work_parallel;
919 taskdata->ompt_task_info.frame.exit_runtime_frame =
920 __builtin_frame_address(0);
921 }
922#endif
923
Jim Cownie5e8470a2013-09-27 10:38:44 +0000924 __kmpc_omp_task_begin_if0(&loc, gtid, task);
925 func(data);
926 __kmpc_omp_task_complete_if0(&loc, gtid, task);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000927
928#if OMPT_SUPPORT
929 if (ompt_status & ompt_status_track) {
930 thread->th.ompt_thread_info = oldInfo;
931 taskdata->ompt_task_info.frame.exit_runtime_frame = 0;
932 }
933#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000934 }
935
936 KA_TRACE(20, ("GOMP_task exit: T#%d\n", gtid));
937}
938
939
940void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000941xexpand(KMP_API_NAME_GOMP_TASKWAIT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000942{
943 MKLOC(loc, "GOMP_taskwait");
944 int gtid = __kmp_entry_gtid();
945
946 KA_TRACE(20, ("GOMP_taskwait: T#%d\n", gtid));
947
948 __kmpc_omp_taskwait(&loc, gtid);
949
950 KA_TRACE(20, ("GOMP_taskwait exit: T#%d\n", gtid));
951}
952
953
Jim Cownie5e8470a2013-09-27 10:38:44 +0000954//
955// Sections worksharing constructs
956//
957
958//
959// For the sections construct, we initialize a dynamically scheduled loop
960// worksharing construct with lb 1 and stride 1, and use the iteration #'s
961// that its returns as sections ids.
962//
963// There are no special entry points for ordered sections, so we always use
964// the dynamically scheduled workshare, even if the sections aren't ordered.
965//
966
967unsigned
Jim Cownie181b4bb2013-12-23 17:28:57 +0000968xexpand(KMP_API_NAME_GOMP_SECTIONS_START)(unsigned count)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000969{
970 int status;
971 kmp_int lb, ub, stride;
972 int gtid = __kmp_entry_gtid();
973 MKLOC(loc, "GOMP_sections_start");
974 KA_TRACE(20, ("GOMP_sections_start: T#%d\n", gtid));
975
976 KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
977
978 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
979 if (status) {
980 KMP_DEBUG_ASSERT(stride == 1);
981 KMP_DEBUG_ASSERT(lb > 0);
982 KMP_ASSERT(lb == ub);
983 }
984 else {
985 lb = 0;
986 }
987
988 KA_TRACE(20, ("GOMP_sections_start exit: T#%d returning %u\n", gtid,
989 (unsigned)lb));
990 return (unsigned)lb;
991}
992
993
994unsigned
Jim Cownie181b4bb2013-12-23 17:28:57 +0000995xexpand(KMP_API_NAME_GOMP_SECTIONS_NEXT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000996{
997 int status;
998 kmp_int lb, ub, stride;
999 int gtid = __kmp_get_gtid();
1000 MKLOC(loc, "GOMP_sections_next");
1001 KA_TRACE(20, ("GOMP_sections_next: T#%d\n", gtid));
1002
1003 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
1004 if (status) {
1005 KMP_DEBUG_ASSERT(stride == 1);
1006 KMP_DEBUG_ASSERT(lb > 0);
1007 KMP_ASSERT(lb == ub);
1008 }
1009 else {
1010 lb = 0;
1011 }
1012
1013 KA_TRACE(20, ("GOMP_sections_next exit: T#%d returning %u\n", gtid,
1014 (unsigned)lb));
1015 return (unsigned)lb;
1016}
1017
1018
1019void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001020xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START)(void (*task) (void *), void *data,
Jim Cownie5e8470a2013-09-27 10:38:44 +00001021 unsigned num_threads, unsigned count)
1022{
1023 int gtid = __kmp_entry_gtid();
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001024
1025#if OMPT_SUPPORT
1026 ompt_frame_t *parent_frame;
1027
1028 if (ompt_status & ompt_status_track) {
1029 parent_frame = __ompt_get_task_frame_internal(0);
1030 parent_frame->reenter_runtime_frame = __builtin_frame_address(0);
1031 }
1032#endif
1033
Jim Cownie5e8470a2013-09-27 10:38:44 +00001034 MKLOC(loc, "GOMP_parallel_sections_start");
1035 KA_TRACE(20, ("GOMP_parallel_sections_start: T#%d\n", gtid));
1036
1037 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1038 if (num_threads != 0) {
1039 __kmp_push_num_threads(&loc, gtid, num_threads);
1040 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001041 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie5e8470a2013-09-27 10:38:44 +00001042 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, task, data,
1043 num_threads, &loc, kmp_nm_dynamic_chunked, (kmp_int)1,
1044 (kmp_int)count, (kmp_int)1, (kmp_int)1);
1045 }
1046 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001047 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie5e8470a2013-09-27 10:38:44 +00001048 }
1049
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001050#if OMPT_SUPPORT
1051 if (ompt_status & ompt_status_track) {
1052 parent_frame->reenter_runtime_frame = NULL;
1053 }
1054#endif
1055
Jim Cownie5e8470a2013-09-27 10:38:44 +00001056 KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1057
1058 KA_TRACE(20, ("GOMP_parallel_sections_start exit: T#%d\n", gtid));
1059}
1060
1061
1062void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001063xexpand(KMP_API_NAME_GOMP_SECTIONS_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +00001064{
1065 int gtid = __kmp_get_gtid();
1066 KA_TRACE(20, ("GOMP_sections_end: T#%d\n", gtid))
1067
1068 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
1069
1070 KA_TRACE(20, ("GOMP_sections_end exit: T#%d\n", gtid))
1071}
1072
1073
1074void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001075xexpand(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +00001076{
1077 KA_TRACE(20, ("GOMP_sections_end_nowait: T#%d\n", __kmp_get_gtid()))
1078}
1079
Jim Cownie181b4bb2013-12-23 17:28:57 +00001080// libgomp has an empty function for GOMP_taskyield as of 2013-10-10
1081void
1082xexpand(KMP_API_NAME_GOMP_TASKYIELD)(void)
1083{
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001084 KA_TRACE(20, ("GOMP_taskyield: T#%d\n", __kmp_get_gtid()))
1085 return;
Jim Cownie181b4bb2013-12-23 17:28:57 +00001086}
1087
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001088#if OMP_40_ENABLED // these are new GOMP_4.0 entry points
1089
1090void
1091xexpand(KMP_API_NAME_GOMP_PARALLEL)(void (*task)(void *), void *data, unsigned num_threads, unsigned int flags)
1092{
1093 int gtid = __kmp_entry_gtid();
1094 MKLOC(loc, "GOMP_parallel");
1095 KA_TRACE(20, ("GOMP_parallel: T#%d\n", gtid));
1096
1097 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1098 if (num_threads != 0) {
1099 __kmp_push_num_threads(&loc, gtid, num_threads);
1100 }
1101 if(flags != 0) {
1102 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
1103 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001104 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001105 (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task, data);
1106 }
1107 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001108 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001109 }
1110 task(data);
1111 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
1112}
1113
1114void
1115xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS)(void (*task) (void *), void *data,
1116 unsigned num_threads, unsigned count, unsigned flags)
1117{
1118 int gtid = __kmp_entry_gtid();
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001119 MKLOC(loc, "GOMP_parallel_sections");
1120 KA_TRACE(20, ("GOMP_parallel_sections: T#%d\n", gtid));
1121
1122 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1123 if (num_threads != 0) {
1124 __kmp_push_num_threads(&loc, gtid, num_threads);
1125 }
1126 if(flags != 0) {
1127 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
1128 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001129 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001130 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, task, data,
1131 num_threads, &loc, kmp_nm_dynamic_chunked, (kmp_int)1,
1132 (kmp_int)count, (kmp_int)1, (kmp_int)1);
1133 }
1134 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001135 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001136 }
1137
1138 KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1139
1140 task(data);
1141 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
1142 KA_TRACE(20, ("GOMP_parallel_sections exit: T#%d\n", gtid));
1143}
1144
1145#define PARALLEL_LOOP(func, schedule) \
1146 void func (void (*task) (void *), void *data, unsigned num_threads, \
1147 long lb, long ub, long str, long chunk_sz, unsigned flags) \
1148 { \
1149 int gtid = __kmp_entry_gtid(); \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001150 MKLOC(loc, #func); \
1151 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
1152 gtid, lb, ub, str, chunk_sz )); \
1153 \
1154 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) { \
1155 if (num_threads != 0) { \
1156 __kmp_push_num_threads(&loc, gtid, num_threads); \
1157 } \
1158 if (flags != 0) { \
1159 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags); \
1160 } \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001161 __kmp_GOMP_fork_call(&loc, gtid, task, \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001162 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, \
1163 task, data, num_threads, &loc, (schedule), lb, \
1164 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz); \
1165 } \
1166 else { \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001167 __kmp_GOMP_serialized_parallel(&loc, gtid, task); \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001168 } \
1169 \
1170 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
1171 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
1172 (schedule) != kmp_sch_static); \
1173 task(data); \
1174 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(); \
1175 \
1176 KA_TRACE(20, ( #func " exit: T#%d\n", gtid)); \
1177 }
1178
1179PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC), kmp_sch_static)
1180PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC), kmp_sch_dynamic_chunked)
1181PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED), kmp_sch_guided_chunked)
1182PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME), kmp_sch_runtime)
1183
1184
1185void
1186xexpand(KMP_API_NAME_GOMP_TASKGROUP_START)(void)
1187{
1188 int gtid = __kmp_get_gtid();
1189 MKLOC(loc, "GOMP_taskgroup_start");
1190 KA_TRACE(20, ("GOMP_taskgroup_start: T#%d\n", gtid));
1191
1192 __kmpc_taskgroup(&loc, gtid);
1193
1194 return;
1195}
1196
1197void
1198xexpand(KMP_API_NAME_GOMP_TASKGROUP_END)(void)
1199{
1200 int gtid = __kmp_get_gtid();
1201 MKLOC(loc, "GOMP_taskgroup_end");
1202 KA_TRACE(20, ("GOMP_taskgroup_end: T#%d\n", gtid));
1203
1204 __kmpc_end_taskgroup(&loc, gtid);
1205
1206 return;
1207}
1208
1209#ifndef KMP_DEBUG
1210static
1211#endif /* KMP_DEBUG */
Jonathan Peyton66338292015-06-01 02:37:28 +00001212kmp_int32 __kmp_gomp_to_omp_cancellation_kind(int gomp_kind) {
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001213 kmp_int32 cncl_kind = 0;
1214 switch(gomp_kind) {
1215 case 1:
1216 cncl_kind = cancel_parallel;
1217 break;
1218 case 2:
1219 cncl_kind = cancel_loop;
1220 break;
1221 case 4:
1222 cncl_kind = cancel_sections;
1223 break;
1224 case 8:
1225 cncl_kind = cancel_taskgroup;
1226 break;
1227 }
1228 return cncl_kind;
1229}
1230
1231bool
1232xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(int which)
1233{
1234 if(__kmp_omp_cancellation) {
1235 KMP_FATAL(NoGompCancellation);
1236 }
1237 int gtid = __kmp_get_gtid();
1238 MKLOC(loc, "GOMP_cancellation_point");
1239 KA_TRACE(20, ("GOMP_cancellation_point: T#%d\n", gtid));
1240
Jonathan Peyton66338292015-06-01 02:37:28 +00001241 kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001242
1243 return __kmpc_cancellationpoint(&loc, gtid, cncl_kind);
1244}
1245
1246bool
1247xexpand(KMP_API_NAME_GOMP_BARRIER_CANCEL)(void)
1248{
1249 if(__kmp_omp_cancellation) {
1250 KMP_FATAL(NoGompCancellation);
1251 }
1252 KMP_FATAL(NoGompCancellation);
1253 int gtid = __kmp_get_gtid();
1254 MKLOC(loc, "GOMP_barrier_cancel");
1255 KA_TRACE(20, ("GOMP_barrier_cancel: T#%d\n", gtid));
1256
1257 return __kmpc_cancel_barrier(&loc, gtid);
1258}
1259
1260bool
1261xexpand(KMP_API_NAME_GOMP_CANCEL)(int which, bool do_cancel)
1262{
1263 if(__kmp_omp_cancellation) {
1264 KMP_FATAL(NoGompCancellation);
1265 } else {
1266 return FALSE;
1267 }
1268
1269 int gtid = __kmp_get_gtid();
1270 MKLOC(loc, "GOMP_cancel");
1271 KA_TRACE(20, ("GOMP_cancel: T#%d\n", gtid));
1272
Jonathan Peyton66338292015-06-01 02:37:28 +00001273 kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001274
1275 if(do_cancel == FALSE) {
1276 return xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(which);
1277 } else {
1278 return __kmpc_cancel(&loc, gtid, cncl_kind);
1279 }
1280}
1281
1282bool
1283xexpand(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL)(void)
1284{
1285 if(__kmp_omp_cancellation) {
1286 KMP_FATAL(NoGompCancellation);
1287 }
1288 int gtid = __kmp_get_gtid();
1289 MKLOC(loc, "GOMP_sections_end_cancel");
1290 KA_TRACE(20, ("GOMP_sections_end_cancel: T#%d\n", gtid));
1291
1292 return __kmpc_cancel_barrier(&loc, gtid);
1293}
1294
1295bool
1296xexpand(KMP_API_NAME_GOMP_LOOP_END_CANCEL)(void)
1297{
1298 if(__kmp_omp_cancellation) {
1299 KMP_FATAL(NoGompCancellation);
1300 }
1301 int gtid = __kmp_get_gtid();
1302 MKLOC(loc, "GOMP_loop_end_cancel");
1303 KA_TRACE(20, ("GOMP_loop_end_cancel: T#%d\n", gtid));
1304
1305 return __kmpc_cancel_barrier(&loc, gtid);
1306}
1307
1308// All target functions are empty as of 2014-05-29
1309void
1310xexpand(KMP_API_NAME_GOMP_TARGET)(int device, void (*fn) (void *), const void *openmp_target,
1311 size_t mapnum, void **hostaddrs, size_t *sizes, unsigned char *kinds)
1312{
1313 return;
1314}
1315
1316void
1317xexpand(KMP_API_NAME_GOMP_TARGET_DATA)(int device, const void *openmp_target, size_t mapnum,
1318 void **hostaddrs, size_t *sizes, unsigned char *kinds)
1319{
1320 return;
1321}
1322
1323void
1324xexpand(KMP_API_NAME_GOMP_TARGET_END_DATA)(void)
1325{
1326 return;
1327}
1328
1329void
1330xexpand(KMP_API_NAME_GOMP_TARGET_UPDATE)(int device, const void *openmp_target, size_t mapnum,
1331 void **hostaddrs, size_t *sizes, unsigned char *kinds)
1332{
1333 return;
1334}
1335
1336void
1337xexpand(KMP_API_NAME_GOMP_TEAMS)(unsigned int num_teams, unsigned int thread_limit)
1338{
1339 return;
1340}
1341#endif // OMP_40_ENABLED
1342
1343
Jim Cownie181b4bb2013-12-23 17:28:57 +00001344/*
1345 The following sections of code create aliases for the GOMP_* functions,
1346 then create versioned symbols using the assembler directive .symver.
1347 This is only pertinent for ELF .so library
1348 xaliasify and xversionify are defined in kmp_ftn_os.h
1349*/
1350
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001351#ifdef KMP_USE_VERSION_SYMBOLS
Jim Cownie181b4bb2013-12-23 17:28:57 +00001352
1353// GOMP_1.0 aliases
1354xaliasify(KMP_API_NAME_GOMP_ATOMIC_END, 10);
1355xaliasify(KMP_API_NAME_GOMP_ATOMIC_START, 10);
1356xaliasify(KMP_API_NAME_GOMP_BARRIER, 10);
1357xaliasify(KMP_API_NAME_GOMP_CRITICAL_END, 10);
1358xaliasify(KMP_API_NAME_GOMP_CRITICAL_NAME_END, 10);
1359xaliasify(KMP_API_NAME_GOMP_CRITICAL_NAME_START, 10);
1360xaliasify(KMP_API_NAME_GOMP_CRITICAL_START, 10);
1361xaliasify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT, 10);
1362xaliasify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START, 10);
1363xaliasify(KMP_API_NAME_GOMP_LOOP_END, 10);
1364xaliasify(KMP_API_NAME_GOMP_LOOP_END_NOWAIT, 10);
1365xaliasify(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT, 10);
1366xaliasify(KMP_API_NAME_GOMP_LOOP_GUIDED_START, 10);
1367xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT, 10);
1368xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START, 10);
1369xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT, 10);
1370xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START, 10);
1371xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT, 10);
1372xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START, 10);
1373xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT, 10);
1374xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START, 10);
1375xaliasify(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT, 10);
1376xaliasify(KMP_API_NAME_GOMP_LOOP_RUNTIME_START, 10);
1377xaliasify(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT, 10);
1378xaliasify(KMP_API_NAME_GOMP_LOOP_STATIC_START, 10);
1379xaliasify(KMP_API_NAME_GOMP_ORDERED_END, 10);
1380xaliasify(KMP_API_NAME_GOMP_ORDERED_START, 10);
1381xaliasify(KMP_API_NAME_GOMP_PARALLEL_END, 10);
1382xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START, 10);
1383xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START, 10);
1384xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START, 10);
1385xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START, 10);
1386xaliasify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START, 10);
1387xaliasify(KMP_API_NAME_GOMP_PARALLEL_START, 10);
1388xaliasify(KMP_API_NAME_GOMP_SECTIONS_END, 10);
1389xaliasify(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT, 10);
1390xaliasify(KMP_API_NAME_GOMP_SECTIONS_NEXT, 10);
1391xaliasify(KMP_API_NAME_GOMP_SECTIONS_START, 10);
1392xaliasify(KMP_API_NAME_GOMP_SINGLE_COPY_END, 10);
1393xaliasify(KMP_API_NAME_GOMP_SINGLE_COPY_START, 10);
1394xaliasify(KMP_API_NAME_GOMP_SINGLE_START, 10);
1395
1396// GOMP_2.0 aliases
Jim Cownie181b4bb2013-12-23 17:28:57 +00001397xaliasify(KMP_API_NAME_GOMP_TASK, 20);
1398xaliasify(KMP_API_NAME_GOMP_TASKWAIT, 20);
Jim Cownie181b4bb2013-12-23 17:28:57 +00001399xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT, 20);
1400xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START, 20);
1401xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT, 20);
1402xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START, 20);
1403xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT, 20);
1404xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START, 20);
1405xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT, 20);
1406xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START, 20);
1407xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT, 20);
1408xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START, 20);
1409xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT, 20);
1410xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START, 20);
1411xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT, 20);
1412xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START, 20);
1413xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT, 20);
1414xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START, 20);
1415
1416// GOMP_3.0 aliases
1417xaliasify(KMP_API_NAME_GOMP_TASKYIELD, 30);
1418
1419// GOMP_4.0 aliases
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001420// The GOMP_parallel* entry points below aren't OpenMP 4.0 related.
1421#if OMP_40_ENABLED
1422xaliasify(KMP_API_NAME_GOMP_PARALLEL, 40);
1423xaliasify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS, 40);
1424xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC, 40);
1425xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED, 40);
1426xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME, 40);
1427xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC, 40);
1428xaliasify(KMP_API_NAME_GOMP_TASKGROUP_START, 40);
1429xaliasify(KMP_API_NAME_GOMP_TASKGROUP_END, 40);
1430xaliasify(KMP_API_NAME_GOMP_BARRIER_CANCEL, 40);
1431xaliasify(KMP_API_NAME_GOMP_CANCEL, 40);
1432xaliasify(KMP_API_NAME_GOMP_CANCELLATION_POINT, 40);
1433xaliasify(KMP_API_NAME_GOMP_LOOP_END_CANCEL, 40);
1434xaliasify(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL, 40);
1435xaliasify(KMP_API_NAME_GOMP_TARGET, 40);
1436xaliasify(KMP_API_NAME_GOMP_TARGET_DATA, 40);
1437xaliasify(KMP_API_NAME_GOMP_TARGET_END_DATA, 40);
1438xaliasify(KMP_API_NAME_GOMP_TARGET_UPDATE, 40);
1439xaliasify(KMP_API_NAME_GOMP_TEAMS, 40);
1440#endif
Jim Cownie181b4bb2013-12-23 17:28:57 +00001441
1442// GOMP_1.0 versioned symbols
1443xversionify(KMP_API_NAME_GOMP_ATOMIC_END, 10, "GOMP_1.0");
1444xversionify(KMP_API_NAME_GOMP_ATOMIC_START, 10, "GOMP_1.0");
1445xversionify(KMP_API_NAME_GOMP_BARRIER, 10, "GOMP_1.0");
1446xversionify(KMP_API_NAME_GOMP_CRITICAL_END, 10, "GOMP_1.0");
1447xversionify(KMP_API_NAME_GOMP_CRITICAL_NAME_END, 10, "GOMP_1.0");
1448xversionify(KMP_API_NAME_GOMP_CRITICAL_NAME_START, 10, "GOMP_1.0");
1449xversionify(KMP_API_NAME_GOMP_CRITICAL_START, 10, "GOMP_1.0");
1450xversionify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT, 10, "GOMP_1.0");
1451xversionify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START, 10, "GOMP_1.0");
1452xversionify(KMP_API_NAME_GOMP_LOOP_END, 10, "GOMP_1.0");
1453xversionify(KMP_API_NAME_GOMP_LOOP_END_NOWAIT, 10, "GOMP_1.0");
1454xversionify(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT, 10, "GOMP_1.0");
1455xversionify(KMP_API_NAME_GOMP_LOOP_GUIDED_START, 10, "GOMP_1.0");
1456xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT, 10, "GOMP_1.0");
1457xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START, 10, "GOMP_1.0");
1458xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT, 10, "GOMP_1.0");
1459xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START, 10, "GOMP_1.0");
1460xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT, 10, "GOMP_1.0");
1461xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START, 10, "GOMP_1.0");
1462xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT, 10, "GOMP_1.0");
1463xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START, 10, "GOMP_1.0");
1464xversionify(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT, 10, "GOMP_1.0");
1465xversionify(KMP_API_NAME_GOMP_LOOP_RUNTIME_START, 10, "GOMP_1.0");
1466xversionify(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT, 10, "GOMP_1.0");
1467xversionify(KMP_API_NAME_GOMP_LOOP_STATIC_START, 10, "GOMP_1.0");
1468xversionify(KMP_API_NAME_GOMP_ORDERED_END, 10, "GOMP_1.0");
1469xversionify(KMP_API_NAME_GOMP_ORDERED_START, 10, "GOMP_1.0");
1470xversionify(KMP_API_NAME_GOMP_PARALLEL_END, 10, "GOMP_1.0");
1471xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START, 10, "GOMP_1.0");
1472xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START, 10, "GOMP_1.0");
1473xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START, 10, "GOMP_1.0");
1474xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START, 10, "GOMP_1.0");
1475xversionify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START, 10, "GOMP_1.0");
1476xversionify(KMP_API_NAME_GOMP_PARALLEL_START, 10, "GOMP_1.0");
1477xversionify(KMP_API_NAME_GOMP_SECTIONS_END, 10, "GOMP_1.0");
1478xversionify(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT, 10, "GOMP_1.0");
1479xversionify(KMP_API_NAME_GOMP_SECTIONS_NEXT, 10, "GOMP_1.0");
1480xversionify(KMP_API_NAME_GOMP_SECTIONS_START, 10, "GOMP_1.0");
1481xversionify(KMP_API_NAME_GOMP_SINGLE_COPY_END, 10, "GOMP_1.0");
1482xversionify(KMP_API_NAME_GOMP_SINGLE_COPY_START, 10, "GOMP_1.0");
1483xversionify(KMP_API_NAME_GOMP_SINGLE_START, 10, "GOMP_1.0");
1484
1485// GOMP_2.0 versioned symbols
Jim Cownie181b4bb2013-12-23 17:28:57 +00001486xversionify(KMP_API_NAME_GOMP_TASK, 20, "GOMP_2.0");
1487xversionify(KMP_API_NAME_GOMP_TASKWAIT, 20, "GOMP_2.0");
Jim Cownie181b4bb2013-12-23 17:28:57 +00001488xversionify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT, 20, "GOMP_2.0");
1489xversionify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START, 20, "GOMP_2.0");
1490xversionify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT, 20, "GOMP_2.0");
1491xversionify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START, 20, "GOMP_2.0");
1492xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT, 20, "GOMP_2.0");
1493xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START, 20, "GOMP_2.0");
1494xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT, 20, "GOMP_2.0");
1495xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START, 20, "GOMP_2.0");
1496xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT, 20, "GOMP_2.0");
1497xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START, 20, "GOMP_2.0");
1498xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT, 20, "GOMP_2.0");
1499xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START, 20, "GOMP_2.0");
1500xversionify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT, 20, "GOMP_2.0");
1501xversionify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START, 20, "GOMP_2.0");
1502xversionify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT, 20, "GOMP_2.0");
1503xversionify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START, 20, "GOMP_2.0");
1504
1505// GOMP_3.0 versioned symbols
1506xversionify(KMP_API_NAME_GOMP_TASKYIELD, 30, "GOMP_3.0");
1507
1508// GOMP_4.0 versioned symbols
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001509#if OMP_40_ENABLED
1510xversionify(KMP_API_NAME_GOMP_PARALLEL, 40, "GOMP_4.0");
1511xversionify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS, 40, "GOMP_4.0");
1512xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC, 40, "GOMP_4.0");
1513xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED, 40, "GOMP_4.0");
1514xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME, 40, "GOMP_4.0");
1515xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC, 40, "GOMP_4.0");
1516xversionify(KMP_API_NAME_GOMP_TASKGROUP_START, 40, "GOMP_4.0");
1517xversionify(KMP_API_NAME_GOMP_TASKGROUP_END, 40, "GOMP_4.0");
1518xversionify(KMP_API_NAME_GOMP_BARRIER_CANCEL, 40, "GOMP_4.0");
1519xversionify(KMP_API_NAME_GOMP_CANCEL, 40, "GOMP_4.0");
1520xversionify(KMP_API_NAME_GOMP_CANCELLATION_POINT, 40, "GOMP_4.0");
1521xversionify(KMP_API_NAME_GOMP_LOOP_END_CANCEL, 40, "GOMP_4.0");
1522xversionify(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL, 40, "GOMP_4.0");
1523xversionify(KMP_API_NAME_GOMP_TARGET, 40, "GOMP_4.0");
1524xversionify(KMP_API_NAME_GOMP_TARGET_DATA, 40, "GOMP_4.0");
1525xversionify(KMP_API_NAME_GOMP_TARGET_END_DATA, 40, "GOMP_4.0");
1526xversionify(KMP_API_NAME_GOMP_TARGET_UPDATE, 40, "GOMP_4.0");
1527xversionify(KMP_API_NAME_GOMP_TEAMS, 40, "GOMP_4.0");
1528#endif
Jim Cownie181b4bb2013-12-23 17:28:57 +00001529
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001530#endif // KMP_USE_VERSION_SYMBOLS
Jim Cownie181b4bb2013-12-23 17:28:57 +00001531
Jim Cownie5e8470a2013-09-27 10:38:44 +00001532#ifdef __cplusplus
1533 } //extern "C"
1534#endif // __cplusplus
1535
1536