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