blob: 29f4f72b3b1a0c1f6ea88769e2b0cc0c9e7e4448 [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();
Jonathan Peytone8104ad2015-06-08 18:56:33 +0000479 kmp_info_t *thr;
480
481 thr = __kmp_threads[gtid];
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000482
Jim Cownie5e8470a2013-09-27 10:38:44 +0000483 MKLOC(loc, "GOMP_parallel_end");
484 KA_TRACE(20, ("GOMP_parallel_end: T#%d\n", gtid));
485
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000486
487#if OMPT_SUPPORT
488 ompt_parallel_id_t parallel_id;
489 ompt_frame_t *ompt_frame = NULL;
490
491 if (ompt_status & ompt_status_track) {
492 ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
493 parallel_id = team_info->parallel_id;
494
495 ompt_frame = __ompt_get_task_frame_internal(0);
496 ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
497
498#if OMPT_TRACE
499 if ((ompt_status == ompt_status_track_callback) &&
500 ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)) {
501 ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
502 ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)(
503 parallel_id, task_info->task_id);
504 }
505#endif
506
507 // unlink if necessary. no-op if there is not a lightweight task.
508 ompt_lw_taskteam_t *lwt = __ompt_lw_taskteam_unlink(thr);
509 // GOMP allocates/frees lwt since it can't be kept on the stack
510 if (lwt) __kmp_free(lwt);
511 }
512#endif
513
Jim Cownie5e8470a2013-09-27 10:38:44 +0000514 if (! __kmp_threads[gtid]->th.th_team->t.t_serialized) {
515 kmp_info_t *thr = __kmp_threads[gtid];
516 __kmp_run_after_invoked_task(gtid, __kmp_tid_from_gtid(gtid), thr,
517 thr->th.th_team);
518 __kmp_join_call(&loc, gtid);
519 }
520 else {
521 __kmpc_end_serialized_parallel(&loc, gtid);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000522
523#if OMPT_SUPPORT
524 if (ompt_status & ompt_status_track) {
525 if ((ompt_status == ompt_status_track_callback) &&
526 ompt_callbacks.ompt_callback(ompt_event_parallel_end)) {
527 ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
528 ompt_callbacks.ompt_callback(ompt_event_parallel_end)(
529 parallel_id, task_info->task_id);
530 }
531
532 thr->th.ompt_thread_info.state =
533 (((thr->th.th_team)->t.t_serialized) ?
534 ompt_state_work_serial : ompt_state_work_parallel);
535 }
536#endif
537
Jim Cownie5e8470a2013-09-27 10:38:44 +0000538 }
539}
540
541
Jim Cownie5e8470a2013-09-27 10:38:44 +0000542//
543// Loop worksharing constructs
544//
545
546//
547// The Gnu codegen passes in an exclusive upper bound for the overall range,
548// but the libguide dispatch code expects an inclusive upper bound, hence the
549// "end - incr" 5th argument to KMP_DISPATCH_INIT (and the " ub - str" 11th
550// argument to __kmp_GOMP_fork_call).
551//
552// Conversely, KMP_DISPATCH_NEXT returns and inclusive upper bound in *p_ub,
553// but the Gnu codegen expects an excluside upper bound, so the adjustment
554// "*p_ub += stride" compenstates for the discrepancy.
555//
556// Correction: the gnu codegen always adjusts the upper bound by +-1, not the
557// stride value. We adjust the dispatch parameters accordingly (by +-1), but
558// we still adjust p_ub by the actual stride value.
559//
560// The "runtime" versions do not take a chunk_sz parameter.
561//
562// The profile lib cannot support construct checking of unordered loops that
563// are predetermined by the compiler to be statically scheduled, as the gcc
564// codegen will not always emit calls to GOMP_loop_static_next() to get the
565// next iteration. Instead, it emits inline code to call omp_get_thread_num()
566// num and calculate the iteration space using the result. It doesn't do this
567// with ordered static loop, so they can be checked.
568//
569
570#define LOOP_START(func,schedule) \
571 int func (long lb, long ub, long str, long chunk_sz, long *p_lb, \
572 long *p_ub) \
573 { \
574 int status; \
575 long stride; \
576 int gtid = __kmp_entry_gtid(); \
577 MKLOC(loc, #func); \
578 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
579 gtid, lb, ub, str, chunk_sz )); \
580 \
581 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
582 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
583 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
584 (schedule) != kmp_sch_static); \
585 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
586 (kmp_int *)p_ub, (kmp_int *)&stride); \
587 if (status) { \
588 KMP_DEBUG_ASSERT(stride == str); \
589 *p_ub += (str > 0) ? 1 : -1; \
590 } \
591 } \
592 else { \
593 status = 0; \
594 } \
595 \
596 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
597 gtid, *p_lb, *p_ub, status)); \
598 return status; \
599 }
600
601
602#define LOOP_RUNTIME_START(func,schedule) \
603 int func (long lb, long ub, long str, long *p_lb, long *p_ub) \
604 { \
605 int status; \
606 long stride; \
607 long chunk_sz = 0; \
608 int gtid = __kmp_entry_gtid(); \
609 MKLOC(loc, #func); \
610 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n", \
611 gtid, lb, ub, str, chunk_sz )); \
612 \
613 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
614 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
615 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, TRUE); \
616 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
617 (kmp_int *)p_ub, (kmp_int *)&stride); \
618 if (status) { \
619 KMP_DEBUG_ASSERT(stride == str); \
620 *p_ub += (str > 0) ? 1 : -1; \
621 } \
622 } \
623 else { \
624 status = 0; \
625 } \
626 \
627 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
628 gtid, *p_lb, *p_ub, status)); \
629 return status; \
630 }
631
632
633#define LOOP_NEXT(func,fini_code) \
634 int func(long *p_lb, long *p_ub) \
635 { \
636 int status; \
637 long stride; \
638 int gtid = __kmp_get_gtid(); \
639 MKLOC(loc, #func); \
640 KA_TRACE(20, ( #func ": T#%d\n", gtid)); \
641 \
642 fini_code \
643 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
644 (kmp_int *)p_ub, (kmp_int *)&stride); \
645 if (status) { \
646 *p_ub += (stride > 0) ? 1 : -1; \
647 } \
648 \
649 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, stride 0x%lx, " \
650 "returning %d\n", gtid, *p_lb, *p_ub, stride, status)); \
651 return status; \
652 }
653
654
Jim Cownie181b4bb2013-12-23 17:28:57 +0000655LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_STATIC_START), kmp_sch_static)
656LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT), {})
657LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START), kmp_sch_dynamic_chunked)
658LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT), {})
659LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_GUIDED_START), kmp_sch_guided_chunked)
660LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT), {})
661LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_START), kmp_sch_runtime)
662LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT), {})
Jim Cownie5e8470a2013-09-27 10:38:44 +0000663
Jim Cownie181b4bb2013-12-23 17:28:57 +0000664LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START), kmp_ord_static)
665LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000666 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000667LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START), kmp_ord_dynamic_chunked)
668LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000669 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000670LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START), kmp_ord_guided_chunked)
671LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000672 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000673LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START), kmp_ord_runtime)
674LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000675 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
676
677
678void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000679xexpand(KMP_API_NAME_GOMP_LOOP_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000680{
681 int gtid = __kmp_get_gtid();
682 KA_TRACE(20, ("GOMP_loop_end: T#%d\n", gtid))
683
684 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
685
686 KA_TRACE(20, ("GOMP_loop_end exit: T#%d\n", gtid))
687}
688
689
690void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000691xexpand(KMP_API_NAME_GOMP_LOOP_END_NOWAIT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000692{
693 KA_TRACE(20, ("GOMP_loop_end_nowait: T#%d\n", __kmp_get_gtid()))
694}
695
696
Jim Cownie5e8470a2013-09-27 10:38:44 +0000697//
698// Unsigned long long loop worksharing constructs
699//
700// These are new with gcc 4.4
701//
702
703#define LOOP_START_ULL(func,schedule) \
704 int func (int up, unsigned long long lb, unsigned long long ub, \
705 unsigned long long str, unsigned long long chunk_sz, \
706 unsigned long long *p_lb, unsigned long long *p_ub) \
707 { \
708 int status; \
709 long long str2 = up ? ((long long)str) : -((long long)str); \
710 long long stride; \
711 int gtid = __kmp_entry_gtid(); \
712 MKLOC(loc, #func); \
713 \
714 KA_TRACE(20, ( #func ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
715 gtid, up, lb, ub, str, chunk_sz )); \
716 \
717 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
718 KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
719 (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, \
720 (schedule) != kmp_sch_static); \
721 status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, \
722 (kmp_uint64 *)p_lb, (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
723 if (status) { \
724 KMP_DEBUG_ASSERT(stride == str2); \
725 *p_ub += (str > 0) ? 1 : -1; \
726 } \
727 } \
728 else { \
729 status = 0; \
730 } \
731 \
732 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
733 gtid, *p_lb, *p_ub, status)); \
734 return status; \
735 }
736
737
738#define LOOP_RUNTIME_START_ULL(func,schedule) \
739 int func (int up, unsigned long long lb, unsigned long long ub, \
740 unsigned long long str, unsigned long long *p_lb, \
741 unsigned long long *p_ub) \
742 { \
743 int status; \
744 long long str2 = up ? ((long long)str) : -((long long)str); \
745 unsigned long long stride; \
746 unsigned long long chunk_sz = 0; \
747 int gtid = __kmp_entry_gtid(); \
748 MKLOC(loc, #func); \
749 \
750 KA_TRACE(20, ( #func ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
751 gtid, up, lb, ub, str, chunk_sz )); \
752 \
753 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
754 KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
755 (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, TRUE); \
756 status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, \
757 (kmp_uint64 *)p_lb, (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
758 if (status) { \
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000759 KMP_DEBUG_ASSERT((long long)stride == str2); \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000760 *p_ub += (str > 0) ? 1 : -1; \
761 } \
762 } \
763 else { \
764 status = 0; \
765 } \
766 \
767 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
768 gtid, *p_lb, *p_ub, status)); \
769 return status; \
770 }
771
772
773#define LOOP_NEXT_ULL(func,fini_code) \
774 int func(unsigned long long *p_lb, unsigned long long *p_ub) \
775 { \
776 int status; \
777 long long stride; \
778 int gtid = __kmp_get_gtid(); \
779 MKLOC(loc, #func); \
780 KA_TRACE(20, ( #func ": T#%d\n", gtid)); \
781 \
782 fini_code \
783 status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
784 (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
785 if (status) { \
786 *p_ub += (stride > 0) ? 1 : -1; \
787 } \
788 \
789 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, stride 0x%llx, " \
790 "returning %d\n", gtid, *p_lb, *p_ub, stride, status)); \
791 return status; \
792 }
793
794
Jim Cownie181b4bb2013-12-23 17:28:57 +0000795LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START), kmp_sch_static)
796LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT), {})
797LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START), kmp_sch_dynamic_chunked)
798LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT), {})
799LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START), kmp_sch_guided_chunked)
800LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT), {})
801LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START), kmp_sch_runtime)
802LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT), {})
Jim Cownie5e8470a2013-09-27 10:38:44 +0000803
Jim Cownie181b4bb2013-12-23 17:28:57 +0000804LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START), kmp_ord_static)
805LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000806 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000807LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START), kmp_ord_dynamic_chunked)
808LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000809 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000810LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START), kmp_ord_guided_chunked)
811LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000812 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000813LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START), kmp_ord_runtime)
814LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000815 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
816
817
Jim Cownie5e8470a2013-09-27 10:38:44 +0000818//
819// Combined parallel / loop worksharing constructs
820//
821// There are no ull versions (yet).
822//
823
824#define PARALLEL_LOOP_START(func, schedule) \
825 void func (void (*task) (void *), void *data, unsigned num_threads, \
826 long lb, long ub, long str, long chunk_sz) \
827 { \
828 int gtid = __kmp_entry_gtid(); \
829 int last = FALSE; \
830 MKLOC(loc, #func); \
831 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
832 gtid, lb, ub, str, chunk_sz )); \
833 \
834 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) { \
835 if (num_threads != 0) { \
836 __kmp_push_num_threads(&loc, gtid, num_threads); \
837 } \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000838 __kmp_GOMP_fork_call(&loc, gtid, task, \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000839 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, \
840 task, data, num_threads, &loc, (schedule), lb, \
841 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz); \
842 } \
843 else { \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000844 __kmp_GOMP_serialized_parallel(&loc, gtid, task); \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000845 } \
846 \
847 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
848 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
849 (schedule) != kmp_sch_static); \
850 \
851 KA_TRACE(20, ( #func " exit: T#%d\n", gtid)); \
852 }
853
854
Jim Cownie181b4bb2013-12-23 17:28:57 +0000855PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START), kmp_sch_static)
856PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START), kmp_sch_dynamic_chunked)
857PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START), kmp_sch_guided_chunked)
858PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START), kmp_sch_runtime)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000859
860
Jim Cownie5e8470a2013-09-27 10:38:44 +0000861//
862// Tasking constructs
863//
864
865void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000866xexpand(KMP_API_NAME_GOMP_TASK)(void (*func)(void *), void *data, void (*copy_func)(void *, void *),
Jim Cownie5e8470a2013-09-27 10:38:44 +0000867 long arg_size, long arg_align, int if_cond, unsigned gomp_flags)
868{
869 MKLOC(loc, "GOMP_task");
870 int gtid = __kmp_entry_gtid();
871 kmp_int32 flags = 0;
872 kmp_tasking_flags_t *input_flags = (kmp_tasking_flags_t *) & flags;
873
874 KA_TRACE(20, ("GOMP_task: T#%d\n", gtid));
875
876 // The low-order bit is the "tied" flag
877 if (gomp_flags & 1) {
878 input_flags->tiedness = 1;
879 }
880 input_flags->native = 1;
881 // __kmp_task_alloc() sets up all other flags
882
883 if (! if_cond) {
884 arg_size = 0;
885 }
886
887 kmp_task_t *task = __kmp_task_alloc(&loc, gtid, input_flags,
888 sizeof(kmp_task_t), arg_size ? arg_size + arg_align - 1 : 0,
889 (kmp_routine_entry_t)func);
890
891 if (arg_size > 0) {
892 if (arg_align > 0) {
893 task->shareds = (void *)((((size_t)task->shareds)
894 + arg_align - 1) / arg_align * arg_align);
895 }
896 //else error??
897
898 if (copy_func) {
899 (*copy_func)(task->shareds, data);
900 }
901 else {
Andrey Churbanov74bf17b2015-04-02 13:27:08 +0000902 KMP_MEMCPY(task->shareds, data, arg_size);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000903 }
904 }
905
906 if (if_cond) {
907 __kmpc_omp_task(&loc, gtid, task);
908 }
909 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000910#if OMPT_SUPPORT
911 ompt_thread_info_t oldInfo;
912 kmp_info_t *thread;
913 kmp_taskdata_t *taskdata;
914 if (ompt_status & ompt_status_track) {
915 // Store the threads states and restore them after the task
916 thread = __kmp_threads[ gtid ];
917 taskdata = KMP_TASK_TO_TASKDATA(task);
918 oldInfo = thread->th.ompt_thread_info;
919 thread->th.ompt_thread_info.wait_id = 0;
920 thread->th.ompt_thread_info.state = ompt_state_work_parallel;
921 taskdata->ompt_task_info.frame.exit_runtime_frame =
922 __builtin_frame_address(0);
923 }
924#endif
925
Jim Cownie5e8470a2013-09-27 10:38:44 +0000926 __kmpc_omp_task_begin_if0(&loc, gtid, task);
927 func(data);
928 __kmpc_omp_task_complete_if0(&loc, gtid, task);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000929
930#if OMPT_SUPPORT
931 if (ompt_status & ompt_status_track) {
932 thread->th.ompt_thread_info = oldInfo;
933 taskdata->ompt_task_info.frame.exit_runtime_frame = 0;
934 }
935#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000936 }
937
938 KA_TRACE(20, ("GOMP_task exit: T#%d\n", gtid));
939}
940
941
942void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000943xexpand(KMP_API_NAME_GOMP_TASKWAIT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000944{
945 MKLOC(loc, "GOMP_taskwait");
946 int gtid = __kmp_entry_gtid();
947
948 KA_TRACE(20, ("GOMP_taskwait: T#%d\n", gtid));
949
950 __kmpc_omp_taskwait(&loc, gtid);
951
952 KA_TRACE(20, ("GOMP_taskwait exit: T#%d\n", gtid));
953}
954
955
Jim Cownie5e8470a2013-09-27 10:38:44 +0000956//
957// Sections worksharing constructs
958//
959
960//
961// For the sections construct, we initialize a dynamically scheduled loop
962// worksharing construct with lb 1 and stride 1, and use the iteration #'s
963// that its returns as sections ids.
964//
965// There are no special entry points for ordered sections, so we always use
966// the dynamically scheduled workshare, even if the sections aren't ordered.
967//
968
969unsigned
Jim Cownie181b4bb2013-12-23 17:28:57 +0000970xexpand(KMP_API_NAME_GOMP_SECTIONS_START)(unsigned count)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000971{
972 int status;
973 kmp_int lb, ub, stride;
974 int gtid = __kmp_entry_gtid();
975 MKLOC(loc, "GOMP_sections_start");
976 KA_TRACE(20, ("GOMP_sections_start: T#%d\n", gtid));
977
978 KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
979
980 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
981 if (status) {
982 KMP_DEBUG_ASSERT(stride == 1);
983 KMP_DEBUG_ASSERT(lb > 0);
984 KMP_ASSERT(lb == ub);
985 }
986 else {
987 lb = 0;
988 }
989
990 KA_TRACE(20, ("GOMP_sections_start exit: T#%d returning %u\n", gtid,
991 (unsigned)lb));
992 return (unsigned)lb;
993}
994
995
996unsigned
Jim Cownie181b4bb2013-12-23 17:28:57 +0000997xexpand(KMP_API_NAME_GOMP_SECTIONS_NEXT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000998{
999 int status;
1000 kmp_int lb, ub, stride;
1001 int gtid = __kmp_get_gtid();
1002 MKLOC(loc, "GOMP_sections_next");
1003 KA_TRACE(20, ("GOMP_sections_next: T#%d\n", gtid));
1004
1005 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
1006 if (status) {
1007 KMP_DEBUG_ASSERT(stride == 1);
1008 KMP_DEBUG_ASSERT(lb > 0);
1009 KMP_ASSERT(lb == ub);
1010 }
1011 else {
1012 lb = 0;
1013 }
1014
1015 KA_TRACE(20, ("GOMP_sections_next exit: T#%d returning %u\n", gtid,
1016 (unsigned)lb));
1017 return (unsigned)lb;
1018}
1019
1020
1021void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001022xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START)(void (*task) (void *), void *data,
Jim Cownie5e8470a2013-09-27 10:38:44 +00001023 unsigned num_threads, unsigned count)
1024{
1025 int gtid = __kmp_entry_gtid();
1026 int last = FALSE;
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001027
1028#if OMPT_SUPPORT
1029 ompt_frame_t *parent_frame;
1030
1031 if (ompt_status & ompt_status_track) {
1032 parent_frame = __ompt_get_task_frame_internal(0);
1033 parent_frame->reenter_runtime_frame = __builtin_frame_address(0);
1034 }
1035#endif
1036
Jim Cownie5e8470a2013-09-27 10:38:44 +00001037 MKLOC(loc, "GOMP_parallel_sections_start");
1038 KA_TRACE(20, ("GOMP_parallel_sections_start: T#%d\n", gtid));
1039
1040 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1041 if (num_threads != 0) {
1042 __kmp_push_num_threads(&loc, gtid, num_threads);
1043 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001044 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie5e8470a2013-09-27 10:38:44 +00001045 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, task, data,
1046 num_threads, &loc, kmp_nm_dynamic_chunked, (kmp_int)1,
1047 (kmp_int)count, (kmp_int)1, (kmp_int)1);
1048 }
1049 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001050 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie5e8470a2013-09-27 10:38:44 +00001051 }
1052
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001053#if OMPT_SUPPORT
1054 if (ompt_status & ompt_status_track) {
1055 parent_frame->reenter_runtime_frame = NULL;
1056 }
1057#endif
1058
Jim Cownie5e8470a2013-09-27 10:38:44 +00001059 KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1060
1061 KA_TRACE(20, ("GOMP_parallel_sections_start exit: T#%d\n", gtid));
1062}
1063
1064
1065void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001066xexpand(KMP_API_NAME_GOMP_SECTIONS_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +00001067{
1068 int gtid = __kmp_get_gtid();
1069 KA_TRACE(20, ("GOMP_sections_end: T#%d\n", gtid))
1070
1071 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
1072
1073 KA_TRACE(20, ("GOMP_sections_end exit: T#%d\n", gtid))
1074}
1075
1076
1077void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001078xexpand(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +00001079{
1080 KA_TRACE(20, ("GOMP_sections_end_nowait: T#%d\n", __kmp_get_gtid()))
1081}
1082
Jim Cownie181b4bb2013-12-23 17:28:57 +00001083// libgomp has an empty function for GOMP_taskyield as of 2013-10-10
1084void
1085xexpand(KMP_API_NAME_GOMP_TASKYIELD)(void)
1086{
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001087 KA_TRACE(20, ("GOMP_taskyield: T#%d\n", __kmp_get_gtid()))
1088 return;
Jim Cownie181b4bb2013-12-23 17:28:57 +00001089}
1090
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001091#if OMP_40_ENABLED // these are new GOMP_4.0 entry points
1092
1093void
1094xexpand(KMP_API_NAME_GOMP_PARALLEL)(void (*task)(void *), void *data, unsigned num_threads, unsigned int flags)
1095{
1096 int gtid = __kmp_entry_gtid();
1097 MKLOC(loc, "GOMP_parallel");
1098 KA_TRACE(20, ("GOMP_parallel: T#%d\n", gtid));
1099
1100 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1101 if (num_threads != 0) {
1102 __kmp_push_num_threads(&loc, gtid, num_threads);
1103 }
1104 if(flags != 0) {
1105 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
1106 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001107 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001108 (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task, data);
1109 }
1110 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001111 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001112 }
1113 task(data);
1114 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
1115}
1116
1117void
1118xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS)(void (*task) (void *), void *data,
1119 unsigned num_threads, unsigned count, unsigned flags)
1120{
1121 int gtid = __kmp_entry_gtid();
1122 int last = FALSE;
1123 MKLOC(loc, "GOMP_parallel_sections");
1124 KA_TRACE(20, ("GOMP_parallel_sections: T#%d\n", gtid));
1125
1126 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1127 if (num_threads != 0) {
1128 __kmp_push_num_threads(&loc, gtid, num_threads);
1129 }
1130 if(flags != 0) {
1131 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
1132 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001133 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001134 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, task, data,
1135 num_threads, &loc, kmp_nm_dynamic_chunked, (kmp_int)1,
1136 (kmp_int)count, (kmp_int)1, (kmp_int)1);
1137 }
1138 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001139 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001140 }
1141
1142 KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1143
1144 task(data);
1145 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
1146 KA_TRACE(20, ("GOMP_parallel_sections exit: T#%d\n", gtid));
1147}
1148
1149#define PARALLEL_LOOP(func, schedule) \
1150 void func (void (*task) (void *), void *data, unsigned num_threads, \
1151 long lb, long ub, long str, long chunk_sz, unsigned flags) \
1152 { \
1153 int gtid = __kmp_entry_gtid(); \
1154 int last = FALSE; \
1155 MKLOC(loc, #func); \
1156 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
1157 gtid, lb, ub, str, chunk_sz )); \
1158 \
1159 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) { \
1160 if (num_threads != 0) { \
1161 __kmp_push_num_threads(&loc, gtid, num_threads); \
1162 } \
1163 if (flags != 0) { \
1164 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags); \
1165 } \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001166 __kmp_GOMP_fork_call(&loc, gtid, task, \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001167 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, \
1168 task, data, num_threads, &loc, (schedule), lb, \
1169 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz); \
1170 } \
1171 else { \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001172 __kmp_GOMP_serialized_parallel(&loc, gtid, task); \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001173 } \
1174 \
1175 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
1176 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
1177 (schedule) != kmp_sch_static); \
1178 task(data); \
1179 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(); \
1180 \
1181 KA_TRACE(20, ( #func " exit: T#%d\n", gtid)); \
1182 }
1183
1184PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC), kmp_sch_static)
1185PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC), kmp_sch_dynamic_chunked)
1186PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED), kmp_sch_guided_chunked)
1187PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME), kmp_sch_runtime)
1188
1189
1190void
1191xexpand(KMP_API_NAME_GOMP_TASKGROUP_START)(void)
1192{
1193 int gtid = __kmp_get_gtid();
1194 MKLOC(loc, "GOMP_taskgroup_start");
1195 KA_TRACE(20, ("GOMP_taskgroup_start: T#%d\n", gtid));
1196
1197 __kmpc_taskgroup(&loc, gtid);
1198
1199 return;
1200}
1201
1202void
1203xexpand(KMP_API_NAME_GOMP_TASKGROUP_END)(void)
1204{
1205 int gtid = __kmp_get_gtid();
1206 MKLOC(loc, "GOMP_taskgroup_end");
1207 KA_TRACE(20, ("GOMP_taskgroup_end: T#%d\n", gtid));
1208
1209 __kmpc_end_taskgroup(&loc, gtid);
1210
1211 return;
1212}
1213
1214#ifndef KMP_DEBUG
1215static
1216#endif /* KMP_DEBUG */
Jonathan Peyton66338292015-06-01 02:37:28 +00001217kmp_int32 __kmp_gomp_to_omp_cancellation_kind(int gomp_kind) {
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001218 kmp_int32 cncl_kind = 0;
1219 switch(gomp_kind) {
1220 case 1:
1221 cncl_kind = cancel_parallel;
1222 break;
1223 case 2:
1224 cncl_kind = cancel_loop;
1225 break;
1226 case 4:
1227 cncl_kind = cancel_sections;
1228 break;
1229 case 8:
1230 cncl_kind = cancel_taskgroup;
1231 break;
1232 }
1233 return cncl_kind;
1234}
1235
1236bool
1237xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(int which)
1238{
1239 if(__kmp_omp_cancellation) {
1240 KMP_FATAL(NoGompCancellation);
1241 }
1242 int gtid = __kmp_get_gtid();
1243 MKLOC(loc, "GOMP_cancellation_point");
1244 KA_TRACE(20, ("GOMP_cancellation_point: T#%d\n", gtid));
1245
Jonathan Peyton66338292015-06-01 02:37:28 +00001246 kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001247
1248 return __kmpc_cancellationpoint(&loc, gtid, cncl_kind);
1249}
1250
1251bool
1252xexpand(KMP_API_NAME_GOMP_BARRIER_CANCEL)(void)
1253{
1254 if(__kmp_omp_cancellation) {
1255 KMP_FATAL(NoGompCancellation);
1256 }
1257 KMP_FATAL(NoGompCancellation);
1258 int gtid = __kmp_get_gtid();
1259 MKLOC(loc, "GOMP_barrier_cancel");
1260 KA_TRACE(20, ("GOMP_barrier_cancel: T#%d\n", gtid));
1261
1262 return __kmpc_cancel_barrier(&loc, gtid);
1263}
1264
1265bool
1266xexpand(KMP_API_NAME_GOMP_CANCEL)(int which, bool do_cancel)
1267{
1268 if(__kmp_omp_cancellation) {
1269 KMP_FATAL(NoGompCancellation);
1270 } else {
1271 return FALSE;
1272 }
1273
1274 int gtid = __kmp_get_gtid();
1275 MKLOC(loc, "GOMP_cancel");
1276 KA_TRACE(20, ("GOMP_cancel: T#%d\n", gtid));
1277
Jonathan Peyton66338292015-06-01 02:37:28 +00001278 kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001279
1280 if(do_cancel == FALSE) {
1281 return xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(which);
1282 } else {
1283 return __kmpc_cancel(&loc, gtid, cncl_kind);
1284 }
1285}
1286
1287bool
1288xexpand(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL)(void)
1289{
1290 if(__kmp_omp_cancellation) {
1291 KMP_FATAL(NoGompCancellation);
1292 }
1293 int gtid = __kmp_get_gtid();
1294 MKLOC(loc, "GOMP_sections_end_cancel");
1295 KA_TRACE(20, ("GOMP_sections_end_cancel: T#%d\n", gtid));
1296
1297 return __kmpc_cancel_barrier(&loc, gtid);
1298}
1299
1300bool
1301xexpand(KMP_API_NAME_GOMP_LOOP_END_CANCEL)(void)
1302{
1303 if(__kmp_omp_cancellation) {
1304 KMP_FATAL(NoGompCancellation);
1305 }
1306 int gtid = __kmp_get_gtid();
1307 MKLOC(loc, "GOMP_loop_end_cancel");
1308 KA_TRACE(20, ("GOMP_loop_end_cancel: T#%d\n", gtid));
1309
1310 return __kmpc_cancel_barrier(&loc, gtid);
1311}
1312
1313// All target functions are empty as of 2014-05-29
1314void
1315xexpand(KMP_API_NAME_GOMP_TARGET)(int device, void (*fn) (void *), const void *openmp_target,
1316 size_t mapnum, void **hostaddrs, size_t *sizes, unsigned char *kinds)
1317{
1318 return;
1319}
1320
1321void
1322xexpand(KMP_API_NAME_GOMP_TARGET_DATA)(int device, const void *openmp_target, size_t mapnum,
1323 void **hostaddrs, size_t *sizes, unsigned char *kinds)
1324{
1325 return;
1326}
1327
1328void
1329xexpand(KMP_API_NAME_GOMP_TARGET_END_DATA)(void)
1330{
1331 return;
1332}
1333
1334void
1335xexpand(KMP_API_NAME_GOMP_TARGET_UPDATE)(int device, const void *openmp_target, size_t mapnum,
1336 void **hostaddrs, size_t *sizes, unsigned char *kinds)
1337{
1338 return;
1339}
1340
1341void
1342xexpand(KMP_API_NAME_GOMP_TEAMS)(unsigned int num_teams, unsigned int thread_limit)
1343{
1344 return;
1345}
1346#endif // OMP_40_ENABLED
1347
1348
Jim Cownie181b4bb2013-12-23 17:28:57 +00001349/*
1350 The following sections of code create aliases for the GOMP_* functions,
1351 then create versioned symbols using the assembler directive .symver.
1352 This is only pertinent for ELF .so library
1353 xaliasify and xversionify are defined in kmp_ftn_os.h
1354*/
1355
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001356#ifdef KMP_USE_VERSION_SYMBOLS
Jim Cownie181b4bb2013-12-23 17:28:57 +00001357
1358// GOMP_1.0 aliases
1359xaliasify(KMP_API_NAME_GOMP_ATOMIC_END, 10);
1360xaliasify(KMP_API_NAME_GOMP_ATOMIC_START, 10);
1361xaliasify(KMP_API_NAME_GOMP_BARRIER, 10);
1362xaliasify(KMP_API_NAME_GOMP_CRITICAL_END, 10);
1363xaliasify(KMP_API_NAME_GOMP_CRITICAL_NAME_END, 10);
1364xaliasify(KMP_API_NAME_GOMP_CRITICAL_NAME_START, 10);
1365xaliasify(KMP_API_NAME_GOMP_CRITICAL_START, 10);
1366xaliasify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT, 10);
1367xaliasify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START, 10);
1368xaliasify(KMP_API_NAME_GOMP_LOOP_END, 10);
1369xaliasify(KMP_API_NAME_GOMP_LOOP_END_NOWAIT, 10);
1370xaliasify(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT, 10);
1371xaliasify(KMP_API_NAME_GOMP_LOOP_GUIDED_START, 10);
1372xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT, 10);
1373xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START, 10);
1374xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT, 10);
1375xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START, 10);
1376xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT, 10);
1377xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START, 10);
1378xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT, 10);
1379xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START, 10);
1380xaliasify(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT, 10);
1381xaliasify(KMP_API_NAME_GOMP_LOOP_RUNTIME_START, 10);
1382xaliasify(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT, 10);
1383xaliasify(KMP_API_NAME_GOMP_LOOP_STATIC_START, 10);
1384xaliasify(KMP_API_NAME_GOMP_ORDERED_END, 10);
1385xaliasify(KMP_API_NAME_GOMP_ORDERED_START, 10);
1386xaliasify(KMP_API_NAME_GOMP_PARALLEL_END, 10);
1387xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START, 10);
1388xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START, 10);
1389xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START, 10);
1390xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START, 10);
1391xaliasify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START, 10);
1392xaliasify(KMP_API_NAME_GOMP_PARALLEL_START, 10);
1393xaliasify(KMP_API_NAME_GOMP_SECTIONS_END, 10);
1394xaliasify(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT, 10);
1395xaliasify(KMP_API_NAME_GOMP_SECTIONS_NEXT, 10);
1396xaliasify(KMP_API_NAME_GOMP_SECTIONS_START, 10);
1397xaliasify(KMP_API_NAME_GOMP_SINGLE_COPY_END, 10);
1398xaliasify(KMP_API_NAME_GOMP_SINGLE_COPY_START, 10);
1399xaliasify(KMP_API_NAME_GOMP_SINGLE_START, 10);
1400
1401// GOMP_2.0 aliases
Jim Cownie181b4bb2013-12-23 17:28:57 +00001402xaliasify(KMP_API_NAME_GOMP_TASK, 20);
1403xaliasify(KMP_API_NAME_GOMP_TASKWAIT, 20);
Jim Cownie181b4bb2013-12-23 17:28:57 +00001404xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT, 20);
1405xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START, 20);
1406xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT, 20);
1407xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START, 20);
1408xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT, 20);
1409xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START, 20);
1410xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT, 20);
1411xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START, 20);
1412xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT, 20);
1413xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START, 20);
1414xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT, 20);
1415xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START, 20);
1416xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT, 20);
1417xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START, 20);
1418xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT, 20);
1419xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START, 20);
1420
1421// GOMP_3.0 aliases
1422xaliasify(KMP_API_NAME_GOMP_TASKYIELD, 30);
1423
1424// GOMP_4.0 aliases
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001425// The GOMP_parallel* entry points below aren't OpenMP 4.0 related.
1426#if OMP_40_ENABLED
1427xaliasify(KMP_API_NAME_GOMP_PARALLEL, 40);
1428xaliasify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS, 40);
1429xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC, 40);
1430xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED, 40);
1431xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME, 40);
1432xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC, 40);
1433xaliasify(KMP_API_NAME_GOMP_TASKGROUP_START, 40);
1434xaliasify(KMP_API_NAME_GOMP_TASKGROUP_END, 40);
1435xaliasify(KMP_API_NAME_GOMP_BARRIER_CANCEL, 40);
1436xaliasify(KMP_API_NAME_GOMP_CANCEL, 40);
1437xaliasify(KMP_API_NAME_GOMP_CANCELLATION_POINT, 40);
1438xaliasify(KMP_API_NAME_GOMP_LOOP_END_CANCEL, 40);
1439xaliasify(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL, 40);
1440xaliasify(KMP_API_NAME_GOMP_TARGET, 40);
1441xaliasify(KMP_API_NAME_GOMP_TARGET_DATA, 40);
1442xaliasify(KMP_API_NAME_GOMP_TARGET_END_DATA, 40);
1443xaliasify(KMP_API_NAME_GOMP_TARGET_UPDATE, 40);
1444xaliasify(KMP_API_NAME_GOMP_TEAMS, 40);
1445#endif
Jim Cownie181b4bb2013-12-23 17:28:57 +00001446
1447// GOMP_1.0 versioned symbols
1448xversionify(KMP_API_NAME_GOMP_ATOMIC_END, 10, "GOMP_1.0");
1449xversionify(KMP_API_NAME_GOMP_ATOMIC_START, 10, "GOMP_1.0");
1450xversionify(KMP_API_NAME_GOMP_BARRIER, 10, "GOMP_1.0");
1451xversionify(KMP_API_NAME_GOMP_CRITICAL_END, 10, "GOMP_1.0");
1452xversionify(KMP_API_NAME_GOMP_CRITICAL_NAME_END, 10, "GOMP_1.0");
1453xversionify(KMP_API_NAME_GOMP_CRITICAL_NAME_START, 10, "GOMP_1.0");
1454xversionify(KMP_API_NAME_GOMP_CRITICAL_START, 10, "GOMP_1.0");
1455xversionify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT, 10, "GOMP_1.0");
1456xversionify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START, 10, "GOMP_1.0");
1457xversionify(KMP_API_NAME_GOMP_LOOP_END, 10, "GOMP_1.0");
1458xversionify(KMP_API_NAME_GOMP_LOOP_END_NOWAIT, 10, "GOMP_1.0");
1459xversionify(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT, 10, "GOMP_1.0");
1460xversionify(KMP_API_NAME_GOMP_LOOP_GUIDED_START, 10, "GOMP_1.0");
1461xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT, 10, "GOMP_1.0");
1462xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START, 10, "GOMP_1.0");
1463xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT, 10, "GOMP_1.0");
1464xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START, 10, "GOMP_1.0");
1465xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT, 10, "GOMP_1.0");
1466xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START, 10, "GOMP_1.0");
1467xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT, 10, "GOMP_1.0");
1468xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START, 10, "GOMP_1.0");
1469xversionify(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT, 10, "GOMP_1.0");
1470xversionify(KMP_API_NAME_GOMP_LOOP_RUNTIME_START, 10, "GOMP_1.0");
1471xversionify(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT, 10, "GOMP_1.0");
1472xversionify(KMP_API_NAME_GOMP_LOOP_STATIC_START, 10, "GOMP_1.0");
1473xversionify(KMP_API_NAME_GOMP_ORDERED_END, 10, "GOMP_1.0");
1474xversionify(KMP_API_NAME_GOMP_ORDERED_START, 10, "GOMP_1.0");
1475xversionify(KMP_API_NAME_GOMP_PARALLEL_END, 10, "GOMP_1.0");
1476xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START, 10, "GOMP_1.0");
1477xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START, 10, "GOMP_1.0");
1478xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START, 10, "GOMP_1.0");
1479xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START, 10, "GOMP_1.0");
1480xversionify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START, 10, "GOMP_1.0");
1481xversionify(KMP_API_NAME_GOMP_PARALLEL_START, 10, "GOMP_1.0");
1482xversionify(KMP_API_NAME_GOMP_SECTIONS_END, 10, "GOMP_1.0");
1483xversionify(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT, 10, "GOMP_1.0");
1484xversionify(KMP_API_NAME_GOMP_SECTIONS_NEXT, 10, "GOMP_1.0");
1485xversionify(KMP_API_NAME_GOMP_SECTIONS_START, 10, "GOMP_1.0");
1486xversionify(KMP_API_NAME_GOMP_SINGLE_COPY_END, 10, "GOMP_1.0");
1487xversionify(KMP_API_NAME_GOMP_SINGLE_COPY_START, 10, "GOMP_1.0");
1488xversionify(KMP_API_NAME_GOMP_SINGLE_START, 10, "GOMP_1.0");
1489
1490// GOMP_2.0 versioned symbols
Jim Cownie181b4bb2013-12-23 17:28:57 +00001491xversionify(KMP_API_NAME_GOMP_TASK, 20, "GOMP_2.0");
1492xversionify(KMP_API_NAME_GOMP_TASKWAIT, 20, "GOMP_2.0");
Jim Cownie181b4bb2013-12-23 17:28:57 +00001493xversionify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT, 20, "GOMP_2.0");
1494xversionify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START, 20, "GOMP_2.0");
1495xversionify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT, 20, "GOMP_2.0");
1496xversionify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START, 20, "GOMP_2.0");
1497xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT, 20, "GOMP_2.0");
1498xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START, 20, "GOMP_2.0");
1499xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT, 20, "GOMP_2.0");
1500xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START, 20, "GOMP_2.0");
1501xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT, 20, "GOMP_2.0");
1502xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START, 20, "GOMP_2.0");
1503xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT, 20, "GOMP_2.0");
1504xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START, 20, "GOMP_2.0");
1505xversionify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT, 20, "GOMP_2.0");
1506xversionify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START, 20, "GOMP_2.0");
1507xversionify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT, 20, "GOMP_2.0");
1508xversionify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START, 20, "GOMP_2.0");
1509
1510// GOMP_3.0 versioned symbols
1511xversionify(KMP_API_NAME_GOMP_TASKYIELD, 30, "GOMP_3.0");
1512
1513// GOMP_4.0 versioned symbols
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001514#if OMP_40_ENABLED
1515xversionify(KMP_API_NAME_GOMP_PARALLEL, 40, "GOMP_4.0");
1516xversionify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS, 40, "GOMP_4.0");
1517xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC, 40, "GOMP_4.0");
1518xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED, 40, "GOMP_4.0");
1519xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME, 40, "GOMP_4.0");
1520xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC, 40, "GOMP_4.0");
1521xversionify(KMP_API_NAME_GOMP_TASKGROUP_START, 40, "GOMP_4.0");
1522xversionify(KMP_API_NAME_GOMP_TASKGROUP_END, 40, "GOMP_4.0");
1523xversionify(KMP_API_NAME_GOMP_BARRIER_CANCEL, 40, "GOMP_4.0");
1524xversionify(KMP_API_NAME_GOMP_CANCEL, 40, "GOMP_4.0");
1525xversionify(KMP_API_NAME_GOMP_CANCELLATION_POINT, 40, "GOMP_4.0");
1526xversionify(KMP_API_NAME_GOMP_LOOP_END_CANCEL, 40, "GOMP_4.0");
1527xversionify(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL, 40, "GOMP_4.0");
1528xversionify(KMP_API_NAME_GOMP_TARGET, 40, "GOMP_4.0");
1529xversionify(KMP_API_NAME_GOMP_TARGET_DATA, 40, "GOMP_4.0");
1530xversionify(KMP_API_NAME_GOMP_TARGET_END_DATA, 40, "GOMP_4.0");
1531xversionify(KMP_API_NAME_GOMP_TARGET_UPDATE, 40, "GOMP_4.0");
1532xversionify(KMP_API_NAME_GOMP_TEAMS, 40, "GOMP_4.0");
1533#endif
Jim Cownie181b4bb2013-12-23 17:28:57 +00001534
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001535#endif // KMP_USE_VERSION_SYMBOLS
Jim Cownie181b4bb2013-12-23 17:28:57 +00001536
Jim Cownie5e8470a2013-09-27 10:38:44 +00001537#ifdef __cplusplus
1538 } //extern "C"
1539#endif // __cplusplus
1540
1541