blob: 99dc822671f7146e19111543062fe17bb65de913 [file] [log] [blame]
Jim Cownie5e8470a2013-09-27 10:38:44 +00001/*
2 * kmp_gsupport.c
Jim Cownie5e8470a2013-09-27 10:38:44 +00003 */
4
5
6//===----------------------------------------------------------------------===//
7//
8// The LLVM Compiler Infrastructure
9//
10// This file is dual licensed under the MIT and the University of Illinois Open
11// Source Licenses. See LICENSE.txt for details.
12//
13//===----------------------------------------------------------------------===//
14
15
Andrey Churbanovcbda8682015-01-13 14:43:35 +000016#if defined(__x86_64) || defined (__powerpc64__) || defined(__aarch64__)
Jim Cownie5e8470a2013-09-27 10:38:44 +000017# define KMP_I8
18#endif
19#include "kmp.h"
20#include "kmp_atomic.h"
21
Andrey Churbanovd7d088f2015-04-29 16:42:24 +000022#if OMPT_SUPPORT
23#include "ompt-specific.h"
24#endif
25
Jim Cownie5e8470a2013-09-27 10:38:44 +000026#ifdef __cplusplus
27 extern "C" {
28#endif // __cplusplus
29
30#define MKLOC(loc,routine) \
31 static ident_t (loc) = {0, KMP_IDENT_KMPC, 0, 0, ";unknown;unknown;0;0;;" };
32
Jim Cownie181b4bb2013-12-23 17:28:57 +000033#include "kmp_ftn_os.h"
Jim Cownie5e8470a2013-09-27 10:38:44 +000034
35void
Jim Cownie181b4bb2013-12-23 17:28:57 +000036xexpand(KMP_API_NAME_GOMP_BARRIER)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +000037{
38 int gtid = __kmp_entry_gtid();
39 MKLOC(loc, "GOMP_barrier");
40 KA_TRACE(20, ("GOMP_barrier: T#%d\n", gtid));
41 __kmpc_barrier(&loc, gtid);
42}
43
44
Jim Cownie5e8470a2013-09-27 10:38:44 +000045//
46// Mutual exclusion
47//
48
49//
50// The symbol that icc/ifort generates for unnamed for unnamed critical
51// sections - .gomp_critical_user_ - is defined using .comm in any objects
52// reference it. We can't reference it directly here in C code, as the
53// 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//
59extern kmp_critical_name *__kmp_unnamed_critical_addr;
60
61
62void
Jim Cownie181b4bb2013-12-23 17:28:57 +000063xexpand(KMP_API_NAME_GOMP_CRITICAL_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +000064{
65 int gtid = __kmp_entry_gtid();
66 MKLOC(loc, "GOMP_critical_start");
67 KA_TRACE(20, ("GOMP_critical_start: T#%d\n", gtid));
68 __kmpc_critical(&loc, gtid, __kmp_unnamed_critical_addr);
69}
70
71
72void
Jim Cownie181b4bb2013-12-23 17:28:57 +000073xexpand(KMP_API_NAME_GOMP_CRITICAL_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +000074{
75 int gtid = __kmp_get_gtid();
76 MKLOC(loc, "GOMP_critical_end");
77 KA_TRACE(20, ("GOMP_critical_end: T#%d\n", gtid));
78 __kmpc_end_critical(&loc, gtid, __kmp_unnamed_critical_addr);
79}
80
81
82void
Jim Cownie181b4bb2013-12-23 17:28:57 +000083xexpand(KMP_API_NAME_GOMP_CRITICAL_NAME_START)(void **pptr)
Jim Cownie5e8470a2013-09-27 10:38:44 +000084{
85 int gtid = __kmp_entry_gtid();
86 MKLOC(loc, "GOMP_critical_name_start");
87 KA_TRACE(20, ("GOMP_critical_name_start: T#%d\n", gtid));
88 __kmpc_critical(&loc, gtid, (kmp_critical_name *)pptr);
89}
90
91
92void
Jim Cownie181b4bb2013-12-23 17:28:57 +000093xexpand(KMP_API_NAME_GOMP_CRITICAL_NAME_END)(void **pptr)
Jim Cownie5e8470a2013-09-27 10:38:44 +000094{
95 int gtid = __kmp_get_gtid();
96 MKLOC(loc, "GOMP_critical_name_end");
97 KA_TRACE(20, ("GOMP_critical_name_end: T#%d\n", gtid));
98 __kmpc_end_critical(&loc, gtid, (kmp_critical_name *)pptr);
99}
100
101
102//
103// The Gnu codegen tries to use locked operations to perform atomic updates
104// inline. If it can't, then it calls GOMP_atomic_start() before performing
105// the update and GOMP_atomic_end() afterward, regardless of the data type.
106//
107
108void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000109xexpand(KMP_API_NAME_GOMP_ATOMIC_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000110{
111 int gtid = __kmp_entry_gtid();
112 KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000113
114#if OMPT_SUPPORT
115 __ompt_thread_assign_wait_id(0);
116#endif
117
Jim Cownie5e8470a2013-09-27 10:38:44 +0000118 __kmp_acquire_atomic_lock(&__kmp_atomic_lock, gtid);
119}
120
121
122void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000123xexpand(KMP_API_NAME_GOMP_ATOMIC_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000124{
125 int gtid = __kmp_get_gtid();
126 KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
127 __kmp_release_atomic_lock(&__kmp_atomic_lock, gtid);
128}
129
130
131int
Jim Cownie181b4bb2013-12-23 17:28:57 +0000132xexpand(KMP_API_NAME_GOMP_SINGLE_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000133{
134 int gtid = __kmp_entry_gtid();
135 MKLOC(loc, "GOMP_single_start");
136 KA_TRACE(20, ("GOMP_single_start: T#%d\n", gtid));
137
138 if (! TCR_4(__kmp_init_parallel))
139 __kmp_parallel_initialize();
140
141 //
142 // 3rd parameter == FALSE prevents kmp_enter_single from pushing a
143 // workshare when USE_CHECKS is defined. We need to avoid the push,
144 // as there is no corresponding GOMP_single_end() call.
145 //
146 return __kmp_enter_single(gtid, &loc, FALSE);
147}
148
149
150void *
Jim Cownie181b4bb2013-12-23 17:28:57 +0000151xexpand(KMP_API_NAME_GOMP_SINGLE_COPY_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000152{
153 void *retval;
154 int gtid = __kmp_entry_gtid();
155 MKLOC(loc, "GOMP_single_copy_start");
156 KA_TRACE(20, ("GOMP_single_copy_start: T#%d\n", gtid));
157
158 if (! TCR_4(__kmp_init_parallel))
159 __kmp_parallel_initialize();
160
161 //
162 // If this is the first thread to enter, return NULL. The generated
163 // code will then call GOMP_single_copy_end() for this thread only,
164 // with the copyprivate data pointer as an argument.
165 //
166 if (__kmp_enter_single(gtid, &loc, FALSE))
167 return NULL;
168
169 //
170 // Wait for the first thread to set the copyprivate data pointer,
171 // and for all other threads to reach this point.
172 //
173 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
174
175 //
176 // Retrieve the value of the copyprivate data point, and wait for all
177 // threads to do likewise, then return.
178 //
179 retval = __kmp_team_from_gtid(gtid)->t.t_copypriv_data;
180 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
181 return retval;
182}
183
184
185void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000186xexpand(KMP_API_NAME_GOMP_SINGLE_COPY_END)(void *data)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000187{
188 int gtid = __kmp_get_gtid();
189 MKLOC(loc, "GOMP_single_copy_end");
190 KA_TRACE(20, ("GOMP_single_copy_end: T#%d\n", gtid));
191
192 //
193 // Set the copyprivate data pointer fo the team, then hit the barrier
194 // so that the other threads will continue on and read it. Hit another
195 // barrier before continuing, so that the know that the copyprivate
196 // data pointer has been propagated to all threads before trying to
197 // reuse the t_copypriv_data field.
198 //
199 __kmp_team_from_gtid(gtid)->t.t_copypriv_data = data;
200 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
201 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
202}
203
204
205void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000206xexpand(KMP_API_NAME_GOMP_ORDERED_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000207{
208 int gtid = __kmp_entry_gtid();
209 MKLOC(loc, "GOMP_ordered_start");
210 KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
211 __kmpc_ordered(&loc, gtid);
212}
213
214
215void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000216xexpand(KMP_API_NAME_GOMP_ORDERED_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000217{
218 int gtid = __kmp_get_gtid();
219 MKLOC(loc, "GOMP_ordered_end");
220 KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
221 __kmpc_end_ordered(&loc, gtid);
222}
223
224
Jim Cownie5e8470a2013-09-27 10:38:44 +0000225//
226// Dispatch macro defs
227//
228// They come in two flavors: 64-bit unsigned, and either 32-bit signed
229// (IA-32 architecture) or 64-bit signed (Intel(R) 64).
230//
231
Jim Cownie181b4bb2013-12-23 17:28:57 +0000232#if KMP_ARCH_X86 || KMP_ARCH_ARM
Jim Cownie5e8470a2013-09-27 10:38:44 +0000233# define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_4
234# define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_4
235# define KMP_DISPATCH_NEXT __kmpc_dispatch_next_4
236#else
237# define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_8
238# define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_8
239# define KMP_DISPATCH_NEXT __kmpc_dispatch_next_8
240#endif /* KMP_ARCH_X86 */
241
242# define KMP_DISPATCH_INIT_ULL __kmp_aux_dispatch_init_8u
243# define KMP_DISPATCH_FINI_CHUNK_ULL __kmp_aux_dispatch_fini_chunk_8u
244# define KMP_DISPATCH_NEXT_ULL __kmpc_dispatch_next_8u
245
246
Jim Cownie5e8470a2013-09-27 10:38:44 +0000247//
248// The parallel contruct
249//
250
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000251#ifndef KMP_DEBUG
Jim Cownie5e8470a2013-09-27 10:38:44 +0000252static
253#endif /* KMP_DEBUG */
254void
255__kmp_GOMP_microtask_wrapper(int *gtid, int *npr, void (*task)(void *),
256 void *data)
257{
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000258#if OMPT_SUPPORT
259 kmp_info_t *thr;
260 ompt_frame_t *ompt_frame;
261 ompt_state_t enclosing_state;
262
263 if (ompt_status & ompt_status_track) {
264 // get pointer to thread data structure
265 thr = __kmp_threads[*gtid];
266
267 // save enclosing task state; set current state for task
268 enclosing_state = thr->th.ompt_thread_info.state;
269 thr->th.ompt_thread_info.state = ompt_state_work_parallel;
270
271 // set task frame
272 ompt_frame = __ompt_get_task_frame_internal(0);
273 ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
274 }
275#endif
276
Jim Cownie5e8470a2013-09-27 10:38:44 +0000277 task(data);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000278
279#if OMPT_SUPPORT
280 if (ompt_status & ompt_status_track) {
281 // clear task frame
282 ompt_frame->exit_runtime_frame = NULL;
283
284 // restore enclosing state
285 thr->th.ompt_thread_info.state = enclosing_state;
286 }
287#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000288}
289
290
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000291#ifndef KMP_DEBUG
Jim Cownie5e8470a2013-09-27 10:38:44 +0000292static
293#endif /* KMP_DEBUG */
294void
295__kmp_GOMP_parallel_microtask_wrapper(int *gtid, int *npr,
296 void (*task)(void *), void *data, unsigned num_threads, ident_t *loc,
297 enum sched_type schedule, long start, long end, long incr, long chunk_size)
298{
299 //
300 // Intialize the loop worksharing construct.
301 //
302 KMP_DISPATCH_INIT(loc, *gtid, schedule, start, end, incr, chunk_size,
303 schedule != kmp_sch_static);
304
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000305#if OMPT_SUPPORT
306 kmp_info_t *thr;
307 ompt_frame_t *ompt_frame;
308 ompt_state_t enclosing_state;
309
310 if (ompt_status & ompt_status_track) {
311 thr = __kmp_threads[*gtid];
312 // save enclosing task state; set current state for task
313 enclosing_state = thr->th.ompt_thread_info.state;
314 thr->th.ompt_thread_info.state = ompt_state_work_parallel;
315
316 // set task frame
317 ompt_frame = __ompt_get_task_frame_internal(0);
318 ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
319 }
320#endif
321
Jim Cownie5e8470a2013-09-27 10:38:44 +0000322 //
323 // Now invoke the microtask.
324 //
325 task(data);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000326
327#if OMPT_SUPPORT
328 if (ompt_status & ompt_status_track) {
329 // clear task frame
330 ompt_frame->exit_runtime_frame = NULL;
331
332 // reset enclosing state
333 thr->th.ompt_thread_info.state = enclosing_state;
334 }
335#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000336}
337
338
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000339#ifndef KMP_DEBUG
Jim Cownie5e8470a2013-09-27 10:38:44 +0000340static
341#endif /* KMP_DEBUG */
342void
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000343__kmp_GOMP_fork_call(ident_t *loc, int gtid, void (*unwrapped_task)(void *), microtask_t wrapper, int argc,...)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000344{
345 int rc;
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000346 kmp_info_t *thr = __kmp_threads[gtid];
347 kmp_team_t *team = thr->th.th_team;
348 int tid = __kmp_tid_from_gtid(gtid);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000349
350 va_list ap;
351 va_start(ap, argc);
352
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000353#if OMPT_SUPPORT
354 team->t.t_implicit_task_taskdata[tid].
355 ompt_task_info.frame.reenter_runtime_frame = NULL;
356#endif
357
358 rc = __kmp_fork_call(loc, gtid, fork_context_gnu, argc,
359#if OMPT_SUPPORT
360 VOLATILE_CAST(void *) unwrapped_task,
361#endif
362 wrapper, __kmp_invoke_task_func,
Andrey Churbanovcbda8682015-01-13 14:43:35 +0000363#if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
Jim Cownie5e8470a2013-09-27 10:38:44 +0000364 &ap
365#else
366 ap
367#endif
368 );
369
370 va_end(ap);
371
372 if (rc) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000373 __kmp_run_before_invoked_task(gtid, tid, thr, team);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000374 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000375
376#if OMPT_SUPPORT && OMPT_TRACE
377 if (ompt_status & ompt_status_track) {
378 ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
379 ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
380
381 // implicit task callback
382 if ((ompt_status == ompt_status_track_callback) &&
383 ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)) {
384 ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)(
385 team_info->parallel_id, task_info->task_id);
386 }
387 thr->th.ompt_thread_info.state = ompt_state_work_parallel;
388 }
389#endif
390}
391
392static void
393__kmp_GOMP_serialized_parallel(ident_t *loc, kmp_int32 gtid, void (*task)(void *))
394{
395 __kmp_serialized_parallel(loc, gtid);
396
397#if OMPT_SUPPORT
398 if (ompt_status & ompt_status_track) {
399 ompt_task_id_t ompt_task_id = __ompt_get_task_id_internal(0);
400 ompt_frame_t *ompt_frame = __ompt_get_task_frame_internal(0);
401 kmp_info_t *thr = __kmp_threads[gtid];
402
403 ompt_parallel_id_t ompt_parallel_id = __ompt_parallel_id_new(gtid);
404 ompt_task_id_t my_ompt_task_id = __ompt_task_id_new(gtid);
405
406 ompt_frame->exit_runtime_frame = NULL;
407
408 // parallel region callback
409 if ((ompt_status == ompt_status_track_callback) &&
410 ompt_callbacks.ompt_callback(ompt_event_parallel_begin)) {
411 int team_size = 1;
412 ompt_callbacks.ompt_callback(ompt_event_parallel_begin)(
413 ompt_task_id, ompt_frame, ompt_parallel_id,
414 team_size, (void *) task);
415 }
416
417 // set up lightweight task
418 ompt_lw_taskteam_t *lwt = (ompt_lw_taskteam_t *)
419 __kmp_allocate(sizeof(ompt_lw_taskteam_t));
420 __ompt_lw_taskteam_init(lwt, thr, gtid, (void *) task, ompt_parallel_id);
421 lwt->ompt_task_info.task_id = my_ompt_task_id;
422 lwt->ompt_task_info.frame.exit_runtime_frame = 0;
423 __ompt_lw_taskteam_link(lwt, thr);
424
425#if OMPT_TRACE
426 // implicit task callback
427 if ((ompt_status == ompt_status_track_callback) &&
428 ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)) {
429 ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)(
430 ompt_parallel_id, my_ompt_task_id);
431 }
432 thr->th.ompt_thread_info.state = ompt_state_work_parallel;
433#endif
434 }
435#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000436}
437
438
439void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000440xexpand(KMP_API_NAME_GOMP_PARALLEL_START)(void (*task)(void *), void *data, unsigned num_threads)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000441{
442 int gtid = __kmp_entry_gtid();
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000443
444#if OMPT_SUPPORT
445 ompt_frame_t *parent_frame;
446
447 if (ompt_status & ompt_status_track) {
448 parent_frame = __ompt_get_task_frame_internal(0);
449 parent_frame->reenter_runtime_frame = __builtin_frame_address(0);
450 }
451#endif
452
Jim Cownie5e8470a2013-09-27 10:38:44 +0000453 MKLOC(loc, "GOMP_parallel_start");
454 KA_TRACE(20, ("GOMP_parallel_start: T#%d\n", gtid));
455
456 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
457 if (num_threads != 0) {
458 __kmp_push_num_threads(&loc, gtid, num_threads);
459 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000460 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie5e8470a2013-09-27 10:38:44 +0000461 (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task, data);
462 }
463 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000464 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000465 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000466
467#if OMPT_SUPPORT
468 if (ompt_status & ompt_status_track) {
469 parent_frame->reenter_runtime_frame = NULL;
470 }
471#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000472}
473
474
475void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000476xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000477{
478 int gtid = __kmp_get_gtid();
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000479 kmp_info_t *thr = __kmp_threads[gtid];
480
Jim Cownie5e8470a2013-09-27 10:38:44 +0000481 MKLOC(loc, "GOMP_parallel_end");
482 KA_TRACE(20, ("GOMP_parallel_end: T#%d\n", gtid));
483
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000484
485#if OMPT_SUPPORT
486 ompt_parallel_id_t parallel_id;
487 ompt_frame_t *ompt_frame = NULL;
488
489 if (ompt_status & ompt_status_track) {
490 ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
491 parallel_id = team_info->parallel_id;
492
493 ompt_frame = __ompt_get_task_frame_internal(0);
494 ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
495
496#if OMPT_TRACE
497 if ((ompt_status == ompt_status_track_callback) &&
498 ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)) {
499 ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
500 ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)(
501 parallel_id, task_info->task_id);
502 }
503#endif
504
505 // unlink if necessary. no-op if there is not a lightweight task.
506 ompt_lw_taskteam_t *lwt = __ompt_lw_taskteam_unlink(thr);
507 // GOMP allocates/frees lwt since it can't be kept on the stack
508 if (lwt) __kmp_free(lwt);
509 }
510#endif
511
Jim Cownie5e8470a2013-09-27 10:38:44 +0000512 if (! __kmp_threads[gtid]->th.th_team->t.t_serialized) {
513 kmp_info_t *thr = __kmp_threads[gtid];
514 __kmp_run_after_invoked_task(gtid, __kmp_tid_from_gtid(gtid), thr,
515 thr->th.th_team);
516 __kmp_join_call(&loc, gtid);
517 }
518 else {
519 __kmpc_end_serialized_parallel(&loc, gtid);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000520
521#if OMPT_SUPPORT
522 if (ompt_status & ompt_status_track) {
523 if ((ompt_status == ompt_status_track_callback) &&
524 ompt_callbacks.ompt_callback(ompt_event_parallel_end)) {
525 ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
526 ompt_callbacks.ompt_callback(ompt_event_parallel_end)(
527 parallel_id, task_info->task_id);
528 }
529
530 thr->th.ompt_thread_info.state =
531 (((thr->th.th_team)->t.t_serialized) ?
532 ompt_state_work_serial : ompt_state_work_parallel);
533 }
534#endif
535
Jim Cownie5e8470a2013-09-27 10:38:44 +0000536 }
537}
538
539
Jim Cownie5e8470a2013-09-27 10:38:44 +0000540//
541// Loop worksharing constructs
542//
543
544//
545// The Gnu codegen passes in an exclusive upper bound for the overall range,
546// but the libguide dispatch code expects an inclusive upper bound, hence the
547// "end - incr" 5th argument to KMP_DISPATCH_INIT (and the " ub - str" 11th
548// argument to __kmp_GOMP_fork_call).
549//
550// Conversely, KMP_DISPATCH_NEXT returns and inclusive upper bound in *p_ub,
551// but the Gnu codegen expects an excluside upper bound, so the adjustment
552// "*p_ub += stride" compenstates for the discrepancy.
553//
554// Correction: the gnu codegen always adjusts the upper bound by +-1, not the
555// stride value. We adjust the dispatch parameters accordingly (by +-1), but
556// we still adjust p_ub by the actual stride value.
557//
558// The "runtime" versions do not take a chunk_sz parameter.
559//
560// The profile lib cannot support construct checking of unordered loops that
561// are predetermined by the compiler to be statically scheduled, as the gcc
562// codegen will not always emit calls to GOMP_loop_static_next() to get the
563// next iteration. Instead, it emits inline code to call omp_get_thread_num()
564// num and calculate the iteration space using the result. It doesn't do this
565// with ordered static loop, so they can be checked.
566//
567
568#define LOOP_START(func,schedule) \
569 int func (long lb, long ub, long str, long chunk_sz, long *p_lb, \
570 long *p_ub) \
571 { \
572 int status; \
573 long stride; \
574 int gtid = __kmp_entry_gtid(); \
575 MKLOC(loc, #func); \
576 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
577 gtid, lb, ub, str, chunk_sz )); \
578 \
579 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
580 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
581 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
582 (schedule) != kmp_sch_static); \
583 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
584 (kmp_int *)p_ub, (kmp_int *)&stride); \
585 if (status) { \
586 KMP_DEBUG_ASSERT(stride == str); \
587 *p_ub += (str > 0) ? 1 : -1; \
588 } \
589 } \
590 else { \
591 status = 0; \
592 } \
593 \
594 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
595 gtid, *p_lb, *p_ub, status)); \
596 return status; \
597 }
598
599
600#define LOOP_RUNTIME_START(func,schedule) \
601 int func (long lb, long ub, long str, long *p_lb, long *p_ub) \
602 { \
603 int status; \
604 long stride; \
605 long chunk_sz = 0; \
606 int gtid = __kmp_entry_gtid(); \
607 MKLOC(loc, #func); \
608 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n", \
609 gtid, lb, ub, str, chunk_sz )); \
610 \
611 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
612 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
613 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, TRUE); \
614 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
615 (kmp_int *)p_ub, (kmp_int *)&stride); \
616 if (status) { \
617 KMP_DEBUG_ASSERT(stride == str); \
618 *p_ub += (str > 0) ? 1 : -1; \
619 } \
620 } \
621 else { \
622 status = 0; \
623 } \
624 \
625 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
626 gtid, *p_lb, *p_ub, status)); \
627 return status; \
628 }
629
630
631#define LOOP_NEXT(func,fini_code) \
632 int func(long *p_lb, long *p_ub) \
633 { \
634 int status; \
635 long stride; \
636 int gtid = __kmp_get_gtid(); \
637 MKLOC(loc, #func); \
638 KA_TRACE(20, ( #func ": T#%d\n", gtid)); \
639 \
640 fini_code \
641 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
642 (kmp_int *)p_ub, (kmp_int *)&stride); \
643 if (status) { \
644 *p_ub += (stride > 0) ? 1 : -1; \
645 } \
646 \
647 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, stride 0x%lx, " \
648 "returning %d\n", gtid, *p_lb, *p_ub, stride, status)); \
649 return status; \
650 }
651
652
Jim Cownie181b4bb2013-12-23 17:28:57 +0000653LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_STATIC_START), kmp_sch_static)
654LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT), {})
655LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START), kmp_sch_dynamic_chunked)
656LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT), {})
657LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_GUIDED_START), kmp_sch_guided_chunked)
658LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT), {})
659LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_START), kmp_sch_runtime)
660LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT), {})
Jim Cownie5e8470a2013-09-27 10:38:44 +0000661
Jim Cownie181b4bb2013-12-23 17:28:57 +0000662LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START), kmp_ord_static)
663LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000664 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000665LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START), kmp_ord_dynamic_chunked)
666LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000667 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000668LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START), kmp_ord_guided_chunked)
669LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000670 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000671LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START), kmp_ord_runtime)
672LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000673 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
674
675
676void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000677xexpand(KMP_API_NAME_GOMP_LOOP_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000678{
679 int gtid = __kmp_get_gtid();
680 KA_TRACE(20, ("GOMP_loop_end: T#%d\n", gtid))
681
682 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
683
684 KA_TRACE(20, ("GOMP_loop_end exit: T#%d\n", gtid))
685}
686
687
688void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000689xexpand(KMP_API_NAME_GOMP_LOOP_END_NOWAIT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000690{
691 KA_TRACE(20, ("GOMP_loop_end_nowait: T#%d\n", __kmp_get_gtid()))
692}
693
694
Jim Cownie5e8470a2013-09-27 10:38:44 +0000695//
696// Unsigned long long loop worksharing constructs
697//
698// These are new with gcc 4.4
699//
700
701#define LOOP_START_ULL(func,schedule) \
702 int func (int up, unsigned long long lb, unsigned long long ub, \
703 unsigned long long str, unsigned long long chunk_sz, \
704 unsigned long long *p_lb, unsigned long long *p_ub) \
705 { \
706 int status; \
707 long long str2 = up ? ((long long)str) : -((long long)str); \
708 long long stride; \
709 int gtid = __kmp_entry_gtid(); \
710 MKLOC(loc, #func); \
711 \
712 KA_TRACE(20, ( #func ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
713 gtid, up, lb, ub, str, chunk_sz )); \
714 \
715 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
716 KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
717 (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, \
718 (schedule) != kmp_sch_static); \
719 status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, \
720 (kmp_uint64 *)p_lb, (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
721 if (status) { \
722 KMP_DEBUG_ASSERT(stride == str2); \
723 *p_ub += (str > 0) ? 1 : -1; \
724 } \
725 } \
726 else { \
727 status = 0; \
728 } \
729 \
730 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
731 gtid, *p_lb, *p_ub, status)); \
732 return status; \
733 }
734
735
736#define LOOP_RUNTIME_START_ULL(func,schedule) \
737 int func (int up, unsigned long long lb, unsigned long long ub, \
738 unsigned long long str, unsigned long long *p_lb, \
739 unsigned long long *p_ub) \
740 { \
741 int status; \
742 long long str2 = up ? ((long long)str) : -((long long)str); \
743 unsigned long long stride; \
744 unsigned long long chunk_sz = 0; \
745 int gtid = __kmp_entry_gtid(); \
746 MKLOC(loc, #func); \
747 \
748 KA_TRACE(20, ( #func ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
749 gtid, up, lb, ub, str, chunk_sz )); \
750 \
751 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
752 KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
753 (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, TRUE); \
754 status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, \
755 (kmp_uint64 *)p_lb, (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
756 if (status) { \
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000757 KMP_DEBUG_ASSERT((long long)stride == str2); \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000758 *p_ub += (str > 0) ? 1 : -1; \
759 } \
760 } \
761 else { \
762 status = 0; \
763 } \
764 \
765 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
766 gtid, *p_lb, *p_ub, status)); \
767 return status; \
768 }
769
770
771#define LOOP_NEXT_ULL(func,fini_code) \
772 int func(unsigned long long *p_lb, unsigned long long *p_ub) \
773 { \
774 int status; \
775 long long stride; \
776 int gtid = __kmp_get_gtid(); \
777 MKLOC(loc, #func); \
778 KA_TRACE(20, ( #func ": T#%d\n", gtid)); \
779 \
780 fini_code \
781 status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
782 (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
783 if (status) { \
784 *p_ub += (stride > 0) ? 1 : -1; \
785 } \
786 \
787 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, stride 0x%llx, " \
788 "returning %d\n", gtid, *p_lb, *p_ub, stride, status)); \
789 return status; \
790 }
791
792
Jim Cownie181b4bb2013-12-23 17:28:57 +0000793LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START), kmp_sch_static)
794LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT), {})
795LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START), kmp_sch_dynamic_chunked)
796LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT), {})
797LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START), kmp_sch_guided_chunked)
798LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT), {})
799LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START), kmp_sch_runtime)
800LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT), {})
Jim Cownie5e8470a2013-09-27 10:38:44 +0000801
Jim Cownie181b4bb2013-12-23 17:28:57 +0000802LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START), kmp_ord_static)
803LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000804 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000805LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START), kmp_ord_dynamic_chunked)
806LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000807 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000808LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START), kmp_ord_guided_chunked)
809LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000810 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000811LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START), kmp_ord_runtime)
812LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000813 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
814
815
Jim Cownie5e8470a2013-09-27 10:38:44 +0000816//
817// Combined parallel / loop worksharing constructs
818//
819// There are no ull versions (yet).
820//
821
822#define PARALLEL_LOOP_START(func, schedule) \
823 void func (void (*task) (void *), void *data, unsigned num_threads, \
824 long lb, long ub, long str, long chunk_sz) \
825 { \
826 int gtid = __kmp_entry_gtid(); \
827 int last = FALSE; \
828 MKLOC(loc, #func); \
829 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
830 gtid, lb, ub, str, chunk_sz )); \
831 \
832 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) { \
833 if (num_threads != 0) { \
834 __kmp_push_num_threads(&loc, gtid, num_threads); \
835 } \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000836 __kmp_GOMP_fork_call(&loc, gtid, task, \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000837 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, \
838 task, data, num_threads, &loc, (schedule), lb, \
839 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz); \
840 } \
841 else { \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000842 __kmp_GOMP_serialized_parallel(&loc, gtid, task); \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000843 } \
844 \
845 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
846 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
847 (schedule) != kmp_sch_static); \
848 \
849 KA_TRACE(20, ( #func " exit: T#%d\n", gtid)); \
850 }
851
852
Jim Cownie181b4bb2013-12-23 17:28:57 +0000853PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START), kmp_sch_static)
854PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START), kmp_sch_dynamic_chunked)
855PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START), kmp_sch_guided_chunked)
856PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START), kmp_sch_runtime)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000857
858
Jim Cownie5e8470a2013-09-27 10:38:44 +0000859//
860// Tasking constructs
861//
862
863void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000864xexpand(KMP_API_NAME_GOMP_TASK)(void (*func)(void *), void *data, void (*copy_func)(void *, void *),
Jim Cownie5e8470a2013-09-27 10:38:44 +0000865 long arg_size, long arg_align, int if_cond, unsigned gomp_flags)
866{
867 MKLOC(loc, "GOMP_task");
868 int gtid = __kmp_entry_gtid();
869 kmp_int32 flags = 0;
870 kmp_tasking_flags_t *input_flags = (kmp_tasking_flags_t *) & flags;
871
872 KA_TRACE(20, ("GOMP_task: T#%d\n", gtid));
873
874 // The low-order bit is the "tied" flag
875 if (gomp_flags & 1) {
876 input_flags->tiedness = 1;
877 }
878 input_flags->native = 1;
879 // __kmp_task_alloc() sets up all other flags
880
881 if (! if_cond) {
882 arg_size = 0;
883 }
884
885 kmp_task_t *task = __kmp_task_alloc(&loc, gtid, input_flags,
886 sizeof(kmp_task_t), arg_size ? arg_size + arg_align - 1 : 0,
887 (kmp_routine_entry_t)func);
888
889 if (arg_size > 0) {
890 if (arg_align > 0) {
891 task->shareds = (void *)((((size_t)task->shareds)
892 + arg_align - 1) / arg_align * arg_align);
893 }
894 //else error??
895
896 if (copy_func) {
897 (*copy_func)(task->shareds, data);
898 }
899 else {
Andrey Churbanov74bf17b2015-04-02 13:27:08 +0000900 KMP_MEMCPY(task->shareds, data, arg_size);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000901 }
902 }
903
904 if (if_cond) {
905 __kmpc_omp_task(&loc, gtid, task);
906 }
907 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000908#if OMPT_SUPPORT
909 ompt_thread_info_t oldInfo;
910 kmp_info_t *thread;
911 kmp_taskdata_t *taskdata;
912 if (ompt_status & ompt_status_track) {
913 // Store the threads states and restore them after the task
914 thread = __kmp_threads[ gtid ];
915 taskdata = KMP_TASK_TO_TASKDATA(task);
916 oldInfo = thread->th.ompt_thread_info;
917 thread->th.ompt_thread_info.wait_id = 0;
918 thread->th.ompt_thread_info.state = ompt_state_work_parallel;
919 taskdata->ompt_task_info.frame.exit_runtime_frame =
920 __builtin_frame_address(0);
921 }
922#endif
923
Jim Cownie5e8470a2013-09-27 10:38:44 +0000924 __kmpc_omp_task_begin_if0(&loc, gtid, task);
925 func(data);
926 __kmpc_omp_task_complete_if0(&loc, gtid, task);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000927
928#if OMPT_SUPPORT
929 if (ompt_status & ompt_status_track) {
930 thread->th.ompt_thread_info = oldInfo;
931 taskdata->ompt_task_info.frame.exit_runtime_frame = 0;
932 }
933#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000934 }
935
936 KA_TRACE(20, ("GOMP_task exit: T#%d\n", gtid));
937}
938
939
940void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000941xexpand(KMP_API_NAME_GOMP_TASKWAIT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000942{
943 MKLOC(loc, "GOMP_taskwait");
944 int gtid = __kmp_entry_gtid();
945
946 KA_TRACE(20, ("GOMP_taskwait: T#%d\n", gtid));
947
948 __kmpc_omp_taskwait(&loc, gtid);
949
950 KA_TRACE(20, ("GOMP_taskwait exit: T#%d\n", gtid));
951}
952
953
Jim Cownie5e8470a2013-09-27 10:38:44 +0000954//
955// Sections worksharing constructs
956//
957
958//
959// For the sections construct, we initialize a dynamically scheduled loop
960// worksharing construct with lb 1 and stride 1, and use the iteration #'s
961// that its returns as sections ids.
962//
963// There are no special entry points for ordered sections, so we always use
964// the dynamically scheduled workshare, even if the sections aren't ordered.
965//
966
967unsigned
Jim Cownie181b4bb2013-12-23 17:28:57 +0000968xexpand(KMP_API_NAME_GOMP_SECTIONS_START)(unsigned count)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000969{
970 int status;
971 kmp_int lb, ub, stride;
972 int gtid = __kmp_entry_gtid();
973 MKLOC(loc, "GOMP_sections_start");
974 KA_TRACE(20, ("GOMP_sections_start: T#%d\n", gtid));
975
976 KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
977
978 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
979 if (status) {
980 KMP_DEBUG_ASSERT(stride == 1);
981 KMP_DEBUG_ASSERT(lb > 0);
982 KMP_ASSERT(lb == ub);
983 }
984 else {
985 lb = 0;
986 }
987
988 KA_TRACE(20, ("GOMP_sections_start exit: T#%d returning %u\n", gtid,
989 (unsigned)lb));
990 return (unsigned)lb;
991}
992
993
994unsigned
Jim Cownie181b4bb2013-12-23 17:28:57 +0000995xexpand(KMP_API_NAME_GOMP_SECTIONS_NEXT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000996{
997 int status;
998 kmp_int lb, ub, stride;
999 int gtid = __kmp_get_gtid();
1000 MKLOC(loc, "GOMP_sections_next");
1001 KA_TRACE(20, ("GOMP_sections_next: T#%d\n", gtid));
1002
1003 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
1004 if (status) {
1005 KMP_DEBUG_ASSERT(stride == 1);
1006 KMP_DEBUG_ASSERT(lb > 0);
1007 KMP_ASSERT(lb == ub);
1008 }
1009 else {
1010 lb = 0;
1011 }
1012
1013 KA_TRACE(20, ("GOMP_sections_next exit: T#%d returning %u\n", gtid,
1014 (unsigned)lb));
1015 return (unsigned)lb;
1016}
1017
1018
1019void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001020xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START)(void (*task) (void *), void *data,
Jim Cownie5e8470a2013-09-27 10:38:44 +00001021 unsigned num_threads, unsigned count)
1022{
1023 int gtid = __kmp_entry_gtid();
1024 int last = FALSE;
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001025
1026#if OMPT_SUPPORT
1027 ompt_frame_t *parent_frame;
1028
1029 if (ompt_status & ompt_status_track) {
1030 parent_frame = __ompt_get_task_frame_internal(0);
1031 parent_frame->reenter_runtime_frame = __builtin_frame_address(0);
1032 }
1033#endif
1034
Jim Cownie5e8470a2013-09-27 10:38:44 +00001035 MKLOC(loc, "GOMP_parallel_sections_start");
1036 KA_TRACE(20, ("GOMP_parallel_sections_start: T#%d\n", gtid));
1037
1038 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1039 if (num_threads != 0) {
1040 __kmp_push_num_threads(&loc, gtid, num_threads);
1041 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001042 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie5e8470a2013-09-27 10:38:44 +00001043 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, task, data,
1044 num_threads, &loc, kmp_nm_dynamic_chunked, (kmp_int)1,
1045 (kmp_int)count, (kmp_int)1, (kmp_int)1);
1046 }
1047 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001048 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie5e8470a2013-09-27 10:38:44 +00001049 }
1050
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001051#if OMPT_SUPPORT
1052 if (ompt_status & ompt_status_track) {
1053 parent_frame->reenter_runtime_frame = NULL;
1054 }
1055#endif
1056
Jim Cownie5e8470a2013-09-27 10:38:44 +00001057 KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1058
1059 KA_TRACE(20, ("GOMP_parallel_sections_start exit: T#%d\n", gtid));
1060}
1061
1062
1063void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001064xexpand(KMP_API_NAME_GOMP_SECTIONS_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +00001065{
1066 int gtid = __kmp_get_gtid();
1067 KA_TRACE(20, ("GOMP_sections_end: T#%d\n", gtid))
1068
1069 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
1070
1071 KA_TRACE(20, ("GOMP_sections_end exit: T#%d\n", gtid))
1072}
1073
1074
1075void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001076xexpand(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +00001077{
1078 KA_TRACE(20, ("GOMP_sections_end_nowait: T#%d\n", __kmp_get_gtid()))
1079}
1080
Jim Cownie181b4bb2013-12-23 17:28:57 +00001081// libgomp has an empty function for GOMP_taskyield as of 2013-10-10
1082void
1083xexpand(KMP_API_NAME_GOMP_TASKYIELD)(void)
1084{
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001085 KA_TRACE(20, ("GOMP_taskyield: T#%d\n", __kmp_get_gtid()))
1086 return;
Jim Cownie181b4bb2013-12-23 17:28:57 +00001087}
1088
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001089#if OMP_40_ENABLED // these are new GOMP_4.0 entry points
1090
1091void
1092xexpand(KMP_API_NAME_GOMP_PARALLEL)(void (*task)(void *), void *data, unsigned num_threads, unsigned int flags)
1093{
1094 int gtid = __kmp_entry_gtid();
1095 MKLOC(loc, "GOMP_parallel");
1096 KA_TRACE(20, ("GOMP_parallel: T#%d\n", gtid));
1097
1098 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1099 if (num_threads != 0) {
1100 __kmp_push_num_threads(&loc, gtid, num_threads);
1101 }
1102 if(flags != 0) {
1103 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
1104 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001105 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001106 (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task, data);
1107 }
1108 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001109 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001110 }
1111 task(data);
1112 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
1113}
1114
1115void
1116xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS)(void (*task) (void *), void *data,
1117 unsigned num_threads, unsigned count, unsigned flags)
1118{
1119 int gtid = __kmp_entry_gtid();
1120 int last = FALSE;
1121 MKLOC(loc, "GOMP_parallel_sections");
1122 KA_TRACE(20, ("GOMP_parallel_sections: T#%d\n", gtid));
1123
1124 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1125 if (num_threads != 0) {
1126 __kmp_push_num_threads(&loc, gtid, num_threads);
1127 }
1128 if(flags != 0) {
1129 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
1130 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001131 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001132 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, task, data,
1133 num_threads, &loc, kmp_nm_dynamic_chunked, (kmp_int)1,
1134 (kmp_int)count, (kmp_int)1, (kmp_int)1);
1135 }
1136 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001137 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001138 }
1139
1140 KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1141
1142 task(data);
1143 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
1144 KA_TRACE(20, ("GOMP_parallel_sections exit: T#%d\n", gtid));
1145}
1146
1147#define PARALLEL_LOOP(func, schedule) \
1148 void func (void (*task) (void *), void *data, unsigned num_threads, \
1149 long lb, long ub, long str, long chunk_sz, unsigned flags) \
1150 { \
1151 int gtid = __kmp_entry_gtid(); \
1152 int last = FALSE; \
1153 MKLOC(loc, #func); \
1154 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
1155 gtid, lb, ub, str, chunk_sz )); \
1156 \
1157 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) { \
1158 if (num_threads != 0) { \
1159 __kmp_push_num_threads(&loc, gtid, num_threads); \
1160 } \
1161 if (flags != 0) { \
1162 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags); \
1163 } \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001164 __kmp_GOMP_fork_call(&loc, gtid, task, \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001165 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, \
1166 task, data, num_threads, &loc, (schedule), lb, \
1167 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz); \
1168 } \
1169 else { \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001170 __kmp_GOMP_serialized_parallel(&loc, gtid, task); \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001171 } \
1172 \
1173 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
1174 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
1175 (schedule) != kmp_sch_static); \
1176 task(data); \
1177 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(); \
1178 \
1179 KA_TRACE(20, ( #func " exit: T#%d\n", gtid)); \
1180 }
1181
1182PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC), kmp_sch_static)
1183PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC), kmp_sch_dynamic_chunked)
1184PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED), kmp_sch_guided_chunked)
1185PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME), kmp_sch_runtime)
1186
1187
1188void
1189xexpand(KMP_API_NAME_GOMP_TASKGROUP_START)(void)
1190{
1191 int gtid = __kmp_get_gtid();
1192 MKLOC(loc, "GOMP_taskgroup_start");
1193 KA_TRACE(20, ("GOMP_taskgroup_start: T#%d\n", gtid));
1194
1195 __kmpc_taskgroup(&loc, gtid);
1196
1197 return;
1198}
1199
1200void
1201xexpand(KMP_API_NAME_GOMP_TASKGROUP_END)(void)
1202{
1203 int gtid = __kmp_get_gtid();
1204 MKLOC(loc, "GOMP_taskgroup_end");
1205 KA_TRACE(20, ("GOMP_taskgroup_end: T#%d\n", gtid));
1206
1207 __kmpc_end_taskgroup(&loc, gtid);
1208
1209 return;
1210}
1211
1212#ifndef KMP_DEBUG
1213static
1214#endif /* KMP_DEBUG */
1215kmp_int32 __kmp_gomp_to_iomp_cancellation_kind(int gomp_kind) {
1216 kmp_int32 cncl_kind = 0;
1217 switch(gomp_kind) {
1218 case 1:
1219 cncl_kind = cancel_parallel;
1220 break;
1221 case 2:
1222 cncl_kind = cancel_loop;
1223 break;
1224 case 4:
1225 cncl_kind = cancel_sections;
1226 break;
1227 case 8:
1228 cncl_kind = cancel_taskgroup;
1229 break;
1230 }
1231 return cncl_kind;
1232}
1233
1234bool
1235xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(int which)
1236{
1237 if(__kmp_omp_cancellation) {
1238 KMP_FATAL(NoGompCancellation);
1239 }
1240 int gtid = __kmp_get_gtid();
1241 MKLOC(loc, "GOMP_cancellation_point");
1242 KA_TRACE(20, ("GOMP_cancellation_point: T#%d\n", gtid));
1243
1244 kmp_int32 cncl_kind = __kmp_gomp_to_iomp_cancellation_kind(which);
1245
1246 return __kmpc_cancellationpoint(&loc, gtid, cncl_kind);
1247}
1248
1249bool
1250xexpand(KMP_API_NAME_GOMP_BARRIER_CANCEL)(void)
1251{
1252 if(__kmp_omp_cancellation) {
1253 KMP_FATAL(NoGompCancellation);
1254 }
1255 KMP_FATAL(NoGompCancellation);
1256 int gtid = __kmp_get_gtid();
1257 MKLOC(loc, "GOMP_barrier_cancel");
1258 KA_TRACE(20, ("GOMP_barrier_cancel: T#%d\n", gtid));
1259
1260 return __kmpc_cancel_barrier(&loc, gtid);
1261}
1262
1263bool
1264xexpand(KMP_API_NAME_GOMP_CANCEL)(int which, bool do_cancel)
1265{
1266 if(__kmp_omp_cancellation) {
1267 KMP_FATAL(NoGompCancellation);
1268 } else {
1269 return FALSE;
1270 }
1271
1272 int gtid = __kmp_get_gtid();
1273 MKLOC(loc, "GOMP_cancel");
1274 KA_TRACE(20, ("GOMP_cancel: T#%d\n", gtid));
1275
1276 kmp_int32 cncl_kind = __kmp_gomp_to_iomp_cancellation_kind(which);
1277
1278 if(do_cancel == FALSE) {
1279 return xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(which);
1280 } else {
1281 return __kmpc_cancel(&loc, gtid, cncl_kind);
1282 }
1283}
1284
1285bool
1286xexpand(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL)(void)
1287{
1288 if(__kmp_omp_cancellation) {
1289 KMP_FATAL(NoGompCancellation);
1290 }
1291 int gtid = __kmp_get_gtid();
1292 MKLOC(loc, "GOMP_sections_end_cancel");
1293 KA_TRACE(20, ("GOMP_sections_end_cancel: T#%d\n", gtid));
1294
1295 return __kmpc_cancel_barrier(&loc, gtid);
1296}
1297
1298bool
1299xexpand(KMP_API_NAME_GOMP_LOOP_END_CANCEL)(void)
1300{
1301 if(__kmp_omp_cancellation) {
1302 KMP_FATAL(NoGompCancellation);
1303 }
1304 int gtid = __kmp_get_gtid();
1305 MKLOC(loc, "GOMP_loop_end_cancel");
1306 KA_TRACE(20, ("GOMP_loop_end_cancel: T#%d\n", gtid));
1307
1308 return __kmpc_cancel_barrier(&loc, gtid);
1309}
1310
1311// All target functions are empty as of 2014-05-29
1312void
1313xexpand(KMP_API_NAME_GOMP_TARGET)(int device, void (*fn) (void *), const void *openmp_target,
1314 size_t mapnum, void **hostaddrs, size_t *sizes, unsigned char *kinds)
1315{
1316 return;
1317}
1318
1319void
1320xexpand(KMP_API_NAME_GOMP_TARGET_DATA)(int device, const void *openmp_target, size_t mapnum,
1321 void **hostaddrs, size_t *sizes, unsigned char *kinds)
1322{
1323 return;
1324}
1325
1326void
1327xexpand(KMP_API_NAME_GOMP_TARGET_END_DATA)(void)
1328{
1329 return;
1330}
1331
1332void
1333xexpand(KMP_API_NAME_GOMP_TARGET_UPDATE)(int device, const void *openmp_target, size_t mapnum,
1334 void **hostaddrs, size_t *sizes, unsigned char *kinds)
1335{
1336 return;
1337}
1338
1339void
1340xexpand(KMP_API_NAME_GOMP_TEAMS)(unsigned int num_teams, unsigned int thread_limit)
1341{
1342 return;
1343}
1344#endif // OMP_40_ENABLED
1345
1346
Jim Cownie181b4bb2013-12-23 17:28:57 +00001347/*
1348 The following sections of code create aliases for the GOMP_* functions,
1349 then create versioned symbols using the assembler directive .symver.
1350 This is only pertinent for ELF .so library
1351 xaliasify and xversionify are defined in kmp_ftn_os.h
1352*/
1353
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001354#ifdef KMP_USE_VERSION_SYMBOLS
Jim Cownie181b4bb2013-12-23 17:28:57 +00001355
1356// GOMP_1.0 aliases
1357xaliasify(KMP_API_NAME_GOMP_ATOMIC_END, 10);
1358xaliasify(KMP_API_NAME_GOMP_ATOMIC_START, 10);
1359xaliasify(KMP_API_NAME_GOMP_BARRIER, 10);
1360xaliasify(KMP_API_NAME_GOMP_CRITICAL_END, 10);
1361xaliasify(KMP_API_NAME_GOMP_CRITICAL_NAME_END, 10);
1362xaliasify(KMP_API_NAME_GOMP_CRITICAL_NAME_START, 10);
1363xaliasify(KMP_API_NAME_GOMP_CRITICAL_START, 10);
1364xaliasify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT, 10);
1365xaliasify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START, 10);
1366xaliasify(KMP_API_NAME_GOMP_LOOP_END, 10);
1367xaliasify(KMP_API_NAME_GOMP_LOOP_END_NOWAIT, 10);
1368xaliasify(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT, 10);
1369xaliasify(KMP_API_NAME_GOMP_LOOP_GUIDED_START, 10);
1370xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT, 10);
1371xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START, 10);
1372xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT, 10);
1373xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START, 10);
1374xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT, 10);
1375xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START, 10);
1376xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT, 10);
1377xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START, 10);
1378xaliasify(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT, 10);
1379xaliasify(KMP_API_NAME_GOMP_LOOP_RUNTIME_START, 10);
1380xaliasify(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT, 10);
1381xaliasify(KMP_API_NAME_GOMP_LOOP_STATIC_START, 10);
1382xaliasify(KMP_API_NAME_GOMP_ORDERED_END, 10);
1383xaliasify(KMP_API_NAME_GOMP_ORDERED_START, 10);
1384xaliasify(KMP_API_NAME_GOMP_PARALLEL_END, 10);
1385xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START, 10);
1386xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START, 10);
1387xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START, 10);
1388xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START, 10);
1389xaliasify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START, 10);
1390xaliasify(KMP_API_NAME_GOMP_PARALLEL_START, 10);
1391xaliasify(KMP_API_NAME_GOMP_SECTIONS_END, 10);
1392xaliasify(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT, 10);
1393xaliasify(KMP_API_NAME_GOMP_SECTIONS_NEXT, 10);
1394xaliasify(KMP_API_NAME_GOMP_SECTIONS_START, 10);
1395xaliasify(KMP_API_NAME_GOMP_SINGLE_COPY_END, 10);
1396xaliasify(KMP_API_NAME_GOMP_SINGLE_COPY_START, 10);
1397xaliasify(KMP_API_NAME_GOMP_SINGLE_START, 10);
1398
1399// GOMP_2.0 aliases
Jim Cownie181b4bb2013-12-23 17:28:57 +00001400xaliasify(KMP_API_NAME_GOMP_TASK, 20);
1401xaliasify(KMP_API_NAME_GOMP_TASKWAIT, 20);
Jim Cownie181b4bb2013-12-23 17:28:57 +00001402xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT, 20);
1403xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START, 20);
1404xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT, 20);
1405xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START, 20);
1406xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT, 20);
1407xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START, 20);
1408xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT, 20);
1409xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START, 20);
1410xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT, 20);
1411xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START, 20);
1412xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT, 20);
1413xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START, 20);
1414xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT, 20);
1415xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START, 20);
1416xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT, 20);
1417xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START, 20);
1418
1419// GOMP_3.0 aliases
1420xaliasify(KMP_API_NAME_GOMP_TASKYIELD, 30);
1421
1422// GOMP_4.0 aliases
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001423// The GOMP_parallel* entry points below aren't OpenMP 4.0 related.
1424#if OMP_40_ENABLED
1425xaliasify(KMP_API_NAME_GOMP_PARALLEL, 40);
1426xaliasify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS, 40);
1427xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC, 40);
1428xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED, 40);
1429xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME, 40);
1430xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC, 40);
1431xaliasify(KMP_API_NAME_GOMP_TASKGROUP_START, 40);
1432xaliasify(KMP_API_NAME_GOMP_TASKGROUP_END, 40);
1433xaliasify(KMP_API_NAME_GOMP_BARRIER_CANCEL, 40);
1434xaliasify(KMP_API_NAME_GOMP_CANCEL, 40);
1435xaliasify(KMP_API_NAME_GOMP_CANCELLATION_POINT, 40);
1436xaliasify(KMP_API_NAME_GOMP_LOOP_END_CANCEL, 40);
1437xaliasify(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL, 40);
1438xaliasify(KMP_API_NAME_GOMP_TARGET, 40);
1439xaliasify(KMP_API_NAME_GOMP_TARGET_DATA, 40);
1440xaliasify(KMP_API_NAME_GOMP_TARGET_END_DATA, 40);
1441xaliasify(KMP_API_NAME_GOMP_TARGET_UPDATE, 40);
1442xaliasify(KMP_API_NAME_GOMP_TEAMS, 40);
1443#endif
Jim Cownie181b4bb2013-12-23 17:28:57 +00001444
1445// GOMP_1.0 versioned symbols
1446xversionify(KMP_API_NAME_GOMP_ATOMIC_END, 10, "GOMP_1.0");
1447xversionify(KMP_API_NAME_GOMP_ATOMIC_START, 10, "GOMP_1.0");
1448xversionify(KMP_API_NAME_GOMP_BARRIER, 10, "GOMP_1.0");
1449xversionify(KMP_API_NAME_GOMP_CRITICAL_END, 10, "GOMP_1.0");
1450xversionify(KMP_API_NAME_GOMP_CRITICAL_NAME_END, 10, "GOMP_1.0");
1451xversionify(KMP_API_NAME_GOMP_CRITICAL_NAME_START, 10, "GOMP_1.0");
1452xversionify(KMP_API_NAME_GOMP_CRITICAL_START, 10, "GOMP_1.0");
1453xversionify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT, 10, "GOMP_1.0");
1454xversionify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START, 10, "GOMP_1.0");
1455xversionify(KMP_API_NAME_GOMP_LOOP_END, 10, "GOMP_1.0");
1456xversionify(KMP_API_NAME_GOMP_LOOP_END_NOWAIT, 10, "GOMP_1.0");
1457xversionify(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT, 10, "GOMP_1.0");
1458xversionify(KMP_API_NAME_GOMP_LOOP_GUIDED_START, 10, "GOMP_1.0");
1459xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT, 10, "GOMP_1.0");
1460xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START, 10, "GOMP_1.0");
1461xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT, 10, "GOMP_1.0");
1462xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START, 10, "GOMP_1.0");
1463xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT, 10, "GOMP_1.0");
1464xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START, 10, "GOMP_1.0");
1465xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT, 10, "GOMP_1.0");
1466xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START, 10, "GOMP_1.0");
1467xversionify(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT, 10, "GOMP_1.0");
1468xversionify(KMP_API_NAME_GOMP_LOOP_RUNTIME_START, 10, "GOMP_1.0");
1469xversionify(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT, 10, "GOMP_1.0");
1470xversionify(KMP_API_NAME_GOMP_LOOP_STATIC_START, 10, "GOMP_1.0");
1471xversionify(KMP_API_NAME_GOMP_ORDERED_END, 10, "GOMP_1.0");
1472xversionify(KMP_API_NAME_GOMP_ORDERED_START, 10, "GOMP_1.0");
1473xversionify(KMP_API_NAME_GOMP_PARALLEL_END, 10, "GOMP_1.0");
1474xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START, 10, "GOMP_1.0");
1475xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START, 10, "GOMP_1.0");
1476xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START, 10, "GOMP_1.0");
1477xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START, 10, "GOMP_1.0");
1478xversionify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START, 10, "GOMP_1.0");
1479xversionify(KMP_API_NAME_GOMP_PARALLEL_START, 10, "GOMP_1.0");
1480xversionify(KMP_API_NAME_GOMP_SECTIONS_END, 10, "GOMP_1.0");
1481xversionify(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT, 10, "GOMP_1.0");
1482xversionify(KMP_API_NAME_GOMP_SECTIONS_NEXT, 10, "GOMP_1.0");
1483xversionify(KMP_API_NAME_GOMP_SECTIONS_START, 10, "GOMP_1.0");
1484xversionify(KMP_API_NAME_GOMP_SINGLE_COPY_END, 10, "GOMP_1.0");
1485xversionify(KMP_API_NAME_GOMP_SINGLE_COPY_START, 10, "GOMP_1.0");
1486xversionify(KMP_API_NAME_GOMP_SINGLE_START, 10, "GOMP_1.0");
1487
1488// GOMP_2.0 versioned symbols
Jim Cownie181b4bb2013-12-23 17:28:57 +00001489xversionify(KMP_API_NAME_GOMP_TASK, 20, "GOMP_2.0");
1490xversionify(KMP_API_NAME_GOMP_TASKWAIT, 20, "GOMP_2.0");
Jim Cownie181b4bb2013-12-23 17:28:57 +00001491xversionify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT, 20, "GOMP_2.0");
1492xversionify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START, 20, "GOMP_2.0");
1493xversionify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT, 20, "GOMP_2.0");
1494xversionify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START, 20, "GOMP_2.0");
1495xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT, 20, "GOMP_2.0");
1496xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START, 20, "GOMP_2.0");
1497xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT, 20, "GOMP_2.0");
1498xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START, 20, "GOMP_2.0");
1499xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT, 20, "GOMP_2.0");
1500xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START, 20, "GOMP_2.0");
1501xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT, 20, "GOMP_2.0");
1502xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START, 20, "GOMP_2.0");
1503xversionify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT, 20, "GOMP_2.0");
1504xversionify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START, 20, "GOMP_2.0");
1505xversionify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT, 20, "GOMP_2.0");
1506xversionify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START, 20, "GOMP_2.0");
1507
1508// GOMP_3.0 versioned symbols
1509xversionify(KMP_API_NAME_GOMP_TASKYIELD, 30, "GOMP_3.0");
1510
1511// GOMP_4.0 versioned symbols
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001512#if OMP_40_ENABLED
1513xversionify(KMP_API_NAME_GOMP_PARALLEL, 40, "GOMP_4.0");
1514xversionify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS, 40, "GOMP_4.0");
1515xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC, 40, "GOMP_4.0");
1516xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED, 40, "GOMP_4.0");
1517xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME, 40, "GOMP_4.0");
1518xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC, 40, "GOMP_4.0");
1519xversionify(KMP_API_NAME_GOMP_TASKGROUP_START, 40, "GOMP_4.0");
1520xversionify(KMP_API_NAME_GOMP_TASKGROUP_END, 40, "GOMP_4.0");
1521xversionify(KMP_API_NAME_GOMP_BARRIER_CANCEL, 40, "GOMP_4.0");
1522xversionify(KMP_API_NAME_GOMP_CANCEL, 40, "GOMP_4.0");
1523xversionify(KMP_API_NAME_GOMP_CANCELLATION_POINT, 40, "GOMP_4.0");
1524xversionify(KMP_API_NAME_GOMP_LOOP_END_CANCEL, 40, "GOMP_4.0");
1525xversionify(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL, 40, "GOMP_4.0");
1526xversionify(KMP_API_NAME_GOMP_TARGET, 40, "GOMP_4.0");
1527xversionify(KMP_API_NAME_GOMP_TARGET_DATA, 40, "GOMP_4.0");
1528xversionify(KMP_API_NAME_GOMP_TARGET_END_DATA, 40, "GOMP_4.0");
1529xversionify(KMP_API_NAME_GOMP_TARGET_UPDATE, 40, "GOMP_4.0");
1530xversionify(KMP_API_NAME_GOMP_TEAMS, 40, "GOMP_4.0");
1531#endif
Jim Cownie181b4bb2013-12-23 17:28:57 +00001532
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001533#endif // KMP_USE_VERSION_SYMBOLS
Jim Cownie181b4bb2013-12-23 17:28:57 +00001534
Jim Cownie5e8470a2013-09-27 10:38:44 +00001535#ifdef __cplusplus
1536 } //extern "C"
1537#endif // __cplusplus
1538
1539