5 //===----------------------------------------------------------------------===//
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
11 //===----------------------------------------------------------------------===//
14 #include "kmp_atomic.h"
15 #include "kmp_utils.h"
18 #include "ompt-specific.h"
22 KMP_GOMP_TASK_UNTIED_FLAG
= 1,
23 KMP_GOMP_TASK_FINAL_FLAG
= 2,
24 KMP_GOMP_TASK_DEPENDS_FLAG
= 8
28 KMP_GOMP_DEPOBJ_IN
= 1,
29 KMP_GOMP_DEPOBJ_OUT
= 2,
30 KMP_GOMP_DEPOBJ_INOUT
= 3,
31 KMP_GOMP_DEPOBJ_MTXINOUTSET
= 4
34 // This class helps convert gomp dependency info into
35 // kmp_depend_info_t structures
36 class kmp_gomp_depends_info_t
{
39 size_t num_out
, num_mutexinout
, num_in
, num_depobj
;
43 kmp_gomp_depends_info_t(void **depend
) : depend(depend
) {
44 size_t ndeps
= (kmp_intptr_t
)depend
[0];
45 // GOMP taskdep structure:
47 // depend = [ ndeps | nout | &out | ... | &out | &in | ... | &in ]
50 // depend = [ 0 | ndeps | nout | nmtx | nin | &out | ... | &out | &mtx |
51 // ... | &mtx | &in | ... | &in | &depobj | ... | &depobj ]
53 num_out
= (kmp_intptr_t
)depend
[1];
54 num_in
= ndeps
- num_out
;
55 num_mutexinout
= num_depobj
= 0;
58 ndeps
= (kmp_intptr_t
)depend
[1];
59 num_out
= (kmp_intptr_t
)depend
[2];
60 num_mutexinout
= (kmp_intptr_t
)depend
[3];
61 num_in
= (kmp_intptr_t
)depend
[4];
62 num_depobj
= ndeps
- num_out
- num_mutexinout
- num_in
;
63 KMP_ASSERT(num_depobj
<= ndeps
);
66 num_deps
= static_cast<kmp_int32
>(ndeps
);
68 kmp_int32
get_num_deps() const { return num_deps
; }
69 kmp_depend_info_t
get_kmp_depend(size_t index
) const {
70 kmp_depend_info_t retval
;
71 memset(&retval
, '\0', sizeof(retval
));
72 KMP_ASSERT(index
< (size_t)num_deps
);
74 // Because inout and out are logically equivalent,
75 // use inout and in dependency flags. GOMP does not provide a
76 // way to distinguish if user specified out vs. inout.
77 if (index
< num_out
) {
80 retval
.base_addr
= (kmp_intptr_t
)depend
[offset
+ index
];
81 } else if (index
>= num_out
&& index
< (num_out
+ num_mutexinout
)) {
83 retval
.base_addr
= (kmp_intptr_t
)depend
[offset
+ index
];
84 } else if (index
>= (num_out
+ num_mutexinout
) &&
85 index
< (num_out
+ num_mutexinout
+ num_in
)) {
87 retval
.base_addr
= (kmp_intptr_t
)depend
[offset
+ index
];
89 // depobj is a two element array (size of elements are size of pointer)
90 // depobj[0] = base_addr
91 // depobj[1] = type (in, out, inout, mutexinoutset, etc.)
92 kmp_intptr_t
*depobj
= (kmp_intptr_t
*)depend
[offset
+ index
];
93 retval
.base_addr
= depobj
[0];
95 case KMP_GOMP_DEPOBJ_IN
:
98 case KMP_GOMP_DEPOBJ_OUT
:
101 case KMP_GOMP_DEPOBJ_INOUT
:
103 retval
.flags
.out
= 1;
105 case KMP_GOMP_DEPOBJ_MTXINOUTSET
:
106 retval
.flags
.mtx
= 1;
109 KMP_FATAL(GompFeatureNotSupported
, "Unknown depobj type");
118 #endif // __cplusplus
120 #define MKLOC(loc, routine) \
121 static ident_t loc = {0, KMP_IDENT_KMPC, 0, 0, ";unknown;unknown;0;0;;"};
123 #include "kmp_ftn_os.h"
125 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_BARRIER
)(void) {
126 int gtid
= __kmp_entry_gtid();
127 MKLOC(loc
, "GOMP_barrier");
128 KA_TRACE(20, ("GOMP_barrier: T#%d\n", gtid
));
129 #if OMPT_SUPPORT && OMPT_OPTIONAL
130 ompt_frame_t
*ompt_frame
;
131 if (ompt_enabled
.enabled
) {
132 __ompt_get_task_info_internal(0, NULL
, NULL
, &ompt_frame
, NULL
, NULL
);
133 ompt_frame
->enter_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
135 OMPT_STORE_RETURN_ADDRESS(gtid
);
137 __kmpc_barrier(&loc
, gtid
);
138 #if OMPT_SUPPORT && OMPT_OPTIONAL
139 if (ompt_enabled
.enabled
) {
140 ompt_frame
->enter_frame
= ompt_data_none
;
147 // The symbol that icc/ifort generates for unnamed critical sections
148 // - .gomp_critical_user_ - is defined using .comm in any objects reference it.
149 // We can't reference it directly here in C code, as the symbol contains a ".".
151 // The RTL contains an assembly language definition of .gomp_critical_user_
152 // with another symbol __kmp_unnamed_critical_addr initialized with it's
154 extern kmp_critical_name
*__kmp_unnamed_critical_addr
;
156 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CRITICAL_START
)(void) {
157 int gtid
= __kmp_entry_gtid();
158 MKLOC(loc
, "GOMP_critical_start");
159 KA_TRACE(20, ("GOMP_critical_start: T#%d\n", gtid
));
160 #if OMPT_SUPPORT && OMPT_OPTIONAL
161 OMPT_STORE_RETURN_ADDRESS(gtid
);
163 __kmpc_critical(&loc
, gtid
, __kmp_unnamed_critical_addr
);
166 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CRITICAL_END
)(void) {
167 int gtid
= __kmp_get_gtid();
168 MKLOC(loc
, "GOMP_critical_end");
169 KA_TRACE(20, ("GOMP_critical_end: T#%d\n", gtid
));
170 #if OMPT_SUPPORT && OMPT_OPTIONAL
171 OMPT_STORE_RETURN_ADDRESS(gtid
);
173 __kmpc_end_critical(&loc
, gtid
, __kmp_unnamed_critical_addr
);
176 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CRITICAL_NAME_START
)(void **pptr
) {
177 int gtid
= __kmp_entry_gtid();
178 MKLOC(loc
, "GOMP_critical_name_start");
179 KA_TRACE(20, ("GOMP_critical_name_start: T#%d\n", gtid
));
180 __kmpc_critical(&loc
, gtid
, (kmp_critical_name
*)pptr
);
183 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CRITICAL_NAME_END
)(void **pptr
) {
184 int gtid
= __kmp_get_gtid();
185 MKLOC(loc
, "GOMP_critical_name_end");
186 KA_TRACE(20, ("GOMP_critical_name_end: T#%d\n", gtid
));
187 __kmpc_end_critical(&loc
, gtid
, (kmp_critical_name
*)pptr
);
190 // The Gnu codegen tries to use locked operations to perform atomic updates
191 // inline. If it can't, then it calls GOMP_atomic_start() before performing
192 // the update and GOMP_atomic_end() afterward, regardless of the data type.
193 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ATOMIC_START
)(void) {
194 int gtid
= __kmp_entry_gtid();
195 KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid
));
198 __ompt_thread_assign_wait_id(0);
201 __kmp_acquire_atomic_lock(&__kmp_atomic_lock
, gtid
);
204 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ATOMIC_END
)(void) {
205 int gtid
= __kmp_get_gtid();
206 KA_TRACE(20, ("GOMP_atomic_end: T#%d\n", gtid
));
207 __kmp_release_atomic_lock(&__kmp_atomic_lock
, gtid
);
210 int KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_START
)(void) {
211 int gtid
= __kmp_entry_gtid();
212 MKLOC(loc
, "GOMP_single_start");
213 KA_TRACE(20, ("GOMP_single_start: T#%d\n", gtid
));
215 if (!TCR_4(__kmp_init_parallel
))
216 __kmp_parallel_initialize();
217 __kmp_resume_if_soft_paused();
219 // 3rd parameter == FALSE prevents kmp_enter_single from pushing a
220 // workshare when USE_CHECKS is defined. We need to avoid the push,
221 // as there is no corresponding GOMP_single_end() call.
222 kmp_int32 rc
= __kmp_enter_single(gtid
, &loc
, FALSE
);
224 #if OMPT_SUPPORT && OMPT_OPTIONAL
225 kmp_info_t
*this_thr
= __kmp_threads
[gtid
];
226 kmp_team_t
*team
= this_thr
->th
.th_team
;
227 int tid
= __kmp_tid_from_gtid(gtid
);
229 if (ompt_enabled
.enabled
) {
231 if (ompt_enabled
.ompt_callback_work
) {
232 ompt_callbacks
.ompt_callback(ompt_callback_work
)(
233 ompt_work_single_executor
, ompt_scope_begin
,
234 &(team
->t
.ompt_team_info
.parallel_data
),
235 &(team
->t
.t_implicit_task_taskdata
[tid
].ompt_task_info
.task_data
),
236 1, OMPT_GET_RETURN_ADDRESS(0));
239 if (ompt_enabled
.ompt_callback_work
) {
240 ompt_callbacks
.ompt_callback(ompt_callback_work
)(
241 ompt_work_single_other
, ompt_scope_begin
,
242 &(team
->t
.ompt_team_info
.parallel_data
),
243 &(team
->t
.t_implicit_task_taskdata
[tid
].ompt_task_info
.task_data
),
244 1, OMPT_GET_RETURN_ADDRESS(0));
245 ompt_callbacks
.ompt_callback(ompt_callback_work
)(
246 ompt_work_single_other
, ompt_scope_end
,
247 &(team
->t
.ompt_team_info
.parallel_data
),
248 &(team
->t
.t_implicit_task_taskdata
[tid
].ompt_task_info
.task_data
),
249 1, OMPT_GET_RETURN_ADDRESS(0));
258 void *KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_COPY_START
)(void) {
260 int gtid
= __kmp_entry_gtid();
261 MKLOC(loc
, "GOMP_single_copy_start");
262 KA_TRACE(20, ("GOMP_single_copy_start: T#%d\n", gtid
));
264 if (!TCR_4(__kmp_init_parallel
))
265 __kmp_parallel_initialize();
266 __kmp_resume_if_soft_paused();
268 // If this is the first thread to enter, return NULL. The generated code will
269 // then call GOMP_single_copy_end() for this thread only, with the
270 // copyprivate data pointer as an argument.
271 if (__kmp_enter_single(gtid
, &loc
, FALSE
))
274 // Wait for the first thread to set the copyprivate data pointer,
275 // and for all other threads to reach this point.
277 #if OMPT_SUPPORT && OMPT_OPTIONAL
278 ompt_frame_t
*ompt_frame
;
279 if (ompt_enabled
.enabled
) {
280 __ompt_get_task_info_internal(0, NULL
, NULL
, &ompt_frame
, NULL
, NULL
);
281 ompt_frame
->enter_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
283 OMPT_STORE_RETURN_ADDRESS(gtid
);
285 __kmp_barrier(bs_plain_barrier
, gtid
, FALSE
, 0, NULL
, NULL
);
287 // Retrieve the value of the copyprivate data point, and wait for all
288 // threads to do likewise, then return.
289 retval
= __kmp_team_from_gtid(gtid
)->t
.t_copypriv_data
;
291 #if OMPT_SUPPORT && OMPT_OPTIONAL
292 OMPT_STORE_RETURN_ADDRESS(gtid
);
294 __kmp_barrier(bs_plain_barrier
, gtid
, FALSE
, 0, NULL
, NULL
);
296 #if OMPT_SUPPORT && OMPT_OPTIONAL
297 if (ompt_enabled
.enabled
) {
298 ompt_frame
->enter_frame
= ompt_data_none
;
304 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_COPY_END
)(void *data
) {
305 int gtid
= __kmp_get_gtid();
306 KA_TRACE(20, ("GOMP_single_copy_end: T#%d\n", gtid
));
308 // Set the copyprivate data pointer fo the team, then hit the barrier so that
309 // the other threads will continue on and read it. Hit another barrier before
310 // continuing, so that the know that the copyprivate data pointer has been
311 // propagated to all threads before trying to reuse the t_copypriv_data field.
312 __kmp_team_from_gtid(gtid
)->t
.t_copypriv_data
= data
;
313 #if OMPT_SUPPORT && OMPT_OPTIONAL
314 ompt_frame_t
*ompt_frame
;
315 if (ompt_enabled
.enabled
) {
316 __ompt_get_task_info_internal(0, NULL
, NULL
, &ompt_frame
, NULL
, NULL
);
317 ompt_frame
->enter_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
319 OMPT_STORE_RETURN_ADDRESS(gtid
);
321 __kmp_barrier(bs_plain_barrier
, gtid
, FALSE
, 0, NULL
, NULL
);
323 #if OMPT_SUPPORT && OMPT_OPTIONAL
324 OMPT_STORE_RETURN_ADDRESS(gtid
);
326 __kmp_barrier(bs_plain_barrier
, gtid
, FALSE
, 0, NULL
, NULL
);
328 #if OMPT_SUPPORT && OMPT_OPTIONAL
329 if (ompt_enabled
.enabled
) {
330 ompt_frame
->enter_frame
= ompt_data_none
;
335 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ORDERED_START
)(void) {
336 int gtid
= __kmp_entry_gtid();
337 MKLOC(loc
, "GOMP_ordered_start");
338 KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid
));
339 #if OMPT_SUPPORT && OMPT_OPTIONAL
340 OMPT_STORE_RETURN_ADDRESS(gtid
);
342 __kmpc_ordered(&loc
, gtid
);
345 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ORDERED_END
)(void) {
346 int gtid
= __kmp_get_gtid();
347 MKLOC(loc
, "GOMP_ordered_end");
348 KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid
));
349 #if OMPT_SUPPORT && OMPT_OPTIONAL
350 OMPT_STORE_RETURN_ADDRESS(gtid
);
352 __kmpc_end_ordered(&loc
, gtid
);
355 // Dispatch macro defs
357 // They come in two flavors: 64-bit unsigned, and either 32-bit signed
358 // (IA-32 architecture) or 64-bit signed (Intel(R) 64).
360 #if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS || KMP_ARCH_WASM || \
361 KMP_ARCH_PPC || KMP_ARCH_AARCH64_32
362 #define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_4
363 #define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_4
364 #define KMP_DISPATCH_NEXT __kmpc_dispatch_next_4
366 #define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_8
367 #define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_8
368 #define KMP_DISPATCH_NEXT __kmpc_dispatch_next_8
369 #endif /* KMP_ARCH_X86 */
371 #define KMP_DISPATCH_INIT_ULL __kmp_aux_dispatch_init_8u
372 #define KMP_DISPATCH_FINI_CHUNK_ULL __kmp_aux_dispatch_fini_chunk_8u
373 #define KMP_DISPATCH_NEXT_ULL __kmpc_dispatch_next_8u
375 // The parallel construct
379 #endif /* KMP_DEBUG */
381 __kmp_GOMP_microtask_wrapper(int *gtid
, int *npr
, void (*task
)(void *),
385 ompt_frame_t
*ompt_frame
;
386 ompt_state_t enclosing_state
;
388 if (ompt_enabled
.enabled
) {
389 // get pointer to thread data structure
390 thr
= __kmp_threads
[*gtid
];
392 // save enclosing task state; set current state for task
393 enclosing_state
= thr
->th
.ompt_thread_info
.state
;
394 thr
->th
.ompt_thread_info
.state
= ompt_state_work_parallel
;
397 __ompt_get_task_info_internal(0, NULL
, NULL
, &ompt_frame
, NULL
, NULL
);
398 ompt_frame
->exit_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
405 if (ompt_enabled
.enabled
) {
407 ompt_frame
->exit_frame
= ompt_data_none
;
409 // restore enclosing state
410 thr
->th
.ompt_thread_info
.state
= enclosing_state
;
417 #endif /* KMP_DEBUG */
419 __kmp_GOMP_parallel_microtask_wrapper(int *gtid
, int *npr
,
420 void (*task
)(void *), void *data
,
421 unsigned num_threads
, ident_t
*loc
,
422 enum sched_type schedule
, long start
,
425 // Initialize the loop worksharing construct.
427 KMP_DISPATCH_INIT(loc
, *gtid
, schedule
, start
, end
, incr
, chunk_size
,
428 schedule
!= kmp_sch_static
);
432 ompt_frame_t
*ompt_frame
;
433 ompt_state_t enclosing_state
;
435 if (ompt_enabled
.enabled
) {
436 thr
= __kmp_threads
[*gtid
];
437 // save enclosing task state; set current state for task
438 enclosing_state
= thr
->th
.ompt_thread_info
.state
;
439 thr
->th
.ompt_thread_info
.state
= ompt_state_work_parallel
;
442 __ompt_get_task_info_internal(0, NULL
, NULL
, &ompt_frame
, NULL
, NULL
);
443 ompt_frame
->exit_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
447 // Now invoke the microtask.
451 if (ompt_enabled
.enabled
) {
453 ompt_frame
->exit_frame
= ompt_data_none
;
455 // reset enclosing state
456 thr
->th
.ompt_thread_info
.state
= enclosing_state
;
461 static void __kmp_GOMP_fork_call(ident_t
*loc
, int gtid
, unsigned num_threads
,
462 unsigned flags
, void (*unwrapped_task
)(void *),
463 microtask_t wrapper
, int argc
, ...) {
465 kmp_info_t
*thr
= __kmp_threads
[gtid
];
466 kmp_team_t
*team
= thr
->th
.th_team
;
467 int tid
= __kmp_tid_from_gtid(gtid
);
472 if (num_threads
!= 0)
473 __kmp_push_num_threads(loc
, gtid
, num_threads
);
475 __kmp_push_proc_bind(loc
, gtid
, (kmp_proc_bind_t
)flags
);
476 rc
= __kmp_fork_call(loc
, gtid
, fork_context_gnu
, argc
, wrapper
,
477 __kmp_invoke_task_func
, kmp_va_addr_of(ap
));
482 __kmp_run_before_invoked_task(gtid
, tid
, thr
, team
);
487 if (ompt_enabled
.enabled
) {
488 ompt_team_info_t
*team_info
= __ompt_get_teaminfo(0, NULL
);
489 ompt_task_info_t
*task_info
= __ompt_get_task_info_object(0);
491 // implicit task callback
492 if (ompt_enabled
.ompt_callback_implicit_task
) {
493 ompt_team_size
= __kmp_team_from_gtid(gtid
)->t
.t_nproc
;
494 ompt_callbacks
.ompt_callback(ompt_callback_implicit_task
)(
495 ompt_scope_begin
, &(team_info
->parallel_data
),
496 &(task_info
->task_data
), ompt_team_size
, __kmp_tid_from_gtid(gtid
),
497 ompt_task_implicit
); // TODO: Can this be ompt_task_initial?
498 task_info
->thread_num
= __kmp_tid_from_gtid(gtid
);
500 thr
->th
.ompt_thread_info
.state
= ompt_state_work_parallel
;
505 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_START
)(void (*task
)(void *),
507 unsigned num_threads
) {
508 int gtid
= __kmp_entry_gtid();
511 ompt_frame_t
*parent_frame
, *frame
;
513 if (ompt_enabled
.enabled
) {
514 __ompt_get_task_info_internal(0, NULL
, NULL
, &parent_frame
, NULL
, NULL
);
515 parent_frame
->enter_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
517 OMPT_STORE_RETURN_ADDRESS(gtid
);
520 MKLOC(loc
, "GOMP_parallel_start");
521 KA_TRACE(20, ("GOMP_parallel_start: T#%d\n", gtid
));
522 __kmp_GOMP_fork_call(&loc
, gtid
, num_threads
, 0u, task
,
523 (microtask_t
)__kmp_GOMP_microtask_wrapper
, 2, task
,
526 if (ompt_enabled
.enabled
) {
527 __ompt_get_task_info_internal(0, NULL
, NULL
, &frame
, NULL
, NULL
);
528 frame
->exit_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
532 if (ompd_state
& OMPD_ENABLE_BP
)
533 ompd_bp_parallel_begin();
537 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_END
)(void) {
538 int gtid
= __kmp_get_gtid();
541 thr
= __kmp_threads
[gtid
];
543 MKLOC(loc
, "GOMP_parallel_end");
544 KA_TRACE(20, ("GOMP_parallel_end: T#%d\n", gtid
));
546 if (!thr
->th
.th_team
->t
.t_serialized
) {
547 __kmp_run_after_invoked_task(gtid
, __kmp_tid_from_gtid(gtid
), thr
,
551 if (ompt_enabled
.enabled
) {
552 // Implicit task is finished here, in the barrier we might schedule
554 // these don't see the implicit task on the stack
555 OMPT_CUR_TASK_INFO(thr
)->frame
.exit_frame
= ompt_data_none
;
559 __kmp_join_call(&loc
, gtid
566 if (ompd_state
& OMPD_ENABLE_BP
)
567 ompd_bp_parallel_end();
571 // Loop worksharing constructs
573 // The Gnu codegen passes in an exclusive upper bound for the overall range,
574 // but the libguide dispatch code expects an inclusive upper bound, hence the
575 // "end - incr" 5th argument to KMP_DISPATCH_INIT (and the " ub - str" 11th
576 // argument to __kmp_GOMP_fork_call).
578 // Conversely, KMP_DISPATCH_NEXT returns and inclusive upper bound in *p_ub,
579 // but the Gnu codegen expects an exclusive upper bound, so the adjustment
580 // "*p_ub += stride" compensates for the discrepancy.
582 // Correction: the gnu codegen always adjusts the upper bound by +-1, not the
583 // stride value. We adjust the dispatch parameters accordingly (by +-1), but
584 // we still adjust p_ub by the actual stride value.
586 // The "runtime" versions do not take a chunk_sz parameter.
588 // The profile lib cannot support construct checking of unordered loops that
589 // are predetermined by the compiler to be statically scheduled, as the gcc
590 // codegen will not always emit calls to GOMP_loop_static_next() to get the
591 // next iteration. Instead, it emits inline code to call omp_get_thread_num()
592 // num and calculate the iteration space using the result. It doesn't do this
593 // with ordered static loop, so they can be checked.
596 #define IF_OMPT_SUPPORT(code) code
598 #define IF_OMPT_SUPPORT(code)
601 #define LOOP_START(func, schedule) \
602 int func(long lb, long ub, long str, long chunk_sz, long *p_lb, \
606 int gtid = __kmp_entry_gtid(); \
607 MKLOC(loc, KMP_STR(func)); \
611 func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
612 gtid, lb, ub, str, chunk_sz)); \
614 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
616 IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
617 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
618 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
619 (schedule) != kmp_sch_static); \
622 IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
623 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
624 (kmp_int *)p_ub, (kmp_int *)&stride); \
627 KMP_DEBUG_ASSERT(stride == str); \
628 *p_ub += (str > 0) ? 1 : -1; \
637 func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
638 gtid, *p_lb, *p_ub, status)); \
642 #define LOOP_RUNTIME_START(func, schedule) \
643 int func(long lb, long ub, long str, long *p_lb, long *p_ub) { \
647 int gtid = __kmp_entry_gtid(); \
648 MKLOC(loc, KMP_STR(func)); \
651 (KMP_STR(func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n", \
652 gtid, lb, ub, str, chunk_sz)); \
654 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
656 IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
657 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
658 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
662 IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
663 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
664 (kmp_int *)p_ub, (kmp_int *)&stride); \
667 KMP_DEBUG_ASSERT(stride == str); \
668 *p_ub += (str > 0) ? 1 : -1; \
677 func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
678 gtid, *p_lb, *p_ub, status)); \
682 #define KMP_DOACROSS_FINI(status, gtid) \
683 if (!status && __kmp_threads[gtid]->th.th_dispatch->th_doacross_flags) { \
684 __kmpc_doacross_fini(NULL, gtid); \
687 #define LOOP_NEXT(func, fini_code) \
688 int func(long *p_lb, long *p_ub) { \
691 int gtid = __kmp_get_gtid(); \
692 MKLOC(loc, KMP_STR(func)); \
693 KA_TRACE(20, (KMP_STR(func) ": T#%d\n", gtid)); \
695 IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
696 fini_code status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
697 (kmp_int *)p_ub, (kmp_int *)&stride); \
699 *p_ub += (stride > 0) ? 1 : -1; \
701 KMP_DOACROSS_FINI(status, gtid) \
705 (KMP_STR(func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, stride 0x%lx, " \
707 gtid, *p_lb, *p_ub, stride, status)); \
711 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_STATIC_START
), kmp_sch_static
)
712 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT
), {})
713 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START
),
714 kmp_sch_dynamic_chunked
)
715 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_DYNAMIC_START
),
716 kmp_sch_dynamic_chunked
)
717 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT
), {})
718 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_DYNAMIC_NEXT
), {})
719 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_GUIDED_START
),
720 kmp_sch_guided_chunked
)
721 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_GUIDED_START
),
722 kmp_sch_guided_chunked
)
723 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT
), {})
724 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_GUIDED_NEXT
), {})
725 LOOP_RUNTIME_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_RUNTIME_START
),
727 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT
), {})
729 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_MAYBE_NONMONOTONIC_RUNTIME_START
),
732 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_RUNTIME_START
),
735 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_MAYBE_NONMONOTONIC_RUNTIME_NEXT
), {})
736 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_RUNTIME_NEXT
), {})
738 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START
),
740 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT
),
741 { KMP_DISPATCH_FINI_CHUNK(&loc
, gtid
); })
742 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START
),
743 kmp_ord_dynamic_chunked
)
744 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT
),
745 { KMP_DISPATCH_FINI_CHUNK(&loc
, gtid
); })
746 LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START
),
747 kmp_ord_guided_chunked
)
748 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT
),
749 { KMP_DISPATCH_FINI_CHUNK(&loc
, gtid
); })
751 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START
),
753 LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT
),
754 { KMP_DISPATCH_FINI_CHUNK(&loc
, gtid
); })
756 #define LOOP_DOACROSS_START(func, schedule) \
757 bool func(unsigned ncounts, long *counts, long chunk_sz, long *p_lb, \
760 long stride, lb, ub, str; \
761 int gtid = __kmp_entry_gtid(); \
762 struct kmp_dim *dims = \
763 (struct kmp_dim *)__kmp_allocate(sizeof(struct kmp_dim) * ncounts); \
764 MKLOC(loc, KMP_STR(func)); \
765 for (unsigned i = 0; i < ncounts; ++i) { \
767 dims[i].up = counts[i] - 1; \
770 __kmpc_doacross_init(&loc, gtid, (int)ncounts, dims); \
774 KA_TRACE(20, (KMP_STR(func) ": T#%d, ncounts %u, lb 0x%lx, ub 0x%lx, str " \
777 gtid, ncounts, lb, ub, str, chunk_sz)); \
779 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
780 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
781 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
782 (schedule) != kmp_sch_static); \
783 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
784 (kmp_int *)p_ub, (kmp_int *)&stride); \
786 KMP_DEBUG_ASSERT(stride == str); \
787 *p_ub += (str > 0) ? 1 : -1; \
792 KMP_DOACROSS_FINI(status, gtid); \
797 func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
798 gtid, *p_lb, *p_ub, status)); \
803 #define LOOP_DOACROSS_RUNTIME_START(func, schedule) \
804 int func(unsigned ncounts, long *counts, long *p_lb, long *p_ub) { \
806 long stride, lb, ub, str; \
808 int gtid = __kmp_entry_gtid(); \
809 struct kmp_dim *dims = \
810 (struct kmp_dim *)__kmp_allocate(sizeof(struct kmp_dim) * ncounts); \
811 MKLOC(loc, KMP_STR(func)); \
812 for (unsigned i = 0; i < ncounts; ++i) { \
814 dims[i].up = counts[i] - 1; \
817 __kmpc_doacross_init(&loc, gtid, (int)ncounts, dims); \
823 (KMP_STR(func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n", \
824 gtid, lb, ub, str, chunk_sz)); \
826 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
827 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
828 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, TRUE); \
829 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
830 (kmp_int *)p_ub, (kmp_int *)&stride); \
832 KMP_DEBUG_ASSERT(stride == str); \
833 *p_ub += (str > 0) ? 1 : -1; \
838 KMP_DOACROSS_FINI(status, gtid); \
843 func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
844 gtid, *p_lb, *p_ub, status)); \
850 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_STATIC_START
),
853 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_DYNAMIC_START
),
854 kmp_sch_dynamic_chunked
)
856 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_GUIDED_START
),
857 kmp_sch_guided_chunked
)
858 LOOP_DOACROSS_RUNTIME_START(
859 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_RUNTIME_START
),
862 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_END
)(void) {
863 int gtid
= __kmp_get_gtid();
864 KA_TRACE(20, ("GOMP_loop_end: T#%d\n", gtid
))
866 #if OMPT_SUPPORT && OMPT_OPTIONAL
867 ompt_frame_t
*ompt_frame
;
868 if (ompt_enabled
.enabled
) {
869 __ompt_get_task_info_internal(0, NULL
, NULL
, &ompt_frame
, NULL
, NULL
);
870 ompt_frame
->enter_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
871 OMPT_STORE_RETURN_ADDRESS(gtid
);
874 __kmp_barrier(bs_plain_barrier
, gtid
, FALSE
, 0, NULL
, NULL
);
875 #if OMPT_SUPPORT && OMPT_OPTIONAL
876 if (ompt_enabled
.enabled
) {
877 ompt_frame
->enter_frame
= ompt_data_none
;
881 KA_TRACE(20, ("GOMP_loop_end exit: T#%d\n", gtid
))
884 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_END_NOWAIT
)(void) {
885 KA_TRACE(20, ("GOMP_loop_end_nowait: T#%d\n", __kmp_get_gtid()))
888 // Unsigned long long loop worksharing constructs
890 // These are new with gcc 4.4
892 #define LOOP_START_ULL(func, schedule) \
893 int func(int up, unsigned long long lb, unsigned long long ub, \
894 unsigned long long str, unsigned long long chunk_sz, \
895 unsigned long long *p_lb, unsigned long long *p_ub) { \
897 long long str2 = up ? ((long long)str) : -((long long)str); \
899 int gtid = __kmp_entry_gtid(); \
900 MKLOC(loc, KMP_STR(func)); \
902 KA_TRACE(20, (KMP_STR(func) ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str " \
903 "0x%llx, chunk_sz 0x%llx\n", \
904 gtid, up, lb, ub, str, chunk_sz)); \
906 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
907 KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
908 (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, \
909 (schedule) != kmp_sch_static); \
911 KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
912 (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
914 KMP_DEBUG_ASSERT(stride == str2); \
915 *p_ub += (str > 0) ? 1 : -1; \
924 func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
925 gtid, *p_lb, *p_ub, status)); \
929 #define LOOP_RUNTIME_START_ULL(func, schedule) \
930 int func(int up, unsigned long long lb, unsigned long long ub, \
931 unsigned long long str, unsigned long long *p_lb, \
932 unsigned long long *p_ub) { \
934 long long str2 = up ? ((long long)str) : -((long long)str); \
935 unsigned long long stride; \
936 unsigned long long chunk_sz = 0; \
937 int gtid = __kmp_entry_gtid(); \
938 MKLOC(loc, KMP_STR(func)); \
940 KA_TRACE(20, (KMP_STR(func) ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str " \
941 "0x%llx, chunk_sz 0x%llx\n", \
942 gtid, up, lb, ub, str, chunk_sz)); \
944 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
945 KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
946 (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, \
949 KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
950 (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
952 KMP_DEBUG_ASSERT((long long)stride == str2); \
953 *p_ub += (str > 0) ? 1 : -1; \
962 func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
963 gtid, *p_lb, *p_ub, status)); \
967 #define LOOP_NEXT_ULL(func, fini_code) \
968 int func(unsigned long long *p_lb, unsigned long long *p_ub) { \
971 int gtid = __kmp_get_gtid(); \
972 MKLOC(loc, KMP_STR(func)); \
973 KA_TRACE(20, (KMP_STR(func) ": T#%d\n", gtid)); \
976 KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
977 (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
979 *p_ub += (stride > 0) ? 1 : -1; \
985 func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, stride 0x%llx, " \
987 gtid, *p_lb, *p_ub, stride, status)); \
991 LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START
),
993 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT
), {})
994 LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START
),
995 kmp_sch_dynamic_chunked
)
996 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT
), {})
997 LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START
),
998 kmp_sch_guided_chunked
)
999 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT
), {})
1001 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_DYNAMIC_START
),
1002 kmp_sch_dynamic_chunked
)
1004 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_DYNAMIC_NEXT
), {})
1006 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_GUIDED_START
),
1007 kmp_sch_guided_chunked
)
1009 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_GUIDED_NEXT
), {})
1010 LOOP_RUNTIME_START_ULL(
1011 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START
), kmp_sch_runtime
)
1012 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT
), {})
1013 LOOP_RUNTIME_START_ULL(
1015 KMP_API_NAME_GOMP_LOOP_ULL_MAYBE_NONMONOTONIC_RUNTIME_START
),
1017 LOOP_RUNTIME_START_ULL(
1018 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_RUNTIME_START
),
1021 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_MAYBE_NONMONOTONIC_RUNTIME_NEXT
),
1024 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_RUNTIME_NEXT
), {})
1026 LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START
),
1028 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT
),
1029 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc
, gtid
); })
1031 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START
),
1032 kmp_ord_dynamic_chunked
)
1033 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT
),
1034 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc
, gtid
); })
1035 LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START
),
1036 kmp_ord_guided_chunked
)
1037 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT
),
1038 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc
, gtid
); })
1039 LOOP_RUNTIME_START_ULL(
1040 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START
),
1042 LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT
),
1043 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc
, gtid
); })
1045 #define LOOP_DOACROSS_START_ULL(func, schedule) \
1046 int func(unsigned ncounts, unsigned long long *counts, \
1047 unsigned long long chunk_sz, unsigned long long *p_lb, \
1048 unsigned long long *p_ub) { \
1050 long long stride, str, lb, ub; \
1051 int gtid = __kmp_entry_gtid(); \
1052 struct kmp_dim *dims = \
1053 (struct kmp_dim *)__kmp_allocate(sizeof(struct kmp_dim) * ncounts); \
1054 MKLOC(loc, KMP_STR(func)); \
1055 for (unsigned i = 0; i < ncounts; ++i) { \
1057 dims[i].up = counts[i] - 1; \
1060 __kmpc_doacross_init(&loc, gtid, (int)ncounts, dims); \
1065 KA_TRACE(20, (KMP_STR(func) ": T#%d, lb 0x%llx, ub 0x%llx, str " \
1066 "0x%llx, chunk_sz 0x%llx\n", \
1067 gtid, lb, ub, str, chunk_sz)); \
1069 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
1070 KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
1071 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
1072 (schedule) != kmp_sch_static); \
1074 KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
1075 (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
1077 KMP_DEBUG_ASSERT(stride == str); \
1078 *p_ub += (str > 0) ? 1 : -1; \
1083 KMP_DOACROSS_FINI(status, gtid); \
1088 func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
1089 gtid, *p_lb, *p_ub, status)); \
1094 #define LOOP_DOACROSS_RUNTIME_START_ULL(func, schedule) \
1095 int func(unsigned ncounts, unsigned long long *counts, \
1096 unsigned long long *p_lb, unsigned long long *p_ub) { \
1098 unsigned long long stride, str, lb, ub; \
1099 unsigned long long chunk_sz = 0; \
1100 int gtid = __kmp_entry_gtid(); \
1101 struct kmp_dim *dims = \
1102 (struct kmp_dim *)__kmp_allocate(sizeof(struct kmp_dim) * ncounts); \
1103 MKLOC(loc, KMP_STR(func)); \
1104 for (unsigned i = 0; i < ncounts; ++i) { \
1106 dims[i].up = counts[i] - 1; \
1109 __kmpc_doacross_init(&loc, gtid, (int)ncounts, dims); \
1113 KA_TRACE(20, (KMP_STR(func) ": T#%d, lb 0x%llx, ub 0x%llx, str " \
1114 "0x%llx, chunk_sz 0x%llx\n", \
1115 gtid, lb, ub, str, chunk_sz)); \
1117 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
1118 KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
1119 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
1122 KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
1123 (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
1125 KMP_DEBUG_ASSERT(stride == str); \
1126 *p_ub += (str > 0) ? 1 : -1; \
1131 KMP_DOACROSS_FINI(status, gtid); \
1136 func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
1137 gtid, *p_lb, *p_ub, status)); \
1142 LOOP_DOACROSS_START_ULL(
1143 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_STATIC_START
),
1145 LOOP_DOACROSS_START_ULL(
1146 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_DYNAMIC_START
),
1147 kmp_sch_dynamic_chunked
)
1148 LOOP_DOACROSS_START_ULL(
1149 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_GUIDED_START
),
1150 kmp_sch_guided_chunked
)
1151 LOOP_DOACROSS_RUNTIME_START_ULL(
1152 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_RUNTIME_START
),
1155 // Combined parallel / loop worksharing constructs
1157 // There are no ull versions (yet).
1159 #define PARALLEL_LOOP_START(func, schedule, ompt_pre, ompt_post) \
1160 void func(void (*task)(void *), void *data, unsigned num_threads, long lb, \
1161 long ub, long str, long chunk_sz) { \
1162 int gtid = __kmp_entry_gtid(); \
1163 MKLOC(loc, KMP_STR(func)); \
1167 func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
1168 gtid, lb, ub, str, chunk_sz)); \
1172 __kmp_GOMP_fork_call(&loc, gtid, num_threads, 0u, task, \
1173 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, \
1174 9, task, data, num_threads, &loc, (schedule), lb, \
1175 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz); \
1176 IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid)); \
1178 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
1179 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
1180 (schedule) != kmp_sch_static); \
1184 KA_TRACE(20, (KMP_STR(func) " exit: T#%d\n", gtid)); \
1187 #if OMPT_SUPPORT && OMPT_OPTIONAL
1189 #define OMPT_LOOP_PRE() \
1190 ompt_frame_t *parent_frame; \
1191 if (ompt_enabled.enabled) { \
1192 __ompt_get_task_info_internal(0, NULL, NULL, &parent_frame, NULL, NULL); \
1193 parent_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0); \
1194 OMPT_STORE_RETURN_ADDRESS(gtid); \
1197 #define OMPT_LOOP_POST() \
1198 if (ompt_enabled.enabled) { \
1199 parent_frame->enter_frame = ompt_data_none; \
1204 #define OMPT_LOOP_PRE()
1206 #define OMPT_LOOP_POST()
1210 PARALLEL_LOOP_START(
1211 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START
),
1212 kmp_sch_static
, OMPT_LOOP_PRE
, OMPT_LOOP_POST
)
1213 PARALLEL_LOOP_START(
1214 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START
),
1215 kmp_sch_dynamic_chunked
, OMPT_LOOP_PRE
, OMPT_LOOP_POST
)
1216 PARALLEL_LOOP_START(
1217 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START
),
1218 kmp_sch_guided_chunked
, OMPT_LOOP_PRE
, OMPT_LOOP_POST
)
1219 PARALLEL_LOOP_START(
1220 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START
),
1221 kmp_sch_runtime
, OMPT_LOOP_PRE
, OMPT_LOOP_POST
)
1223 // Tasking constructs
1225 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASK
)(void (*func
)(void *), void *data
,
1226 void (*copy_func
)(void *, void *),
1227 long arg_size
, long arg_align
,
1228 bool if_cond
, unsigned gomp_flags
,
1230 MKLOC(loc
, "GOMP_task");
1231 int gtid
= __kmp_entry_gtid();
1232 kmp_int32 flags
= 0;
1233 kmp_tasking_flags_t
*input_flags
= (kmp_tasking_flags_t
*)&flags
;
1235 KA_TRACE(20, ("GOMP_task: T#%d\n", gtid
));
1237 // The low-order bit is the "untied" flag
1238 if (!(gomp_flags
& KMP_GOMP_TASK_UNTIED_FLAG
)) {
1239 input_flags
->tiedness
= TASK_TIED
;
1241 // The second low-order bit is the "final" flag
1242 if (gomp_flags
& KMP_GOMP_TASK_FINAL_FLAG
) {
1243 input_flags
->final
= 1;
1245 input_flags
->native
= 1;
1246 // __kmp_task_alloc() sets up all other flags
1252 kmp_task_t
*task
= __kmp_task_alloc(
1253 &loc
, gtid
, input_flags
, sizeof(kmp_task_t
),
1254 arg_size
? arg_size
+ arg_align
- 1 : 0, (kmp_routine_entry_t
)func
);
1257 if (arg_align
> 0) {
1258 task
->shareds
= (void *)((((size_t)task
->shareds
) + arg_align
- 1) /
1259 arg_align
* arg_align
);
1264 (*copy_func
)(task
->shareds
, data
);
1266 KMP_MEMCPY(task
->shareds
, data
, arg_size
);
1271 kmp_taskdata_t
*current_task
;
1272 if (ompt_enabled
.enabled
) {
1273 current_task
= __kmp_threads
[gtid
]->th
.th_current_task
;
1274 current_task
->ompt_task_info
.frame
.enter_frame
.ptr
=
1275 OMPT_GET_FRAME_ADDRESS(0);
1277 OMPT_STORE_RETURN_ADDRESS(gtid
);
1281 if (gomp_flags
& KMP_GOMP_TASK_DEPENDS_FLAG
) {
1283 kmp_gomp_depends_info_t
gomp_depends(depend
);
1284 kmp_int32 ndeps
= gomp_depends
.get_num_deps();
1285 SimpleVLA
<kmp_depend_info_t
> dep_list(ndeps
);
1286 for (kmp_int32 i
= 0; i
< ndeps
; i
++)
1287 dep_list
[i
] = gomp_depends
.get_kmp_depend(i
);
1288 kmp_int32 ndeps_cnv
;
1289 __kmp_type_convert(ndeps
, &ndeps_cnv
);
1290 __kmpc_omp_task_with_deps(&loc
, gtid
, task
, ndeps_cnv
, dep_list
, 0, NULL
);
1292 __kmpc_omp_task(&loc
, gtid
, task
);
1296 ompt_thread_info_t oldInfo
;
1298 kmp_taskdata_t
*taskdata
;
1299 if (ompt_enabled
.enabled
) {
1300 // Store the threads states and restore them after the task
1301 thread
= __kmp_threads
[gtid
];
1302 taskdata
= KMP_TASK_TO_TASKDATA(task
);
1303 oldInfo
= thread
->th
.ompt_thread_info
;
1304 thread
->th
.ompt_thread_info
.wait_id
= 0;
1305 thread
->th
.ompt_thread_info
.state
= ompt_state_work_parallel
;
1306 taskdata
->ompt_task_info
.frame
.exit_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
1308 OMPT_STORE_RETURN_ADDRESS(gtid
);
1310 if (gomp_flags
& KMP_GOMP_TASK_DEPENDS_FLAG
) {
1312 kmp_gomp_depends_info_t
gomp_depends(depend
);
1313 kmp_int32 ndeps
= gomp_depends
.get_num_deps();
1314 SimpleVLA
<kmp_depend_info_t
> dep_list(ndeps
);
1315 for (kmp_int32 i
= 0; i
< ndeps
; i
++)
1316 dep_list
[i
] = gomp_depends
.get_kmp_depend(i
);
1317 __kmpc_omp_wait_deps(&loc
, gtid
, ndeps
, dep_list
, 0, NULL
);
1320 __kmpc_omp_task_begin_if0(&loc
, gtid
, task
);
1322 __kmpc_omp_task_complete_if0(&loc
, gtid
, task
);
1325 if (ompt_enabled
.enabled
) {
1326 thread
->th
.ompt_thread_info
= oldInfo
;
1327 taskdata
->ompt_task_info
.frame
.exit_frame
= ompt_data_none
;
1332 if (ompt_enabled
.enabled
) {
1333 current_task
->ompt_task_info
.frame
.enter_frame
= ompt_data_none
;
1337 KA_TRACE(20, ("GOMP_task exit: T#%d\n", gtid
));
1340 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKWAIT
)(void) {
1341 MKLOC(loc
, "GOMP_taskwait");
1342 int gtid
= __kmp_entry_gtid();
1345 OMPT_STORE_RETURN_ADDRESS(gtid
);
1348 KA_TRACE(20, ("GOMP_taskwait: T#%d\n", gtid
));
1350 __kmpc_omp_taskwait(&loc
, gtid
);
1352 KA_TRACE(20, ("GOMP_taskwait exit: T#%d\n", gtid
));
1355 // Sections worksharing constructs
1357 // For the sections construct, we initialize a dynamically scheduled loop
1358 // worksharing construct with lb 1 and stride 1, and use the iteration #'s
1359 // that its returns as sections ids.
1361 // There are no special entry points for ordered sections, so we always use
1362 // the dynamically scheduled workshare, even if the sections aren't ordered.
1364 unsigned KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SECTIONS_START
)(unsigned count
) {
1366 kmp_int lb
, ub
, stride
;
1367 int gtid
= __kmp_entry_gtid();
1368 MKLOC(loc
, "GOMP_sections_start");
1369 KA_TRACE(20, ("GOMP_sections_start: T#%d\n", gtid
));
1371 KMP_DISPATCH_INIT(&loc
, gtid
, kmp_nm_dynamic_chunked
, 1, count
, 1, 1, TRUE
);
1373 status
= KMP_DISPATCH_NEXT(&loc
, gtid
, NULL
, &lb
, &ub
, &stride
);
1375 KMP_DEBUG_ASSERT(stride
== 1);
1376 KMP_DEBUG_ASSERT(lb
> 0);
1377 KMP_ASSERT(lb
== ub
);
1382 KA_TRACE(20, ("GOMP_sections_start exit: T#%d returning %u\n", gtid
,
1384 return (unsigned)lb
;
1387 unsigned KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SECTIONS_NEXT
)(void) {
1389 kmp_int lb
, ub
, stride
;
1390 int gtid
= __kmp_get_gtid();
1391 MKLOC(loc
, "GOMP_sections_next");
1392 KA_TRACE(20, ("GOMP_sections_next: T#%d\n", gtid
));
1395 OMPT_STORE_RETURN_ADDRESS(gtid
);
1398 status
= KMP_DISPATCH_NEXT(&loc
, gtid
, NULL
, &lb
, &ub
, &stride
);
1400 KMP_DEBUG_ASSERT(stride
== 1);
1401 KMP_DEBUG_ASSERT(lb
> 0);
1402 KMP_ASSERT(lb
== ub
);
1408 20, ("GOMP_sections_next exit: T#%d returning %u\n", gtid
, (unsigned)lb
));
1409 return (unsigned)lb
;
1412 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START
)(
1413 void (*task
)(void *), void *data
, unsigned num_threads
, unsigned count
) {
1414 int gtid
= __kmp_entry_gtid();
1417 ompt_frame_t
*parent_frame
;
1419 if (ompt_enabled
.enabled
) {
1420 __ompt_get_task_info_internal(0, NULL
, NULL
, &parent_frame
, NULL
, NULL
);
1421 parent_frame
->enter_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
1423 OMPT_STORE_RETURN_ADDRESS(gtid
);
1426 MKLOC(loc
, "GOMP_parallel_sections_start");
1427 KA_TRACE(20, ("GOMP_parallel_sections_start: T#%d\n", gtid
));
1429 __kmp_GOMP_fork_call(&loc
, gtid
, num_threads
, 0u, task
,
1430 (microtask_t
)__kmp_GOMP_parallel_microtask_wrapper
, 9,
1431 task
, data
, num_threads
, &loc
, kmp_nm_dynamic_chunked
,
1432 (kmp_int
)1, (kmp_int
)count
, (kmp_int
)1, (kmp_int
)1);
1435 if (ompt_enabled
.enabled
) {
1436 parent_frame
->enter_frame
= ompt_data_none
;
1440 KMP_DISPATCH_INIT(&loc
, gtid
, kmp_nm_dynamic_chunked
, 1, count
, 1, 1, TRUE
);
1442 KA_TRACE(20, ("GOMP_parallel_sections_start exit: T#%d\n", gtid
));
1445 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SECTIONS_END
)(void) {
1446 int gtid
= __kmp_get_gtid();
1447 KA_TRACE(20, ("GOMP_sections_end: T#%d\n", gtid
))
1450 ompt_frame_t
*ompt_frame
;
1451 if (ompt_enabled
.enabled
) {
1452 __ompt_get_task_info_internal(0, NULL
, NULL
, &ompt_frame
, NULL
, NULL
);
1453 ompt_frame
->enter_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
1455 OMPT_STORE_RETURN_ADDRESS(gtid
);
1457 __kmp_barrier(bs_plain_barrier
, gtid
, FALSE
, 0, NULL
, NULL
);
1459 if (ompt_enabled
.enabled
) {
1460 ompt_frame
->enter_frame
= ompt_data_none
;
1464 KA_TRACE(20, ("GOMP_sections_end exit: T#%d\n", gtid
))
1467 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT
)(void) {
1468 KA_TRACE(20, ("GOMP_sections_end_nowait: T#%d\n", __kmp_get_gtid()))
1471 // libgomp has an empty function for GOMP_taskyield as of 2013-10-10
1472 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKYIELD
)(void) {
1473 KA_TRACE(20, ("GOMP_taskyield: T#%d\n", __kmp_get_gtid()))
1477 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL
)(void (*task
)(void *),
1479 unsigned num_threads
,
1480 unsigned int flags
) {
1481 int gtid
= __kmp_entry_gtid();
1482 MKLOC(loc
, "GOMP_parallel");
1483 KA_TRACE(20, ("GOMP_parallel: T#%d\n", gtid
));
1486 ompt_task_info_t
*parent_task_info
, *task_info
;
1487 if (ompt_enabled
.enabled
) {
1488 parent_task_info
= __ompt_get_task_info_object(0);
1489 parent_task_info
->frame
.enter_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
1491 OMPT_STORE_RETURN_ADDRESS(gtid
);
1493 __kmp_GOMP_fork_call(&loc
, gtid
, num_threads
, flags
, task
,
1494 (microtask_t
)__kmp_GOMP_microtask_wrapper
, 2, task
,
1497 if (ompt_enabled
.enabled
) {
1498 task_info
= __ompt_get_task_info_object(0);
1499 task_info
->frame
.exit_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
1505 OMPT_STORE_RETURN_ADDRESS(gtid
);
1507 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_END
)();
1510 if (ompt_enabled
.enabled
) {
1511 task_info
->frame
.exit_frame
= ompt_data_none
;
1512 parent_task_info
->frame
.enter_frame
= ompt_data_none
;
1517 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_SECTIONS
)(void (*task
)(void *),
1519 unsigned num_threads
,
1522 int gtid
= __kmp_entry_gtid();
1523 MKLOC(loc
, "GOMP_parallel_sections");
1524 KA_TRACE(20, ("GOMP_parallel_sections: T#%d\n", gtid
));
1527 ompt_frame_t
*task_frame
;
1529 if (ompt_enabled
.enabled
) {
1530 thr
= __kmp_threads
[gtid
];
1531 task_frame
= &(thr
->th
.th_current_task
->ompt_task_info
.frame
);
1532 task_frame
->enter_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
1534 OMPT_STORE_RETURN_ADDRESS(gtid
);
1537 __kmp_GOMP_fork_call(&loc
, gtid
, num_threads
, flags
, task
,
1538 (microtask_t
)__kmp_GOMP_parallel_microtask_wrapper
, 9,
1539 task
, data
, num_threads
, &loc
, kmp_nm_dynamic_chunked
,
1540 (kmp_int
)1, (kmp_int
)count
, (kmp_int
)1, (kmp_int
)1);
1544 OMPT_STORE_RETURN_ADDRESS(gtid
);
1547 KMP_DISPATCH_INIT(&loc
, gtid
, kmp_nm_dynamic_chunked
, 1, count
, 1, 1, TRUE
);
1551 ompt_frame_t
*child_frame
;
1552 if (ompt_enabled
.enabled
) {
1553 child_frame
= &(thr
->th
.th_current_task
->ompt_task_info
.frame
);
1554 child_frame
->exit_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
1561 if (ompt_enabled
.enabled
) {
1562 child_frame
->exit_frame
= ompt_data_none
;
1566 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_END
)();
1567 KA_TRACE(20, ("GOMP_parallel_sections exit: T#%d\n", gtid
));
1570 if (ompt_enabled
.enabled
) {
1571 task_frame
->enter_frame
= ompt_data_none
;
1576 #define PARALLEL_LOOP(func, schedule, ompt_pre, ompt_post) \
1577 void func(void (*task)(void *), void *data, unsigned num_threads, long lb, \
1578 long ub, long str, long chunk_sz, unsigned flags) { \
1579 int gtid = __kmp_entry_gtid(); \
1580 MKLOC(loc, KMP_STR(func)); \
1584 func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
1585 gtid, lb, ub, str, chunk_sz)); \
1588 IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
1589 __kmp_GOMP_fork_call(&loc, gtid, num_threads, flags, task, \
1590 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, \
1591 9, task, data, num_threads, &loc, (schedule), lb, \
1592 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz); \
1595 IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
1596 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
1597 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
1598 (schedule) != kmp_sch_static); \
1601 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_END)(); \
1604 KA_TRACE(20, (KMP_STR(func) " exit: T#%d\n", gtid)); \
1607 PARALLEL_LOOP(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC
),
1608 kmp_sch_static
, OMPT_LOOP_PRE
, OMPT_LOOP_POST
)
1609 PARALLEL_LOOP(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC
),
1610 kmp_sch_dynamic_chunked
, OMPT_LOOP_PRE
, OMPT_LOOP_POST
)
1612 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_NONMONOTONIC_GUIDED
),
1613 kmp_sch_guided_chunked
, OMPT_LOOP_PRE
, OMPT_LOOP_POST
)
1615 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_NONMONOTONIC_DYNAMIC
),
1616 kmp_sch_dynamic_chunked
, OMPT_LOOP_PRE
, OMPT_LOOP_POST
)
1617 PARALLEL_LOOP(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED
),
1618 kmp_sch_guided_chunked
, OMPT_LOOP_PRE
, OMPT_LOOP_POST
)
1619 PARALLEL_LOOP(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME
),
1620 kmp_sch_runtime
, OMPT_LOOP_PRE
, OMPT_LOOP_POST
)
1622 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_MAYBE_NONMONOTONIC_RUNTIME
),
1623 kmp_sch_runtime
, OMPT_LOOP_PRE
, OMPT_LOOP_POST
)
1625 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_NONMONOTONIC_RUNTIME
),
1626 kmp_sch_runtime
, OMPT_LOOP_PRE
, OMPT_LOOP_POST
)
1628 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKGROUP_START
)(void) {
1629 int gtid
= __kmp_entry_gtid();
1630 MKLOC(loc
, "GOMP_taskgroup_start");
1631 KA_TRACE(20, ("GOMP_taskgroup_start: T#%d\n", gtid
));
1634 OMPT_STORE_RETURN_ADDRESS(gtid
);
1637 __kmpc_taskgroup(&loc
, gtid
);
1642 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKGROUP_END
)(void) {
1643 int gtid
= __kmp_get_gtid();
1644 MKLOC(loc
, "GOMP_taskgroup_end");
1645 KA_TRACE(20, ("GOMP_taskgroup_end: T#%d\n", gtid
));
1648 OMPT_STORE_RETURN_ADDRESS(gtid
);
1651 __kmpc_end_taskgroup(&loc
, gtid
);
1656 static kmp_int32
__kmp_gomp_to_omp_cancellation_kind(int gomp_kind
) {
1657 kmp_int32 cncl_kind
= 0;
1658 switch (gomp_kind
) {
1660 cncl_kind
= cancel_parallel
;
1663 cncl_kind
= cancel_loop
;
1666 cncl_kind
= cancel_sections
;
1669 cncl_kind
= cancel_taskgroup
;
1675 // Return true if cancellation should take place, false otherwise
1676 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CANCELLATION_POINT
)(int which
) {
1677 int gtid
= __kmp_get_gtid();
1678 MKLOC(loc
, "GOMP_cancellation_point");
1679 KA_TRACE(20, ("GOMP_cancellation_point: T#%d which:%d\n", gtid
, which
));
1680 kmp_int32 cncl_kind
= __kmp_gomp_to_omp_cancellation_kind(which
);
1681 return __kmpc_cancellationpoint(&loc
, gtid
, cncl_kind
);
1684 // Return true if cancellation should take place, false otherwise
1685 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CANCEL
)(int which
, bool do_cancel
) {
1686 int gtid
= __kmp_get_gtid();
1687 MKLOC(loc
, "GOMP_cancel");
1688 KA_TRACE(20, ("GOMP_cancel: T#%d which:%d do_cancel:%d\n", gtid
, which
,
1690 kmp_int32 cncl_kind
= __kmp_gomp_to_omp_cancellation_kind(which
);
1692 if (do_cancel
== FALSE
) {
1693 return __kmpc_cancellationpoint(&loc
, gtid
, cncl_kind
);
1695 return __kmpc_cancel(&loc
, gtid
, cncl_kind
);
1699 // Return true if cancellation should take place, false otherwise
1700 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_BARRIER_CANCEL
)(void) {
1701 int gtid
= __kmp_get_gtid();
1702 KA_TRACE(20, ("GOMP_barrier_cancel: T#%d\n", gtid
));
1703 return __kmp_barrier_gomp_cancel(gtid
);
1706 // Return true if cancellation should take place, false otherwise
1707 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL
)(void) {
1708 int gtid
= __kmp_get_gtid();
1709 KA_TRACE(20, ("GOMP_sections_end_cancel: T#%d\n", gtid
));
1710 return __kmp_barrier_gomp_cancel(gtid
);
1713 // Return true if cancellation should take place, false otherwise
1714 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_END_CANCEL
)(void) {
1715 int gtid
= __kmp_get_gtid();
1716 KA_TRACE(20, ("GOMP_loop_end_cancel: T#%d\n", gtid
));
1717 return __kmp_barrier_gomp_cancel(gtid
);
1720 // All target functions are empty as of 2014-05-29
1721 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TARGET
)(int device
, void (*fn
)(void *),
1722 const void *openmp_target
,
1723 size_t mapnum
, void **hostaddrs
,
1725 unsigned char *kinds
) {
1729 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TARGET_DATA
)(
1730 int device
, const void *openmp_target
, size_t mapnum
, void **hostaddrs
,
1731 size_t *sizes
, unsigned char *kinds
) {
1735 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TARGET_END_DATA
)(void) { return; }
1737 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TARGET_UPDATE
)(
1738 int device
, const void *openmp_target
, size_t mapnum
, void **hostaddrs
,
1739 size_t *sizes
, unsigned char *kinds
) {
1743 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TEAMS
)(unsigned int num_teams
,
1744 unsigned int thread_limit
) {
1748 // Task duplication function which copies src to dest (both are
1749 // preallocated task structures)
1750 static void __kmp_gomp_task_dup(kmp_task_t
*dest
, kmp_task_t
*src
,
1751 kmp_int32 last_private
) {
1752 kmp_taskdata_t
*taskdata
= KMP_TASK_TO_TASKDATA(src
);
1753 if (taskdata
->td_copy_func
) {
1754 (taskdata
->td_copy_func
)(dest
->shareds
, src
->shareds
);
1758 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKGROUP_REDUCTION_REGISTER
)(
1765 template <typename T
>
1766 void __GOMP_taskloop(void (*func
)(void *), void *data
,
1767 void (*copy_func
)(void *, void *), long arg_size
,
1768 long arg_align
, unsigned gomp_flags
,
1769 unsigned long num_tasks
, int priority
, T start
, T end
,
1771 typedef void (*p_task_dup_t
)(kmp_task_t
*, kmp_task_t
*, kmp_int32
);
1772 MKLOC(loc
, "GOMP_taskloop");
1775 int gtid
= __kmp_entry_gtid();
1776 kmp_int32 flags
= 0;
1777 int if_val
= gomp_flags
& (1u << 10);
1778 int nogroup
= gomp_flags
& (1u << 11);
1779 int up
= gomp_flags
& (1u << 8);
1780 int reductions
= gomp_flags
& (1u << 12);
1781 p_task_dup_t task_dup
= NULL
;
1782 kmp_tasking_flags_t
*input_flags
= (kmp_tasking_flags_t
*)&flags
;
1786 buff
= __kmp_str_format(
1787 "GOMP_taskloop: T#%%d: func:%%p data:%%p copy_func:%%p "
1788 "arg_size:%%ld arg_align:%%ld gomp_flags:0x%%x num_tasks:%%lu "
1789 "priority:%%d start:%%%s end:%%%s step:%%%s\n",
1790 traits_t
<T
>::spec
, traits_t
<T
>::spec
, traits_t
<T
>::spec
);
1791 KA_TRACE(20, (buff
, gtid
, func
, data
, copy_func
, arg_size
, arg_align
,
1792 gomp_flags
, num_tasks
, priority
, start
, end
, step
));
1793 __kmp_str_free(&buff
);
1796 KMP_ASSERT((size_t)arg_size
>= 2 * sizeof(T
));
1797 KMP_ASSERT(arg_align
> 0);
1798 // The low-order bit is the "untied" flag
1799 if (!(gomp_flags
& 1)) {
1800 input_flags
->tiedness
= TASK_TIED
;
1802 // The second low-order bit is the "final" flag
1803 if (gomp_flags
& 2) {
1804 input_flags
->final
= 1;
1806 // Negative step flag
1808 // If step is flagged as negative, but isn't properly sign extended
1809 // Then manually sign extend it. Could be a short, int, char embedded
1810 // in a long. So cannot assume any cast.
1812 for (int i
= sizeof(T
) * CHAR_BIT
- 1; i
>= 0L; --i
) {
1813 // break at the first 1 bit
1814 if (step
& ((T
)1 << i
))
1816 step
|= ((T
)1 << i
);
1820 input_flags
->native
= 1;
1821 // Figure out if none/grainsize/num_tasks clause specified
1822 if (num_tasks
> 0) {
1823 if (gomp_flags
& (1u << 9))
1824 sched
= 1; // grainsize specified
1826 sched
= 2; // num_tasks specified
1827 // neither grainsize nor num_tasks specified
1832 // __kmp_task_alloc() sets up all other flags
1834 __kmp_task_alloc(&loc
, gtid
, input_flags
, sizeof(kmp_task_t
),
1835 arg_size
+ arg_align
- 1, (kmp_routine_entry_t
)func
);
1836 kmp_taskdata_t
*taskdata
= KMP_TASK_TO_TASKDATA(task
);
1837 taskdata
->td_copy_func
= copy_func
;
1838 taskdata
->td_size_loop_bounds
= sizeof(T
);
1840 // re-align shareds if needed and setup firstprivate copy constructors
1841 // through the task_dup mechanism
1842 task
->shareds
= (void *)((((size_t)task
->shareds
) + arg_align
- 1) /
1843 arg_align
* arg_align
);
1845 task_dup
= __kmp_gomp_task_dup
;
1847 KMP_MEMCPY(task
->shareds
, data
, arg_size
);
1849 loop_bounds
= (T
*)task
->shareds
;
1850 loop_bounds
[0] = start
;
1851 loop_bounds
[1] = end
+ (up
? -1 : 1);
1854 #if OMPT_SUPPORT && OMPT_OPTIONAL
1855 OMPT_STORE_RETURN_ADDRESS(gtid
);
1857 __kmpc_taskgroup(&loc
, gtid
);
1859 // The data pointer points to lb, ub, then reduction data
1864 uintptr_t *d
= ((data_t
*)data
)->d
;
1865 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKGROUP_REDUCTION_REGISTER
)(d
);
1868 __kmpc_taskloop(&loc
, gtid
, task
, if_val
, (kmp_uint64
*)&(loop_bounds
[0]),
1869 (kmp_uint64
*)&(loop_bounds
[1]), (kmp_int64
)step
, 1, sched
,
1870 (kmp_uint64
)num_tasks
, (void *)task_dup
);
1872 #if OMPT_SUPPORT && OMPT_OPTIONAL
1873 OMPT_STORE_RETURN_ADDRESS(gtid
);
1875 __kmpc_end_taskgroup(&loc
, gtid
);
1879 // 4 byte version of GOMP_doacross_post
1880 // This verison needs to create a temporary array which converts 4 byte
1881 // integers into 8 byte integers
1882 template <typename T
, bool need_conversion
= (sizeof(long) == 4)>
1883 void __kmp_GOMP_doacross_post(T
*count
);
1885 template <> void __kmp_GOMP_doacross_post
<long, true>(long *count
) {
1886 int gtid
= __kmp_entry_gtid();
1887 kmp_info_t
*th
= __kmp_threads
[gtid
];
1888 MKLOC(loc
, "GOMP_doacross_post");
1889 kmp_int64 num_dims
= th
->th
.th_dispatch
->th_doacross_info
[0];
1890 kmp_int64
*vec
= (kmp_int64
*)__kmp_thread_malloc(
1891 th
, (size_t)(sizeof(kmp_int64
) * num_dims
));
1892 for (kmp_int64 i
= 0; i
< num_dims
; ++i
) {
1893 vec
[i
] = (kmp_int64
)count
[i
];
1895 __kmpc_doacross_post(&loc
, gtid
, vec
);
1896 __kmp_thread_free(th
, vec
);
1899 // 8 byte versions of GOMP_doacross_post
1900 // This version can just pass in the count array directly instead of creating
1901 // a temporary array
1902 template <> void __kmp_GOMP_doacross_post
<long, false>(long *count
) {
1903 int gtid
= __kmp_entry_gtid();
1904 MKLOC(loc
, "GOMP_doacross_post");
1905 __kmpc_doacross_post(&loc
, gtid
, RCAST(kmp_int64
*, count
));
1908 template <typename T
> void __kmp_GOMP_doacross_wait(T first
, va_list args
) {
1909 int gtid
= __kmp_entry_gtid();
1910 kmp_info_t
*th
= __kmp_threads
[gtid
];
1911 MKLOC(loc
, "GOMP_doacross_wait");
1912 kmp_int64 num_dims
= th
->th
.th_dispatch
->th_doacross_info
[0];
1913 kmp_int64
*vec
= (kmp_int64
*)__kmp_thread_malloc(
1914 th
, (size_t)(sizeof(kmp_int64
) * num_dims
));
1915 vec
[0] = (kmp_int64
)first
;
1916 for (kmp_int64 i
= 1; i
< num_dims
; ++i
) {
1917 T item
= va_arg(args
, T
);
1918 vec
[i
] = (kmp_int64
)item
;
1920 __kmpc_doacross_wait(&loc
, gtid
, vec
);
1921 __kmp_thread_free(th
, vec
);
1927 #endif // __cplusplus
1929 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKLOOP
)(
1930 void (*func
)(void *), void *data
, void (*copy_func
)(void *, void *),
1931 long arg_size
, long arg_align
, unsigned gomp_flags
, unsigned long num_tasks
,
1932 int priority
, long start
, long end
, long step
) {
1933 __GOMP_taskloop
<long>(func
, data
, copy_func
, arg_size
, arg_align
, gomp_flags
,
1934 num_tasks
, priority
, start
, end
, step
);
1937 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKLOOP_ULL
)(
1938 void (*func
)(void *), void *data
, void (*copy_func
)(void *, void *),
1939 long arg_size
, long arg_align
, unsigned gomp_flags
, unsigned long num_tasks
,
1940 int priority
, unsigned long long start
, unsigned long long end
,
1941 unsigned long long step
) {
1942 __GOMP_taskloop
<unsigned long long>(func
, data
, copy_func
, arg_size
,
1943 arg_align
, gomp_flags
, num_tasks
,
1944 priority
, start
, end
, step
);
1947 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_DOACROSS_POST
)(long *count
) {
1948 __kmp_GOMP_doacross_post(count
);
1951 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_DOACROSS_WAIT
)(long first
, ...) {
1953 va_start(args
, first
);
1954 __kmp_GOMP_doacross_wait
<long>(first
, args
);
1958 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_DOACROSS_ULL_POST
)(
1959 unsigned long long *count
) {
1960 int gtid
= __kmp_entry_gtid();
1961 MKLOC(loc
, "GOMP_doacross_ull_post");
1962 __kmpc_doacross_post(&loc
, gtid
, RCAST(kmp_int64
*, count
));
1965 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_DOACROSS_ULL_WAIT
)(
1966 unsigned long long first
, ...) {
1968 va_start(args
, first
);
1969 __kmp_GOMP_doacross_wait
<unsigned long long>(first
, args
);
1973 // fn: the function each primary thread of new team will call
1974 // data: argument to fn
1975 // num_teams, thread_limit: max bounds on respective ICV
1977 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TEAMS_REG
)(void (*fn
)(void *),
1980 unsigned thread_limit
,
1982 MKLOC(loc
, "GOMP_teams_reg");
1983 int gtid
= __kmp_entry_gtid();
1984 KA_TRACE(20, ("GOMP_teams_reg: T#%d num_teams=%u thread_limit=%u flag=%u\n",
1985 gtid
, num_teams
, thread_limit
, flags
));
1986 __kmpc_push_num_teams(&loc
, gtid
, num_teams
, thread_limit
);
1987 __kmpc_fork_teams(&loc
, 2, (microtask_t
)__kmp_GOMP_microtask_wrapper
, fn
,
1989 KA_TRACE(20, ("GOMP_teams_reg exit: T#%d\n", gtid
));
1992 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKWAIT_DEPEND
)(void **depend
) {
1993 MKLOC(loc
, "GOMP_taskwait_depend");
1994 int gtid
= __kmp_entry_gtid();
1995 KA_TRACE(20, ("GOMP_taskwait_depend: T#%d\n", gtid
));
1996 kmp_gomp_depends_info_t
gomp_depends(depend
);
1997 kmp_int32 ndeps
= gomp_depends
.get_num_deps();
1998 SimpleVLA
<kmp_depend_info_t
> dep_list(ndeps
);
1999 for (kmp_int32 i
= 0; i
< ndeps
; i
++)
2000 dep_list
[i
] = gomp_depends
.get_kmp_depend(i
);
2002 OMPT_STORE_RETURN_ADDRESS(gtid
);
2004 __kmpc_omp_wait_deps(&loc
, gtid
, ndeps
, dep_list
, 0, NULL
);
2005 KA_TRACE(20, ("GOMP_taskwait_depend exit: T#%d\n", gtid
));
2009 __kmp_GOMP_taskgroup_reduction_register(uintptr_t *data
, kmp_taskgroup_t
*tg
,
2011 uintptr_t *allocated
= nullptr) {
2013 KMP_ASSERT(nthreads
> 0);
2014 // Have private copy pointers point to previously allocated
2015 // reduction data or allocate new data here
2017 data
[2] = allocated
[2];
2018 data
[6] = allocated
[6];
2020 data
[2] = (uintptr_t)__kmp_allocate(nthreads
* data
[1]);
2021 data
[6] = data
[2] + (nthreads
* data
[1]);
2024 tg
->gomp_data
= data
;
2027 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKGROUP_REDUCTION_REGISTER
)(
2029 int gtid
= __kmp_entry_gtid();
2030 KA_TRACE(20, ("GOMP_taskgroup_reduction_register: T#%d\n", gtid
));
2031 kmp_info_t
*thread
= __kmp_threads
[gtid
];
2032 kmp_taskgroup_t
*tg
= thread
->th
.th_current_task
->td_taskgroup
;
2033 int nthreads
= thread
->th
.th_team_nproc
;
2034 __kmp_GOMP_taskgroup_reduction_register(data
, tg
, nthreads
);
2037 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKGROUP_REDUCTION_UNREGISTER
)(
2040 ("GOMP_taskgroup_reduction_unregister: T#%d\n", __kmp_get_gtid()));
2041 KMP_ASSERT(data
&& data
[2]);
2042 __kmp_free((void *)data
[2]);
2045 // Search through reduction data and set ptrs[] elements
2046 // to proper privatized copy address
2047 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASK_REDUCTION_REMAP
)(size_t cnt
,
2050 int gtid
= __kmp_entry_gtid();
2051 KA_TRACE(20, ("GOMP_task_reduction_remap: T#%d\n", gtid
));
2052 kmp_info_t
*thread
= __kmp_threads
[gtid
];
2053 kmp_int32 tid
= __kmp_get_tid();
2054 for (size_t i
= 0; i
< cnt
; ++i
) {
2055 uintptr_t address
= (uintptr_t)ptrs
[i
];
2056 void *propagated_address
= NULL
;
2057 void *mapped_address
= NULL
;
2058 // Check taskgroups reduce data
2059 kmp_taskgroup_t
*tg
= thread
->th
.th_current_task
->td_taskgroup
;
2061 uintptr_t *gomp_data
= tg
->gomp_data
;
2066 // Check the shared addresses list
2067 size_t num_vars
= (size_t)gomp_data
[0];
2068 uintptr_t per_thread_size
= gomp_data
[1];
2069 uintptr_t reduce_data
= gomp_data
[2];
2070 uintptr_t end_reduce_data
= gomp_data
[6];
2071 for (size_t j
= 0; j
< num_vars
; ++j
) {
2072 uintptr_t *entry
= gomp_data
+ 7 + 3 * j
;
2073 if (entry
[0] == address
) {
2074 uintptr_t offset
= entry
[1];
2076 (void *)(reduce_data
+ tid
* per_thread_size
+ offset
);
2078 propagated_address
= (void *)entry
[0];
2084 // Check if address is within privatized copies range
2085 if (!mapped_address
&& address
>= reduce_data
&&
2086 address
< end_reduce_data
) {
2087 uintptr_t offset
= (address
- reduce_data
) % per_thread_size
;
2088 mapped_address
= (void *)(reduce_data
+ tid
* per_thread_size
+ offset
);
2090 for (size_t j
= 0; j
< num_vars
; ++j
) {
2091 uintptr_t *entry
= gomp_data
+ 7 + 3 * j
;
2092 if (entry
[1] == offset
) {
2093 propagated_address
= (void *)entry
[0];
2103 KMP_ASSERT(mapped_address
);
2104 ptrs
[i
] = mapped_address
;
2106 KMP_ASSERT(propagated_address
);
2107 ptrs
[cnt
+ i
] = propagated_address
;
2112 static void __kmp_GOMP_init_reductions(int gtid
, uintptr_t *data
, int is_ws
) {
2113 kmp_info_t
*thr
= __kmp_threads
[gtid
];
2114 kmp_team_t
*team
= thr
->th
.th_team
;
2115 // First start a taskgroup
2116 __kmpc_taskgroup(NULL
, gtid
);
2117 // Then setup reduction data
2118 void *reduce_data
= KMP_ATOMIC_LD_RLX(&team
->t
.t_tg_reduce_data
[is_ws
]);
2119 if (reduce_data
== NULL
&&
2120 __kmp_atomic_compare_store(&team
->t
.t_tg_reduce_data
[is_ws
], reduce_data
,
2122 // Single thread enters this block to initialize common reduction data
2123 KMP_DEBUG_ASSERT(reduce_data
== NULL
);
2124 __kmp_GOMP_taskgroup_reduction_register(data
, NULL
, thr
->th
.th_team_nproc
);
2125 KMP_ATOMIC_ST_REL(&team
->t
.t_tg_fini_counter
[is_ws
], 0);
2126 KMP_ATOMIC_ST_REL(&team
->t
.t_tg_reduce_data
[is_ws
], (void *)data
);
2128 // Wait for task reduction initialization
2129 while ((reduce_data
= KMP_ATOMIC_LD_ACQ(
2130 &team
->t
.t_tg_reduce_data
[is_ws
])) == (void *)1) {
2133 KMP_DEBUG_ASSERT(reduce_data
> (void *)1); // should be valid pointer here
2135 // For worksharing constructs, each thread has its own reduction structure.
2136 // Have each reduction structure point to same privatized copies of vars.
2137 // For parallel, each thread points to same reduction structure and privatized
2140 __kmp_GOMP_taskgroup_reduction_register(
2141 data
, NULL
, thr
->th
.th_team_nproc
,
2142 (uintptr_t *)KMP_ATOMIC_LD_ACQ(&team
->t
.t_tg_reduce_data
[is_ws
]));
2144 kmp_taskgroup_t
*tg
= thr
->th
.th_current_task
->td_taskgroup
;
2145 tg
->gomp_data
= data
;
2149 __kmp_GOMP_par_reductions_microtask_wrapper(int *gtid
, int *npr
,
2150 void (*task
)(void *), void *data
) {
2151 kmp_info_t
*thr
= __kmp_threads
[*gtid
];
2152 kmp_team_t
*team
= thr
->th
.th_team
;
2153 uintptr_t *reduce_data
= *(uintptr_t **)data
;
2154 __kmp_GOMP_init_reductions(*gtid
, reduce_data
, 0);
2157 ompt_frame_t
*ompt_frame
;
2158 ompt_state_t enclosing_state
;
2160 if (ompt_enabled
.enabled
) {
2161 // save enclosing task state; set current state for task
2162 enclosing_state
= thr
->th
.ompt_thread_info
.state
;
2163 thr
->th
.ompt_thread_info
.state
= ompt_state_work_parallel
;
2166 __ompt_get_task_info_internal(0, NULL
, NULL
, &ompt_frame
, NULL
, NULL
);
2167 ompt_frame
->exit_frame
.ptr
= OMPT_GET_FRAME_ADDRESS(0);
2174 if (ompt_enabled
.enabled
) {
2176 ompt_frame
->exit_frame
= ompt_data_none
;
2178 // restore enclosing state
2179 thr
->th
.ompt_thread_info
.state
= enclosing_state
;
2182 __kmpc_end_taskgroup(NULL
, *gtid
);
2183 // if last thread out, then reset the team's reduce data
2184 // the GOMP_taskgroup_reduction_unregister() function will deallocate
2185 // private copies after reduction calculations take place.
2186 int count
= KMP_ATOMIC_INC(&team
->t
.t_tg_fini_counter
[0]);
2187 if (count
== thr
->th
.th_team_nproc
- 1) {
2188 KMP_ATOMIC_ST_REL(&team
->t
.t_tg_reduce_data
[0], NULL
);
2189 KMP_ATOMIC_ST_REL(&team
->t
.t_tg_fini_counter
[0], 0);
2191 return (unsigned)thr
->th
.th_team_nproc
;
2194 unsigned KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_REDUCTIONS
)(
2195 void (*task
)(void *), void *data
, unsigned num_threads
,
2196 unsigned int flags
) {
2197 MKLOC(loc
, "GOMP_parallel_reductions");
2198 int gtid
= __kmp_entry_gtid();
2199 KA_TRACE(20, ("GOMP_parallel_reductions: T#%d\n", gtid
));
2200 __kmp_GOMP_fork_call(&loc
, gtid
, num_threads
, flags
, task
,
2201 (microtask_t
)__kmp_GOMP_par_reductions_microtask_wrapper
,
2204 __kmp_GOMP_par_reductions_microtask_wrapper(>id
, NULL
, task
, data
);
2205 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_END
)();
2206 KA_TRACE(20, ("GOMP_parallel_reductions exit: T#%d\n", gtid
));
2210 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_START
)(
2211 long start
, long end
, long incr
, long sched
, long chunk_size
, long *istart
,
2212 long *iend
, uintptr_t *reductions
, void **mem
) {
2214 int gtid
= __kmp_entry_gtid();
2215 KA_TRACE(20, ("GOMP_loop_start: T#%d, reductions: %p\n", gtid
, reductions
));
2217 __kmp_GOMP_init_reductions(gtid
, reductions
, 1);
2219 KMP_FATAL(GompFeatureNotSupported
, "scan");
2222 const long MONOTONIC_FLAG
= (long)(kmp_sched_monotonic
);
2223 long monotonic
= sched
& MONOTONIC_FLAG
;
2224 sched
&= ~MONOTONIC_FLAG
;
2227 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_RUNTIME_START
)(
2228 start
, end
, incr
, istart
, iend
);
2230 status
= KMP_EXPAND_NAME(
2231 KMP_API_NAME_GOMP_LOOP_MAYBE_NONMONOTONIC_RUNTIME_START
)(
2232 start
, end
, incr
, istart
, iend
);
2233 } else if (sched
== 1) {
2234 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_STATIC_START
)(
2235 start
, end
, incr
, chunk_size
, istart
, iend
);
2236 } else if (sched
== 2) {
2238 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START
)(
2239 start
, end
, incr
, chunk_size
, istart
, iend
);
2242 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_DYNAMIC_START
)(
2243 start
, end
, incr
, chunk_size
, istart
, iend
);
2244 } else if (sched
== 3) {
2246 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_GUIDED_START
)(
2247 start
, end
, incr
, chunk_size
, istart
, iend
);
2250 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_GUIDED_START
)(
2251 start
, end
, incr
, chunk_size
, istart
, iend
);
2252 } else if (sched
== 4) {
2253 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_RUNTIME_START
)(
2254 start
, end
, incr
, istart
, iend
);
2261 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_START
)(
2262 bool up
, unsigned long long start
, unsigned long long end
,
2263 unsigned long long incr
, long sched
, unsigned long long chunk_size
,
2264 unsigned long long *istart
, unsigned long long *iend
, uintptr_t *reductions
,
2267 int gtid
= __kmp_entry_gtid();
2269 ("GOMP_loop_ull_start: T#%d, reductions: %p\n", gtid
, reductions
));
2271 __kmp_GOMP_init_reductions(gtid
, reductions
, 1);
2273 KMP_FATAL(GompFeatureNotSupported
, "scan");
2276 const long MONOTONIC_FLAG
= (long)(kmp_sched_monotonic
);
2277 long monotonic
= sched
& MONOTONIC_FLAG
;
2278 sched
&= ~MONOTONIC_FLAG
;
2281 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START
)(
2282 up
, start
, end
, incr
, istart
, iend
);
2284 status
= KMP_EXPAND_NAME(
2285 KMP_API_NAME_GOMP_LOOP_ULL_MAYBE_NONMONOTONIC_RUNTIME_START
)(
2286 up
, start
, end
, incr
, istart
, iend
);
2287 } else if (sched
== 1) {
2288 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START
)(
2289 up
, start
, end
, incr
, chunk_size
, istart
, iend
);
2290 } else if (sched
== 2) {
2292 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START
)(
2293 up
, start
, end
, incr
, chunk_size
, istart
, iend
);
2295 status
= KMP_EXPAND_NAME(
2296 KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_DYNAMIC_START
)(
2297 up
, start
, end
, incr
, chunk_size
, istart
, iend
);
2298 } else if (sched
== 3) {
2300 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START
)(
2301 up
, start
, end
, incr
, chunk_size
, istart
, iend
);
2304 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_GUIDED_START
)(
2305 up
, start
, end
, incr
, chunk_size
, istart
, iend
);
2306 } else if (sched
== 4) {
2308 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_RUNTIME_START
)(
2309 up
, start
, end
, incr
, istart
, iend
);
2316 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_START
)(
2317 unsigned ncounts
, long *counts
, long sched
, long chunk_size
, long *istart
,
2318 long *iend
, uintptr_t *reductions
, void **mem
) {
2320 int gtid
= __kmp_entry_gtid();
2321 KA_TRACE(20, ("GOMP_loop_doacross_start: T#%d, reductions: %p\n", gtid
,
2324 __kmp_GOMP_init_reductions(gtid
, reductions
, 1);
2326 KMP_FATAL(GompFeatureNotSupported
, "scan");
2329 // Ignore any monotonic flag
2330 const long MONOTONIC_FLAG
= (long)(kmp_sched_monotonic
);
2331 sched
&= ~MONOTONIC_FLAG
;
2333 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_RUNTIME_START
)(
2334 ncounts
, counts
, istart
, iend
);
2335 } else if (sched
== 1) {
2336 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_STATIC_START
)(
2337 ncounts
, counts
, chunk_size
, istart
, iend
);
2338 } else if (sched
== 2) {
2339 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_DYNAMIC_START
)(
2340 ncounts
, counts
, chunk_size
, istart
, iend
);
2341 } else if (sched
== 3) {
2342 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_GUIDED_START
)(
2343 ncounts
, counts
, chunk_size
, istart
, iend
);
2350 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_START
)(
2351 unsigned ncounts
, unsigned long long *counts
, long sched
,
2352 unsigned long long chunk_size
, unsigned long long *istart
,
2353 unsigned long long *iend
, uintptr_t *reductions
, void **mem
) {
2355 int gtid
= __kmp_entry_gtid();
2356 KA_TRACE(20, ("GOMP_loop_ull_doacross_start: T#%d, reductions: %p\n", gtid
,
2359 __kmp_GOMP_init_reductions(gtid
, reductions
, 1);
2361 KMP_FATAL(GompFeatureNotSupported
, "scan");
2364 // Ignore any monotonic flag
2365 const long MONOTONIC_FLAG
= (long)(kmp_sched_monotonic
);
2366 sched
&= ~MONOTONIC_FLAG
;
2368 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_RUNTIME_START
)(
2369 ncounts
, counts
, istart
, iend
);
2370 } else if (sched
== 1) {
2371 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_STATIC_START
)(
2372 ncounts
, counts
, chunk_size
, istart
, iend
);
2373 } else if (sched
== 2) {
2374 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_DYNAMIC_START
)(
2375 ncounts
, counts
, chunk_size
, istart
, iend
);
2376 } else if (sched
== 3) {
2377 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_GUIDED_START
)(
2378 ncounts
, counts
, chunk_size
, istart
, iend
);
2385 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_START
)(
2386 long start
, long end
, long incr
, long sched
, long chunk_size
, long *istart
,
2387 long *iend
, uintptr_t *reductions
, void **mem
) {
2389 int gtid
= __kmp_entry_gtid();
2390 KA_TRACE(20, ("GOMP_loop_ordered_start: T#%d, reductions: %p\n", gtid
,
2393 __kmp_GOMP_init_reductions(gtid
, reductions
, 1);
2395 KMP_FATAL(GompFeatureNotSupported
, "scan");
2398 // Ignore any monotonic flag
2399 const long MONOTONIC_FLAG
= (long)(kmp_sched_monotonic
);
2400 sched
&= ~MONOTONIC_FLAG
;
2402 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START
)(
2403 start
, end
, incr
, istart
, iend
);
2404 } else if (sched
== 1) {
2405 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START
)(
2406 start
, end
, incr
, chunk_size
, istart
, iend
);
2407 } else if (sched
== 2) {
2408 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START
)(
2409 start
, end
, incr
, chunk_size
, istart
, iend
);
2410 } else if (sched
== 3) {
2411 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START
)(
2412 start
, end
, incr
, chunk_size
, istart
, iend
);
2419 bool KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_START
)(
2420 bool up
, unsigned long long start
, unsigned long long end
,
2421 unsigned long long incr
, long sched
, unsigned long long chunk_size
,
2422 unsigned long long *istart
, unsigned long long *iend
, uintptr_t *reductions
,
2425 int gtid
= __kmp_entry_gtid();
2426 KA_TRACE(20, ("GOMP_loop_ull_ordered_start: T#%d, reductions: %p\n", gtid
,
2429 __kmp_GOMP_init_reductions(gtid
, reductions
, 1);
2431 KMP_FATAL(GompFeatureNotSupported
, "scan");
2434 // Ignore any monotonic flag
2435 const long MONOTONIC_FLAG
= (long)(kmp_sched_monotonic
);
2436 sched
&= ~MONOTONIC_FLAG
;
2438 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START
)(
2439 up
, start
, end
, incr
, istart
, iend
);
2440 } else if (sched
== 1) {
2441 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START
)(
2442 up
, start
, end
, incr
, chunk_size
, istart
, iend
);
2443 } else if (sched
== 2) {
2444 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START
)(
2445 up
, start
, end
, incr
, chunk_size
, istart
, iend
);
2446 } else if (sched
== 3) {
2447 status
= KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START
)(
2448 up
, start
, end
, incr
, chunk_size
, istart
, iend
);
2455 unsigned KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SECTIONS2_START
)(
2456 unsigned count
, uintptr_t *reductions
, void **mem
) {
2457 int gtid
= __kmp_entry_gtid();
2459 ("GOMP_sections2_start: T#%d, reductions: %p\n", gtid
, reductions
));
2461 __kmp_GOMP_init_reductions(gtid
, reductions
, 1);
2463 KMP_FATAL(GompFeatureNotSupported
, "scan");
2464 return KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SECTIONS_START
)(count
);
2467 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_WORKSHARE_TASK_REDUCTION_UNREGISTER
)(
2469 int gtid
= __kmp_get_gtid();
2470 MKLOC(loc
, "GOMP_workshare_task_reduction_unregister");
2471 KA_TRACE(20, ("GOMP_workshare_task_reduction_unregister: T#%d\n", gtid
));
2472 kmp_info_t
*thr
= __kmp_threads
[gtid
];
2473 kmp_team_t
*team
= thr
->th
.th_team
;
2474 __kmpc_end_taskgroup(NULL
, gtid
);
2475 // If last thread out of workshare, then reset the team's reduce data
2476 // the GOMP_taskgroup_reduction_unregister() function will deallocate
2477 // private copies after reduction calculations take place.
2478 int count
= KMP_ATOMIC_INC(&team
->t
.t_tg_fini_counter
[1]);
2479 if (count
== thr
->th
.th_team_nproc
- 1) {
2480 KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKGROUP_REDUCTION_UNREGISTER
)
2481 ((uintptr_t *)KMP_ATOMIC_LD_RLX(&team
->t
.t_tg_reduce_data
[1]));
2482 KMP_ATOMIC_ST_REL(&team
->t
.t_tg_reduce_data
[1], NULL
);
2483 KMP_ATOMIC_ST_REL(&team
->t
.t_tg_fini_counter
[1], 0);
2486 __kmpc_barrier(&loc
, gtid
);
2490 // allocator construct
2491 void *KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ALLOC
)(size_t alignment
, size_t size
,
2492 uintptr_t allocator
) {
2493 int gtid
= __kmp_entry_gtid();
2494 KA_TRACE(20, ("GOMP_alloc: T#%d\n", gtid
));
2495 #if OMPT_SUPPORT && OMPT_OPTIONAL
2496 OMPT_STORE_RETURN_ADDRESS(gtid
);
2498 return __kmp_alloc(gtid
, alignment
, size
, (omp_allocator_handle_t
)allocator
);
2501 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_FREE
)(void *ptr
, uintptr_t allocator
) {
2502 int gtid
= __kmp_entry_gtid();
2503 KA_TRACE(20, ("GOMP_free: T#%d\n", gtid
));
2504 #if OMPT_SUPPORT && OMPT_OPTIONAL
2505 OMPT_STORE_RETURN_ADDRESS(gtid
);
2507 return ___kmpc_free(gtid
, ptr
, (omp_allocator_handle_t
)allocator
);
2510 /* The following sections of code create aliases for the GOMP_* functions, then
2511 create versioned symbols using the assembler directive .symver. This is only
2512 pertinent for ELF .so library. The KMP_VERSION_SYMBOL macro is defined in
2515 #ifdef KMP_USE_VERSION_SYMBOLS
2516 // GOMP_1.0 versioned symbols
2517 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_ATOMIC_END
, 10, "GOMP_1.0");
2518 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_ATOMIC_START
, 10, "GOMP_1.0");
2519 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_BARRIER
, 10, "GOMP_1.0");
2520 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_CRITICAL_END
, 10, "GOMP_1.0");
2521 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_CRITICAL_NAME_END
, 10, "GOMP_1.0");
2522 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_CRITICAL_NAME_START
, 10, "GOMP_1.0");
2523 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_CRITICAL_START
, 10, "GOMP_1.0");
2524 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT
, 10, "GOMP_1.0");
2525 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START
, 10, "GOMP_1.0");
2526 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_END
, 10, "GOMP_1.0");
2527 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_END_NOWAIT
, 10, "GOMP_1.0");
2528 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT
, 10, "GOMP_1.0");
2529 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_GUIDED_START
, 10, "GOMP_1.0");
2530 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT
, 10, "GOMP_1.0");
2531 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START
, 10,
2533 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT
, 10, "GOMP_1.0");
2534 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START
, 10, "GOMP_1.0");
2535 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT
, 10, "GOMP_1.0");
2536 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START
, 10,
2538 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT
, 10, "GOMP_1.0");
2539 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START
, 10, "GOMP_1.0");
2540 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT
, 10, "GOMP_1.0");
2541 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_RUNTIME_START
, 10, "GOMP_1.0");
2542 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT
, 10, "GOMP_1.0");
2543 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_STATIC_START
, 10, "GOMP_1.0");
2544 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_ORDERED_END
, 10, "GOMP_1.0");
2545 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_ORDERED_START
, 10, "GOMP_1.0");
2546 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_END
, 10, "GOMP_1.0");
2547 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START
, 10,
2549 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START
, 10,
2551 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START
, 10,
2553 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START
, 10,
2555 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START
, 10, "GOMP_1.0");
2556 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_START
, 10, "GOMP_1.0");
2557 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SECTIONS_END
, 10, "GOMP_1.0");
2558 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT
, 10, "GOMP_1.0");
2559 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SECTIONS_NEXT
, 10, "GOMP_1.0");
2560 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SECTIONS_START
, 10, "GOMP_1.0");
2561 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SINGLE_COPY_END
, 10, "GOMP_1.0");
2562 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SINGLE_COPY_START
, 10, "GOMP_1.0");
2563 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SINGLE_START
, 10, "GOMP_1.0");
2565 // GOMP_2.0 versioned symbols
2566 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASK
, 20, "GOMP_2.0");
2567 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKWAIT
, 20, "GOMP_2.0");
2568 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT
, 20, "GOMP_2.0");
2569 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START
, 20, "GOMP_2.0");
2570 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT
, 20, "GOMP_2.0");
2571 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START
, 20, "GOMP_2.0");
2572 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT
, 20,
2574 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START
, 20,
2576 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT
, 20,
2578 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START
, 20,
2580 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT
, 20,
2582 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START
, 20,
2584 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT
, 20,
2586 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START
, 20,
2588 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT
, 20, "GOMP_2.0");
2589 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START
, 20, "GOMP_2.0");
2590 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT
, 20, "GOMP_2.0");
2591 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START
, 20, "GOMP_2.0");
2593 // GOMP_3.0 versioned symbols
2594 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKYIELD
, 30, "GOMP_3.0");
2596 // GOMP_4.0 versioned symbols
2597 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL
, 40, "GOMP_4.0");
2598 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_SECTIONS
, 40, "GOMP_4.0");
2599 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC
, 40, "GOMP_4.0");
2600 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED
, 40, "GOMP_4.0");
2601 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME
, 40, "GOMP_4.0");
2602 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC
, 40, "GOMP_4.0");
2603 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKGROUP_START
, 40, "GOMP_4.0");
2604 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKGROUP_END
, 40, "GOMP_4.0");
2605 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_BARRIER_CANCEL
, 40, "GOMP_4.0");
2606 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_CANCEL
, 40, "GOMP_4.0");
2607 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_CANCELLATION_POINT
, 40, "GOMP_4.0");
2608 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_END_CANCEL
, 40, "GOMP_4.0");
2609 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL
, 40, "GOMP_4.0");
2610 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TARGET
, 40, "GOMP_4.0");
2611 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TARGET_DATA
, 40, "GOMP_4.0");
2612 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TARGET_END_DATA
, 40, "GOMP_4.0");
2613 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TARGET_UPDATE
, 40, "GOMP_4.0");
2614 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TEAMS
, 40, "GOMP_4.0");
2616 // GOMP_4.5 versioned symbols
2617 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKLOOP
, 45, "GOMP_4.5");
2618 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKLOOP_ULL
, 45, "GOMP_4.5");
2619 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_DOACROSS_POST
, 45, "GOMP_4.5");
2620 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_DOACROSS_WAIT
, 45, "GOMP_4.5");
2621 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DOACROSS_STATIC_START
, 45,
2623 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DOACROSS_DYNAMIC_START
, 45,
2625 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DOACROSS_GUIDED_START
, 45,
2627 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DOACROSS_RUNTIME_START
, 45,
2629 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_DOACROSS_ULL_POST
, 45, "GOMP_4.5");
2630 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_DOACROSS_ULL_WAIT
, 45, "GOMP_4.5");
2631 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_STATIC_START
, 45,
2633 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_DYNAMIC_START
, 45,
2635 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_GUIDED_START
, 45,
2637 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_RUNTIME_START
, 45,
2639 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_DYNAMIC_START
, 45,
2641 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_DYNAMIC_NEXT
, 45,
2643 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_GUIDED_START
, 45,
2645 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_GUIDED_NEXT
, 45,
2647 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_DYNAMIC_START
, 45,
2649 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_DYNAMIC_NEXT
, 45,
2651 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_GUIDED_START
, 45,
2653 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_GUIDED_NEXT
, 45,
2655 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_NONMONOTONIC_DYNAMIC
, 45,
2657 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_NONMONOTONIC_GUIDED
, 45,
2660 // GOMP_5.0 versioned symbols
2661 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_MAYBE_NONMONOTONIC_RUNTIME_NEXT
, 50,
2663 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_MAYBE_NONMONOTONIC_RUNTIME_START
, 50,
2665 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_RUNTIME_NEXT
, 50,
2667 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_RUNTIME_START
, 50,
2669 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_MAYBE_NONMONOTONIC_RUNTIME_NEXT
,
2671 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_MAYBE_NONMONOTONIC_RUNTIME_START
,
2673 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_RUNTIME_NEXT
, 50,
2675 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_RUNTIME_START
, 50,
2677 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_NONMONOTONIC_RUNTIME
, 50,
2679 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_MAYBE_NONMONOTONIC_RUNTIME
,
2681 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TEAMS_REG
, 50, "GOMP_5.0");
2682 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKWAIT_DEPEND
, 50, "GOMP_5.0");
2683 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKGROUP_REDUCTION_REGISTER
, 50,
2685 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASKGROUP_REDUCTION_UNREGISTER
, 50,
2687 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_TASK_REDUCTION_REMAP
, 50, "GOMP_5.0");
2688 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_REDUCTIONS
, 50, "GOMP_5.0");
2689 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_START
, 50, "GOMP_5.0");
2690 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_START
, 50, "GOMP_5.0");
2691 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_DOACROSS_START
, 50, "GOMP_5.0");
2692 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_DOACROSS_START
, 50, "GOMP_5.0");
2693 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ORDERED_START
, 50, "GOMP_5.0");
2694 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_START
, 50, "GOMP_5.0");
2695 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_SECTIONS2_START
, 50, "GOMP_5.0");
2696 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_WORKSHARE_TASK_REDUCTION_UNREGISTER
, 50,
2699 // GOMP_5.0.1 versioned symbols
2700 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_ALLOC
, 501, "GOMP_5.0.1");
2701 KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_FREE
, 501, "GOMP_5.0.1");
2702 #endif // KMP_USE_VERSION_SYMBOLS
2706 #endif // __cplusplus