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