LLVM OpenMP* Runtime Library
kmp_gsupport.cpp
1 /*
2  * kmp_gsupport.cpp
3  */
4 
5 //===----------------------------------------------------------------------===//
6 //
7 // The LLVM Compiler Infrastructure
8 //
9 // This file is dual licensed under the MIT and the University of Illinois Open
10 // Source Licenses. See LICENSE.txt for details.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "kmp.h"
15 #include "kmp_atomic.h"
16 
17 #if OMPT_SUPPORT
18 #include "ompt-specific.h"
19 #endif
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif // __cplusplus
24 
25 #define MKLOC(loc, routine) \
26  static ident_t(loc) = {0, KMP_IDENT_KMPC, 0, 0, ";unknown;unknown;0;0;;"};
27 
28 #include "kmp_ftn_os.h"
29 
30 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_BARRIER)(void) {
31  int gtid = __kmp_entry_gtid();
32  MKLOC(loc, "GOMP_barrier");
33  KA_TRACE(20, ("GOMP_barrier: T#%d\n", gtid));
34 #if OMPT_SUPPORT && OMPT_OPTIONAL
35  ompt_frame_t *ompt_frame;
36  if (ompt_enabled.enabled) {
37  __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
38  ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
39  OMPT_STORE_RETURN_ADDRESS(gtid);
40  }
41 #endif
42  __kmpc_barrier(&loc, gtid);
43 #if OMPT_SUPPORT && OMPT_OPTIONAL
44  if (ompt_enabled.enabled) {
45  ompt_frame->enter_frame = ompt_data_none;
46  }
47 #endif
48 }
49 
50 // Mutual exclusion
51 
52 // The symbol that icc/ifort generates for unnamed for unnamed critical sections
53 // - .gomp_critical_user_ - is defined using .comm in any objects reference it.
54 // We can't reference it directly here in C code, as the symbol contains a ".".
55 //
56 // The RTL contains an assembly language definition of .gomp_critical_user_
57 // with another symbol __kmp_unnamed_critical_addr initialized with it's
58 // address.
59 extern kmp_critical_name *__kmp_unnamed_critical_addr;
60 
61 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CRITICAL_START)(void) {
62  int gtid = __kmp_entry_gtid();
63  MKLOC(loc, "GOMP_critical_start");
64  KA_TRACE(20, ("GOMP_critical_start: T#%d\n", gtid));
65 #if OMPT_SUPPORT && OMPT_OPTIONAL
66  OMPT_STORE_RETURN_ADDRESS(gtid);
67 #endif
68  __kmpc_critical(&loc, gtid, __kmp_unnamed_critical_addr);
69 }
70 
71 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CRITICAL_END)(void) {
72  int gtid = __kmp_get_gtid();
73  MKLOC(loc, "GOMP_critical_end");
74  KA_TRACE(20, ("GOMP_critical_end: T#%d\n", gtid));
75 #if OMPT_SUPPORT && OMPT_OPTIONAL
76  OMPT_STORE_RETURN_ADDRESS(gtid);
77 #endif
78  __kmpc_end_critical(&loc, gtid, __kmp_unnamed_critical_addr);
79 }
80 
81 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CRITICAL_NAME_START)(void **pptr) {
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 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CRITICAL_NAME_END)(void **pptr) {
89  int gtid = __kmp_get_gtid();
90  MKLOC(loc, "GOMP_critical_name_end");
91  KA_TRACE(20, ("GOMP_critical_name_end: T#%d\n", gtid));
92  __kmpc_end_critical(&loc, gtid, (kmp_critical_name *)pptr);
93 }
94 
95 // The Gnu codegen tries to use locked operations to perform atomic updates
96 // inline. If it can't, then it calls GOMP_atomic_start() before performing
97 // the update and GOMP_atomic_end() afterward, regardless of the data type.
98 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ATOMIC_START)(void) {
99  int gtid = __kmp_entry_gtid();
100  KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
101 
102 #if OMPT_SUPPORT
103  __ompt_thread_assign_wait_id(0);
104 #endif
105 
106  __kmp_acquire_atomic_lock(&__kmp_atomic_lock, gtid);
107 }
108 
109 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ATOMIC_END)(void) {
110  int gtid = __kmp_get_gtid();
111  KA_TRACE(20, ("GOMP_atomic_end: T#%d\n", gtid));
112  __kmp_release_atomic_lock(&__kmp_atomic_lock, gtid);
113 }
114 
115 int KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_START)(void) {
116  int gtid = __kmp_entry_gtid();
117  MKLOC(loc, "GOMP_single_start");
118  KA_TRACE(20, ("GOMP_single_start: T#%d\n", gtid));
119 
120  if (!TCR_4(__kmp_init_parallel))
121  __kmp_parallel_initialize();
122 
123 #if OMP_50_ENABLED
124  __kmp_resume_if_soft_paused();
125 #endif
126 
127  // 3rd parameter == FALSE prevents kmp_enter_single from pushing a
128  // workshare when USE_CHECKS is defined. We need to avoid the push,
129  // as there is no corresponding GOMP_single_end() call.
130  kmp_int32 rc = __kmp_enter_single(gtid, &loc, FALSE);
131 
132 #if OMPT_SUPPORT && OMPT_OPTIONAL
133  kmp_info_t *this_thr = __kmp_threads[gtid];
134  kmp_team_t *team = this_thr->th.th_team;
135  int tid = __kmp_tid_from_gtid(gtid);
136 
137  if (ompt_enabled.enabled) {
138  if (rc) {
139  if (ompt_enabled.ompt_callback_work) {
140  ompt_callbacks.ompt_callback(ompt_callback_work)(
141  ompt_work_single_executor, ompt_scope_begin,
142  &(team->t.ompt_team_info.parallel_data),
143  &(team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_data),
144  1, OMPT_GET_RETURN_ADDRESS(0));
145  }
146  } else {
147  if (ompt_enabled.ompt_callback_work) {
148  ompt_callbacks.ompt_callback(ompt_callback_work)(
149  ompt_work_single_other, ompt_scope_begin,
150  &(team->t.ompt_team_info.parallel_data),
151  &(team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_data),
152  1, OMPT_GET_RETURN_ADDRESS(0));
153  ompt_callbacks.ompt_callback(ompt_callback_work)(
154  ompt_work_single_other, ompt_scope_end,
155  &(team->t.ompt_team_info.parallel_data),
156  &(team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_data),
157  1, OMPT_GET_RETURN_ADDRESS(0));
158  }
159  }
160  }
161 #endif
162 
163  return rc;
164 }
165 
166 void *KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_COPY_START)(void) {
167  void *retval;
168  int gtid = __kmp_entry_gtid();
169  MKLOC(loc, "GOMP_single_copy_start");
170  KA_TRACE(20, ("GOMP_single_copy_start: T#%d\n", gtid));
171 
172  if (!TCR_4(__kmp_init_parallel))
173  __kmp_parallel_initialize();
174 
175 #if OMP_50_ENABLED
176  __kmp_resume_if_soft_paused();
177 #endif
178 
179  // If this is the first thread to enter, return NULL. The generated code will
180  // then call GOMP_single_copy_end() for this thread only, with the
181  // copyprivate data pointer as an argument.
182  if (__kmp_enter_single(gtid, &loc, FALSE))
183  return NULL;
184 
185 // Wait for the first thread to set the copyprivate data pointer,
186 // and for all other threads to reach this point.
187 
188 #if OMPT_SUPPORT && OMPT_OPTIONAL
189  ompt_frame_t *ompt_frame;
190  if (ompt_enabled.enabled) {
191  __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
192  ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
193  OMPT_STORE_RETURN_ADDRESS(gtid);
194  }
195 #endif
196  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
197 
198  // Retrieve the value of the copyprivate data point, and wait for all
199  // threads to do likewise, then return.
200  retval = __kmp_team_from_gtid(gtid)->t.t_copypriv_data;
201 #if OMPT_SUPPORT && OMPT_OPTIONAL
202  if (ompt_enabled.enabled) {
203  OMPT_STORE_RETURN_ADDRESS(gtid);
204  }
205 #endif
206  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
207 #if OMPT_SUPPORT && OMPT_OPTIONAL
208  if (ompt_enabled.enabled) {
209  ompt_frame->enter_frame = ompt_data_none;
210  }
211 #endif
212  return retval;
213 }
214 
215 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_COPY_END)(void *data) {
216  int gtid = __kmp_get_gtid();
217  KA_TRACE(20, ("GOMP_single_copy_end: T#%d\n", gtid));
218 
219  // Set the copyprivate data pointer fo the team, then hit the barrier so that
220  // the other threads will continue on and read it. Hit another barrier before
221  // continuing, so that the know that the copyprivate data pointer has been
222  // propagated to all threads before trying to reuse the t_copypriv_data field.
223  __kmp_team_from_gtid(gtid)->t.t_copypriv_data = data;
224 #if OMPT_SUPPORT && OMPT_OPTIONAL
225  ompt_frame_t *ompt_frame;
226  if (ompt_enabled.enabled) {
227  __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
228  ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
229  OMPT_STORE_RETURN_ADDRESS(gtid);
230  }
231 #endif
232  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
233 #if OMPT_SUPPORT && OMPT_OPTIONAL
234  if (ompt_enabled.enabled) {
235  OMPT_STORE_RETURN_ADDRESS(gtid);
236  }
237 #endif
238  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
239 #if OMPT_SUPPORT && OMPT_OPTIONAL
240  if (ompt_enabled.enabled) {
241  ompt_frame->enter_frame = ompt_data_none;
242  }
243 #endif
244 }
245 
246 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ORDERED_START)(void) {
247  int gtid = __kmp_entry_gtid();
248  MKLOC(loc, "GOMP_ordered_start");
249  KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
250 #if OMPT_SUPPORT && OMPT_OPTIONAL
251  OMPT_STORE_RETURN_ADDRESS(gtid);
252 #endif
253  __kmpc_ordered(&loc, gtid);
254 }
255 
256 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ORDERED_END)(void) {
257  int gtid = __kmp_get_gtid();
258  MKLOC(loc, "GOMP_ordered_end");
259  KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
260 #if OMPT_SUPPORT && OMPT_OPTIONAL
261  OMPT_STORE_RETURN_ADDRESS(gtid);
262 #endif
263  __kmpc_end_ordered(&loc, gtid);
264 }
265 
266 // Dispatch macro defs
267 //
268 // They come in two flavors: 64-bit unsigned, and either 32-bit signed
269 // (IA-32 architecture) or 64-bit signed (Intel(R) 64).
270 
271 #if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS
272 #define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_4
273 #define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_4
274 #define KMP_DISPATCH_NEXT __kmpc_dispatch_next_4
275 #else
276 #define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_8
277 #define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_8
278 #define KMP_DISPATCH_NEXT __kmpc_dispatch_next_8
279 #endif /* KMP_ARCH_X86 */
280 
281 #define KMP_DISPATCH_INIT_ULL __kmp_aux_dispatch_init_8u
282 #define KMP_DISPATCH_FINI_CHUNK_ULL __kmp_aux_dispatch_fini_chunk_8u
283 #define KMP_DISPATCH_NEXT_ULL __kmpc_dispatch_next_8u
284 
285 // The parallel contruct
286 
287 #ifndef KMP_DEBUG
288 static
289 #endif /* KMP_DEBUG */
290  void
291  __kmp_GOMP_microtask_wrapper(int *gtid, int *npr, void (*task)(void *),
292  void *data) {
293 #if OMPT_SUPPORT
294  kmp_info_t *thr;
295  ompt_frame_t *ompt_frame;
296  ompt_state_t enclosing_state;
297 
298  if (ompt_enabled.enabled) {
299  // get pointer to thread data structure
300  thr = __kmp_threads[*gtid];
301 
302  // save enclosing task state; set current state for task
303  enclosing_state = thr->th.ompt_thread_info.state;
304  thr->th.ompt_thread_info.state = ompt_state_work_parallel;
305 
306  // set task frame
307  __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
308  ompt_frame->exit_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
309  }
310 #endif
311 
312  task(data);
313 
314 #if OMPT_SUPPORT
315  if (ompt_enabled.enabled) {
316  // clear task frame
317  ompt_frame->exit_frame = ompt_data_none;
318 
319  // restore enclosing state
320  thr->th.ompt_thread_info.state = enclosing_state;
321  }
322 #endif
323 }
324 
325 #ifndef KMP_DEBUG
326 static
327 #endif /* KMP_DEBUG */
328  void
329  __kmp_GOMP_parallel_microtask_wrapper(int *gtid, int *npr,
330  void (*task)(void *), void *data,
331  unsigned num_threads, ident_t *loc,
332  enum sched_type schedule, long start,
333  long end, long incr,
334  long chunk_size) {
335  // Intialize the loop worksharing construct.
336 
337  KMP_DISPATCH_INIT(loc, *gtid, schedule, start, end, incr, chunk_size,
338  schedule != kmp_sch_static);
339 
340 #if OMPT_SUPPORT
341  kmp_info_t *thr;
342  ompt_frame_t *ompt_frame;
343  ompt_state_t enclosing_state;
344 
345  if (ompt_enabled.enabled) {
346  thr = __kmp_threads[*gtid];
347  // save enclosing task state; set current state for task
348  enclosing_state = thr->th.ompt_thread_info.state;
349  thr->th.ompt_thread_info.state = ompt_state_work_parallel;
350 
351  // set task frame
352  __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
353  ompt_frame->exit_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
354  }
355 #endif
356 
357  // Now invoke the microtask.
358  task(data);
359 
360 #if OMPT_SUPPORT
361  if (ompt_enabled.enabled) {
362  // clear task frame
363  ompt_frame->exit_frame = ompt_data_none;
364 
365  // reset enclosing state
366  thr->th.ompt_thread_info.state = enclosing_state;
367  }
368 #endif
369 }
370 
371 #ifndef KMP_DEBUG
372 static
373 #endif /* KMP_DEBUG */
374  void
375  __kmp_GOMP_fork_call(ident_t *loc, int gtid, void (*unwrapped_task)(void *),
376  microtask_t wrapper, int argc, ...) {
377  int rc;
378  kmp_info_t *thr = __kmp_threads[gtid];
379  kmp_team_t *team = thr->th.th_team;
380  int tid = __kmp_tid_from_gtid(gtid);
381 
382  va_list ap;
383  va_start(ap, argc);
384 
385  rc = __kmp_fork_call(loc, gtid, fork_context_gnu, argc, wrapper,
386  __kmp_invoke_task_func,
387 #if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
388  &ap
389 #else
390  ap
391 #endif
392  );
393 
394  va_end(ap);
395 
396  if (rc) {
397  __kmp_run_before_invoked_task(gtid, tid, thr, team);
398  }
399 
400 #if OMPT_SUPPORT
401  int ompt_team_size;
402  if (ompt_enabled.enabled) {
403  ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
404  ompt_task_info_t *task_info = __ompt_get_task_info_object(0);
405 
406  // implicit task callback
407  if (ompt_enabled.ompt_callback_implicit_task) {
408  ompt_team_size = __kmp_team_from_gtid(gtid)->t.t_nproc;
409  ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
410  ompt_scope_begin, &(team_info->parallel_data),
411  &(task_info->task_data), ompt_team_size, __kmp_tid_from_gtid(gtid), ompt_task_implicit); // TODO: Can this be ompt_task_initial?
412  task_info->thread_num = __kmp_tid_from_gtid(gtid);
413  }
414  thr->th.ompt_thread_info.state = ompt_state_work_parallel;
415  }
416 #endif
417 }
418 
419 static void __kmp_GOMP_serialized_parallel(ident_t *loc, kmp_int32 gtid,
420  void (*task)(void *)) {
421 #if OMPT_SUPPORT
422  OMPT_STORE_RETURN_ADDRESS(gtid);
423 #endif
424  __kmp_serialized_parallel(loc, gtid);
425 }
426 
427 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_START)(void (*task)(void *),
428  void *data,
429  unsigned num_threads) {
430  int gtid = __kmp_entry_gtid();
431 
432 #if OMPT_SUPPORT
433  ompt_frame_t *parent_frame, *frame;
434 
435  if (ompt_enabled.enabled) {
436  __ompt_get_task_info_internal(0, NULL, NULL, &parent_frame, NULL, NULL);
437  parent_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
438  OMPT_STORE_RETURN_ADDRESS(gtid);
439  }
440 #endif
441 
442  MKLOC(loc, "GOMP_parallel_start");
443  KA_TRACE(20, ("GOMP_parallel_start: T#%d\n", gtid));
444 
445  if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
446  if (num_threads != 0) {
447  __kmp_push_num_threads(&loc, gtid, num_threads);
448  }
449  __kmp_GOMP_fork_call(&loc, gtid, task,
450  (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task,
451  data);
452  } else {
453  __kmp_GOMP_serialized_parallel(&loc, gtid, task);
454  }
455 
456 #if OMPT_SUPPORT
457  if (ompt_enabled.enabled) {
458  __ompt_get_task_info_internal(0, NULL, NULL, &frame, NULL, NULL);
459  frame->exit_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
460  }
461 #endif
462 }
463 
464 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_END)(void) {
465  int gtid = __kmp_get_gtid();
466  kmp_info_t *thr;
467 
468  thr = __kmp_threads[gtid];
469 
470  MKLOC(loc, "GOMP_parallel_end");
471  KA_TRACE(20, ("GOMP_parallel_end: T#%d\n", gtid));
472 
473  if (!thr->th.th_team->t.t_serialized) {
474  __kmp_run_after_invoked_task(gtid, __kmp_tid_from_gtid(gtid), thr,
475  thr->th.th_team);
476 
477 #if OMPT_SUPPORT
478  if (ompt_enabled.enabled) {
479  // Implicit task is finished here, in the barrier we might schedule
480  // deferred tasks,
481  // these don't see the implicit task on the stack
482  OMPT_CUR_TASK_INFO(thr)->frame.exit_frame = ompt_data_none;
483  }
484 #endif
485 
486  __kmp_join_call(&loc, gtid
487 #if OMPT_SUPPORT
488  ,
489  fork_context_gnu
490 #endif
491  );
492  } else {
493  __kmpc_end_serialized_parallel(&loc, gtid);
494  }
495 }
496 
497 // Loop worksharing constructs
498 
499 // The Gnu codegen passes in an exclusive upper bound for the overall range,
500 // but the libguide dispatch code expects an inclusive upper bound, hence the
501 // "end - incr" 5th argument to KMP_DISPATCH_INIT (and the " ub - str" 11th
502 // argument to __kmp_GOMP_fork_call).
503 //
504 // Conversely, KMP_DISPATCH_NEXT returns and inclusive upper bound in *p_ub,
505 // but the Gnu codegen expects an excluside upper bound, so the adjustment
506 // "*p_ub += stride" compenstates for the discrepancy.
507 //
508 // Correction: the gnu codegen always adjusts the upper bound by +-1, not the
509 // stride value. We adjust the dispatch parameters accordingly (by +-1), but
510 // we still adjust p_ub by the actual stride value.
511 //
512 // The "runtime" versions do not take a chunk_sz parameter.
513 //
514 // The profile lib cannot support construct checking of unordered loops that
515 // are predetermined by the compiler to be statically scheduled, as the gcc
516 // codegen will not always emit calls to GOMP_loop_static_next() to get the
517 // next iteration. Instead, it emits inline code to call omp_get_thread_num()
518 // num and calculate the iteration space using the result. It doesn't do this
519 // with ordered static loop, so they can be checked.
520 
521 #if OMPT_SUPPORT
522 #define IF_OMPT_SUPPORT(code) code
523 #else
524 #define IF_OMPT_SUPPORT(code)
525 #endif
526 
527 #define LOOP_START(func, schedule) \
528  int func(long lb, long ub, long str, long chunk_sz, long *p_lb, \
529  long *p_ub) { \
530  int status; \
531  long stride; \
532  int gtid = __kmp_entry_gtid(); \
533  MKLOC(loc, KMP_STR(func)); \
534  KA_TRACE( \
535  20, \
536  (KMP_STR( \
537  func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
538  gtid, lb, ub, str, chunk_sz)); \
539  \
540  if ((str > 0) ? (lb < ub) : (lb > ub)) { \
541  IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
542  KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
543  (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
544  (schedule) != kmp_sch_static); \
545  IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
546  status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
547  (kmp_int *)p_ub, (kmp_int *)&stride); \
548  if (status) { \
549  KMP_DEBUG_ASSERT(stride == str); \
550  *p_ub += (str > 0) ? 1 : -1; \
551  } \
552  } else { \
553  status = 0; \
554  } \
555  \
556  KA_TRACE( \
557  20, \
558  (KMP_STR( \
559  func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
560  gtid, *p_lb, *p_ub, status)); \
561  return status; \
562  }
563 
564 #define LOOP_RUNTIME_START(func, schedule) \
565  int func(long lb, long ub, long str, long *p_lb, long *p_ub) { \
566  int status; \
567  long stride; \
568  long chunk_sz = 0; \
569  int gtid = __kmp_entry_gtid(); \
570  MKLOC(loc, KMP_STR(func)); \
571  KA_TRACE( \
572  20, \
573  (KMP_STR(func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n", \
574  gtid, lb, ub, str, chunk_sz)); \
575  \
576  if ((str > 0) ? (lb < ub) : (lb > ub)) { \
577  IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
578  KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
579  (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, TRUE); \
580  IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
581  status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
582  (kmp_int *)p_ub, (kmp_int *)&stride); \
583  if (status) { \
584  KMP_DEBUG_ASSERT(stride == str); \
585  *p_ub += (str > 0) ? 1 : -1; \
586  } \
587  } else { \
588  status = 0; \
589  } \
590  \
591  KA_TRACE( \
592  20, \
593  (KMP_STR( \
594  func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
595  gtid, *p_lb, *p_ub, status)); \
596  return status; \
597  }
598 
599 #if OMP_45_ENABLED
600 #define KMP_DOACROSS_FINI(status, gtid) \
601  if (!status && __kmp_threads[gtid]->th.th_dispatch->th_doacross_flags) { \
602  __kmpc_doacross_fini(NULL, gtid); \
603  }
604 #else
605 #define KMP_DOACROSS_FINI(status, gtid) /* Nothing */
606 #endif
607 
608 #define LOOP_NEXT(func, fini_code) \
609  int func(long *p_lb, long *p_ub) { \
610  int status; \
611  long stride; \
612  int gtid = __kmp_get_gtid(); \
613  MKLOC(loc, KMP_STR(func)); \
614  KA_TRACE(20, (KMP_STR(func) ": T#%d\n", gtid)); \
615  \
616  IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
617  fini_code status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
618  (kmp_int *)p_ub, (kmp_int *)&stride); \
619  if (status) { \
620  *p_ub += (stride > 0) ? 1 : -1; \
621  } \
622  KMP_DOACROSS_FINI(status, gtid) \
623  \
624  KA_TRACE( \
625  20, \
626  (KMP_STR(func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, stride 0x%lx, " \
627  "returning %d\n", \
628  gtid, *p_lb, *p_ub, stride, status)); \
629  return status; \
630  }
631 
632 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_STATIC_START), kmp_sch_static)
633 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT), {})
634 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START),
635  kmp_sch_dynamic_chunked)
636 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT), {})
637 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_GUIDED_START),
639 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT), {})
640 LOOP_RUNTIME_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_RUNTIME_START),
641  kmp_sch_runtime)
642 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT), {})
643 
644 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START),
646 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT),
647  { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
648 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START),
649  kmp_ord_dynamic_chunked)
650 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT),
651  { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
652 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START),
653  kmp_ord_guided_chunked)
654 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT),
655  { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
656 LOOP_RUNTIME_START(
657  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START),
658  kmp_ord_runtime)
659 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT),
660  { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
661 
662 #if OMP_45_ENABLED
663 #define LOOP_DOACROSS_START(func, schedule) \
664  bool func(unsigned ncounts, long *counts, long chunk_sz, long *p_lb, \
665  long *p_ub) { \
666  int status; \
667  long stride, lb, ub, str; \
668  int gtid = __kmp_entry_gtid(); \
669  struct kmp_dim *dims = \
670  (struct kmp_dim *)__kmp_allocate(sizeof(struct kmp_dim) * ncounts); \
671  MKLOC(loc, KMP_STR(func)); \
672  for (unsigned i = 0; i < ncounts; ++i) { \
673  dims[i].lo = 0; \
674  dims[i].up = counts[i] - 1; \
675  dims[i].st = 1; \
676  } \
677  __kmpc_doacross_init(&loc, gtid, (int)ncounts, dims); \
678  lb = 0; \
679  ub = counts[0]; \
680  str = 1; \
681  KA_TRACE(20, (KMP_STR(func) ": T#%d, ncounts %u, lb 0x%lx, ub 0x%lx, str " \
682  "0x%lx, chunk_sz " \
683  "0x%lx\n", \
684  gtid, ncounts, lb, ub, str, chunk_sz)); \
685  \
686  if ((str > 0) ? (lb < ub) : (lb > ub)) { \
687  KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
688  (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
689  (schedule) != kmp_sch_static); \
690  status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
691  (kmp_int *)p_ub, (kmp_int *)&stride); \
692  if (status) { \
693  KMP_DEBUG_ASSERT(stride == str); \
694  *p_ub += (str > 0) ? 1 : -1; \
695  } \
696  } else { \
697  status = 0; \
698  } \
699  KMP_DOACROSS_FINI(status, gtid); \
700  \
701  KA_TRACE( \
702  20, \
703  (KMP_STR( \
704  func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
705  gtid, *p_lb, *p_ub, status)); \
706  __kmp_free(dims); \
707  return status; \
708  }
709 
710 #define LOOP_DOACROSS_RUNTIME_START(func, schedule) \
711  int func(unsigned ncounts, long *counts, long *p_lb, long *p_ub) { \
712  int status; \
713  long stride, lb, ub, str; \
714  long chunk_sz = 0; \
715  int gtid = __kmp_entry_gtid(); \
716  struct kmp_dim *dims = \
717  (struct kmp_dim *)__kmp_allocate(sizeof(struct kmp_dim) * ncounts); \
718  MKLOC(loc, KMP_STR(func)); \
719  for (unsigned i = 0; i < ncounts; ++i) { \
720  dims[i].lo = 0; \
721  dims[i].up = counts[i] - 1; \
722  dims[i].st = 1; \
723  } \
724  __kmpc_doacross_init(&loc, gtid, (int)ncounts, dims); \
725  lb = 0; \
726  ub = counts[0]; \
727  str = 1; \
728  KA_TRACE( \
729  20, \
730  (KMP_STR(func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n", \
731  gtid, lb, ub, str, chunk_sz)); \
732  \
733  if ((str > 0) ? (lb < ub) : (lb > ub)) { \
734  KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
735  (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, TRUE); \
736  status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
737  (kmp_int *)p_ub, (kmp_int *)&stride); \
738  if (status) { \
739  KMP_DEBUG_ASSERT(stride == str); \
740  *p_ub += (str > 0) ? 1 : -1; \
741  } \
742  } else { \
743  status = 0; \
744  } \
745  KMP_DOACROSS_FINI(status, gtid); \
746  \
747  KA_TRACE( \
748  20, \
749  (KMP_STR( \
750  func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
751  gtid, *p_lb, *p_ub, status)); \
752  __kmp_free(dims); \
753  return status; \
754  }
755 
756 LOOP_DOACROSS_START(
757  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_STATIC_START),
759 LOOP_DOACROSS_START(
760  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_DYNAMIC_START),
761  kmp_sch_dynamic_chunked)
762 LOOP_DOACROSS_START(
763  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_GUIDED_START),
765 LOOP_DOACROSS_RUNTIME_START(
766  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_RUNTIME_START),
767  kmp_sch_runtime)
768 #endif // OMP_45_ENABLED
769 
770 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_END)(void) {
771  int gtid = __kmp_get_gtid();
772  KA_TRACE(20, ("GOMP_loop_end: T#%d\n", gtid))
773 
774 #if OMPT_SUPPORT && OMPT_OPTIONAL
775  ompt_frame_t *ompt_frame;
776  if (ompt_enabled.enabled) {
777  __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
778  ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
779  OMPT_STORE_RETURN_ADDRESS(gtid);
780  }
781 #endif
782  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
783 #if OMPT_SUPPORT && OMPT_OPTIONAL
784  if (ompt_enabled.enabled) {
785  ompt_frame->enter_frame = ompt_data_none;
786  }
787 #endif
788 
789  KA_TRACE(20, ("GOMP_loop_end exit: T#%d\n", gtid))
790 }
791 
792 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_END_NOWAIT)(void) {
793  KA_TRACE(20, ("GOMP_loop_end_nowait: T#%d\n", __kmp_get_gtid()))
794 }
795 
796 // Unsigned long long loop worksharing constructs
797 //
798 // These are new with gcc 4.4
799 
800 #define LOOP_START_ULL(func, schedule) \
801  int func(int up, unsigned long long lb, unsigned long long ub, \
802  unsigned long long str, unsigned long long chunk_sz, \
803  unsigned long long *p_lb, unsigned long long *p_ub) { \
804  int status; \
805  long long str2 = up ? ((long long)str) : -((long long)str); \
806  long long stride; \
807  int gtid = __kmp_entry_gtid(); \
808  MKLOC(loc, KMP_STR(func)); \
809  \
810  KA_TRACE(20, (KMP_STR(func) ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str " \
811  "0x%llx, chunk_sz 0x%llx\n", \
812  gtid, up, lb, ub, str, chunk_sz)); \
813  \
814  if ((str > 0) ? (lb < ub) : (lb > ub)) { \
815  KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
816  (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, \
817  (schedule) != kmp_sch_static); \
818  status = \
819  KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
820  (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
821  if (status) { \
822  KMP_DEBUG_ASSERT(stride == str2); \
823  *p_ub += (str > 0) ? 1 : -1; \
824  } \
825  } else { \
826  status = 0; \
827  } \
828  \
829  KA_TRACE( \
830  20, \
831  (KMP_STR( \
832  func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
833  gtid, *p_lb, *p_ub, status)); \
834  return status; \
835  }
836 
837 #define LOOP_RUNTIME_START_ULL(func, schedule) \
838  int func(int up, unsigned long long lb, unsigned long long ub, \
839  unsigned long long str, unsigned long long *p_lb, \
840  unsigned long long *p_ub) { \
841  int status; \
842  long long str2 = up ? ((long long)str) : -((long long)str); \
843  unsigned long long stride; \
844  unsigned long long chunk_sz = 0; \
845  int gtid = __kmp_entry_gtid(); \
846  MKLOC(loc, KMP_STR(func)); \
847  \
848  KA_TRACE(20, (KMP_STR(func) ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str " \
849  "0x%llx, chunk_sz 0x%llx\n", \
850  gtid, up, lb, ub, str, chunk_sz)); \
851  \
852  if ((str > 0) ? (lb < ub) : (lb > ub)) { \
853  KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
854  (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, \
855  TRUE); \
856  status = \
857  KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
858  (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
859  if (status) { \
860  KMP_DEBUG_ASSERT((long long)stride == str2); \
861  *p_ub += (str > 0) ? 1 : -1; \
862  } \
863  } else { \
864  status = 0; \
865  } \
866  \
867  KA_TRACE( \
868  20, \
869  (KMP_STR( \
870  func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
871  gtid, *p_lb, *p_ub, status)); \
872  return status; \
873  }
874 
875 #define LOOP_NEXT_ULL(func, fini_code) \
876  int func(unsigned long long *p_lb, unsigned long long *p_ub) { \
877  int status; \
878  long long stride; \
879  int gtid = __kmp_get_gtid(); \
880  MKLOC(loc, KMP_STR(func)); \
881  KA_TRACE(20, (KMP_STR(func) ": T#%d\n", gtid)); \
882  \
883  fini_code status = \
884  KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
885  (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
886  if (status) { \
887  *p_ub += (stride > 0) ? 1 : -1; \
888  } \
889  \
890  KA_TRACE( \
891  20, \
892  (KMP_STR( \
893  func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, stride 0x%llx, " \
894  "returning %d\n", \
895  gtid, *p_lb, *p_ub, stride, status)); \
896  return status; \
897  }
898 
899 LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START),
901 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT), {})
902 LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START),
903  kmp_sch_dynamic_chunked)
904 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT), {})
905 LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START),
907 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT), {})
908 LOOP_RUNTIME_START_ULL(
909  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START), kmp_sch_runtime)
910 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT), {})
911 
912 LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START),
914 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT),
915  { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
916 LOOP_START_ULL(
917  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START),
918  kmp_ord_dynamic_chunked)
919 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT),
920  { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
921 LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START),
922  kmp_ord_guided_chunked)
923 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT),
924  { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
925 LOOP_RUNTIME_START_ULL(
926  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START),
927  kmp_ord_runtime)
928 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT),
929  { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
930 
931 #if OMP_45_ENABLED
932 #define LOOP_DOACROSS_START_ULL(func, schedule) \
933  int func(unsigned ncounts, unsigned long long *counts, \
934  unsigned long long chunk_sz, unsigned long long *p_lb, \
935  unsigned long long *p_ub) { \
936  int status; \
937  long long stride, str, lb, ub; \
938  int gtid = __kmp_entry_gtid(); \
939  struct kmp_dim *dims = \
940  (struct kmp_dim *)__kmp_allocate(sizeof(struct kmp_dim) * ncounts); \
941  MKLOC(loc, KMP_STR(func)); \
942  for (unsigned i = 0; i < ncounts; ++i) { \
943  dims[i].lo = 0; \
944  dims[i].up = counts[i] - 1; \
945  dims[i].st = 1; \
946  } \
947  __kmpc_doacross_init(&loc, gtid, (int)ncounts, dims); \
948  lb = 0; \
949  ub = counts[0]; \
950  str = 1; \
951  \
952  KA_TRACE(20, (KMP_STR(func) ": T#%d, lb 0x%llx, ub 0x%llx, str " \
953  "0x%llx, chunk_sz 0x%llx\n", \
954  gtid, lb, ub, str, chunk_sz)); \
955  \
956  if ((str > 0) ? (lb < ub) : (lb > ub)) { \
957  KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
958  (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
959  (schedule) != kmp_sch_static); \
960  status = \
961  KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
962  (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
963  if (status) { \
964  KMP_DEBUG_ASSERT(stride == str); \
965  *p_ub += (str > 0) ? 1 : -1; \
966  } \
967  } else { \
968  status = 0; \
969  } \
970  KMP_DOACROSS_FINI(status, gtid); \
971  \
972  KA_TRACE( \
973  20, \
974  (KMP_STR( \
975  func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
976  gtid, *p_lb, *p_ub, status)); \
977  __kmp_free(dims); \
978  return status; \
979  }
980 
981 #define LOOP_DOACROSS_RUNTIME_START_ULL(func, schedule) \
982  int func(unsigned ncounts, unsigned long long *counts, \
983  unsigned long long *p_lb, unsigned long long *p_ub) { \
984  int status; \
985  unsigned long long stride, str, lb, ub; \
986  unsigned long long chunk_sz = 0; \
987  int gtid = __kmp_entry_gtid(); \
988  struct kmp_dim *dims = \
989  (struct kmp_dim *)__kmp_allocate(sizeof(struct kmp_dim) * ncounts); \
990  MKLOC(loc, KMP_STR(func)); \
991  for (unsigned i = 0; i < ncounts; ++i) { \
992  dims[i].lo = 0; \
993  dims[i].up = counts[i] - 1; \
994  dims[i].st = 1; \
995  } \
996  __kmpc_doacross_init(&loc, gtid, (int)ncounts, dims); \
997  lb = 0; \
998  ub = counts[0]; \
999  str = 1; \
1000  KA_TRACE(20, (KMP_STR(func) ": T#%d, lb 0x%llx, ub 0x%llx, str " \
1001  "0x%llx, chunk_sz 0x%llx\n", \
1002  gtid, lb, ub, str, chunk_sz)); \
1003  \
1004  if ((str > 0) ? (lb < ub) : (lb > ub)) { \
1005  KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
1006  (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
1007  TRUE); \
1008  status = \
1009  KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
1010  (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
1011  if (status) { \
1012  KMP_DEBUG_ASSERT(stride == str); \
1013  *p_ub += (str > 0) ? 1 : -1; \
1014  } \
1015  } else { \
1016  status = 0; \
1017  } \
1018  KMP_DOACROSS_FINI(status, gtid); \
1019  \
1020  KA_TRACE( \
1021  20, \
1022  (KMP_STR( \
1023  func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
1024  gtid, *p_lb, *p_ub, status)); \
1025  __kmp_free(dims); \
1026  return status; \
1027  }
1028 
1029 LOOP_DOACROSS_START_ULL(
1030  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_STATIC_START),
1032 LOOP_DOACROSS_START_ULL(
1033  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_DYNAMIC_START),
1034  kmp_sch_dynamic_chunked)
1035 LOOP_DOACROSS_START_ULL(
1036  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_GUIDED_START),
1038 LOOP_DOACROSS_RUNTIME_START_ULL(
1039  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_RUNTIME_START),
1040  kmp_sch_runtime)
1041 #endif
1042 
1043 // Combined parallel / loop worksharing constructs
1044 //
1045 // There are no ull versions (yet).
1046 
1047 #define PARALLEL_LOOP_START(func, schedule, ompt_pre, ompt_post) \
1048  void func(void (*task)(void *), void *data, unsigned num_threads, long lb, \
1049  long ub, long str, long chunk_sz) { \
1050  int gtid = __kmp_entry_gtid(); \
1051  MKLOC(loc, KMP_STR(func)); \
1052  KA_TRACE( \
1053  20, \
1054  (KMP_STR( \
1055  func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
1056  gtid, lb, ub, str, chunk_sz)); \
1057  \
1058  ompt_pre(); \
1059  \
1060  if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) { \
1061  if (num_threads != 0) { \
1062  __kmp_push_num_threads(&loc, gtid, num_threads); \
1063  } \
1064  __kmp_GOMP_fork_call(&loc, gtid, task, \
1065  (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, \
1066  9, task, data, num_threads, &loc, (schedule), lb, \
1067  (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz); \
1068  IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid)); \
1069  } else { \
1070  __kmp_GOMP_serialized_parallel(&loc, gtid, task); \
1071  IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid)); \
1072  } \
1073  \
1074  KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
1075  (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
1076  (schedule) != kmp_sch_static); \
1077  \
1078  ompt_post(); \
1079  \
1080  KA_TRACE(20, (KMP_STR(func) " exit: T#%d\n", gtid)); \
1081  }
1082 
1083 #if OMPT_SUPPORT && OMPT_OPTIONAL
1084 
1085 #define OMPT_LOOP_PRE() \
1086  ompt_frame_t *parent_frame; \
1087  if (ompt_enabled.enabled) { \
1088  __ompt_get_task_info_internal(0, NULL, NULL, &parent_frame, NULL, NULL); \
1089  parent_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0); \
1090  OMPT_STORE_RETURN_ADDRESS(gtid); \
1091  }
1092 
1093 #define OMPT_LOOP_POST() \
1094  if (ompt_enabled.enabled) { \
1095  parent_frame->enter_frame = ompt_data_none; \
1096  }
1097 
1098 #else
1099 
1100 #define OMPT_LOOP_PRE()
1101 
1102 #define OMPT_LOOP_POST()
1103 
1104 #endif
1105 
1106 PARALLEL_LOOP_START(
1107  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START),
1108  kmp_sch_static, OMPT_LOOP_PRE, OMPT_LOOP_POST)
1109 PARALLEL_LOOP_START(
1110  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START),
1111  kmp_sch_dynamic_chunked, OMPT_LOOP_PRE, OMPT_LOOP_POST)
1112 PARALLEL_LOOP_START(
1113  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START),
1114  kmp_sch_guided_chunked, OMPT_LOOP_PRE, OMPT_LOOP_POST)
1115 PARALLEL_LOOP_START(
1116  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START),
1117  kmp_sch_runtime, OMPT_LOOP_PRE, OMPT_LOOP_POST)
1118 
1119 // Tasking constructs
1120 
1121 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASK)(void (*func)(void *), void *data,
1122  void (*copy_func)(void *, void *),
1123  long arg_size, long arg_align,
1124  bool if_cond, unsigned gomp_flags
1125 #if OMP_40_ENABLED
1126  ,
1127  void **depend
1128 #endif
1129  ) {
1130  MKLOC(loc, "GOMP_task");
1131  int gtid = __kmp_entry_gtid();
1132  kmp_int32 flags = 0;
1133  kmp_tasking_flags_t *input_flags = (kmp_tasking_flags_t *)&flags;
1134 
1135  KA_TRACE(20, ("GOMP_task: T#%d\n", gtid));
1136 
1137  // The low-order bit is the "untied" flag
1138  if (!(gomp_flags & 1)) {
1139  input_flags->tiedness = 1;
1140  }
1141  // The second low-order bit is the "final" flag
1142  if (gomp_flags & 2) {
1143  input_flags->final = 1;
1144  }
1145  input_flags->native = 1;
1146  // __kmp_task_alloc() sets up all other flags
1147 
1148  if (!if_cond) {
1149  arg_size = 0;
1150  }
1151 
1152  kmp_task_t *task = __kmp_task_alloc(
1153  &loc, gtid, input_flags, sizeof(kmp_task_t),
1154  arg_size ? arg_size + arg_align - 1 : 0, (kmp_routine_entry_t)func);
1155 
1156  if (arg_size > 0) {
1157  if (arg_align > 0) {
1158  task->shareds = (void *)((((size_t)task->shareds) + arg_align - 1) /
1159  arg_align * arg_align);
1160  }
1161  // else error??
1162 
1163  if (copy_func) {
1164  (*copy_func)(task->shareds, data);
1165  } else {
1166  KMP_MEMCPY(task->shareds, data, arg_size);
1167  }
1168  }
1169 
1170 #if OMPT_SUPPORT
1171  kmp_taskdata_t *current_task;
1172  if (ompt_enabled.enabled) {
1173  OMPT_STORE_RETURN_ADDRESS(gtid);
1174  current_task = __kmp_threads[gtid]->th.th_current_task;
1175  current_task->ompt_task_info.frame.enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
1176  }
1177 #endif
1178 
1179  if (if_cond) {
1180 #if OMP_40_ENABLED
1181  if (gomp_flags & 8) {
1182  KMP_ASSERT(depend);
1183  const size_t ndeps = (kmp_intptr_t)depend[0];
1184  const size_t nout = (kmp_intptr_t)depend[1];
1185  kmp_depend_info_t dep_list[ndeps];
1186 
1187  for (size_t i = 0U; i < ndeps; i++) {
1188  dep_list[i].base_addr = (kmp_intptr_t)depend[2U + i];
1189  dep_list[i].len = 0U;
1190  dep_list[i].flags.in = 1;
1191  dep_list[i].flags.out = (i < nout);
1192  }
1193  __kmpc_omp_task_with_deps(&loc, gtid, task, ndeps, dep_list, 0, NULL);
1194  } else {
1195 #endif
1196  __kmpc_omp_task(&loc, gtid, task);
1197  }
1198  } else {
1199 #if OMPT_SUPPORT
1200  ompt_thread_info_t oldInfo;
1201  kmp_info_t *thread;
1202  kmp_taskdata_t *taskdata;
1203  if (ompt_enabled.enabled) {
1204  // Store the threads states and restore them after the task
1205  thread = __kmp_threads[gtid];
1206  taskdata = KMP_TASK_TO_TASKDATA(task);
1207  oldInfo = thread->th.ompt_thread_info;
1208  thread->th.ompt_thread_info.wait_id = 0;
1209  thread->th.ompt_thread_info.state = ompt_state_work_parallel;
1210  taskdata->ompt_task_info.frame.exit_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
1211  OMPT_STORE_RETURN_ADDRESS(gtid);
1212  }
1213 #endif
1214 
1215  __kmpc_omp_task_begin_if0(&loc, gtid, task);
1216  func(data);
1217  __kmpc_omp_task_complete_if0(&loc, gtid, task);
1218 
1219 #if OMPT_SUPPORT
1220  if (ompt_enabled.enabled) {
1221  thread->th.ompt_thread_info = oldInfo;
1222  taskdata->ompt_task_info.frame.exit_frame = ompt_data_none;
1223  }
1224 #endif
1225  }
1226 #if OMPT_SUPPORT
1227  if (ompt_enabled.enabled) {
1228  current_task->ompt_task_info.frame.enter_frame = ompt_data_none;
1229  }
1230 #endif
1231 
1232  KA_TRACE(20, ("GOMP_task exit: T#%d\n", gtid));
1233 }
1234 
1235 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKWAIT)(void) {
1236  MKLOC(loc, "GOMP_taskwait");
1237  int gtid = __kmp_entry_gtid();
1238 
1239 #if OMPT_SUPPORT
1240  if (ompt_enabled.enabled)
1241  OMPT_STORE_RETURN_ADDRESS(gtid);
1242 #endif
1243 
1244  KA_TRACE(20, ("GOMP_taskwait: T#%d\n", gtid));
1245 
1246  __kmpc_omp_taskwait(&loc, gtid);
1247 
1248  KA_TRACE(20, ("GOMP_taskwait exit: T#%d\n", gtid));
1249 }
1250 
1251 // Sections worksharing constructs
1252 //
1253 // For the sections construct, we initialize a dynamically scheduled loop
1254 // worksharing construct with lb 1 and stride 1, and use the iteration #'s
1255 // that its returns as sections ids.
1256 //
1257 // There are no special entry points for ordered sections, so we always use
1258 // the dynamically scheduled workshare, even if the sections aren't ordered.
1259 
1260 unsigned KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SECTIONS_START)(unsigned count) {
1261  int status;
1262  kmp_int lb, ub, stride;
1263  int gtid = __kmp_entry_gtid();
1264  MKLOC(loc, "GOMP_sections_start");
1265  KA_TRACE(20, ("GOMP_sections_start: T#%d\n", gtid));
1266 
1267  KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1268 
1269  status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
1270  if (status) {
1271  KMP_DEBUG_ASSERT(stride == 1);
1272  KMP_DEBUG_ASSERT(lb > 0);
1273  KMP_ASSERT(lb == ub);
1274  } else {
1275  lb = 0;
1276  }
1277 
1278  KA_TRACE(20, ("GOMP_sections_start exit: T#%d returning %u\n", gtid,
1279  (unsigned)lb));
1280  return (unsigned)lb;
1281 }
1282 
1283 unsigned KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SECTIONS_NEXT)(void) {
1284  int status;
1285  kmp_int lb, ub, stride;
1286  int gtid = __kmp_get_gtid();
1287  MKLOC(loc, "GOMP_sections_next");
1288  KA_TRACE(20, ("GOMP_sections_next: T#%d\n", gtid));
1289 
1290 #if OMPT_SUPPORT
1291  OMPT_STORE_RETURN_ADDRESS(gtid);
1292 #endif
1293 
1294  status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
1295  if (status) {
1296  KMP_DEBUG_ASSERT(stride == 1);
1297  KMP_DEBUG_ASSERT(lb > 0);
1298  KMP_ASSERT(lb == ub);
1299  } else {
1300  lb = 0;
1301  }
1302 
1303  KA_TRACE(
1304  20, ("GOMP_sections_next exit: T#%d returning %u\n", gtid, (unsigned)lb));
1305  return (unsigned)lb;
1306 }
1307 
1308 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START)(
1309  void (*task)(void *), void *data, unsigned num_threads, unsigned count) {
1310  int gtid = __kmp_entry_gtid();
1311 
1312 #if OMPT_SUPPORT
1313  ompt_frame_t *parent_frame;
1314 
1315  if (ompt_enabled.enabled) {
1316  __ompt_get_task_info_internal(0, NULL, NULL, &parent_frame, NULL, NULL);
1317  parent_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
1318  OMPT_STORE_RETURN_ADDRESS(gtid);
1319  }
1320 #endif
1321 
1322  MKLOC(loc, "GOMP_parallel_sections_start");
1323  KA_TRACE(20, ("GOMP_parallel_sections_start: T#%d\n", gtid));
1324 
1325  if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1326  if (num_threads != 0) {
1327  __kmp_push_num_threads(&loc, gtid, num_threads);
1328  }
1329  __kmp_GOMP_fork_call(&loc, gtid, task,
1330  (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9,
1331  task, data, num_threads, &loc, kmp_nm_dynamic_chunked,
1332  (kmp_int)1, (kmp_int)count, (kmp_int)1, (kmp_int)1);
1333  } else {
1334  __kmp_GOMP_serialized_parallel(&loc, gtid, task);
1335  }
1336 
1337 #if OMPT_SUPPORT
1338  if (ompt_enabled.enabled) {
1339  parent_frame->enter_frame = ompt_data_none;
1340  }
1341 #endif
1342 
1343  KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1344 
1345  KA_TRACE(20, ("GOMP_parallel_sections_start exit: T#%d\n", gtid));
1346 }
1347 
1348 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SECTIONS_END)(void) {
1349  int gtid = __kmp_get_gtid();
1350  KA_TRACE(20, ("GOMP_sections_end: T#%d\n", gtid))
1351 
1352 #if OMPT_SUPPORT
1353  ompt_frame_t *ompt_frame;
1354  if (ompt_enabled.enabled) {
1355  __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
1356  ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
1357  OMPT_STORE_RETURN_ADDRESS(gtid);
1358  }
1359 #endif
1360  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
1361 #if OMPT_SUPPORT
1362  if (ompt_enabled.enabled) {
1363  ompt_frame->enter_frame = ompt_data_none;
1364  }
1365 #endif
1366 
1367  KA_TRACE(20, ("GOMP_sections_end exit: T#%d\n", gtid))
1368 }
1369 
1370 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT)(void) {
1371  KA_TRACE(20, ("GOMP_sections_end_nowait: T#%d\n", __kmp_get_gtid()))
1372 }
1373 
1374 // libgomp has an empty function for GOMP_taskyield as of 2013-10-10
1375 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKYIELD)(void) {
1376  KA_TRACE(20, ("GOMP_taskyield: T#%d\n", __kmp_get_gtid()))
1377  return;
1378 }
1379 
1380 #if OMP_40_ENABLED // these are new GOMP_4.0 entry points
1381 
1382 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL)(void (*task)(void *),
1383  void *data,
1384  unsigned num_threads,
1385  unsigned int flags) {
1386  int gtid = __kmp_entry_gtid();
1387  MKLOC(loc, "GOMP_parallel");
1388  KA_TRACE(20, ("GOMP_parallel: T#%d\n", gtid));
1389 
1390 #if OMPT_SUPPORT
1391  ompt_task_info_t *parent_task_info, *task_info;
1392  if (ompt_enabled.enabled) {
1393  parent_task_info = __ompt_get_task_info_object(0);
1394  parent_task_info->frame.enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
1395  OMPT_STORE_RETURN_ADDRESS(gtid);
1396  }
1397 #endif
1398  if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1399  if (num_threads != 0) {
1400  __kmp_push_num_threads(&loc, gtid, num_threads);
1401  }
1402  if (flags != 0) {
1403  __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
1404  }
1405  __kmp_GOMP_fork_call(&loc, gtid, task,
1406  (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task,
1407  data);
1408  } else {
1409  __kmp_GOMP_serialized_parallel(&loc, gtid, task);
1410  }
1411 #if OMPT_SUPPORT
1412  if (ompt_enabled.enabled) {
1413  task_info = __ompt_get_task_info_object(0);
1414  task_info->frame.exit_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
1415  }
1416 #endif
1417  task(data);
1418 #if OMPT_SUPPORT
1419  if (ompt_enabled.enabled) {
1420  OMPT_STORE_RETURN_ADDRESS(gtid);
1421  }
1422 #endif
1423  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_END)();
1424 #if OMPT_SUPPORT
1425  if (ompt_enabled.enabled) {
1426  task_info->frame.exit_frame = ompt_data_none;
1427  parent_task_info->frame.enter_frame = ompt_data_none;
1428  }
1429 #endif
1430 }
1431 
1432 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_SECTIONS)(void (*task)(void *),
1433  void *data,
1434  unsigned num_threads,
1435  unsigned count,
1436  unsigned flags) {
1437  int gtid = __kmp_entry_gtid();
1438  MKLOC(loc, "GOMP_parallel_sections");
1439  KA_TRACE(20, ("GOMP_parallel_sections: T#%d\n", gtid));
1440 
1441 #if OMPT_SUPPORT
1442  OMPT_STORE_RETURN_ADDRESS(gtid);
1443 #endif
1444 
1445  if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1446  if (num_threads != 0) {
1447  __kmp_push_num_threads(&loc, gtid, num_threads);
1448  }
1449  if (flags != 0) {
1450  __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
1451  }
1452  __kmp_GOMP_fork_call(&loc, gtid, task,
1453  (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9,
1454  task, data, num_threads, &loc, kmp_nm_dynamic_chunked,
1455  (kmp_int)1, (kmp_int)count, (kmp_int)1, (kmp_int)1);
1456  } else {
1457  __kmp_GOMP_serialized_parallel(&loc, gtid, task);
1458  }
1459 
1460 #if OMPT_SUPPORT
1461  OMPT_STORE_RETURN_ADDRESS(gtid);
1462 #endif
1463 
1464  KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1465 
1466  task(data);
1467  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_END)();
1468  KA_TRACE(20, ("GOMP_parallel_sections exit: T#%d\n", gtid));
1469 }
1470 
1471 #define PARALLEL_LOOP(func, schedule, ompt_pre, ompt_post) \
1472  void func(void (*task)(void *), void *data, unsigned num_threads, long lb, \
1473  long ub, long str, long chunk_sz, unsigned flags) { \
1474  int gtid = __kmp_entry_gtid(); \
1475  MKLOC(loc, KMP_STR(func)); \
1476  KA_TRACE( \
1477  20, \
1478  (KMP_STR( \
1479  func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
1480  gtid, lb, ub, str, chunk_sz)); \
1481  \
1482  ompt_pre(); \
1483  if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) { \
1484  if (num_threads != 0) { \
1485  __kmp_push_num_threads(&loc, gtid, num_threads); \
1486  } \
1487  if (flags != 0) { \
1488  __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags); \
1489  } \
1490  __kmp_GOMP_fork_call(&loc, gtid, task, \
1491  (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, \
1492  9, task, data, num_threads, &loc, (schedule), lb, \
1493  (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz); \
1494  } else { \
1495  __kmp_GOMP_serialized_parallel(&loc, gtid, task); \
1496  } \
1497  \
1498  IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
1499  KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
1500  (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
1501  (schedule) != kmp_sch_static); \
1502  task(data); \
1503  KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_END)(); \
1504  ompt_post(); \
1505  \
1506  KA_TRACE(20, (KMP_STR(func) " exit: T#%d\n", gtid)); \
1507  }
1508 
1509 PARALLEL_LOOP(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC),
1510  kmp_sch_static, OMPT_LOOP_PRE, OMPT_LOOP_POST)
1511 PARALLEL_LOOP(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC),
1512  kmp_sch_dynamic_chunked, OMPT_LOOP_PRE, OMPT_LOOP_POST)
1513 PARALLEL_LOOP(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED),
1514  kmp_sch_guided_chunked, OMPT_LOOP_PRE, OMPT_LOOP_POST)
1515 PARALLEL_LOOP(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME),
1516  kmp_sch_runtime, OMPT_LOOP_PRE, OMPT_LOOP_POST)
1517 
1518 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKGROUP_START)(void) {
1519  int gtid = __kmp_entry_gtid();
1520  MKLOC(loc, "GOMP_taskgroup_start");
1521  KA_TRACE(20, ("GOMP_taskgroup_start: T#%d\n", gtid));
1522 
1523 #if OMPT_SUPPORT
1524  if (ompt_enabled.enabled)
1525  OMPT_STORE_RETURN_ADDRESS(gtid);
1526 #endif
1527 
1528  __kmpc_taskgroup(&loc, gtid);
1529 
1530  return;
1531 }
1532 
1533 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKGROUP_END)(void) {
1534  int gtid = __kmp_get_gtid();
1535  MKLOC(loc, "GOMP_taskgroup_end");
1536  KA_TRACE(20, ("GOMP_taskgroup_end: T#%d\n", gtid));
1537 
1538 #if OMPT_SUPPORT
1539  if (ompt_enabled.enabled)
1540  OMPT_STORE_RETURN_ADDRESS(gtid);
1541 #endif
1542 
1543  __kmpc_end_taskgroup(&loc, gtid);
1544 
1545  return;
1546 }
1547 
1548 #ifndef KMP_DEBUG
1549 static
1550 #endif /* KMP_DEBUG */
1551  kmp_int32
1552  __kmp_gomp_to_omp_cancellation_kind(int gomp_kind) {
1553  kmp_int32 cncl_kind = 0;
1554  switch (gomp_kind) {
1555  case 1:
1556  cncl_kind = cancel_parallel;
1557  break;
1558  case 2:
1559  cncl_kind = cancel_loop;
1560  break;
1561  case 4:
1562  cncl_kind = cancel_sections;
1563  break;
1564  case 8:
1565  cncl_kind = cancel_taskgroup;
1566  break;
1567  }
1568  return cncl_kind;
1569 }
1570 
1571 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CANCELLATION_POINT)(int which) {
1572  if (__kmp_omp_cancellation) {
1573  KMP_FATAL(NoGompCancellation);
1574  }
1575  int gtid = __kmp_get_gtid();
1576  MKLOC(loc, "GOMP_cancellation_point");
1577  KA_TRACE(20, ("GOMP_cancellation_point: T#%d\n", gtid));
1578 
1579  kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
1580 
1581  return __kmpc_cancellationpoint(&loc, gtid, cncl_kind);
1582 }
1583 
1584 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_BARRIER_CANCEL)(void) {
1585  if (__kmp_omp_cancellation) {
1586  KMP_FATAL(NoGompCancellation);
1587  }
1588  KMP_FATAL(NoGompCancellation);
1589  int gtid = __kmp_get_gtid();
1590  MKLOC(loc, "GOMP_barrier_cancel");
1591  KA_TRACE(20, ("GOMP_barrier_cancel: T#%d\n", gtid));
1592 
1593  return __kmpc_cancel_barrier(&loc, gtid);
1594 }
1595 
1596 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CANCEL)(int which, bool do_cancel) {
1597  if (__kmp_omp_cancellation) {
1598  KMP_FATAL(NoGompCancellation);
1599  } else {
1600  return FALSE;
1601  }
1602 
1603  int gtid = __kmp_get_gtid();
1604  MKLOC(loc, "GOMP_cancel");
1605  KA_TRACE(20, ("GOMP_cancel: T#%d\n", gtid));
1606 
1607  kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
1608 
1609  if (do_cancel == FALSE) {
1610  return KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CANCELLATION_POINT)(which);
1611  } else {
1612  return __kmpc_cancel(&loc, gtid, cncl_kind);
1613  }
1614 }
1615 
1616 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL)(void) {
1617  if (__kmp_omp_cancellation) {
1618  KMP_FATAL(NoGompCancellation);
1619  }
1620  int gtid = __kmp_get_gtid();
1621  MKLOC(loc, "GOMP_sections_end_cancel");
1622  KA_TRACE(20, ("GOMP_sections_end_cancel: T#%d\n", gtid));
1623 
1624  return __kmpc_cancel_barrier(&loc, gtid);
1625 }
1626 
1627 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_END_CANCEL)(void) {
1628  if (__kmp_omp_cancellation) {
1629  KMP_FATAL(NoGompCancellation);
1630  }
1631  int gtid = __kmp_get_gtid();
1632  MKLOC(loc, "GOMP_loop_end_cancel");
1633  KA_TRACE(20, ("GOMP_loop_end_cancel: T#%d\n", gtid));
1634 
1635  return __kmpc_cancel_barrier(&loc, gtid);
1636 }
1637 
1638 // All target functions are empty as of 2014-05-29
1639 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TARGET)(int device, void (*fn)(void *),
1640  const void *openmp_target,
1641  size_t mapnum, void **hostaddrs,
1642  size_t *sizes,
1643  unsigned char *kinds) {
1644  return;
1645 }
1646 
1647 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TARGET_DATA)(
1648  int device, const void *openmp_target, size_t mapnum, void **hostaddrs,
1649  size_t *sizes, unsigned char *kinds) {
1650  return;
1651 }
1652 
1653 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TARGET_END_DATA)(void) { return; }
1654 
1655 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TARGET_UPDATE)(
1656  int device, const void *openmp_target, size_t mapnum, void **hostaddrs,
1657  size_t *sizes, unsigned char *kinds) {
1658  return;
1659 }
1660 
1661 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TEAMS)(unsigned int num_teams,
1662  unsigned int thread_limit) {
1663  return;
1664 }
1665 #endif // OMP_40_ENABLED
1666 
1667 #if OMP_45_ENABLED
1668 
1669 // Task duplication function which copies src to dest (both are
1670 // preallocated task structures)
1671 static void __kmp_gomp_task_dup(kmp_task_t *dest, kmp_task_t *src,
1672  kmp_int32 last_private) {
1673  kmp_taskdata_t *taskdata = KMP_TASK_TO_TASKDATA(src);
1674  if (taskdata->td_copy_func) {
1675  (taskdata->td_copy_func)(dest->shareds, src->shareds);
1676  }
1677 }
1678 
1679 #ifdef __cplusplus
1680 } // extern "C"
1681 #endif
1682 
1683 template <typename T>
1684 void __GOMP_taskloop(void (*func)(void *), void *data,
1685  void (*copy_func)(void *, void *), long arg_size,
1686  long arg_align, unsigned gomp_flags,
1687  unsigned long num_tasks, int priority, T start, T end,
1688  T step) {
1689  typedef void (*p_task_dup_t)(kmp_task_t *, kmp_task_t *, kmp_int32);
1690  MKLOC(loc, "GOMP_taskloop");
1691  int sched;
1692  T *loop_bounds;
1693  int gtid = __kmp_entry_gtid();
1694  kmp_int32 flags = 0;
1695  int if_val = gomp_flags & (1u << 10);
1696  int nogroup = gomp_flags & (1u << 11);
1697  int up = gomp_flags & (1u << 8);
1698  p_task_dup_t task_dup = NULL;
1699  kmp_tasking_flags_t *input_flags = (kmp_tasking_flags_t *)&flags;
1700 #ifdef KMP_DEBUG
1701  {
1702  char *buff;
1703  buff = __kmp_str_format(
1704  "GOMP_taskloop: T#%%d: func:%%p data:%%p copy_func:%%p "
1705  "arg_size:%%ld arg_align:%%ld gomp_flags:0x%%x num_tasks:%%lu "
1706  "priority:%%d start:%%%s end:%%%s step:%%%s\n",
1707  traits_t<T>::spec, traits_t<T>::spec, traits_t<T>::spec);
1708  KA_TRACE(20, (buff, gtid, func, data, copy_func, arg_size, arg_align,
1709  gomp_flags, num_tasks, priority, start, end, step));
1710  __kmp_str_free(&buff);
1711  }
1712 #endif
1713  KMP_ASSERT((size_t)arg_size >= 2 * sizeof(T));
1714  KMP_ASSERT(arg_align > 0);
1715  // The low-order bit is the "untied" flag
1716  if (!(gomp_flags & 1)) {
1717  input_flags->tiedness = 1;
1718  }
1719  // The second low-order bit is the "final" flag
1720  if (gomp_flags & 2) {
1721  input_flags->final = 1;
1722  }
1723  // Negative step flag
1724  if (!up) {
1725  // If step is flagged as negative, but isn't properly sign extended
1726  // Then manually sign extend it. Could be a short, int, char embedded
1727  // in a long. So cannot assume any cast.
1728  if (step > 0) {
1729  for (int i = sizeof(T) * CHAR_BIT - 1; i >= 0L; --i) {
1730  // break at the first 1 bit
1731  if (step & ((T)1 << i))
1732  break;
1733  step |= ((T)1 << i);
1734  }
1735  }
1736  }
1737  input_flags->native = 1;
1738  // Figure out if none/grainsize/num_tasks clause specified
1739  if (num_tasks > 0) {
1740  if (gomp_flags & (1u << 9))
1741  sched = 1; // grainsize specified
1742  else
1743  sched = 2; // num_tasks specified
1744  // neither grainsize nor num_tasks specified
1745  } else {
1746  sched = 0;
1747  }
1748 
1749  // __kmp_task_alloc() sets up all other flags
1750  kmp_task_t *task =
1751  __kmp_task_alloc(&loc, gtid, input_flags, sizeof(kmp_task_t),
1752  arg_size + arg_align - 1, (kmp_routine_entry_t)func);
1753  kmp_taskdata_t *taskdata = KMP_TASK_TO_TASKDATA(task);
1754  taskdata->td_copy_func = copy_func;
1755  taskdata->td_size_loop_bounds = sizeof(T);
1756 
1757  // re-align shareds if needed and setup firstprivate copy constructors
1758  // through the task_dup mechanism
1759  task->shareds = (void *)((((size_t)task->shareds) + arg_align - 1) /
1760  arg_align * arg_align);
1761  if (copy_func) {
1762  task_dup = __kmp_gomp_task_dup;
1763  }
1764  KMP_MEMCPY(task->shareds, data, arg_size);
1765 
1766  loop_bounds = (T *)task->shareds;
1767  loop_bounds[0] = start;
1768  loop_bounds[1] = end + (up ? -1 : 1);
1769  __kmpc_taskloop(&loc, gtid, task, if_val, (kmp_uint64 *)&(loop_bounds[0]),
1770  (kmp_uint64 *)&(loop_bounds[1]), (kmp_int64)step, nogroup,
1771  sched, (kmp_uint64)num_tasks, (void *)task_dup);
1772 }
1773 
1774 // 4 byte version of GOMP_doacross_post
1775 // This verison needs to create a temporary array which converts 4 byte
1776 // integers into 8 byte integeres
1777 template <typename T, bool need_conversion = (sizeof(long) == 4)>
1778 void __kmp_GOMP_doacross_post(T *count);
1779 
1780 template <> void __kmp_GOMP_doacross_post<long, true>(long *count) {
1781  int gtid = __kmp_entry_gtid();
1782  kmp_info_t *th = __kmp_threads[gtid];
1783  MKLOC(loc, "GOMP_doacross_post");
1784  kmp_int64 num_dims = th->th.th_dispatch->th_doacross_info[0];
1785  kmp_int64 *vec =
1786  (kmp_int64 *)__kmp_thread_malloc(th, sizeof(kmp_int64) * num_dims);
1787  for (kmp_int64 i = 0; i < num_dims; ++i) {
1788  vec[i] = (kmp_int64)count[i];
1789  }
1790  __kmpc_doacross_post(&loc, gtid, vec);
1791  __kmp_thread_free(th, vec);
1792 }
1793 
1794 // 8 byte versions of GOMP_doacross_post
1795 // This version can just pass in the count array directly instead of creating
1796 // a temporary array
1797 template <> void __kmp_GOMP_doacross_post<long, false>(long *count) {
1798  int gtid = __kmp_entry_gtid();
1799  MKLOC(loc, "GOMP_doacross_post");
1800  __kmpc_doacross_post(&loc, gtid, RCAST(kmp_int64 *, count));
1801 }
1802 
1803 template <typename T> void __kmp_GOMP_doacross_wait(T first, va_list args) {
1804  int gtid = __kmp_entry_gtid();
1805  kmp_info_t *th = __kmp_threads[gtid];
1806  MKLOC(loc, "GOMP_doacross_wait");
1807  kmp_int64 num_dims = th->th.th_dispatch->th_doacross_info[0];
1808  kmp_int64 *vec =
1809  (kmp_int64 *)__kmp_thread_malloc(th, sizeof(kmp_int64) * num_dims);
1810  vec[0] = (kmp_int64)first;
1811  for (kmp_int64 i = 1; i < num_dims; ++i) {
1812  T item = va_arg(args, T);
1813  vec[i] = (kmp_int64)item;
1814  }
1815  __kmpc_doacross_wait(&loc, gtid, vec);
1816  __kmp_thread_free(th, vec);
1817  return;
1818 }
1819 
1820 #ifdef __cplusplus
1821 extern "C" {
1822 #endif // __cplusplus
1823 
1824 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKLOOP)(
1825  void (*func)(void *), void *data, void (*copy_func)(void *, void *),
1826  long arg_size, long arg_align, unsigned gomp_flags, unsigned long num_tasks,
1827  int priority, long start, long end, long step) {
1828  __GOMP_taskloop<long>(func, data, copy_func, arg_size, arg_align, gomp_flags,
1829  num_tasks, priority, start, end, step);
1830 }
1831 
1832 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKLOOP_ULL)(
1833  void (*func)(void *), void *data, void (*copy_func)(void *, void *),
1834  long arg_size, long arg_align, unsigned gomp_flags, unsigned long num_tasks,
1835  int priority, unsigned long long start, unsigned long long end,
1836  unsigned long long step) {
1837  __GOMP_taskloop<unsigned long long>(func, data, copy_func, arg_size,
1838  arg_align, gomp_flags, num_tasks,
1839  priority, start, end, step);
1840 }
1841 
1842 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_DOACROSS_POST)(long *count) {
1843  __kmp_GOMP_doacross_post(count);
1844 }
1845 
1846 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_DOACROSS_WAIT)(long first, ...) {
1847  va_list args;
1848  va_start(args, first);
1849  __kmp_GOMP_doacross_wait<long>(first, args);
1850  va_end(args);
1851 }
1852 
1853 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_DOACROSS_ULL_POST)(
1854  unsigned long long *count) {
1855  int gtid = __kmp_entry_gtid();
1856  MKLOC(loc, "GOMP_doacross_ull_post");
1857  __kmpc_doacross_post(&loc, gtid, RCAST(kmp_int64 *, count));
1858 }
1859 
1860 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_DOACROSS_ULL_WAIT)(
1861  unsigned long long first, ...) {
1862  va_list args;
1863  va_start(args, first);
1864  __kmp_GOMP_doacross_wait<unsigned long long>(first, args);
1865  va_end(args);
1866 }
1867 
1868 #endif // OMP_45_ENABLED
1869 
1870 /* The following sections of code create aliases for the GOMP_* functions, then
1871  create versioned symbols using the assembler directive .symver. This is only
1872  pertinent for ELF .so library. The KMP_VERSION_SYMBOL macro is defined in
1873  kmp_os.h */
1874 
1875 #ifdef KMP_USE_VERSION_SYMBOLS
1876 // GOMP_1.0 versioned symbols
1877 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_ATOMIC_END, 10, "GOMP_1.0");
1878 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_ATOMIC_START, 10, "GOMP_1.0");
1879 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_BARRIER, 10, "GOMP_1.0");
1880 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_CRITICAL_END, 10, "GOMP_1.0");
1881 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_CRITICAL_NAME_END, 10, "GOMP_1.0");
1882 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_CRITICAL_NAME_START, 10, "GOMP_1.0");
1883 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_CRITICAL_START, 10, "GOMP_1.0");
1884 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT, 10, "GOMP_1.0");
1885 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START, 10, "GOMP_1.0");
1886 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_END, 10, "GOMP_1.0");
1887 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_END_NOWAIT, 10, "GOMP_1.0");
1888 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT, 10, "GOMP_1.0");
1889 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_GUIDED_START, 10, "GOMP_1.0");
1890 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT, 10, "GOMP_1.0");
1891 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START, 10,
1892  "GOMP_1.0");
1893 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT, 10, "GOMP_1.0");
1894 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START, 10, "GOMP_1.0");
1895 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT, 10, "GOMP_1.0");
1896 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START, 10,
1897  "GOMP_1.0");
1898 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT, 10, "GOMP_1.0");
1899 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START, 10, "GOMP_1.0");
1900 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT, 10, "GOMP_1.0");
1901 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_RUNTIME_START, 10, "GOMP_1.0");
1902 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT, 10, "GOMP_1.0");
1903 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_STATIC_START, 10, "GOMP_1.0");
1904 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_ORDERED_END, 10, "GOMP_1.0");
1905 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_ORDERED_START, 10, "GOMP_1.0");
1906 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_END, 10, "GOMP_1.0");
1907 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START, 10,
1908  "GOMP_1.0");
1909 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START, 10,
1910  "GOMP_1.0");
1911 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START, 10,
1912  "GOMP_1.0");
1913 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START, 10,
1914  "GOMP_1.0");
1915 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START, 10, "GOMP_1.0");
1916 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_START, 10, "GOMP_1.0");
1917 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SECTIONS_END, 10, "GOMP_1.0");
1918 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT, 10, "GOMP_1.0");
1919 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SECTIONS_NEXT, 10, "GOMP_1.0");
1920 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SECTIONS_START, 10, "GOMP_1.0");
1921 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SINGLE_COPY_END, 10, "GOMP_1.0");
1922 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SINGLE_COPY_START, 10, "GOMP_1.0");
1923 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SINGLE_START, 10, "GOMP_1.0");
1924 
1925 // GOMP_2.0 versioned symbols
1926 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASK, 20, "GOMP_2.0");
1927 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKWAIT, 20, "GOMP_2.0");
1928 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT, 20, "GOMP_2.0");
1929 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START, 20, "GOMP_2.0");
1930 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT, 20, "GOMP_2.0");
1931 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START, 20, "GOMP_2.0");
1932 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT, 20,
1933  "GOMP_2.0");
1934 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START, 20,
1935  "GOMP_2.0");
1936 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT, 20,
1937  "GOMP_2.0");
1938 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START, 20,
1939  "GOMP_2.0");
1940 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT, 20,
1941  "GOMP_2.0");
1942 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START, 20,
1943  "GOMP_2.0");
1944 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT, 20,
1945  "GOMP_2.0");
1946 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START, 20,
1947  "GOMP_2.0");
1948 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT, 20, "GOMP_2.0");
1949 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START, 20, "GOMP_2.0");
1950 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT, 20, "GOMP_2.0");
1951 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START, 20, "GOMP_2.0");
1952 
1953 // GOMP_3.0 versioned symbols
1954 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKYIELD, 30, "GOMP_3.0");
1955 
1956 // GOMP_4.0 versioned symbols
1957 #if OMP_40_ENABLED
1958 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL, 40, "GOMP_4.0");
1959 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_SECTIONS, 40, "GOMP_4.0");
1960 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC, 40, "GOMP_4.0");
1961 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED, 40, "GOMP_4.0");
1962 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME, 40, "GOMP_4.0");
1963 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC, 40, "GOMP_4.0");
1964 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKGROUP_START, 40, "GOMP_4.0");
1965 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKGROUP_END, 40, "GOMP_4.0");
1966 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_BARRIER_CANCEL, 40, "GOMP_4.0");
1967 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_CANCEL, 40, "GOMP_4.0");
1968 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_CANCELLATION_POINT, 40, "GOMP_4.0");
1969 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_END_CANCEL, 40, "GOMP_4.0");
1970 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL, 40, "GOMP_4.0");
1971 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TARGET, 40, "GOMP_4.0");
1972 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TARGET_DATA, 40, "GOMP_4.0");
1973 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TARGET_END_DATA, 40, "GOMP_4.0");
1974 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TARGET_UPDATE, 40, "GOMP_4.0");
1975 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TEAMS, 40, "GOMP_4.0");
1976 #endif
1977 
1978 // GOMP_4.5 versioned symbols
1979 #if OMP_45_ENABLED
1980 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKLOOP, 45, "GOMP_4.5");
1981 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKLOOP_ULL, 45, "GOMP_4.5");
1982 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_DOACROSS_POST, 45, "GOMP_4.5");
1983 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_DOACROSS_WAIT, 45, "GOMP_4.5");
1984 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DOACROSS_STATIC_START, 45,
1985  "GOMP_4.5");
1986 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DOACROSS_DYNAMIC_START, 45,
1987  "GOMP_4.5");
1988 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DOACROSS_GUIDED_START, 45,
1989  "GOMP_4.5");
1990 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DOACROSS_RUNTIME_START, 45,
1991  "GOMP_4.5");
1992 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_DOACROSS_ULL_POST, 45, "GOMP_4.5");
1993 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_DOACROSS_ULL_WAIT, 45, "GOMP_4.5");
1994 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_STATIC_START, 45,
1995  "GOMP_4.5");
1996 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_DYNAMIC_START, 45,
1997  "GOMP_4.5");
1998 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_GUIDED_START, 45,
1999  "GOMP_4.5");
2000 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_RUNTIME_START, 45,
2001  "GOMP_4.5");
2002 #endif
2003 
2004 #endif // KMP_USE_VERSION_SYMBOLS
2005 
2006 #ifdef __cplusplus
2007 } // extern "C"
2008 #endif // __cplusplus
KMP_EXPORT void __kmpc_end_ordered(ident_t *, kmp_int32 global_tid)
KMP_EXPORT void __kmpc_end_serialized_parallel(ident_t *, kmp_int32 global_tid)
KMP_EXPORT kmp_int32 __kmpc_omp_task_with_deps(ident_t *loc_ref, kmp_int32 gtid, kmp_task_t *new_task, kmp_int32 ndeps, kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list)
KMP_EXPORT void __kmpc_ordered(ident_t *, kmp_int32 global_tid)
sched_type
Definition: kmp.h:337
KMP_EXPORT void __kmpc_critical(ident_t *, kmp_int32 global_tid, kmp_critical_name *)
Definition: kmp.h:224
KMP_EXPORT kmp_int32 __kmpc_ok_to_fork(ident_t *)
KMP_EXPORT void __kmpc_barrier(ident_t *, kmp_int32 global_tid)
KMP_EXPORT void __kmpc_end_critical(ident_t *, kmp_int32 global_tid, kmp_critical_name *)