1 /*
2  * kmp_gsupport.cpp
3  */
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 
16 #include "kmp.h"
17 #include "kmp_atomic.h"
18 
19 #if OMPT_SUPPORT
20 #include "ompt-specific.h"
21 #endif
22 
23 #ifdef __cplusplus
24     extern "C" {
25 #endif // __cplusplus
26 
27 #define MKLOC(loc,routine) \
28     static ident_t (loc) = {0, KMP_IDENT_KMPC, 0, 0, ";unknown;unknown;0;0;;" };
29 
30 #include "kmp_ftn_os.h"
31 
32 void
33 xexpand(KMP_API_NAME_GOMP_BARRIER)(void)
34 {
35     int gtid = __kmp_entry_gtid();
36     MKLOC(loc, "GOMP_barrier");
37     KA_TRACE(20, ("GOMP_barrier: T#%d\n", gtid));
38 #if OMPT_SUPPORT && OMPT_TRACE
39     ompt_frame_t * ompt_frame;
40     if (ompt_enabled ) {
41         ompt_frame = __ompt_get_task_frame_internal(0);
42         ompt_frame->reenter_runtime_frame = __builtin_frame_address(1);
43     }
44 #endif
45     __kmpc_barrier(&loc, gtid);
46 }
47 
48 
49 //
50 // Mutual exclusion
51 //
52 
53 //
54 // The symbol that icc/ifort generates for unnamed for unnamed critical
55 // sections - .gomp_critical_user_ - is defined using .comm in any objects
56 // reference it.  We can't reference it directly here in C code, as the
57 // symbol contains a ".".
58 //
59 // The RTL contains an assembly language definition of .gomp_critical_user_
60 // with another symbol __kmp_unnamed_critical_addr initialized with it's
61 // address.
62 //
63 extern kmp_critical_name *__kmp_unnamed_critical_addr;
64 
65 
66 void
67 xexpand(KMP_API_NAME_GOMP_CRITICAL_START)(void)
68 {
69     int gtid = __kmp_entry_gtid();
70     MKLOC(loc, "GOMP_critical_start");
71     KA_TRACE(20, ("GOMP_critical_start: T#%d\n", gtid));
72     __kmpc_critical(&loc, gtid, __kmp_unnamed_critical_addr);
73 }
74 
75 
76 void
77 xexpand(KMP_API_NAME_GOMP_CRITICAL_END)(void)
78 {
79     int gtid = __kmp_get_gtid();
80     MKLOC(loc, "GOMP_critical_end");
81     KA_TRACE(20, ("GOMP_critical_end: T#%d\n", gtid));
82     __kmpc_end_critical(&loc, gtid, __kmp_unnamed_critical_addr);
83 }
84 
85 
86 void
87 xexpand(KMP_API_NAME_GOMP_CRITICAL_NAME_START)(void **pptr)
88 {
89     int gtid = __kmp_entry_gtid();
90     MKLOC(loc, "GOMP_critical_name_start");
91     KA_TRACE(20, ("GOMP_critical_name_start: T#%d\n", gtid));
92     __kmpc_critical(&loc, gtid, (kmp_critical_name *)pptr);
93 }
94 
95 
96 void
97 xexpand(KMP_API_NAME_GOMP_CRITICAL_NAME_END)(void **pptr)
98 {
99     int gtid = __kmp_get_gtid();
100     MKLOC(loc, "GOMP_critical_name_end");
101     KA_TRACE(20, ("GOMP_critical_name_end: T#%d\n", gtid));
102     __kmpc_end_critical(&loc, gtid, (kmp_critical_name *)pptr);
103 }
104 
105 
106 //
107 // The Gnu codegen tries to use locked operations to perform atomic updates
108 // inline.  If it can't, then it calls GOMP_atomic_start() before performing
109 // the update and GOMP_atomic_end() afterward, regardless of the data type.
110 //
111 
112 void
113 xexpand(KMP_API_NAME_GOMP_ATOMIC_START)(void)
114 {
115     int gtid = __kmp_entry_gtid();
116     KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
117 
118 #if OMPT_SUPPORT
119     __ompt_thread_assign_wait_id(0);
120 #endif
121 
122     __kmp_acquire_atomic_lock(&__kmp_atomic_lock, gtid);
123 }
124 
125 
126 void
127 xexpand(KMP_API_NAME_GOMP_ATOMIC_END)(void)
128 {
129     int gtid = __kmp_get_gtid();
130     KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
131     __kmp_release_atomic_lock(&__kmp_atomic_lock, gtid);
132 }
133 
134 
135 int
136 xexpand(KMP_API_NAME_GOMP_SINGLE_START)(void)
137 {
138     int gtid = __kmp_entry_gtid();
139     MKLOC(loc, "GOMP_single_start");
140     KA_TRACE(20, ("GOMP_single_start: T#%d\n", gtid));
141 
142     if (! TCR_4(__kmp_init_parallel))
143         __kmp_parallel_initialize();
144 
145     //
146     // 3rd parameter == FALSE prevents kmp_enter_single from pushing a
147     // workshare when USE_CHECKS is defined.  We need to avoid the push,
148     // as there is no corresponding GOMP_single_end() call.
149     //
150     return __kmp_enter_single(gtid, &loc, FALSE);
151 }
152 
153 
154 void *
155 xexpand(KMP_API_NAME_GOMP_SINGLE_COPY_START)(void)
156 {
157     void *retval;
158     int gtid = __kmp_entry_gtid();
159     MKLOC(loc, "GOMP_single_copy_start");
160     KA_TRACE(20, ("GOMP_single_copy_start: T#%d\n", gtid));
161 
162     if (! TCR_4(__kmp_init_parallel))
163         __kmp_parallel_initialize();
164 
165     //
166     // If this is the first thread to enter, return NULL.  The generated
167     // code will then call GOMP_single_copy_end() for this thread only,
168     // with the copyprivate data pointer as an argument.
169     //
170     if (__kmp_enter_single(gtid, &loc, FALSE))
171         return NULL;
172 
173     //
174     // Wait for the first thread to set the copyprivate data pointer,
175     // and for all other threads to reach this point.
176     //
177     __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
178 
179     //
180     // Retrieve the value of the copyprivate data point, and wait for all
181     // threads to do likewise, then return.
182     //
183     retval = __kmp_team_from_gtid(gtid)->t.t_copypriv_data;
184     __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
185     return retval;
186 }
187 
188 
189 void
190 xexpand(KMP_API_NAME_GOMP_SINGLE_COPY_END)(void *data)
191 {
192     int gtid = __kmp_get_gtid();
193     KA_TRACE(20, ("GOMP_single_copy_end: T#%d\n", gtid));
194 
195     //
196     // Set the copyprivate data pointer fo the team, then hit the barrier
197     // so that the other threads will continue on and read it.  Hit another
198     // barrier before continuing, so that the know that the copyprivate
199     // data pointer has been propagated to all threads before trying to
200     // reuse the t_copypriv_data field.
201     //
202     __kmp_team_from_gtid(gtid)->t.t_copypriv_data = data;
203     __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
204     __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
205 }
206 
207 
208 void
209 xexpand(KMP_API_NAME_GOMP_ORDERED_START)(void)
210 {
211     int gtid = __kmp_entry_gtid();
212     MKLOC(loc, "GOMP_ordered_start");
213     KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
214     __kmpc_ordered(&loc, gtid);
215 }
216 
217 
218 void
219 xexpand(KMP_API_NAME_GOMP_ORDERED_END)(void)
220 {
221     int gtid = __kmp_get_gtid();
222     MKLOC(loc, "GOMP_ordered_end");
223     KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
224     __kmpc_end_ordered(&loc, gtid);
225 }
226 
227 
228 //
229 // Dispatch macro defs
230 //
231 // They come in two flavors: 64-bit unsigned, and either 32-bit signed
232 // (IA-32 architecture) or 64-bit signed (Intel(R) 64).
233 //
234 
235 #if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS
236 # define KMP_DISPATCH_INIT              __kmp_aux_dispatch_init_4
237 # define KMP_DISPATCH_FINI_CHUNK        __kmp_aux_dispatch_fini_chunk_4
238 # define KMP_DISPATCH_NEXT              __kmpc_dispatch_next_4
239 #else
240 # define KMP_DISPATCH_INIT              __kmp_aux_dispatch_init_8
241 # define KMP_DISPATCH_FINI_CHUNK        __kmp_aux_dispatch_fini_chunk_8
242 # define KMP_DISPATCH_NEXT              __kmpc_dispatch_next_8
243 #endif /* KMP_ARCH_X86 */
244 
245 # define KMP_DISPATCH_INIT_ULL          __kmp_aux_dispatch_init_8u
246 # define KMP_DISPATCH_FINI_CHUNK_ULL    __kmp_aux_dispatch_fini_chunk_8u
247 # define KMP_DISPATCH_NEXT_ULL          __kmpc_dispatch_next_8u
248 
249 
250 //
251 // The parallel contruct
252 //
253 
254 #ifndef KMP_DEBUG
255 static
256 #endif /* KMP_DEBUG */
257 void
258 __kmp_GOMP_microtask_wrapper(int *gtid, int *npr, void (*task)(void *),
259   void *data)
260 {
261 #if OMPT_SUPPORT
262     kmp_info_t *thr;
263     ompt_frame_t *ompt_frame;
264     ompt_state_t enclosing_state;
265 
266     if (ompt_enabled) {
267         // get pointer to thread data structure
268         thr = __kmp_threads[*gtid];
269 
270         // save enclosing task state; set current state for task
271         enclosing_state = thr->th.ompt_thread_info.state;
272         thr->th.ompt_thread_info.state = ompt_state_work_parallel;
273 
274         // set task frame
275         ompt_frame = __ompt_get_task_frame_internal(0);
276         ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
277     }
278 #endif
279 
280     task(data);
281 
282 #if OMPT_SUPPORT
283     if (ompt_enabled) {
284         // clear task frame
285         ompt_frame->exit_runtime_frame = NULL;
286 
287         // restore enclosing state
288         thr->th.ompt_thread_info.state = enclosing_state;
289     }
290 #endif
291 }
292 
293 
294 #ifndef KMP_DEBUG
295 static
296 #endif /* KMP_DEBUG */
297 void
298 __kmp_GOMP_parallel_microtask_wrapper(int *gtid, int *npr,
299   void (*task)(void *), void *data, unsigned num_threads, ident_t *loc,
300   enum sched_type schedule, long start, long end, long incr, long chunk_size)
301 {
302     //
303     // Intialize the loop worksharing construct.
304     //
305     KMP_DISPATCH_INIT(loc, *gtid, schedule, start, end, incr, chunk_size,
306       schedule != kmp_sch_static);
307 
308 #if OMPT_SUPPORT
309     kmp_info_t *thr;
310     ompt_frame_t *ompt_frame;
311     ompt_state_t enclosing_state;
312 
313     if (ompt_enabled) {
314         thr = __kmp_threads[*gtid];
315         // save enclosing task state; set current state for task
316         enclosing_state = thr->th.ompt_thread_info.state;
317         thr->th.ompt_thread_info.state = ompt_state_work_parallel;
318 
319         // set task frame
320         ompt_frame = __ompt_get_task_frame_internal(0);
321         ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
322     }
323 #endif
324 
325     //
326     // Now invoke the microtask.
327     //
328     task(data);
329 
330 #if OMPT_SUPPORT
331     if (ompt_enabled) {
332         // clear task frame
333         ompt_frame->exit_runtime_frame = NULL;
334 
335         // reset enclosing state
336         thr->th.ompt_thread_info.state = enclosing_state;
337     }
338 #endif
339 }
340 
341 
342 #ifndef KMP_DEBUG
343 static
344 #endif /* KMP_DEBUG */
345 void
346 __kmp_GOMP_fork_call(ident_t *loc, int gtid, void (*unwrapped_task)(void *), microtask_t wrapper, int argc,...)
347 {
348     int rc;
349     kmp_info_t *thr = __kmp_threads[gtid];
350     kmp_team_t *team = thr->th.th_team;
351     int tid = __kmp_tid_from_gtid(gtid);
352 
353     va_list ap;
354     va_start(ap, argc);
355 
356     rc = __kmp_fork_call(loc, gtid, fork_context_gnu, argc,
357 #if OMPT_SUPPORT
358       VOLATILE_CAST(void *) unwrapped_task,
359 #endif
360       wrapper, __kmp_invoke_task_func,
361 #if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
362       &ap
363 #else
364       ap
365 #endif
366       );
367 
368     va_end(ap);
369 
370     if (rc) {
371         __kmp_run_before_invoked_task(gtid, tid, thr, team);
372     }
373 
374 #if OMPT_SUPPORT
375     if (ompt_enabled) {
376 #if OMPT_TRACE
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_callbacks.ompt_callback(ompt_event_implicit_task_begin)) {
382             ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)(
383                 team_info->parallel_id, task_info->task_id);
384         }
385 #endif
386         thr->th.ompt_thread_info.state = ompt_state_work_parallel;
387     }
388 #endif
389 }
390 
391 static void
392 __kmp_GOMP_serialized_parallel(ident_t *loc, kmp_int32 gtid, void (*task)(void *))
393 {
394 #if OMPT_SUPPORT
395     ompt_parallel_id_t ompt_parallel_id;
396     if (ompt_enabled) {
397         ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
398 
399         ompt_parallel_id = __ompt_parallel_id_new(gtid);
400 
401         // parallel region callback
402         if (ompt_callbacks.ompt_callback(ompt_event_parallel_begin)) {
403             int team_size = 1;
404             ompt_callbacks.ompt_callback(ompt_event_parallel_begin)(
405                 task_info->task_id, &task_info->frame, ompt_parallel_id,
406                 team_size, (void *) task,
407                 OMPT_INVOKER(fork_context_gnu));
408         }
409     }
410 #endif
411 
412     __kmp_serialized_parallel(loc, gtid);
413 
414 #if OMPT_SUPPORT
415     if (ompt_enabled) {
416         kmp_info_t *thr = __kmp_threads[gtid];
417 
418         ompt_task_id_t my_ompt_task_id = __ompt_task_id_new(gtid);
419 
420         // set up lightweight task
421         ompt_lw_taskteam_t *lwt = (ompt_lw_taskteam_t *)
422             __kmp_allocate(sizeof(ompt_lw_taskteam_t));
423         __ompt_lw_taskteam_init(lwt, thr, gtid, (void *) task, ompt_parallel_id);
424         lwt->ompt_task_info.task_id = my_ompt_task_id;
425         __ompt_lw_taskteam_link(lwt, thr);
426 
427 #if OMPT_TRACE
428         // implicit task callback
429         if (ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)) {
430             ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)(
431                 ompt_parallel_id, my_ompt_task_id);
432         }
433         thr->th.ompt_thread_info.state = ompt_state_work_parallel;
434 #endif
435     }
436 #endif
437 }
438 
439 
440 void
441 xexpand(KMP_API_NAME_GOMP_PARALLEL_START)(void (*task)(void *), void *data, unsigned num_threads)
442 {
443     int gtid = __kmp_entry_gtid();
444 
445 #if OMPT_SUPPORT
446     ompt_frame_t *parent_frame, *frame;
447 
448     if (ompt_enabled) {
449         parent_frame = __ompt_get_task_frame_internal(0);
450         parent_frame->reenter_runtime_frame = __builtin_frame_address(1);
451     }
452 #endif
453 
454     MKLOC(loc, "GOMP_parallel_start");
455     KA_TRACE(20, ("GOMP_parallel_start: T#%d\n", gtid));
456 
457     if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
458         if (num_threads != 0) {
459             __kmp_push_num_threads(&loc, gtid, num_threads);
460         }
461         __kmp_GOMP_fork_call(&loc, gtid, task,
462           (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task, data);
463     }
464     else {
465         __kmp_GOMP_serialized_parallel(&loc, gtid, task);
466     }
467 
468 #if OMPT_SUPPORT
469     if (ompt_enabled) {
470         frame = __ompt_get_task_frame_internal(0);
471         frame->exit_runtime_frame = __builtin_frame_address(1);
472     }
473 #endif
474 }
475 
476 
477 void
478 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(void)
479 {
480     int gtid = __kmp_get_gtid();
481     kmp_info_t *thr;
482 
483     thr = __kmp_threads[gtid];
484 
485     MKLOC(loc, "GOMP_parallel_end");
486     KA_TRACE(20, ("GOMP_parallel_end: T#%d\n", gtid));
487 
488 
489 #if OMPT_SUPPORT
490     ompt_parallel_id_t parallel_id;
491     ompt_task_id_t serialized_task_id;
492     ompt_frame_t *ompt_frame = NULL;
493 
494     if (ompt_enabled) {
495         ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
496         parallel_id = team_info->parallel_id;
497 
498         ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
499         serialized_task_id = task_info->task_id;
500 
501         // unlink if necessary. no-op if there is not a lightweight task.
502         ompt_lw_taskteam_t *lwt = __ompt_lw_taskteam_unlink(thr);
503         // GOMP allocates/frees lwt since it can't be kept on the stack
504         if (lwt) {
505            __kmp_free(lwt);
506 
507         }
508     }
509 #endif
510 
511     if (! thr->th.th_team->t.t_serialized) {
512         __kmp_run_after_invoked_task(gtid, __kmp_tid_from_gtid(gtid), thr,
513           thr->th.th_team);
514 
515 #if OMPT_SUPPORT
516         if (ompt_enabled) {
517           // Implicit task is finished here, in the barrier we might schedule deferred tasks,
518           // these don't see the implicit task on the stack
519           ompt_frame = __ompt_get_task_frame_internal(0);
520           ompt_frame->exit_runtime_frame = NULL;
521         }
522 #endif
523 
524         __kmp_join_call(&loc, gtid
525 #if OMPT_SUPPORT
526             , fork_context_gnu
527 #endif
528         );
529     }
530     else {
531 #if OMPT_SUPPORT && OMPT_TRACE
532         if (ompt_enabled &&
533             ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)) {
534             ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)(
535                 parallel_id, serialized_task_id);
536         }
537 #endif
538 
539         __kmpc_end_serialized_parallel(&loc, gtid);
540 
541 #if OMPT_SUPPORT
542         if (ompt_enabled) {
543             // Record that we re-entered the runtime system in the frame that
544             // created the parallel region.
545             ompt_task_info_t *parent_task_info = __ompt_get_taskinfo(0);
546 
547             if (ompt_callbacks.ompt_callback(ompt_event_parallel_end)) {
548                 ompt_callbacks.ompt_callback(ompt_event_parallel_end)(
549                     parallel_id, parent_task_info->task_id,
550                     OMPT_INVOKER(fork_context_gnu));
551             }
552 
553             parent_task_info->frame.reenter_runtime_frame = NULL;
554 
555             thr->th.ompt_thread_info.state =
556                 (((thr->th.th_team)->t.t_serialized) ?
557                 ompt_state_work_serial : ompt_state_work_parallel);
558         }
559 #endif
560     }
561 }
562 
563 
564 //
565 // Loop worksharing constructs
566 //
567 
568 //
569 // The Gnu codegen passes in an exclusive upper bound for the overall range,
570 // but the libguide dispatch code expects an inclusive upper bound, hence the
571 // "end - incr" 5th argument to KMP_DISPATCH_INIT (and the " ub - str" 11th
572 // argument to __kmp_GOMP_fork_call).
573 //
574 // Conversely, KMP_DISPATCH_NEXT returns and inclusive upper bound in *p_ub,
575 // but the Gnu codegen expects an excluside upper bound, so the adjustment
576 // "*p_ub += stride" compenstates for the discrepancy.
577 //
578 // Correction: the gnu codegen always adjusts the upper bound by +-1, not the
579 // stride value.  We adjust the dispatch parameters accordingly (by +-1), but
580 // we still adjust p_ub by the actual stride value.
581 //
582 // The "runtime" versions do not take a chunk_sz parameter.
583 //
584 // The profile lib cannot support construct checking of unordered loops that
585 // are predetermined by the compiler to be statically scheduled, as the gcc
586 // codegen will not always emit calls to GOMP_loop_static_next() to get the
587 // next iteration.  Instead, it emits inline code to call omp_get_thread_num()
588 // num and calculate the iteration space using the result.  It doesn't do this
589 // with ordered static loop, so they can be checked.
590 //
591 
592 #define LOOP_START(func,schedule) \
593     int func (long lb, long ub, long str, long chunk_sz, long *p_lb,         \
594       long *p_ub)                                                            \
595     {                                                                        \
596         int status;                                                          \
597         long stride;                                                         \
598         int gtid = __kmp_entry_gtid();                                       \
599         MKLOC(loc, #func);                                                   \
600         KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n",  \
601           gtid, lb, ub, str, chunk_sz ));                                    \
602                                                                              \
603         if ((str > 0) ? (lb < ub) : (lb > ub)) {                             \
604             KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                    \
605               (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz,                \
606               (schedule) != kmp_sch_static);                                 \
607             status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb,    \
608               (kmp_int *)p_ub, (kmp_int *)&stride);                          \
609             if (status) {                                                    \
610                 KMP_DEBUG_ASSERT(stride == str);                             \
611                 *p_ub += (str > 0) ? 1 : -1;                                 \
612             }                                                                \
613         }                                                                    \
614         else {                                                               \
615             status = 0;                                                      \
616         }                                                                    \
617                                                                              \
618         KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
619           gtid, *p_lb, *p_ub, status));                                      \
620         return status;                                                       \
621     }
622 
623 
624 #define LOOP_RUNTIME_START(func,schedule) \
625     int func (long lb, long ub, long str, long *p_lb, long *p_ub)            \
626     {                                                                        \
627         int status;                                                          \
628         long stride;                                                         \
629         long chunk_sz = 0;                                                   \
630         int gtid = __kmp_entry_gtid();                                       \
631         MKLOC(loc, #func);                                                   \
632         KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n",  \
633           gtid, lb, ub, str, chunk_sz ));                                    \
634                                                                              \
635         if ((str > 0) ? (lb < ub) : (lb > ub)) {                             \
636             KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                    \
637               (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, TRUE);         \
638             status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb,    \
639               (kmp_int *)p_ub, (kmp_int *)&stride);                          \
640             if (status) {                                                    \
641                 KMP_DEBUG_ASSERT(stride == str);                             \
642                 *p_ub += (str > 0) ? 1 : -1;                                 \
643             }                                                                \
644         }                                                                    \
645         else {                                                               \
646             status = 0;                                                      \
647         }                                                                    \
648                                                                              \
649         KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
650           gtid, *p_lb, *p_ub, status));                                      \
651         return status;                                                       \
652     }
653 
654 
655 #define LOOP_NEXT(func,fini_code) \
656     int func(long *p_lb, long *p_ub)                                         \
657     {                                                                        \
658         int status;                                                          \
659         long stride;                                                         \
660         int gtid = __kmp_get_gtid();                                         \
661         MKLOC(loc, #func);                                                   \
662         KA_TRACE(20, ( #func ": T#%d\n", gtid));                             \
663                                                                              \
664         fini_code                                                            \
665         status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb,        \
666           (kmp_int *)p_ub, (kmp_int *)&stride);                              \
667         if (status) {                                                        \
668             *p_ub += (stride > 0) ? 1 : -1;                                  \
669         }                                                                    \
670                                                                              \
671         KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, stride 0x%lx, "  \
672           "returning %d\n", gtid, *p_lb, *p_ub, stride, status));            \
673         return status;                                                       \
674     }
675 
676 
677 LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_STATIC_START), kmp_sch_static)
678 LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT), {})
679 LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START), kmp_sch_dynamic_chunked)
680 LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT), {})
681 LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_GUIDED_START), kmp_sch_guided_chunked)
682 LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT), {})
683 LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_START), kmp_sch_runtime)
684 LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT), {})
685 
686 LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START), kmp_ord_static)
687 LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT), \
688     { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
689 LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START), kmp_ord_dynamic_chunked)
690 LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT), \
691     { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
692 LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START), kmp_ord_guided_chunked)
693 LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT), \
694     { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
695 LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START), kmp_ord_runtime)
696 LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT), \
697     { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
698 
699 
700 void
701 xexpand(KMP_API_NAME_GOMP_LOOP_END)(void)
702 {
703     int gtid = __kmp_get_gtid();
704     KA_TRACE(20, ("GOMP_loop_end: T#%d\n", gtid))
705 
706     __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
707 
708     KA_TRACE(20, ("GOMP_loop_end exit: T#%d\n", gtid))
709 }
710 
711 
712 void
713 xexpand(KMP_API_NAME_GOMP_LOOP_END_NOWAIT)(void)
714 {
715     KA_TRACE(20, ("GOMP_loop_end_nowait: T#%d\n", __kmp_get_gtid()))
716 }
717 
718 
719 //
720 // Unsigned long long loop worksharing constructs
721 //
722 // These are new with gcc 4.4
723 //
724 
725 #define LOOP_START_ULL(func,schedule) \
726     int func (int up, unsigned long long lb, unsigned long long ub,          \
727       unsigned long long str, unsigned long long chunk_sz,                   \
728       unsigned long long *p_lb, unsigned long long *p_ub)                    \
729     {                                                                        \
730         int status;                                                          \
731         long long str2 = up ? ((long long)str) : -((long long)str);          \
732         long long stride;                                                    \
733         int gtid = __kmp_entry_gtid();                                       \
734         MKLOC(loc, #func);                                                   \
735                                                                              \
736         KA_TRACE(20, ( #func ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
737           gtid, up, lb, ub, str, chunk_sz ));                                \
738                                                                              \
739         if ((str > 0) ? (lb < ub) : (lb > ub)) {                             \
740             KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb,                \
741               (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz,              \
742               (schedule) != kmp_sch_static);                                 \
743             status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL,                 \
744               (kmp_uint64 *)p_lb, (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
745             if (status) {                                                    \
746                 KMP_DEBUG_ASSERT(stride == str2);                            \
747                 *p_ub += (str > 0) ? 1 : -1;                                 \
748             }                                                                \
749         }                                                                    \
750         else {                                                               \
751             status = 0;                                                      \
752         }                                                                    \
753                                                                              \
754         KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
755           gtid, *p_lb, *p_ub, status));                                      \
756         return status;                                                       \
757     }
758 
759 
760 #define LOOP_RUNTIME_START_ULL(func,schedule) \
761     int func (int up, unsigned long long lb, unsigned long long ub,          \
762       unsigned long long str, unsigned long long *p_lb,                      \
763       unsigned long long *p_ub)                                              \
764     {                                                                        \
765         int status;                                                          \
766         long long str2 = up ? ((long long)str) : -((long long)str);          \
767         unsigned long long stride;                                           \
768         unsigned long long chunk_sz = 0;                                     \
769         int gtid = __kmp_entry_gtid();                                       \
770         MKLOC(loc, #func);                                                   \
771                                                                              \
772         KA_TRACE(20, ( #func ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
773           gtid, up, lb, ub, str, chunk_sz ));                                \
774                                                                              \
775         if ((str > 0) ? (lb < ub) : (lb > ub)) {                             \
776             KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb,                \
777               (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, TRUE);       \
778             status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL,                 \
779               (kmp_uint64 *)p_lb, (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
780             if (status) {                                                    \
781                 KMP_DEBUG_ASSERT((long long)stride == str2);                 \
782                 *p_ub += (str > 0) ? 1 : -1;                                 \
783             }                                                                \
784         }                                                                    \
785         else {                                                               \
786             status = 0;                                                      \
787         }                                                                    \
788                                                                              \
789         KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
790           gtid, *p_lb, *p_ub, status));                                      \
791         return status;                                                       \
792     }
793 
794 
795 #define LOOP_NEXT_ULL(func,fini_code) \
796     int func(unsigned long long *p_lb, unsigned long long *p_ub)             \
797     {                                                                        \
798         int status;                                                          \
799         long long stride;                                                    \
800         int gtid = __kmp_get_gtid();                                         \
801         MKLOC(loc, #func);                                                   \
802         KA_TRACE(20, ( #func ": T#%d\n", gtid));                             \
803                                                                              \
804         fini_code                                                            \
805         status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
806           (kmp_uint64 *)p_ub, (kmp_int64 *)&stride);                         \
807         if (status) {                                                        \
808             *p_ub += (stride > 0) ? 1 : -1;                                  \
809         }                                                                    \
810                                                                              \
811         KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, stride 0x%llx, " \
812           "returning %d\n", gtid, *p_lb, *p_ub, stride, status));            \
813         return status;                                                       \
814     }
815 
816 
817 LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START), kmp_sch_static)
818 LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT), {})
819 LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START), kmp_sch_dynamic_chunked)
820 LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT), {})
821 LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START), kmp_sch_guided_chunked)
822 LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT), {})
823 LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START), kmp_sch_runtime)
824 LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT), {})
825 
826 LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START), kmp_ord_static)
827 LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT), \
828     { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
829 LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START), kmp_ord_dynamic_chunked)
830 LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT), \
831     { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
832 LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START), kmp_ord_guided_chunked)
833 LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT), \
834     { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
835 LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START), kmp_ord_runtime)
836 LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT), \
837     { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
838 
839 
840 //
841 // Combined parallel / loop worksharing constructs
842 //
843 // There are no ull versions (yet).
844 //
845 
846 #define PARALLEL_LOOP_START(func, schedule, ompt_pre, ompt_post) \
847     void func (void (*task) (void *), void *data, unsigned num_threads,      \
848       long lb, long ub, long str, long chunk_sz)                             \
849     {                                                                        \
850         int gtid = __kmp_entry_gtid();                                       \
851         MKLOC(loc, #func);                                                   \
852         KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n",        \
853           gtid, lb, ub, str, chunk_sz ));                                    \
854                                                                              \
855         ompt_pre();                                                          \
856                                                                              \
857         if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {                 \
858             if (num_threads != 0) {                                          \
859                 __kmp_push_num_threads(&loc, gtid, num_threads);             \
860             }                                                                \
861             __kmp_GOMP_fork_call(&loc, gtid, task,                           \
862               (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9,         \
863               task, data, num_threads, &loc, (schedule), lb,                 \
864               (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz);               \
865         }                                                                    \
866         else {                                                               \
867             __kmp_GOMP_serialized_parallel(&loc, gtid, task);                \
868         }                                                                    \
869                                                                              \
870         KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                        \
871           (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz,                    \
872           (schedule) != kmp_sch_static);                                     \
873                                                                              \
874         ompt_post();                                                         \
875                                                                              \
876         KA_TRACE(20, ( #func " exit: T#%d\n", gtid));                        \
877     }
878 
879 
880 
881 #if OMPT_SUPPORT
882 
883 #define OMPT_LOOP_PRE() \
884     ompt_frame_t *parent_frame; \
885     if (ompt_enabled) { \
886         parent_frame = __ompt_get_task_frame_internal(0); \
887         parent_frame->reenter_runtime_frame = __builtin_frame_address(1); \
888     }
889 
890 
891 #define OMPT_LOOP_POST() \
892     if (ompt_enabled) { \
893         parent_frame->reenter_runtime_frame = NULL; \
894     }
895 
896 #else
897 
898 #define OMPT_LOOP_PRE()
899 
900 #define OMPT_LOOP_POST()
901 
902 #endif
903 
904 
905 PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START),
906                     kmp_sch_static, OMPT_LOOP_PRE, OMPT_LOOP_POST)
907 PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START),
908                     kmp_sch_dynamic_chunked, OMPT_LOOP_PRE, OMPT_LOOP_POST)
909 PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START),
910                     kmp_sch_guided_chunked, OMPT_LOOP_PRE, OMPT_LOOP_POST)
911 PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START),
912                     kmp_sch_runtime, OMPT_LOOP_PRE, OMPT_LOOP_POST)
913 
914 
915 //
916 // Tasking constructs
917 //
918 
919 void
920 xexpand(KMP_API_NAME_GOMP_TASK)(void (*func)(void *), void *data, void (*copy_func)(void *, void *),
921   long arg_size, long arg_align, bool if_cond, unsigned gomp_flags
922 #if OMP_40_ENABLED
923   , void **depend
924 #endif
925 )
926 {
927     MKLOC(loc, "GOMP_task");
928     int gtid = __kmp_entry_gtid();
929     kmp_int32 flags = 0;
930     kmp_tasking_flags_t *input_flags = (kmp_tasking_flags_t *) & flags;
931 
932     KA_TRACE(20, ("GOMP_task: T#%d\n", gtid));
933 
934     // The low-order bit is the "tied" flag
935     if (gomp_flags & 1) {
936         input_flags->tiedness = 1;
937     }
938     // The second low-order bit is the "final" flag
939     if (gomp_flags & 2) {
940         input_flags->final = 1;
941     }
942     input_flags->native = 1;
943     // __kmp_task_alloc() sets up all other flags
944 
945     if (! if_cond) {
946         arg_size = 0;
947     }
948 
949     kmp_task_t *task = __kmp_task_alloc(&loc, gtid, input_flags,
950       sizeof(kmp_task_t), arg_size ? arg_size + arg_align - 1 : 0,
951       (kmp_routine_entry_t)func);
952 
953     if (arg_size > 0) {
954         if (arg_align > 0) {
955             task->shareds = (void *)((((size_t)task->shareds)
956               + arg_align - 1) / arg_align * arg_align);
957         }
958         //else error??
959 
960         if (copy_func) {
961             (*copy_func)(task->shareds, data);
962         }
963         else {
964             KMP_MEMCPY(task->shareds, data, arg_size);
965         }
966     }
967 
968     if (if_cond) {
969 #if OMP_40_ENABLED
970         if (gomp_flags & 8) {
971             KMP_ASSERT(depend);
972             const size_t ndeps = (kmp_intptr_t)depend[0];
973             const size_t nout = (kmp_intptr_t)depend[1];
974             kmp_depend_info_t dep_list[ndeps];
975 
976             for (size_t i = 0U; i < ndeps; i++) {
977                 dep_list[i].base_addr = (kmp_intptr_t)depend[2U + i];
978                 dep_list[i].len = 0U;
979                 dep_list[i].flags.in = 1;
980                 dep_list[i].flags.out = (i < nout);
981             }
982             __kmpc_omp_task_with_deps(&loc, gtid, task, ndeps, dep_list, 0, NULL);
983         }
984         else
985 #endif
986         __kmpc_omp_task(&loc, gtid, task);
987     }
988     else {
989 #if OMPT_SUPPORT
990         ompt_thread_info_t oldInfo;
991         kmp_info_t *thread;
992         kmp_taskdata_t *taskdata;
993         if (ompt_enabled) {
994             // Store the threads states and restore them after the task
995             thread = __kmp_threads[ gtid ];
996             taskdata = KMP_TASK_TO_TASKDATA(task);
997             oldInfo = thread->th.ompt_thread_info;
998             thread->th.ompt_thread_info.wait_id = 0;
999             thread->th.ompt_thread_info.state = ompt_state_work_parallel;
1000             taskdata->ompt_task_info.frame.exit_runtime_frame =
1001                 __builtin_frame_address(0);
1002         }
1003 #endif
1004 
1005         __kmpc_omp_task_begin_if0(&loc, gtid, task);
1006         func(data);
1007         __kmpc_omp_task_complete_if0(&loc, gtid, task);
1008 
1009 #if OMPT_SUPPORT
1010         if (ompt_enabled) {
1011             thread->th.ompt_thread_info = oldInfo;
1012             taskdata->ompt_task_info.frame.exit_runtime_frame = NULL;
1013         }
1014 #endif
1015     }
1016 
1017     KA_TRACE(20, ("GOMP_task exit: T#%d\n", gtid));
1018 }
1019 
1020 
1021 void
1022 xexpand(KMP_API_NAME_GOMP_TASKWAIT)(void)
1023 {
1024     MKLOC(loc, "GOMP_taskwait");
1025     int gtid = __kmp_entry_gtid();
1026 
1027     KA_TRACE(20, ("GOMP_taskwait: T#%d\n", gtid));
1028 
1029     __kmpc_omp_taskwait(&loc, gtid);
1030 
1031     KA_TRACE(20, ("GOMP_taskwait exit: T#%d\n", gtid));
1032 }
1033 
1034 
1035 //
1036 // Sections worksharing constructs
1037 //
1038 
1039 //
1040 // For the sections construct, we initialize a dynamically scheduled loop
1041 // worksharing construct with lb 1 and stride 1, and use the iteration #'s
1042 // that its returns as sections ids.
1043 //
1044 // There are no special entry points for ordered sections, so we always use
1045 // the dynamically scheduled workshare, even if the sections aren't ordered.
1046 //
1047 
1048 unsigned
1049 xexpand(KMP_API_NAME_GOMP_SECTIONS_START)(unsigned count)
1050 {
1051     int status;
1052     kmp_int lb, ub, stride;
1053     int gtid = __kmp_entry_gtid();
1054     MKLOC(loc, "GOMP_sections_start");
1055     KA_TRACE(20, ("GOMP_sections_start: T#%d\n", gtid));
1056 
1057     KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1058 
1059     status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
1060     if (status) {
1061         KMP_DEBUG_ASSERT(stride == 1);
1062         KMP_DEBUG_ASSERT(lb > 0);
1063         KMP_ASSERT(lb == ub);
1064     }
1065     else {
1066         lb = 0;
1067     }
1068 
1069     KA_TRACE(20, ("GOMP_sections_start exit: T#%d returning %u\n", gtid,
1070       (unsigned)lb));
1071     return (unsigned)lb;
1072 }
1073 
1074 
1075 unsigned
1076 xexpand(KMP_API_NAME_GOMP_SECTIONS_NEXT)(void)
1077 {
1078     int status;
1079     kmp_int lb, ub, stride;
1080     int gtid = __kmp_get_gtid();
1081     MKLOC(loc, "GOMP_sections_next");
1082     KA_TRACE(20, ("GOMP_sections_next: T#%d\n", gtid));
1083 
1084     status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
1085     if (status) {
1086         KMP_DEBUG_ASSERT(stride == 1);
1087         KMP_DEBUG_ASSERT(lb > 0);
1088         KMP_ASSERT(lb == ub);
1089     }
1090     else {
1091         lb = 0;
1092     }
1093 
1094     KA_TRACE(20, ("GOMP_sections_next exit: T#%d returning %u\n", gtid,
1095       (unsigned)lb));
1096     return (unsigned)lb;
1097 }
1098 
1099 
1100 void
1101 xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START)(void (*task) (void *), void *data,
1102   unsigned num_threads, unsigned count)
1103 {
1104     int gtid = __kmp_entry_gtid();
1105 
1106 #if OMPT_SUPPORT
1107     ompt_frame_t *parent_frame;
1108 
1109     if (ompt_enabled) {
1110         parent_frame = __ompt_get_task_frame_internal(0);
1111         parent_frame->reenter_runtime_frame = __builtin_frame_address(1);
1112     }
1113 #endif
1114 
1115     MKLOC(loc, "GOMP_parallel_sections_start");
1116     KA_TRACE(20, ("GOMP_parallel_sections_start: T#%d\n", gtid));
1117 
1118     if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1119         if (num_threads != 0) {
1120             __kmp_push_num_threads(&loc, gtid, num_threads);
1121         }
1122         __kmp_GOMP_fork_call(&loc, gtid, task,
1123           (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, task, data,
1124           num_threads, &loc, kmp_nm_dynamic_chunked, (kmp_int)1,
1125           (kmp_int)count, (kmp_int)1, (kmp_int)1);
1126     }
1127     else {
1128         __kmp_GOMP_serialized_parallel(&loc, gtid, task);
1129     }
1130 
1131 #if OMPT_SUPPORT
1132     if (ompt_enabled) {
1133         parent_frame->reenter_runtime_frame = NULL;
1134     }
1135 #endif
1136 
1137     KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1138 
1139     KA_TRACE(20, ("GOMP_parallel_sections_start exit: T#%d\n", gtid));
1140 }
1141 
1142 
1143 void
1144 xexpand(KMP_API_NAME_GOMP_SECTIONS_END)(void)
1145 {
1146     int gtid = __kmp_get_gtid();
1147     KA_TRACE(20, ("GOMP_sections_end: T#%d\n", gtid))
1148 
1149     __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
1150 
1151     KA_TRACE(20, ("GOMP_sections_end exit: T#%d\n", gtid))
1152 }
1153 
1154 
1155 void
1156 xexpand(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT)(void)
1157 {
1158     KA_TRACE(20, ("GOMP_sections_end_nowait: T#%d\n", __kmp_get_gtid()))
1159 }
1160 
1161 // libgomp has an empty function for GOMP_taskyield as of 2013-10-10
1162 void
1163 xexpand(KMP_API_NAME_GOMP_TASKYIELD)(void)
1164 {
1165     KA_TRACE(20, ("GOMP_taskyield: T#%d\n", __kmp_get_gtid()))
1166     return;
1167 }
1168 
1169 #if OMP_40_ENABLED // these are new GOMP_4.0 entry points
1170 
1171 void
1172 xexpand(KMP_API_NAME_GOMP_PARALLEL)(void (*task)(void *), void *data, unsigned num_threads, unsigned int flags)
1173 {
1174     int gtid = __kmp_entry_gtid();
1175     MKLOC(loc, "GOMP_parallel");
1176     KA_TRACE(20, ("GOMP_parallel: T#%d\n", gtid));
1177 
1178 #if OMPT_SUPPORT
1179     ompt_task_info_t *parent_task_info, *task_info;
1180     if (ompt_enabled) {
1181         parent_task_info = __ompt_get_taskinfo(0);
1182         parent_task_info->frame.reenter_runtime_frame = __builtin_frame_address(1);
1183     }
1184 #endif
1185     if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1186         if (num_threads != 0) {
1187             __kmp_push_num_threads(&loc, gtid, num_threads);
1188         }
1189         if(flags != 0) {
1190             __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
1191         }
1192         __kmp_GOMP_fork_call(&loc, gtid, task,
1193           (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task, data);
1194     }
1195     else {
1196         __kmp_GOMP_serialized_parallel(&loc, gtid, task);
1197     }
1198 #if OMPT_SUPPORT
1199     if (ompt_enabled) {
1200         task_info = __ompt_get_taskinfo(0);
1201         task_info->frame.exit_runtime_frame = __builtin_frame_address(0);
1202     }
1203 #endif
1204     task(data);
1205     xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
1206 #if OMPT_SUPPORT
1207     if (ompt_enabled) {
1208         task_info->frame.exit_runtime_frame = NULL;
1209         parent_task_info->frame.reenter_runtime_frame = NULL;
1210     }
1211 #endif
1212 }
1213 
1214 void
1215 xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS)(void (*task) (void *), void *data,
1216   unsigned num_threads, unsigned count, unsigned flags)
1217 {
1218     int gtid = __kmp_entry_gtid();
1219     MKLOC(loc, "GOMP_parallel_sections");
1220     KA_TRACE(20, ("GOMP_parallel_sections: T#%d\n", gtid));
1221 
1222     if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1223         if (num_threads != 0) {
1224             __kmp_push_num_threads(&loc, gtid, num_threads);
1225         }
1226         if(flags != 0) {
1227             __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
1228         }
1229         __kmp_GOMP_fork_call(&loc, gtid, task,
1230           (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, task, data,
1231           num_threads, &loc, kmp_nm_dynamic_chunked, (kmp_int)1,
1232           (kmp_int)count, (kmp_int)1, (kmp_int)1);
1233     }
1234     else {
1235         __kmp_GOMP_serialized_parallel(&loc, gtid, task);
1236     }
1237 
1238     KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1239 
1240     task(data);
1241     xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
1242     KA_TRACE(20, ("GOMP_parallel_sections exit: T#%d\n", gtid));
1243 }
1244 
1245 #define PARALLEL_LOOP(func, schedule, ompt_pre, ompt_post) \
1246     void func (void (*task) (void *), void *data, unsigned num_threads,      \
1247       long lb, long ub, long str, long chunk_sz, unsigned flags)             \
1248     {                                                                        \
1249         int gtid = __kmp_entry_gtid();                                       \
1250         MKLOC(loc, #func);                                                   \
1251         KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n",        \
1252           gtid, lb, ub, str, chunk_sz ));                                    \
1253                                                                              \
1254         ompt_pre();                                                          \
1255         if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {                 \
1256             if (num_threads != 0) {                                          \
1257                 __kmp_push_num_threads(&loc, gtid, num_threads);             \
1258             }                                                                \
1259             if (flags != 0) {                                                \
1260                 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);    \
1261             }                                                                \
1262             __kmp_GOMP_fork_call(&loc, gtid, task,                           \
1263               (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9,         \
1264               task, data, num_threads, &loc, (schedule), lb,                 \
1265               (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz);               \
1266         }                                                                    \
1267         else {                                                               \
1268             __kmp_GOMP_serialized_parallel(&loc, gtid, task);                \
1269         }                                                                    \
1270                                                                              \
1271         KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                        \
1272           (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz,                    \
1273           (schedule) != kmp_sch_static);                                     \
1274         task(data);                                                          \
1275         xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();                           \
1276         ompt_post();                                                          \
1277                                                                              \
1278         KA_TRACE(20, ( #func " exit: T#%d\n", gtid));                        \
1279     }
1280 
1281 PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC), kmp_sch_static,
1282                 OMPT_LOOP_PRE, OMPT_LOOP_POST)
1283 PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC), kmp_sch_dynamic_chunked,
1284                 OMPT_LOOP_PRE, OMPT_LOOP_POST)
1285 PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED), kmp_sch_guided_chunked,
1286                 OMPT_LOOP_PRE, OMPT_LOOP_POST)
1287 PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME), kmp_sch_runtime,
1288                 OMPT_LOOP_PRE, OMPT_LOOP_POST)
1289 
1290 
1291 void
1292 xexpand(KMP_API_NAME_GOMP_TASKGROUP_START)(void)
1293 {
1294     int gtid = __kmp_entry_gtid();
1295     MKLOC(loc, "GOMP_taskgroup_start");
1296     KA_TRACE(20, ("GOMP_taskgroup_start: T#%d\n", gtid));
1297 
1298     __kmpc_taskgroup(&loc, gtid);
1299 
1300     return;
1301 }
1302 
1303 void
1304 xexpand(KMP_API_NAME_GOMP_TASKGROUP_END)(void)
1305 {
1306     int gtid = __kmp_get_gtid();
1307     MKLOC(loc, "GOMP_taskgroup_end");
1308     KA_TRACE(20, ("GOMP_taskgroup_end: T#%d\n", gtid));
1309 
1310     __kmpc_end_taskgroup(&loc, gtid);
1311 
1312     return;
1313 }
1314 
1315 #ifndef KMP_DEBUG
1316 static
1317 #endif /* KMP_DEBUG */
1318 kmp_int32 __kmp_gomp_to_omp_cancellation_kind(int gomp_kind) {
1319     kmp_int32 cncl_kind = 0;
1320     switch(gomp_kind) {
1321       case 1:
1322         cncl_kind = cancel_parallel;
1323         break;
1324       case 2:
1325         cncl_kind = cancel_loop;
1326         break;
1327       case 4:
1328         cncl_kind = cancel_sections;
1329         break;
1330       case 8:
1331         cncl_kind = cancel_taskgroup;
1332         break;
1333     }
1334     return cncl_kind;
1335 }
1336 
1337 bool
1338 xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(int which)
1339 {
1340     if(__kmp_omp_cancellation) {
1341         KMP_FATAL(NoGompCancellation);
1342     }
1343     int gtid = __kmp_get_gtid();
1344     MKLOC(loc, "GOMP_cancellation_point");
1345     KA_TRACE(20, ("GOMP_cancellation_point: T#%d\n", gtid));
1346 
1347     kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
1348 
1349     return __kmpc_cancellationpoint(&loc, gtid, cncl_kind);
1350 }
1351 
1352 bool
1353 xexpand(KMP_API_NAME_GOMP_BARRIER_CANCEL)(void)
1354 {
1355     if(__kmp_omp_cancellation) {
1356         KMP_FATAL(NoGompCancellation);
1357     }
1358     KMP_FATAL(NoGompCancellation);
1359     int gtid = __kmp_get_gtid();
1360     MKLOC(loc, "GOMP_barrier_cancel");
1361     KA_TRACE(20, ("GOMP_barrier_cancel: T#%d\n", gtid));
1362 
1363     return __kmpc_cancel_barrier(&loc, gtid);
1364 }
1365 
1366 bool
1367 xexpand(KMP_API_NAME_GOMP_CANCEL)(int which, bool do_cancel)
1368 {
1369     if(__kmp_omp_cancellation) {
1370         KMP_FATAL(NoGompCancellation);
1371     } else {
1372         return FALSE;
1373     }
1374 
1375     int gtid = __kmp_get_gtid();
1376     MKLOC(loc, "GOMP_cancel");
1377     KA_TRACE(20, ("GOMP_cancel: T#%d\n", gtid));
1378 
1379     kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
1380 
1381     if(do_cancel == FALSE) {
1382         return xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(which);
1383     } else {
1384         return __kmpc_cancel(&loc, gtid, cncl_kind);
1385     }
1386 }
1387 
1388 bool
1389 xexpand(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL)(void)
1390 {
1391     if(__kmp_omp_cancellation) {
1392         KMP_FATAL(NoGompCancellation);
1393     }
1394     int gtid = __kmp_get_gtid();
1395     MKLOC(loc, "GOMP_sections_end_cancel");
1396     KA_TRACE(20, ("GOMP_sections_end_cancel: T#%d\n", gtid));
1397 
1398     return __kmpc_cancel_barrier(&loc, gtid);
1399 }
1400 
1401 bool
1402 xexpand(KMP_API_NAME_GOMP_LOOP_END_CANCEL)(void)
1403 {
1404     if(__kmp_omp_cancellation) {
1405         KMP_FATAL(NoGompCancellation);
1406     }
1407     int gtid = __kmp_get_gtid();
1408     MKLOC(loc, "GOMP_loop_end_cancel");
1409     KA_TRACE(20, ("GOMP_loop_end_cancel: T#%d\n", gtid));
1410 
1411     return __kmpc_cancel_barrier(&loc, gtid);
1412 }
1413 
1414 // All target functions are empty as of 2014-05-29
1415 void
1416 xexpand(KMP_API_NAME_GOMP_TARGET)(int device, void (*fn) (void *), const void *openmp_target,
1417              size_t mapnum, void **hostaddrs, size_t *sizes, unsigned char *kinds)
1418 {
1419     return;
1420 }
1421 
1422 void
1423 xexpand(KMP_API_NAME_GOMP_TARGET_DATA)(int device, const void *openmp_target, size_t mapnum,
1424                   void **hostaddrs, size_t *sizes, unsigned char *kinds)
1425 {
1426     return;
1427 }
1428 
1429 void
1430 xexpand(KMP_API_NAME_GOMP_TARGET_END_DATA)(void)
1431 {
1432     return;
1433 }
1434 
1435 void
1436 xexpand(KMP_API_NAME_GOMP_TARGET_UPDATE)(int device, const void *openmp_target, size_t mapnum,
1437                     void **hostaddrs, size_t *sizes, unsigned char *kinds)
1438 {
1439     return;
1440 }
1441 
1442 void
1443 xexpand(KMP_API_NAME_GOMP_TEAMS)(unsigned int num_teams, unsigned int thread_limit)
1444 {
1445     return;
1446 }
1447 #endif // OMP_40_ENABLED
1448 
1449 
1450 /*
1451     The following sections of code create aliases for the GOMP_* functions,
1452     then create versioned symbols using the assembler directive .symver.
1453     This is only pertinent for ELF .so library
1454     xaliasify and xversionify are defined in kmp_ftn_os.h
1455 */
1456 
1457 #ifdef KMP_USE_VERSION_SYMBOLS
1458 
1459 // GOMP_1.0 aliases
1460 xaliasify(KMP_API_NAME_GOMP_ATOMIC_END, 10);
1461 xaliasify(KMP_API_NAME_GOMP_ATOMIC_START, 10);
1462 xaliasify(KMP_API_NAME_GOMP_BARRIER, 10);
1463 xaliasify(KMP_API_NAME_GOMP_CRITICAL_END, 10);
1464 xaliasify(KMP_API_NAME_GOMP_CRITICAL_NAME_END, 10);
1465 xaliasify(KMP_API_NAME_GOMP_CRITICAL_NAME_START, 10);
1466 xaliasify(KMP_API_NAME_GOMP_CRITICAL_START, 10);
1467 xaliasify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT, 10);
1468 xaliasify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START, 10);
1469 xaliasify(KMP_API_NAME_GOMP_LOOP_END, 10);
1470 xaliasify(KMP_API_NAME_GOMP_LOOP_END_NOWAIT, 10);
1471 xaliasify(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT, 10);
1472 xaliasify(KMP_API_NAME_GOMP_LOOP_GUIDED_START, 10);
1473 xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT, 10);
1474 xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START, 10);
1475 xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT, 10);
1476 xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START, 10);
1477 xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT, 10);
1478 xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START, 10);
1479 xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT, 10);
1480 xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START, 10);
1481 xaliasify(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT, 10);
1482 xaliasify(KMP_API_NAME_GOMP_LOOP_RUNTIME_START, 10);
1483 xaliasify(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT, 10);
1484 xaliasify(KMP_API_NAME_GOMP_LOOP_STATIC_START, 10);
1485 xaliasify(KMP_API_NAME_GOMP_ORDERED_END, 10);
1486 xaliasify(KMP_API_NAME_GOMP_ORDERED_START, 10);
1487 xaliasify(KMP_API_NAME_GOMP_PARALLEL_END, 10);
1488 xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START, 10);
1489 xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START, 10);
1490 xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START, 10);
1491 xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START, 10);
1492 xaliasify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START, 10);
1493 xaliasify(KMP_API_NAME_GOMP_PARALLEL_START, 10);
1494 xaliasify(KMP_API_NAME_GOMP_SECTIONS_END, 10);
1495 xaliasify(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT, 10);
1496 xaliasify(KMP_API_NAME_GOMP_SECTIONS_NEXT, 10);
1497 xaliasify(KMP_API_NAME_GOMP_SECTIONS_START, 10);
1498 xaliasify(KMP_API_NAME_GOMP_SINGLE_COPY_END, 10);
1499 xaliasify(KMP_API_NAME_GOMP_SINGLE_COPY_START, 10);
1500 xaliasify(KMP_API_NAME_GOMP_SINGLE_START, 10);
1501 
1502 // GOMP_2.0 aliases
1503 xaliasify(KMP_API_NAME_GOMP_TASK, 20);
1504 xaliasify(KMP_API_NAME_GOMP_TASKWAIT, 20);
1505 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT, 20);
1506 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START, 20);
1507 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT, 20);
1508 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START, 20);
1509 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT, 20);
1510 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START, 20);
1511 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT, 20);
1512 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START, 20);
1513 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT, 20);
1514 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START, 20);
1515 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT, 20);
1516 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START, 20);
1517 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT, 20);
1518 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START, 20);
1519 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT, 20);
1520 xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START, 20);
1521 
1522 // GOMP_3.0 aliases
1523 xaliasify(KMP_API_NAME_GOMP_TASKYIELD, 30);
1524 
1525 // GOMP_4.0 aliases
1526 // The GOMP_parallel* entry points below aren't OpenMP 4.0 related.
1527 #if OMP_40_ENABLED
1528 xaliasify(KMP_API_NAME_GOMP_PARALLEL, 40);
1529 xaliasify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS, 40);
1530 xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC, 40);
1531 xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED, 40);
1532 xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME, 40);
1533 xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC, 40);
1534 xaliasify(KMP_API_NAME_GOMP_TASKGROUP_START, 40);
1535 xaliasify(KMP_API_NAME_GOMP_TASKGROUP_END, 40);
1536 xaliasify(KMP_API_NAME_GOMP_BARRIER_CANCEL, 40);
1537 xaliasify(KMP_API_NAME_GOMP_CANCEL, 40);
1538 xaliasify(KMP_API_NAME_GOMP_CANCELLATION_POINT, 40);
1539 xaliasify(KMP_API_NAME_GOMP_LOOP_END_CANCEL, 40);
1540 xaliasify(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL, 40);
1541 xaliasify(KMP_API_NAME_GOMP_TARGET, 40);
1542 xaliasify(KMP_API_NAME_GOMP_TARGET_DATA, 40);
1543 xaliasify(KMP_API_NAME_GOMP_TARGET_END_DATA, 40);
1544 xaliasify(KMP_API_NAME_GOMP_TARGET_UPDATE, 40);
1545 xaliasify(KMP_API_NAME_GOMP_TEAMS, 40);
1546 #endif
1547 
1548 // GOMP_1.0 versioned symbols
1549 xversionify(KMP_API_NAME_GOMP_ATOMIC_END, 10, "GOMP_1.0");
1550 xversionify(KMP_API_NAME_GOMP_ATOMIC_START, 10, "GOMP_1.0");
1551 xversionify(KMP_API_NAME_GOMP_BARRIER, 10, "GOMP_1.0");
1552 xversionify(KMP_API_NAME_GOMP_CRITICAL_END, 10, "GOMP_1.0");
1553 xversionify(KMP_API_NAME_GOMP_CRITICAL_NAME_END, 10, "GOMP_1.0");
1554 xversionify(KMP_API_NAME_GOMP_CRITICAL_NAME_START, 10, "GOMP_1.0");
1555 xversionify(KMP_API_NAME_GOMP_CRITICAL_START, 10, "GOMP_1.0");
1556 xversionify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT, 10, "GOMP_1.0");
1557 xversionify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START, 10, "GOMP_1.0");
1558 xversionify(KMP_API_NAME_GOMP_LOOP_END, 10, "GOMP_1.0");
1559 xversionify(KMP_API_NAME_GOMP_LOOP_END_NOWAIT, 10, "GOMP_1.0");
1560 xversionify(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT, 10, "GOMP_1.0");
1561 xversionify(KMP_API_NAME_GOMP_LOOP_GUIDED_START, 10, "GOMP_1.0");
1562 xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT, 10, "GOMP_1.0");
1563 xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START, 10, "GOMP_1.0");
1564 xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT, 10, "GOMP_1.0");
1565 xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START, 10, "GOMP_1.0");
1566 xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT, 10, "GOMP_1.0");
1567 xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START, 10, "GOMP_1.0");
1568 xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT, 10, "GOMP_1.0");
1569 xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START, 10, "GOMP_1.0");
1570 xversionify(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT, 10, "GOMP_1.0");
1571 xversionify(KMP_API_NAME_GOMP_LOOP_RUNTIME_START, 10, "GOMP_1.0");
1572 xversionify(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT, 10, "GOMP_1.0");
1573 xversionify(KMP_API_NAME_GOMP_LOOP_STATIC_START, 10, "GOMP_1.0");
1574 xversionify(KMP_API_NAME_GOMP_ORDERED_END, 10, "GOMP_1.0");
1575 xversionify(KMP_API_NAME_GOMP_ORDERED_START, 10, "GOMP_1.0");
1576 xversionify(KMP_API_NAME_GOMP_PARALLEL_END, 10, "GOMP_1.0");
1577 xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START, 10, "GOMP_1.0");
1578 xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START, 10, "GOMP_1.0");
1579 xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START, 10, "GOMP_1.0");
1580 xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START, 10, "GOMP_1.0");
1581 xversionify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START, 10, "GOMP_1.0");
1582 xversionify(KMP_API_NAME_GOMP_PARALLEL_START, 10, "GOMP_1.0");
1583 xversionify(KMP_API_NAME_GOMP_SECTIONS_END, 10, "GOMP_1.0");
1584 xversionify(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT, 10, "GOMP_1.0");
1585 xversionify(KMP_API_NAME_GOMP_SECTIONS_NEXT, 10, "GOMP_1.0");
1586 xversionify(KMP_API_NAME_GOMP_SECTIONS_START, 10, "GOMP_1.0");
1587 xversionify(KMP_API_NAME_GOMP_SINGLE_COPY_END, 10, "GOMP_1.0");
1588 xversionify(KMP_API_NAME_GOMP_SINGLE_COPY_START, 10, "GOMP_1.0");
1589 xversionify(KMP_API_NAME_GOMP_SINGLE_START, 10, "GOMP_1.0");
1590 
1591 // GOMP_2.0 versioned symbols
1592 xversionify(KMP_API_NAME_GOMP_TASK, 20, "GOMP_2.0");
1593 xversionify(KMP_API_NAME_GOMP_TASKWAIT, 20, "GOMP_2.0");
1594 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT, 20, "GOMP_2.0");
1595 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START, 20, "GOMP_2.0");
1596 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT, 20, "GOMP_2.0");
1597 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START, 20, "GOMP_2.0");
1598 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT, 20, "GOMP_2.0");
1599 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START, 20, "GOMP_2.0");
1600 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT, 20, "GOMP_2.0");
1601 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START, 20, "GOMP_2.0");
1602 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT, 20, "GOMP_2.0");
1603 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START, 20, "GOMP_2.0");
1604 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT, 20, "GOMP_2.0");
1605 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START, 20, "GOMP_2.0");
1606 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT, 20, "GOMP_2.0");
1607 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START, 20, "GOMP_2.0");
1608 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT, 20, "GOMP_2.0");
1609 xversionify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START, 20, "GOMP_2.0");
1610 
1611 // GOMP_3.0 versioned symbols
1612 xversionify(KMP_API_NAME_GOMP_TASKYIELD, 30, "GOMP_3.0");
1613 
1614 // GOMP_4.0 versioned symbols
1615 #if OMP_40_ENABLED
1616 xversionify(KMP_API_NAME_GOMP_PARALLEL, 40, "GOMP_4.0");
1617 xversionify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS, 40, "GOMP_4.0");
1618 xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC, 40, "GOMP_4.0");
1619 xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED, 40, "GOMP_4.0");
1620 xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME, 40, "GOMP_4.0");
1621 xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC, 40, "GOMP_4.0");
1622 xversionify(KMP_API_NAME_GOMP_TASKGROUP_START, 40, "GOMP_4.0");
1623 xversionify(KMP_API_NAME_GOMP_TASKGROUP_END, 40, "GOMP_4.0");
1624 xversionify(KMP_API_NAME_GOMP_BARRIER_CANCEL, 40, "GOMP_4.0");
1625 xversionify(KMP_API_NAME_GOMP_CANCEL, 40, "GOMP_4.0");
1626 xversionify(KMP_API_NAME_GOMP_CANCELLATION_POINT, 40, "GOMP_4.0");
1627 xversionify(KMP_API_NAME_GOMP_LOOP_END_CANCEL, 40, "GOMP_4.0");
1628 xversionify(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL, 40, "GOMP_4.0");
1629 xversionify(KMP_API_NAME_GOMP_TARGET, 40, "GOMP_4.0");
1630 xversionify(KMP_API_NAME_GOMP_TARGET_DATA, 40, "GOMP_4.0");
1631 xversionify(KMP_API_NAME_GOMP_TARGET_END_DATA, 40, "GOMP_4.0");
1632 xversionify(KMP_API_NAME_GOMP_TARGET_UPDATE, 40, "GOMP_4.0");
1633 xversionify(KMP_API_NAME_GOMP_TEAMS, 40, "GOMP_4.0");
1634 #endif
1635 
1636 #endif // KMP_USE_VERSION_SYMBOLS
1637 
1638 #ifdef __cplusplus
1639     } //extern "C"
1640 #endif // __cplusplus
1641 
1642 
1643