blob: ada7ce9e42a7a1e201c7c1a29f7f5c121b379484 [file] [log] [blame]
Jim Cownie5e8470a2013-09-27 10:38:44 +00001/*
Jonathan Peytonde4749b2016-12-14 23:01:24 +00002 * kmp_gsupport.cpp
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
Jim Cownie5e8470a2013-09-27 10:38:44 +000016#include "kmp.h"
17#include "kmp_atomic.h"
18
Andrey Churbanovd7d088f2015-04-29 16:42:24 +000019#if OMPT_SUPPORT
20#include "ompt-specific.h"
21#endif
22
Jim Cownie5e8470a2013-09-27 10:38:44 +000023#ifdef __cplusplus
24 extern "C" {
25#endif // __cplusplus
26
27#define MKLOC(loc,routine) \
28 static ident_t (loc) = {0, KMP_IDENT_KMPC, 0, 0, ";unknown;unknown;0;0;;" };
29
Jim Cownie181b4bb2013-12-23 17:28:57 +000030#include "kmp_ftn_os.h"
Jim Cownie5e8470a2013-09-27 10:38:44 +000031
32void
Jim Cownie181b4bb2013-12-23 17:28:57 +000033xexpand(KMP_API_NAME_GOMP_BARRIER)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +000034{
35 int gtid = __kmp_entry_gtid();
36 MKLOC(loc, "GOMP_barrier");
37 KA_TRACE(20, ("GOMP_barrier: T#%d\n", gtid));
Jonas Hahnfeld848d6902016-09-14 13:59:39 +000038#if OMPT_SUPPORT && OMPT_TRACE
39 ompt_frame_t * ompt_frame;
40 if (ompt_enabled ) {
41 ompt_frame = __ompt_get_task_frame_internal(0);
42 ompt_frame->reenter_runtime_frame = __builtin_frame_address(1);
43 }
44#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +000045 __kmpc_barrier(&loc, gtid);
46}
47
48
Jim Cownie5e8470a2013-09-27 10:38:44 +000049//
50// Mutual exclusion
51//
52
53//
54// The symbol that icc/ifort generates for unnamed for unnamed critical
55// sections - .gomp_critical_user_ - is defined using .comm in any objects
56// reference it. We can't reference it directly here in C code, as the
57// symbol contains a ".".
58//
59// The RTL contains an assembly language definition of .gomp_critical_user_
60// with another symbol __kmp_unnamed_critical_addr initialized with it's
61// address.
62//
63extern kmp_critical_name *__kmp_unnamed_critical_addr;
64
65
66void
Jim Cownie181b4bb2013-12-23 17:28:57 +000067xexpand(KMP_API_NAME_GOMP_CRITICAL_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +000068{
69 int gtid = __kmp_entry_gtid();
70 MKLOC(loc, "GOMP_critical_start");
71 KA_TRACE(20, ("GOMP_critical_start: T#%d\n", gtid));
72 __kmpc_critical(&loc, gtid, __kmp_unnamed_critical_addr);
73}
74
75
76void
Jim Cownie181b4bb2013-12-23 17:28:57 +000077xexpand(KMP_API_NAME_GOMP_CRITICAL_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +000078{
79 int gtid = __kmp_get_gtid();
80 MKLOC(loc, "GOMP_critical_end");
81 KA_TRACE(20, ("GOMP_critical_end: T#%d\n", gtid));
82 __kmpc_end_critical(&loc, gtid, __kmp_unnamed_critical_addr);
83}
84
85
86void
Jim Cownie181b4bb2013-12-23 17:28:57 +000087xexpand(KMP_API_NAME_GOMP_CRITICAL_NAME_START)(void **pptr)
Jim Cownie5e8470a2013-09-27 10:38:44 +000088{
89 int gtid = __kmp_entry_gtid();
90 MKLOC(loc, "GOMP_critical_name_start");
91 KA_TRACE(20, ("GOMP_critical_name_start: T#%d\n", gtid));
92 __kmpc_critical(&loc, gtid, (kmp_critical_name *)pptr);
93}
94
95
96void
Jim Cownie181b4bb2013-12-23 17:28:57 +000097xexpand(KMP_API_NAME_GOMP_CRITICAL_NAME_END)(void **pptr)
Jim Cownie5e8470a2013-09-27 10:38:44 +000098{
99 int gtid = __kmp_get_gtid();
100 MKLOC(loc, "GOMP_critical_name_end");
101 KA_TRACE(20, ("GOMP_critical_name_end: T#%d\n", gtid));
102 __kmpc_end_critical(&loc, gtid, (kmp_critical_name *)pptr);
103}
104
105
106//
107// The Gnu codegen tries to use locked operations to perform atomic updates
108// inline. If it can't, then it calls GOMP_atomic_start() before performing
109// the update and GOMP_atomic_end() afterward, regardless of the data type.
110//
111
112void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000113xexpand(KMP_API_NAME_GOMP_ATOMIC_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000114{
115 int gtid = __kmp_entry_gtid();
116 KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000117
118#if OMPT_SUPPORT
119 __ompt_thread_assign_wait_id(0);
120#endif
121
Jim Cownie5e8470a2013-09-27 10:38:44 +0000122 __kmp_acquire_atomic_lock(&__kmp_atomic_lock, gtid);
123}
124
125
126void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000127xexpand(KMP_API_NAME_GOMP_ATOMIC_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000128{
129 int gtid = __kmp_get_gtid();
130 KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
131 __kmp_release_atomic_lock(&__kmp_atomic_lock, gtid);
132}
133
134
135int
Jim Cownie181b4bb2013-12-23 17:28:57 +0000136xexpand(KMP_API_NAME_GOMP_SINGLE_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000137{
138 int gtid = __kmp_entry_gtid();
139 MKLOC(loc, "GOMP_single_start");
140 KA_TRACE(20, ("GOMP_single_start: T#%d\n", gtid));
141
142 if (! TCR_4(__kmp_init_parallel))
143 __kmp_parallel_initialize();
144
145 //
146 // 3rd parameter == FALSE prevents kmp_enter_single from pushing a
147 // workshare when USE_CHECKS is defined. We need to avoid the push,
148 // as there is no corresponding GOMP_single_end() call.
149 //
150 return __kmp_enter_single(gtid, &loc, FALSE);
151}
152
153
154void *
Jim Cownie181b4bb2013-12-23 17:28:57 +0000155xexpand(KMP_API_NAME_GOMP_SINGLE_COPY_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000156{
157 void *retval;
158 int gtid = __kmp_entry_gtid();
159 MKLOC(loc, "GOMP_single_copy_start");
160 KA_TRACE(20, ("GOMP_single_copy_start: T#%d\n", gtid));
161
162 if (! TCR_4(__kmp_init_parallel))
163 __kmp_parallel_initialize();
164
165 //
166 // If this is the first thread to enter, return NULL. The generated
167 // code will then call GOMP_single_copy_end() for this thread only,
168 // with the copyprivate data pointer as an argument.
169 //
170 if (__kmp_enter_single(gtid, &loc, FALSE))
171 return NULL;
172
173 //
174 // Wait for the first thread to set the copyprivate data pointer,
175 // and for all other threads to reach this point.
176 //
177 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
178
179 //
180 // Retrieve the value of the copyprivate data point, and wait for all
181 // threads to do likewise, then return.
182 //
183 retval = __kmp_team_from_gtid(gtid)->t.t_copypriv_data;
184 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
185 return retval;
186}
187
188
189void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000190xexpand(KMP_API_NAME_GOMP_SINGLE_COPY_END)(void *data)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000191{
192 int gtid = __kmp_get_gtid();
Jim Cownie5e8470a2013-09-27 10:38:44 +0000193 KA_TRACE(20, ("GOMP_single_copy_end: T#%d\n", gtid));
194
195 //
196 // Set the copyprivate data pointer fo the team, then hit the barrier
197 // so that the other threads will continue on and read it. Hit another
198 // barrier before continuing, so that the know that the copyprivate
199 // data pointer has been propagated to all threads before trying to
200 // reuse the t_copypriv_data field.
201 //
202 __kmp_team_from_gtid(gtid)->t.t_copypriv_data = data;
203 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
204 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
205}
206
207
208void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000209xexpand(KMP_API_NAME_GOMP_ORDERED_START)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000210{
211 int gtid = __kmp_entry_gtid();
212 MKLOC(loc, "GOMP_ordered_start");
213 KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
214 __kmpc_ordered(&loc, gtid);
215}
216
217
218void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000219xexpand(KMP_API_NAME_GOMP_ORDERED_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000220{
221 int gtid = __kmp_get_gtid();
222 MKLOC(loc, "GOMP_ordered_end");
223 KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
224 __kmpc_end_ordered(&loc, gtid);
225}
226
227
Jim Cownie5e8470a2013-09-27 10:38:44 +0000228//
229// Dispatch macro defs
230//
231// They come in two flavors: 64-bit unsigned, and either 32-bit signed
232// (IA-32 architecture) or 64-bit signed (Intel(R) 64).
233//
234
Sylvestre Ledrucd9d3742016-12-08 09:22:24 +0000235#if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS
Jim Cownie5e8470a2013-09-27 10:38:44 +0000236# define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_4
237# define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_4
238# define KMP_DISPATCH_NEXT __kmpc_dispatch_next_4
239#else
240# define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_8
241# define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_8
242# define KMP_DISPATCH_NEXT __kmpc_dispatch_next_8
243#endif /* KMP_ARCH_X86 */
244
245# define KMP_DISPATCH_INIT_ULL __kmp_aux_dispatch_init_8u
246# define KMP_DISPATCH_FINI_CHUNK_ULL __kmp_aux_dispatch_fini_chunk_8u
247# define KMP_DISPATCH_NEXT_ULL __kmpc_dispatch_next_8u
248
249
Jim Cownie5e8470a2013-09-27 10:38:44 +0000250//
251// The parallel contruct
252//
253
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000254#ifndef KMP_DEBUG
Jim Cownie5e8470a2013-09-27 10:38:44 +0000255static
256#endif /* KMP_DEBUG */
257void
258__kmp_GOMP_microtask_wrapper(int *gtid, int *npr, void (*task)(void *),
259 void *data)
260{
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000261#if OMPT_SUPPORT
262 kmp_info_t *thr;
263 ompt_frame_t *ompt_frame;
264 ompt_state_t enclosing_state;
265
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000266 if (ompt_enabled) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000267 // get pointer to thread data structure
268 thr = __kmp_threads[*gtid];
269
270 // save enclosing task state; set current state for task
271 enclosing_state = thr->th.ompt_thread_info.state;
272 thr->th.ompt_thread_info.state = ompt_state_work_parallel;
273
274 // set task frame
275 ompt_frame = __ompt_get_task_frame_internal(0);
276 ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
277 }
278#endif
279
Jim Cownie5e8470a2013-09-27 10:38:44 +0000280 task(data);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000281
282#if OMPT_SUPPORT
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000283 if (ompt_enabled) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000284 // clear task frame
285 ompt_frame->exit_runtime_frame = NULL;
286
287 // restore enclosing state
288 thr->th.ompt_thread_info.state = enclosing_state;
289 }
290#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000291}
292
293
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000294#ifndef KMP_DEBUG
Jim Cownie5e8470a2013-09-27 10:38:44 +0000295static
296#endif /* KMP_DEBUG */
297void
298__kmp_GOMP_parallel_microtask_wrapper(int *gtid, int *npr,
299 void (*task)(void *), void *data, unsigned num_threads, ident_t *loc,
300 enum sched_type schedule, long start, long end, long incr, long chunk_size)
301{
302 //
303 // Intialize the loop worksharing construct.
304 //
305 KMP_DISPATCH_INIT(loc, *gtid, schedule, start, end, incr, chunk_size,
306 schedule != kmp_sch_static);
307
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000308#if OMPT_SUPPORT
309 kmp_info_t *thr;
310 ompt_frame_t *ompt_frame;
311 ompt_state_t enclosing_state;
312
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000313 if (ompt_enabled) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000314 thr = __kmp_threads[*gtid];
315 // save enclosing task state; set current state for task
316 enclosing_state = thr->th.ompt_thread_info.state;
317 thr->th.ompt_thread_info.state = ompt_state_work_parallel;
318
319 // set task frame
320 ompt_frame = __ompt_get_task_frame_internal(0);
321 ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
322 }
323#endif
324
Jim Cownie5e8470a2013-09-27 10:38:44 +0000325 //
326 // Now invoke the microtask.
327 //
328 task(data);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000329
330#if OMPT_SUPPORT
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000331 if (ompt_enabled) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000332 // clear task frame
333 ompt_frame->exit_runtime_frame = NULL;
334
335 // reset enclosing state
336 thr->th.ompt_thread_info.state = enclosing_state;
337 }
338#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000339}
340
341
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000342#ifndef KMP_DEBUG
Jim Cownie5e8470a2013-09-27 10:38:44 +0000343static
344#endif /* KMP_DEBUG */
345void
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000346__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 +0000347{
348 int rc;
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000349 kmp_info_t *thr = __kmp_threads[gtid];
350 kmp_team_t *team = thr->th.th_team;
351 int tid = __kmp_tid_from_gtid(gtid);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000352
353 va_list ap;
354 va_start(ap, argc);
355
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000356 rc = __kmp_fork_call(loc, gtid, fork_context_gnu, argc,
357#if OMPT_SUPPORT
358 VOLATILE_CAST(void *) unwrapped_task,
359#endif
360 wrapper, __kmp_invoke_task_func,
Andrey Churbanovcbda8682015-01-13 14:43:35 +0000361#if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
Jim Cownie5e8470a2013-09-27 10:38:44 +0000362 &ap
363#else
364 ap
365#endif
366 );
367
368 va_end(ap);
369
370 if (rc) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000371 __kmp_run_before_invoked_task(gtid, tid, thr, team);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000372 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000373
Jonathan Peyton61118492016-05-20 19:03:38 +0000374#if OMPT_SUPPORT
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000375 if (ompt_enabled) {
Jonathan Peyton122dd762015-07-13 18:55:45 +0000376#if OMPT_TRACE
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000377 ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
378 ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
379
380 // implicit task callback
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000381 if (ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000382 ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)(
383 team_info->parallel_id, task_info->task_id);
384 }
Jonathan Peyton122dd762015-07-13 18:55:45 +0000385#endif
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000386 thr->th.ompt_thread_info.state = ompt_state_work_parallel;
387 }
388#endif
389}
390
391static void
392__kmp_GOMP_serialized_parallel(ident_t *loc, kmp_int32 gtid, void (*task)(void *))
393{
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000394#if OMPT_SUPPORT
Jonas Hahnfeld6c250b72016-03-21 12:37:52 +0000395 ompt_parallel_id_t ompt_parallel_id;
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000396 if (ompt_enabled) {
Jonas Hahnfeld6c250b72016-03-21 12:37:52 +0000397 ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000398
Jonas Hahnfeld6c250b72016-03-21 12:37:52 +0000399 ompt_parallel_id = __ompt_parallel_id_new(gtid);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000400
401 // parallel region callback
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000402 if (ompt_callbacks.ompt_callback(ompt_event_parallel_begin)) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000403 int team_size = 1;
404 ompt_callbacks.ompt_callback(ompt_event_parallel_begin)(
Jonas Hahnfeld6c250b72016-03-21 12:37:52 +0000405 task_info->task_id, &task_info->frame, ompt_parallel_id,
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000406 team_size, (void *) task,
407 OMPT_INVOKER(fork_context_gnu));
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000408 }
Jonas Hahnfeld6c250b72016-03-21 12:37:52 +0000409 }
410#endif
411
412 __kmp_serialized_parallel(loc, gtid);
413
414#if OMPT_SUPPORT
415 if (ompt_enabled) {
416 kmp_info_t *thr = __kmp_threads[gtid];
417
418 ompt_task_id_t my_ompt_task_id = __ompt_task_id_new(gtid);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000419
420 // set up lightweight task
421 ompt_lw_taskteam_t *lwt = (ompt_lw_taskteam_t *)
422 __kmp_allocate(sizeof(ompt_lw_taskteam_t));
423 __ompt_lw_taskteam_init(lwt, thr, gtid, (void *) task, ompt_parallel_id);
424 lwt->ompt_task_info.task_id = my_ompt_task_id;
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000425 __ompt_lw_taskteam_link(lwt, thr);
426
427#if OMPT_TRACE
428 // implicit task callback
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000429 if (ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000430 ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)(
431 ompt_parallel_id, my_ompt_task_id);
432 }
433 thr->th.ompt_thread_info.state = ompt_state_work_parallel;
434#endif
435 }
436#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000437}
438
439
440void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000441xexpand(KMP_API_NAME_GOMP_PARALLEL_START)(void (*task)(void *), void *data, unsigned num_threads)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000442{
443 int gtid = __kmp_entry_gtid();
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000444
445#if OMPT_SUPPORT
Jonas Hahnfeld848d6902016-09-14 13:59:39 +0000446 ompt_frame_t *parent_frame, *frame;
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000447
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000448 if (ompt_enabled) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000449 parent_frame = __ompt_get_task_frame_internal(0);
Jonas Hahnfeldfd0614d2016-09-14 13:59:13 +0000450 parent_frame->reenter_runtime_frame = __builtin_frame_address(1);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000451 }
452#endif
453
Jim Cownie5e8470a2013-09-27 10:38:44 +0000454 MKLOC(loc, "GOMP_parallel_start");
455 KA_TRACE(20, ("GOMP_parallel_start: T#%d\n", gtid));
456
457 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
458 if (num_threads != 0) {
459 __kmp_push_num_threads(&loc, gtid, num_threads);
460 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000461 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie5e8470a2013-09-27 10:38:44 +0000462 (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task, data);
463 }
464 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000465 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000466 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000467
468#if OMPT_SUPPORT
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000469 if (ompt_enabled) {
Jonas Hahnfeld848d6902016-09-14 13:59:39 +0000470 frame = __ompt_get_task_frame_internal(0);
471 frame->exit_runtime_frame = __builtin_frame_address(1);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000472 }
473#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000474}
475
476
477void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000478xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000479{
480 int gtid = __kmp_get_gtid();
Jonathan Peytone8104ad2015-06-08 18:56:33 +0000481 kmp_info_t *thr;
482
483 thr = __kmp_threads[gtid];
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000484
Jim Cownie5e8470a2013-09-27 10:38:44 +0000485 MKLOC(loc, "GOMP_parallel_end");
486 KA_TRACE(20, ("GOMP_parallel_end: T#%d\n", gtid));
487
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000488
489#if OMPT_SUPPORT
490 ompt_parallel_id_t parallel_id;
Jonas Hahnfeld1c1c7172016-03-24 12:52:04 +0000491 ompt_task_id_t serialized_task_id;
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000492 ompt_frame_t *ompt_frame = NULL;
493
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000494 if (ompt_enabled) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000495 ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
496 parallel_id = team_info->parallel_id;
497
Jonas Hahnfeld1c1c7172016-03-24 12:52:04 +0000498 ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
499 serialized_task_id = task_info->task_id;
500
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000501 // unlink if necessary. no-op if there is not a lightweight task.
502 ompt_lw_taskteam_t *lwt = __ompt_lw_taskteam_unlink(thr);
503 // GOMP allocates/frees lwt since it can't be kept on the stack
Jonathan Peyton61118492016-05-20 19:03:38 +0000504 if (lwt) {
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000505 __kmp_free(lwt);
Jonathan Peyton61118492016-05-20 19:03:38 +0000506
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000507 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000508 }
509#endif
510
Jonathan Peyton57d19ce2015-08-26 19:55:13 +0000511 if (! thr->th.th_team->t.t_serialized) {
Jim Cownie5e8470a2013-09-27 10:38:44 +0000512 __kmp_run_after_invoked_task(gtid, __kmp_tid_from_gtid(gtid), thr,
513 thr->th.th_team);
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000514
515#if OMPT_SUPPORT
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000516 if (ompt_enabled) {
Jonas Hahnfeld848d6902016-09-14 13:59:39 +0000517 // Implicit task is finished here, in the barrier we might schedule deferred tasks,
518 // these don't see the implicit task on the stack
519 ompt_frame = __ompt_get_task_frame_internal(0);
520 ompt_frame->exit_runtime_frame = NULL;
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000521 }
522#endif
523
Jonathan Peytonf89fbbb2015-08-31 18:15:00 +0000524 __kmp_join_call(&loc, gtid
525#if OMPT_SUPPORT
526 , fork_context_gnu
527#endif
528 );
Jim Cownie5e8470a2013-09-27 10:38:44 +0000529 }
530 else {
Jonas Hahnfeld1c1c7172016-03-24 12:52:04 +0000531#if OMPT_SUPPORT && OMPT_TRACE
532 if (ompt_enabled &&
533 ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)) {
534 ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)(
535 parallel_id, serialized_task_id);
536 }
537#endif
538
Jim Cownie5e8470a2013-09-27 10:38:44 +0000539 __kmpc_end_serialized_parallel(&loc, gtid);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000540
541#if OMPT_SUPPORT
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000542 if (ompt_enabled) {
Jonathan Peyton61118492016-05-20 19:03:38 +0000543 // Record that we re-entered the runtime system in the frame that
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000544 // created the parallel region.
Jonas Hahnfeld848d6902016-09-14 13:59:39 +0000545 ompt_task_info_t *parent_task_info = __ompt_get_taskinfo(0);
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000546
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000547 if (ompt_callbacks.ompt_callback(ompt_event_parallel_end)) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000548 ompt_callbacks.ompt_callback(ompt_event_parallel_end)(
Jonas Hahnfeld848d6902016-09-14 13:59:39 +0000549 parallel_id, parent_task_info->task_id,
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000550 OMPT_INVOKER(fork_context_gnu));
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000551 }
552
Jonas Hahnfeld848d6902016-09-14 13:59:39 +0000553 parent_task_info->frame.reenter_runtime_frame = NULL;
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000554
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000555 thr->th.ompt_thread_info.state =
556 (((thr->th.th_team)->t.t_serialized) ?
557 ompt_state_work_serial : ompt_state_work_parallel);
558 }
559#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000560 }
561}
562
563
Jim Cownie5e8470a2013-09-27 10:38:44 +0000564//
565// Loop worksharing constructs
566//
567
568//
569// The Gnu codegen passes in an exclusive upper bound for the overall range,
570// but the libguide dispatch code expects an inclusive upper bound, hence the
571// "end - incr" 5th argument to KMP_DISPATCH_INIT (and the " ub - str" 11th
572// argument to __kmp_GOMP_fork_call).
573//
574// Conversely, KMP_DISPATCH_NEXT returns and inclusive upper bound in *p_ub,
575// but the Gnu codegen expects an excluside upper bound, so the adjustment
576// "*p_ub += stride" compenstates for the discrepancy.
577//
578// Correction: the gnu codegen always adjusts the upper bound by +-1, not the
579// stride value. We adjust the dispatch parameters accordingly (by +-1), but
580// we still adjust p_ub by the actual stride value.
581//
582// The "runtime" versions do not take a chunk_sz parameter.
583//
584// The profile lib cannot support construct checking of unordered loops that
585// are predetermined by the compiler to be statically scheduled, as the gcc
586// codegen will not always emit calls to GOMP_loop_static_next() to get the
587// next iteration. Instead, it emits inline code to call omp_get_thread_num()
588// num and calculate the iteration space using the result. It doesn't do this
589// with ordered static loop, so they can be checked.
590//
591
592#define LOOP_START(func,schedule) \
593 int func (long lb, long ub, long str, long chunk_sz, long *p_lb, \
594 long *p_ub) \
595 { \
596 int status; \
597 long stride; \
598 int gtid = __kmp_entry_gtid(); \
599 MKLOC(loc, #func); \
600 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
601 gtid, lb, ub, str, chunk_sz )); \
602 \
603 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
604 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
605 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
606 (schedule) != kmp_sch_static); \
607 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
608 (kmp_int *)p_ub, (kmp_int *)&stride); \
609 if (status) { \
610 KMP_DEBUG_ASSERT(stride == str); \
611 *p_ub += (str > 0) ? 1 : -1; \
612 } \
613 } \
614 else { \
615 status = 0; \
616 } \
617 \
618 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
619 gtid, *p_lb, *p_ub, status)); \
620 return status; \
621 }
622
623
624#define LOOP_RUNTIME_START(func,schedule) \
625 int func (long lb, long ub, long str, long *p_lb, long *p_ub) \
626 { \
627 int status; \
628 long stride; \
629 long chunk_sz = 0; \
630 int gtid = __kmp_entry_gtid(); \
631 MKLOC(loc, #func); \
632 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n", \
633 gtid, lb, ub, str, chunk_sz )); \
634 \
635 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
636 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
637 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, TRUE); \
638 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
639 (kmp_int *)p_ub, (kmp_int *)&stride); \
640 if (status) { \
641 KMP_DEBUG_ASSERT(stride == str); \
642 *p_ub += (str > 0) ? 1 : -1; \
643 } \
644 } \
645 else { \
646 status = 0; \
647 } \
648 \
649 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
650 gtid, *p_lb, *p_ub, status)); \
651 return status; \
652 }
653
654
655#define LOOP_NEXT(func,fini_code) \
656 int func(long *p_lb, long *p_ub) \
657 { \
658 int status; \
659 long stride; \
660 int gtid = __kmp_get_gtid(); \
661 MKLOC(loc, #func); \
662 KA_TRACE(20, ( #func ": T#%d\n", gtid)); \
663 \
664 fini_code \
665 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
666 (kmp_int *)p_ub, (kmp_int *)&stride); \
667 if (status) { \
668 *p_ub += (stride > 0) ? 1 : -1; \
669 } \
670 \
671 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, stride 0x%lx, " \
672 "returning %d\n", gtid, *p_lb, *p_ub, stride, status)); \
673 return status; \
674 }
675
676
Jim Cownie181b4bb2013-12-23 17:28:57 +0000677LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_STATIC_START), kmp_sch_static)
678LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT), {})
679LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START), kmp_sch_dynamic_chunked)
680LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT), {})
681LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_GUIDED_START), kmp_sch_guided_chunked)
682LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT), {})
683LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_START), kmp_sch_runtime)
684LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT), {})
Jim Cownie5e8470a2013-09-27 10:38:44 +0000685
Jim Cownie181b4bb2013-12-23 17:28:57 +0000686LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START), kmp_ord_static)
687LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000688 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000689LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START), kmp_ord_dynamic_chunked)
690LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000691 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000692LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START), kmp_ord_guided_chunked)
693LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000694 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000695LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START), kmp_ord_runtime)
696LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000697 { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
698
699
700void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000701xexpand(KMP_API_NAME_GOMP_LOOP_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000702{
703 int gtid = __kmp_get_gtid();
704 KA_TRACE(20, ("GOMP_loop_end: T#%d\n", gtid))
705
706 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
707
708 KA_TRACE(20, ("GOMP_loop_end exit: T#%d\n", gtid))
709}
710
711
712void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000713xexpand(KMP_API_NAME_GOMP_LOOP_END_NOWAIT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000714{
715 KA_TRACE(20, ("GOMP_loop_end_nowait: T#%d\n", __kmp_get_gtid()))
716}
717
718
Jim Cownie5e8470a2013-09-27 10:38:44 +0000719//
720// Unsigned long long loop worksharing constructs
721//
722// These are new with gcc 4.4
723//
724
725#define LOOP_START_ULL(func,schedule) \
726 int func (int up, unsigned long long lb, unsigned long long ub, \
727 unsigned long long str, unsigned long long chunk_sz, \
728 unsigned long long *p_lb, unsigned long long *p_ub) \
729 { \
730 int status; \
731 long long str2 = up ? ((long long)str) : -((long long)str); \
732 long long stride; \
733 int gtid = __kmp_entry_gtid(); \
734 MKLOC(loc, #func); \
735 \
736 KA_TRACE(20, ( #func ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
737 gtid, up, lb, ub, str, chunk_sz )); \
738 \
739 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
740 KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
741 (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, \
742 (schedule) != kmp_sch_static); \
743 status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, \
744 (kmp_uint64 *)p_lb, (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
745 if (status) { \
746 KMP_DEBUG_ASSERT(stride == str2); \
747 *p_ub += (str > 0) ? 1 : -1; \
748 } \
749 } \
750 else { \
751 status = 0; \
752 } \
753 \
754 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
755 gtid, *p_lb, *p_ub, status)); \
756 return status; \
757 }
758
759
760#define LOOP_RUNTIME_START_ULL(func,schedule) \
761 int func (int up, unsigned long long lb, unsigned long long ub, \
762 unsigned long long str, unsigned long long *p_lb, \
763 unsigned long long *p_ub) \
764 { \
765 int status; \
766 long long str2 = up ? ((long long)str) : -((long long)str); \
767 unsigned long long stride; \
768 unsigned long long chunk_sz = 0; \
769 int gtid = __kmp_entry_gtid(); \
770 MKLOC(loc, #func); \
771 \
772 KA_TRACE(20, ( #func ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
773 gtid, up, lb, ub, str, chunk_sz )); \
774 \
775 if ((str > 0) ? (lb < ub) : (lb > ub)) { \
776 KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
777 (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, TRUE); \
778 status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, \
779 (kmp_uint64 *)p_lb, (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
780 if (status) { \
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000781 KMP_DEBUG_ASSERT((long long)stride == str2); \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000782 *p_ub += (str > 0) ? 1 : -1; \
783 } \
784 } \
785 else { \
786 status = 0; \
787 } \
788 \
789 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
790 gtid, *p_lb, *p_ub, status)); \
791 return status; \
792 }
793
794
795#define LOOP_NEXT_ULL(func,fini_code) \
796 int func(unsigned long long *p_lb, unsigned long long *p_ub) \
797 { \
798 int status; \
799 long long stride; \
800 int gtid = __kmp_get_gtid(); \
801 MKLOC(loc, #func); \
802 KA_TRACE(20, ( #func ": T#%d\n", gtid)); \
803 \
804 fini_code \
805 status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
806 (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
807 if (status) { \
808 *p_ub += (stride > 0) ? 1 : -1; \
809 } \
810 \
811 KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, stride 0x%llx, " \
812 "returning %d\n", gtid, *p_lb, *p_ub, stride, status)); \
813 return status; \
814 }
815
816
Jim Cownie181b4bb2013-12-23 17:28:57 +0000817LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START), kmp_sch_static)
818LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT), {})
819LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START), kmp_sch_dynamic_chunked)
820LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT), {})
821LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START), kmp_sch_guided_chunked)
822LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT), {})
823LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START), kmp_sch_runtime)
824LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT), {})
Jim Cownie5e8470a2013-09-27 10:38:44 +0000825
Jim Cownie181b4bb2013-12-23 17:28:57 +0000826LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START), kmp_ord_static)
827LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000828 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000829LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START), kmp_ord_dynamic_chunked)
830LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000831 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000832LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START), kmp_ord_guided_chunked)
833LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000834 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
Jim Cownie181b4bb2013-12-23 17:28:57 +0000835LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START), kmp_ord_runtime)
836LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT), \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000837 { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
838
839
Jim Cownie5e8470a2013-09-27 10:38:44 +0000840//
841// Combined parallel / loop worksharing constructs
842//
843// There are no ull versions (yet).
844//
845
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000846#define PARALLEL_LOOP_START(func, schedule, ompt_pre, ompt_post) \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000847 void func (void (*task) (void *), void *data, unsigned num_threads, \
848 long lb, long ub, long str, long chunk_sz) \
849 { \
850 int gtid = __kmp_entry_gtid(); \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000851 MKLOC(loc, #func); \
852 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
853 gtid, lb, ub, str, chunk_sz )); \
854 \
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000855 ompt_pre(); \
856 \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000857 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) { \
858 if (num_threads != 0) { \
859 __kmp_push_num_threads(&loc, gtid, num_threads); \
860 } \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000861 __kmp_GOMP_fork_call(&loc, gtid, task, \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000862 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, \
863 task, data, num_threads, &loc, (schedule), lb, \
864 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz); \
865 } \
866 else { \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000867 __kmp_GOMP_serialized_parallel(&loc, gtid, task); \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000868 } \
869 \
870 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
871 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
872 (schedule) != kmp_sch_static); \
873 \
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000874 ompt_post(); \
875 \
Jim Cownie5e8470a2013-09-27 10:38:44 +0000876 KA_TRACE(20, ( #func " exit: T#%d\n", gtid)); \
877 }
878
879
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000880
881#if OMPT_SUPPORT
882
883#define OMPT_LOOP_PRE() \
884 ompt_frame_t *parent_frame; \
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000885 if (ompt_enabled) { \
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000886 parent_frame = __ompt_get_task_frame_internal(0); \
Jonas Hahnfeldfd0614d2016-09-14 13:59:13 +0000887 parent_frame->reenter_runtime_frame = __builtin_frame_address(1); \
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000888 }
889
890
891#define OMPT_LOOP_POST() \
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000892 if (ompt_enabled) { \
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000893 parent_frame->reenter_runtime_frame = NULL; \
894 }
895
896#else
897
Jonathan Peyton61118492016-05-20 19:03:38 +0000898#define OMPT_LOOP_PRE()
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000899
900#define OMPT_LOOP_POST()
901
902#endif
903
904
Jonathan Peyton61118492016-05-20 19:03:38 +0000905PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START),
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000906 kmp_sch_static, OMPT_LOOP_PRE, OMPT_LOOP_POST)
Jonathan Peyton61118492016-05-20 19:03:38 +0000907PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START),
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000908 kmp_sch_dynamic_chunked, OMPT_LOOP_PRE, OMPT_LOOP_POST)
Jonathan Peyton61118492016-05-20 19:03:38 +0000909PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START),
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000910 kmp_sch_guided_chunked, OMPT_LOOP_PRE, OMPT_LOOP_POST)
Jonathan Peyton61118492016-05-20 19:03:38 +0000911PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START),
Jonathan Peyton3fdf3292015-07-21 18:03:30 +0000912 kmp_sch_runtime, OMPT_LOOP_PRE, OMPT_LOOP_POST)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000913
914
Jim Cownie5e8470a2013-09-27 10:38:44 +0000915//
916// Tasking constructs
917//
918
919void
Jim Cownie181b4bb2013-12-23 17:28:57 +0000920xexpand(KMP_API_NAME_GOMP_TASK)(void (*func)(void *), void *data, void (*copy_func)(void *, void *),
Paul Osmialowski07885152017-03-23 15:03:17 +0000921 long arg_size, long arg_align, bool if_cond, unsigned gomp_flags
922#if OMP_40_ENABLED
923 , void **depend
924#endif
925)
Jim Cownie5e8470a2013-09-27 10:38:44 +0000926{
927 MKLOC(loc, "GOMP_task");
928 int gtid = __kmp_entry_gtid();
929 kmp_int32 flags = 0;
930 kmp_tasking_flags_t *input_flags = (kmp_tasking_flags_t *) & flags;
931
932 KA_TRACE(20, ("GOMP_task: T#%d\n", gtid));
933
934 // The low-order bit is the "tied" flag
935 if (gomp_flags & 1) {
936 input_flags->tiedness = 1;
937 }
Jonathan Peyton33d1d282015-10-13 18:36:22 +0000938 // The second low-order bit is the "final" flag
939 if (gomp_flags & 2) {
940 input_flags->final = 1;
941 }
Jim Cownie5e8470a2013-09-27 10:38:44 +0000942 input_flags->native = 1;
943 // __kmp_task_alloc() sets up all other flags
944
945 if (! if_cond) {
946 arg_size = 0;
947 }
948
949 kmp_task_t *task = __kmp_task_alloc(&loc, gtid, input_flags,
950 sizeof(kmp_task_t), arg_size ? arg_size + arg_align - 1 : 0,
951 (kmp_routine_entry_t)func);
952
953 if (arg_size > 0) {
954 if (arg_align > 0) {
955 task->shareds = (void *)((((size_t)task->shareds)
956 + arg_align - 1) / arg_align * arg_align);
957 }
958 //else error??
959
960 if (copy_func) {
961 (*copy_func)(task->shareds, data);
962 }
963 else {
Andrey Churbanov74bf17b2015-04-02 13:27:08 +0000964 KMP_MEMCPY(task->shareds, data, arg_size);
Jim Cownie5e8470a2013-09-27 10:38:44 +0000965 }
966 }
967
968 if (if_cond) {
Paul Osmialowski07885152017-03-23 15:03:17 +0000969#if OMP_40_ENABLED
970 if (gomp_flags & 8) {
971 KMP_ASSERT(depend);
972 const size_t ndeps = (kmp_intptr_t)depend[0];
973 const size_t nout = (kmp_intptr_t)depend[1];
974 kmp_depend_info_t dep_list[ndeps];
975
976 for (size_t i = 0U; i < ndeps; i++) {
977 dep_list[i].base_addr = (kmp_intptr_t)depend[2U + i];
978 dep_list[i].len = 0U;
979 dep_list[i].flags.in = 1;
980 dep_list[i].flags.out = (i < nout);
981 }
982 __kmpc_omp_task_with_deps(&loc, gtid, task, ndeps, dep_list, 0, NULL);
983 }
984 else
985#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +0000986 __kmpc_omp_task(&loc, gtid, task);
987 }
988 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000989#if OMPT_SUPPORT
990 ompt_thread_info_t oldInfo;
991 kmp_info_t *thread;
992 kmp_taskdata_t *taskdata;
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000993 if (ompt_enabled) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +0000994 // Store the threads states and restore them after the task
995 thread = __kmp_threads[ gtid ];
996 taskdata = KMP_TASK_TO_TASKDATA(task);
997 oldInfo = thread->th.ompt_thread_info;
998 thread->th.ompt_thread_info.wait_id = 0;
999 thread->th.ompt_thread_info.state = ompt_state_work_parallel;
1000 taskdata->ompt_task_info.frame.exit_runtime_frame =
1001 __builtin_frame_address(0);
1002 }
1003#endif
1004
Jim Cownie5e8470a2013-09-27 10:38:44 +00001005 __kmpc_omp_task_begin_if0(&loc, gtid, task);
1006 func(data);
1007 __kmpc_omp_task_complete_if0(&loc, gtid, task);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001008
1009#if OMPT_SUPPORT
Jonathan Peytonb68a85d2015-09-21 18:11:22 +00001010 if (ompt_enabled) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001011 thread->th.ompt_thread_info = oldInfo;
Jonas Hahnfeldfd0614d2016-09-14 13:59:13 +00001012 taskdata->ompt_task_info.frame.exit_runtime_frame = NULL;
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001013 }
1014#endif
Jim Cownie5e8470a2013-09-27 10:38:44 +00001015 }
1016
1017 KA_TRACE(20, ("GOMP_task exit: T#%d\n", gtid));
1018}
1019
1020
1021void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001022xexpand(KMP_API_NAME_GOMP_TASKWAIT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +00001023{
1024 MKLOC(loc, "GOMP_taskwait");
1025 int gtid = __kmp_entry_gtid();
1026
1027 KA_TRACE(20, ("GOMP_taskwait: T#%d\n", gtid));
1028
1029 __kmpc_omp_taskwait(&loc, gtid);
1030
1031 KA_TRACE(20, ("GOMP_taskwait exit: T#%d\n", gtid));
1032}
1033
1034
Jim Cownie5e8470a2013-09-27 10:38:44 +00001035//
1036// Sections worksharing constructs
1037//
1038
1039//
1040// For the sections construct, we initialize a dynamically scheduled loop
1041// worksharing construct with lb 1 and stride 1, and use the iteration #'s
1042// that its returns as sections ids.
1043//
1044// There are no special entry points for ordered sections, so we always use
1045// the dynamically scheduled workshare, even if the sections aren't ordered.
1046//
1047
1048unsigned
Jim Cownie181b4bb2013-12-23 17:28:57 +00001049xexpand(KMP_API_NAME_GOMP_SECTIONS_START)(unsigned count)
Jim Cownie5e8470a2013-09-27 10:38:44 +00001050{
1051 int status;
1052 kmp_int lb, ub, stride;
1053 int gtid = __kmp_entry_gtid();
1054 MKLOC(loc, "GOMP_sections_start");
1055 KA_TRACE(20, ("GOMP_sections_start: T#%d\n", gtid));
1056
1057 KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1058
1059 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
1060 if (status) {
1061 KMP_DEBUG_ASSERT(stride == 1);
1062 KMP_DEBUG_ASSERT(lb > 0);
1063 KMP_ASSERT(lb == ub);
1064 }
1065 else {
1066 lb = 0;
1067 }
1068
1069 KA_TRACE(20, ("GOMP_sections_start exit: T#%d returning %u\n", gtid,
1070 (unsigned)lb));
1071 return (unsigned)lb;
1072}
1073
1074
1075unsigned
Jim Cownie181b4bb2013-12-23 17:28:57 +00001076xexpand(KMP_API_NAME_GOMP_SECTIONS_NEXT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +00001077{
1078 int status;
1079 kmp_int lb, ub, stride;
1080 int gtid = __kmp_get_gtid();
1081 MKLOC(loc, "GOMP_sections_next");
1082 KA_TRACE(20, ("GOMP_sections_next: T#%d\n", gtid));
1083
1084 status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
1085 if (status) {
1086 KMP_DEBUG_ASSERT(stride == 1);
1087 KMP_DEBUG_ASSERT(lb > 0);
1088 KMP_ASSERT(lb == ub);
1089 }
1090 else {
1091 lb = 0;
1092 }
1093
1094 KA_TRACE(20, ("GOMP_sections_next exit: T#%d returning %u\n", gtid,
1095 (unsigned)lb));
1096 return (unsigned)lb;
1097}
1098
1099
1100void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001101xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START)(void (*task) (void *), void *data,
Jim Cownie5e8470a2013-09-27 10:38:44 +00001102 unsigned num_threads, unsigned count)
1103{
1104 int gtid = __kmp_entry_gtid();
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001105
1106#if OMPT_SUPPORT
1107 ompt_frame_t *parent_frame;
1108
Jonathan Peytonb68a85d2015-09-21 18:11:22 +00001109 if (ompt_enabled) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001110 parent_frame = __ompt_get_task_frame_internal(0);
Jonas Hahnfeldfd0614d2016-09-14 13:59:13 +00001111 parent_frame->reenter_runtime_frame = __builtin_frame_address(1);
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001112 }
1113#endif
1114
Jim Cownie5e8470a2013-09-27 10:38:44 +00001115 MKLOC(loc, "GOMP_parallel_sections_start");
1116 KA_TRACE(20, ("GOMP_parallel_sections_start: T#%d\n", gtid));
1117
1118 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1119 if (num_threads != 0) {
1120 __kmp_push_num_threads(&loc, gtid, num_threads);
1121 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001122 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie5e8470a2013-09-27 10:38:44 +00001123 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, task, data,
1124 num_threads, &loc, kmp_nm_dynamic_chunked, (kmp_int)1,
1125 (kmp_int)count, (kmp_int)1, (kmp_int)1);
1126 }
1127 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001128 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie5e8470a2013-09-27 10:38:44 +00001129 }
1130
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001131#if OMPT_SUPPORT
Jonathan Peytonb68a85d2015-09-21 18:11:22 +00001132 if (ompt_enabled) {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001133 parent_frame->reenter_runtime_frame = NULL;
1134 }
1135#endif
1136
Jim Cownie5e8470a2013-09-27 10:38:44 +00001137 KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1138
1139 KA_TRACE(20, ("GOMP_parallel_sections_start exit: T#%d\n", gtid));
1140}
1141
1142
1143void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001144xexpand(KMP_API_NAME_GOMP_SECTIONS_END)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +00001145{
1146 int gtid = __kmp_get_gtid();
1147 KA_TRACE(20, ("GOMP_sections_end: T#%d\n", gtid))
1148
1149 __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
1150
1151 KA_TRACE(20, ("GOMP_sections_end exit: T#%d\n", gtid))
1152}
1153
1154
1155void
Jim Cownie181b4bb2013-12-23 17:28:57 +00001156xexpand(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT)(void)
Jim Cownie5e8470a2013-09-27 10:38:44 +00001157{
1158 KA_TRACE(20, ("GOMP_sections_end_nowait: T#%d\n", __kmp_get_gtid()))
1159}
1160
Jim Cownie181b4bb2013-12-23 17:28:57 +00001161// libgomp has an empty function for GOMP_taskyield as of 2013-10-10
1162void
1163xexpand(KMP_API_NAME_GOMP_TASKYIELD)(void)
1164{
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001165 KA_TRACE(20, ("GOMP_taskyield: T#%d\n", __kmp_get_gtid()))
1166 return;
Jim Cownie181b4bb2013-12-23 17:28:57 +00001167}
1168
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001169#if OMP_40_ENABLED // these are new GOMP_4.0 entry points
1170
1171void
1172xexpand(KMP_API_NAME_GOMP_PARALLEL)(void (*task)(void *), void *data, unsigned num_threads, unsigned int flags)
1173{
1174 int gtid = __kmp_entry_gtid();
1175 MKLOC(loc, "GOMP_parallel");
1176 KA_TRACE(20, ("GOMP_parallel: T#%d\n", gtid));
1177
Jonas Hahnfeld848d6902016-09-14 13:59:39 +00001178#if OMPT_SUPPORT
1179 ompt_task_info_t *parent_task_info, *task_info;
1180 if (ompt_enabled) {
1181 parent_task_info = __ompt_get_taskinfo(0);
1182 parent_task_info->frame.reenter_runtime_frame = __builtin_frame_address(1);
1183 }
1184#endif
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001185 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1186 if (num_threads != 0) {
1187 __kmp_push_num_threads(&loc, gtid, num_threads);
1188 }
1189 if(flags != 0) {
1190 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
1191 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001192 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001193 (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task, data);
1194 }
1195 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001196 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001197 }
Jonas Hahnfeld848d6902016-09-14 13:59:39 +00001198#if OMPT_SUPPORT
1199 if (ompt_enabled) {
1200 task_info = __ompt_get_taskinfo(0);
1201 task_info->frame.exit_runtime_frame = __builtin_frame_address(0);
1202 }
1203#endif
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001204 task(data);
1205 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
Jonas Hahnfeld848d6902016-09-14 13:59:39 +00001206#if OMPT_SUPPORT
1207 if (ompt_enabled) {
1208 task_info->frame.exit_runtime_frame = NULL;
1209 parent_task_info->frame.reenter_runtime_frame = NULL;
1210 }
1211#endif
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001212}
1213
1214void
1215xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS)(void (*task) (void *), void *data,
1216 unsigned num_threads, unsigned count, unsigned flags)
1217{
1218 int gtid = __kmp_entry_gtid();
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001219 MKLOC(loc, "GOMP_parallel_sections");
1220 KA_TRACE(20, ("GOMP_parallel_sections: T#%d\n", gtid));
1221
1222 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
1223 if (num_threads != 0) {
1224 __kmp_push_num_threads(&loc, gtid, num_threads);
1225 }
1226 if(flags != 0) {
1227 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
1228 }
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001229 __kmp_GOMP_fork_call(&loc, gtid, task,
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001230 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, task, data,
1231 num_threads, &loc, kmp_nm_dynamic_chunked, (kmp_int)1,
1232 (kmp_int)count, (kmp_int)1, (kmp_int)1);
1233 }
1234 else {
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001235 __kmp_GOMP_serialized_parallel(&loc, gtid, task);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001236 }
1237
1238 KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
1239
1240 task(data);
1241 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
1242 KA_TRACE(20, ("GOMP_parallel_sections exit: T#%d\n", gtid));
1243}
1244
Jonas Hahnfeld848d6902016-09-14 13:59:39 +00001245#define PARALLEL_LOOP(func, schedule, ompt_pre, ompt_post) \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001246 void func (void (*task) (void *), void *data, unsigned num_threads, \
1247 long lb, long ub, long str, long chunk_sz, unsigned flags) \
1248 { \
1249 int gtid = __kmp_entry_gtid(); \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001250 MKLOC(loc, #func); \
1251 KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
1252 gtid, lb, ub, str, chunk_sz )); \
1253 \
Jonas Hahnfeld848d6902016-09-14 13:59:39 +00001254 ompt_pre(); \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001255 if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) { \
1256 if (num_threads != 0) { \
1257 __kmp_push_num_threads(&loc, gtid, num_threads); \
1258 } \
1259 if (flags != 0) { \
1260 __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags); \
1261 } \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001262 __kmp_GOMP_fork_call(&loc, gtid, task, \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001263 (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, \
1264 task, data, num_threads, &loc, (schedule), lb, \
1265 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz); \
1266 } \
1267 else { \
Andrey Churbanovd7d088f2015-04-29 16:42:24 +00001268 __kmp_GOMP_serialized_parallel(&loc, gtid, task); \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001269 } \
1270 \
1271 KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
1272 (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
1273 (schedule) != kmp_sch_static); \
1274 task(data); \
1275 xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(); \
Jonas Hahnfeld848d6902016-09-14 13:59:39 +00001276 ompt_post(); \
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001277 \
1278 KA_TRACE(20, ( #func " exit: T#%d\n", gtid)); \
1279 }
1280
Jonas Hahnfeld848d6902016-09-14 13:59:39 +00001281PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC), kmp_sch_static,
1282 OMPT_LOOP_PRE, OMPT_LOOP_POST)
1283PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC), kmp_sch_dynamic_chunked,
1284 OMPT_LOOP_PRE, OMPT_LOOP_POST)
1285PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED), kmp_sch_guided_chunked,
1286 OMPT_LOOP_PRE, OMPT_LOOP_POST)
1287PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME), kmp_sch_runtime,
1288 OMPT_LOOP_PRE, OMPT_LOOP_POST)
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001289
1290
1291void
1292xexpand(KMP_API_NAME_GOMP_TASKGROUP_START)(void)
1293{
Jonas Hahnfeldad0c42e2016-08-08 13:23:08 +00001294 int gtid = __kmp_entry_gtid();
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001295 MKLOC(loc, "GOMP_taskgroup_start");
1296 KA_TRACE(20, ("GOMP_taskgroup_start: T#%d\n", gtid));
1297
1298 __kmpc_taskgroup(&loc, gtid);
1299
1300 return;
1301}
1302
1303void
1304xexpand(KMP_API_NAME_GOMP_TASKGROUP_END)(void)
1305{
1306 int gtid = __kmp_get_gtid();
1307 MKLOC(loc, "GOMP_taskgroup_end");
1308 KA_TRACE(20, ("GOMP_taskgroup_end: T#%d\n", gtid));
1309
1310 __kmpc_end_taskgroup(&loc, gtid);
1311
1312 return;
1313}
1314
1315#ifndef KMP_DEBUG
1316static
1317#endif /* KMP_DEBUG */
Jonathan Peyton66338292015-06-01 02:37:28 +00001318kmp_int32 __kmp_gomp_to_omp_cancellation_kind(int gomp_kind) {
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001319 kmp_int32 cncl_kind = 0;
1320 switch(gomp_kind) {
1321 case 1:
1322 cncl_kind = cancel_parallel;
1323 break;
1324 case 2:
1325 cncl_kind = cancel_loop;
1326 break;
1327 case 4:
1328 cncl_kind = cancel_sections;
1329 break;
1330 case 8:
1331 cncl_kind = cancel_taskgroup;
1332 break;
1333 }
1334 return cncl_kind;
1335}
1336
1337bool
1338xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(int which)
1339{
1340 if(__kmp_omp_cancellation) {
1341 KMP_FATAL(NoGompCancellation);
1342 }
1343 int gtid = __kmp_get_gtid();
1344 MKLOC(loc, "GOMP_cancellation_point");
1345 KA_TRACE(20, ("GOMP_cancellation_point: T#%d\n", gtid));
1346
Jonathan Peyton66338292015-06-01 02:37:28 +00001347 kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001348
1349 return __kmpc_cancellationpoint(&loc, gtid, cncl_kind);
1350}
1351
1352bool
1353xexpand(KMP_API_NAME_GOMP_BARRIER_CANCEL)(void)
1354{
1355 if(__kmp_omp_cancellation) {
1356 KMP_FATAL(NoGompCancellation);
1357 }
1358 KMP_FATAL(NoGompCancellation);
1359 int gtid = __kmp_get_gtid();
1360 MKLOC(loc, "GOMP_barrier_cancel");
1361 KA_TRACE(20, ("GOMP_barrier_cancel: T#%d\n", gtid));
1362
1363 return __kmpc_cancel_barrier(&loc, gtid);
1364}
1365
1366bool
1367xexpand(KMP_API_NAME_GOMP_CANCEL)(int which, bool do_cancel)
1368{
1369 if(__kmp_omp_cancellation) {
1370 KMP_FATAL(NoGompCancellation);
1371 } else {
1372 return FALSE;
1373 }
1374
1375 int gtid = __kmp_get_gtid();
1376 MKLOC(loc, "GOMP_cancel");
1377 KA_TRACE(20, ("GOMP_cancel: T#%d\n", gtid));
1378
Jonathan Peyton66338292015-06-01 02:37:28 +00001379 kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001380
1381 if(do_cancel == FALSE) {
1382 return xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(which);
1383 } else {
1384 return __kmpc_cancel(&loc, gtid, cncl_kind);
1385 }
1386}
1387
1388bool
1389xexpand(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL)(void)
1390{
1391 if(__kmp_omp_cancellation) {
1392 KMP_FATAL(NoGompCancellation);
1393 }
1394 int gtid = __kmp_get_gtid();
1395 MKLOC(loc, "GOMP_sections_end_cancel");
1396 KA_TRACE(20, ("GOMP_sections_end_cancel: T#%d\n", gtid));
1397
1398 return __kmpc_cancel_barrier(&loc, gtid);
1399}
1400
1401bool
1402xexpand(KMP_API_NAME_GOMP_LOOP_END_CANCEL)(void)
1403{
1404 if(__kmp_omp_cancellation) {
1405 KMP_FATAL(NoGompCancellation);
1406 }
1407 int gtid = __kmp_get_gtid();
1408 MKLOC(loc, "GOMP_loop_end_cancel");
1409 KA_TRACE(20, ("GOMP_loop_end_cancel: T#%d\n", gtid));
1410
1411 return __kmpc_cancel_barrier(&loc, gtid);
1412}
1413
1414// All target functions are empty as of 2014-05-29
1415void
1416xexpand(KMP_API_NAME_GOMP_TARGET)(int device, void (*fn) (void *), const void *openmp_target,
1417 size_t mapnum, void **hostaddrs, size_t *sizes, unsigned char *kinds)
1418{
1419 return;
1420}
1421
1422void
1423xexpand(KMP_API_NAME_GOMP_TARGET_DATA)(int device, const void *openmp_target, size_t mapnum,
1424 void **hostaddrs, size_t *sizes, unsigned char *kinds)
1425{
1426 return;
1427}
1428
1429void
1430xexpand(KMP_API_NAME_GOMP_TARGET_END_DATA)(void)
1431{
1432 return;
1433}
1434
1435void
1436xexpand(KMP_API_NAME_GOMP_TARGET_UPDATE)(int device, const void *openmp_target, size_t mapnum,
1437 void **hostaddrs, size_t *sizes, unsigned char *kinds)
1438{
1439 return;
1440}
1441
1442void
1443xexpand(KMP_API_NAME_GOMP_TEAMS)(unsigned int num_teams, unsigned int thread_limit)
1444{
1445 return;
1446}
1447#endif // OMP_40_ENABLED
1448
1449
Jim Cownie181b4bb2013-12-23 17:28:57 +00001450/*
1451 The following sections of code create aliases for the GOMP_* functions,
1452 then create versioned symbols using the assembler directive .symver.
1453 This is only pertinent for ELF .so library
1454 xaliasify and xversionify are defined in kmp_ftn_os.h
1455*/
1456
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001457#ifdef KMP_USE_VERSION_SYMBOLS
Jim Cownie181b4bb2013-12-23 17:28:57 +00001458
1459// GOMP_1.0 aliases
1460xaliasify(KMP_API_NAME_GOMP_ATOMIC_END, 10);
1461xaliasify(KMP_API_NAME_GOMP_ATOMIC_START, 10);
1462xaliasify(KMP_API_NAME_GOMP_BARRIER, 10);
1463xaliasify(KMP_API_NAME_GOMP_CRITICAL_END, 10);
1464xaliasify(KMP_API_NAME_GOMP_CRITICAL_NAME_END, 10);
1465xaliasify(KMP_API_NAME_GOMP_CRITICAL_NAME_START, 10);
1466xaliasify(KMP_API_NAME_GOMP_CRITICAL_START, 10);
1467xaliasify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT, 10);
1468xaliasify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START, 10);
1469xaliasify(KMP_API_NAME_GOMP_LOOP_END, 10);
1470xaliasify(KMP_API_NAME_GOMP_LOOP_END_NOWAIT, 10);
1471xaliasify(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT, 10);
1472xaliasify(KMP_API_NAME_GOMP_LOOP_GUIDED_START, 10);
1473xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT, 10);
1474xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START, 10);
1475xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT, 10);
1476xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START, 10);
1477xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT, 10);
1478xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START, 10);
1479xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT, 10);
1480xaliasify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START, 10);
1481xaliasify(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT, 10);
1482xaliasify(KMP_API_NAME_GOMP_LOOP_RUNTIME_START, 10);
1483xaliasify(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT, 10);
1484xaliasify(KMP_API_NAME_GOMP_LOOP_STATIC_START, 10);
1485xaliasify(KMP_API_NAME_GOMP_ORDERED_END, 10);
1486xaliasify(KMP_API_NAME_GOMP_ORDERED_START, 10);
1487xaliasify(KMP_API_NAME_GOMP_PARALLEL_END, 10);
1488xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START, 10);
1489xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START, 10);
1490xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START, 10);
1491xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START, 10);
1492xaliasify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START, 10);
1493xaliasify(KMP_API_NAME_GOMP_PARALLEL_START, 10);
1494xaliasify(KMP_API_NAME_GOMP_SECTIONS_END, 10);
1495xaliasify(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT, 10);
1496xaliasify(KMP_API_NAME_GOMP_SECTIONS_NEXT, 10);
1497xaliasify(KMP_API_NAME_GOMP_SECTIONS_START, 10);
1498xaliasify(KMP_API_NAME_GOMP_SINGLE_COPY_END, 10);
1499xaliasify(KMP_API_NAME_GOMP_SINGLE_COPY_START, 10);
1500xaliasify(KMP_API_NAME_GOMP_SINGLE_START, 10);
1501
1502// GOMP_2.0 aliases
Jim Cownie181b4bb2013-12-23 17:28:57 +00001503xaliasify(KMP_API_NAME_GOMP_TASK, 20);
1504xaliasify(KMP_API_NAME_GOMP_TASKWAIT, 20);
Jim Cownie181b4bb2013-12-23 17:28:57 +00001505xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT, 20);
1506xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START, 20);
1507xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT, 20);
1508xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START, 20);
1509xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT, 20);
1510xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START, 20);
1511xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT, 20);
1512xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START, 20);
1513xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT, 20);
1514xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START, 20);
1515xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT, 20);
1516xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START, 20);
1517xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT, 20);
1518xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START, 20);
1519xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT, 20);
1520xaliasify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START, 20);
1521
1522// GOMP_3.0 aliases
1523xaliasify(KMP_API_NAME_GOMP_TASKYIELD, 30);
1524
1525// GOMP_4.0 aliases
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001526// The GOMP_parallel* entry points below aren't OpenMP 4.0 related.
1527#if OMP_40_ENABLED
1528xaliasify(KMP_API_NAME_GOMP_PARALLEL, 40);
1529xaliasify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS, 40);
1530xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC, 40);
1531xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED, 40);
1532xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME, 40);
1533xaliasify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC, 40);
1534xaliasify(KMP_API_NAME_GOMP_TASKGROUP_START, 40);
1535xaliasify(KMP_API_NAME_GOMP_TASKGROUP_END, 40);
1536xaliasify(KMP_API_NAME_GOMP_BARRIER_CANCEL, 40);
1537xaliasify(KMP_API_NAME_GOMP_CANCEL, 40);
1538xaliasify(KMP_API_NAME_GOMP_CANCELLATION_POINT, 40);
1539xaliasify(KMP_API_NAME_GOMP_LOOP_END_CANCEL, 40);
1540xaliasify(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL, 40);
1541xaliasify(KMP_API_NAME_GOMP_TARGET, 40);
1542xaliasify(KMP_API_NAME_GOMP_TARGET_DATA, 40);
1543xaliasify(KMP_API_NAME_GOMP_TARGET_END_DATA, 40);
1544xaliasify(KMP_API_NAME_GOMP_TARGET_UPDATE, 40);
1545xaliasify(KMP_API_NAME_GOMP_TEAMS, 40);
1546#endif
Jim Cownie181b4bb2013-12-23 17:28:57 +00001547
1548// GOMP_1.0 versioned symbols
1549xversionify(KMP_API_NAME_GOMP_ATOMIC_END, 10, "GOMP_1.0");
1550xversionify(KMP_API_NAME_GOMP_ATOMIC_START, 10, "GOMP_1.0");
1551xversionify(KMP_API_NAME_GOMP_BARRIER, 10, "GOMP_1.0");
1552xversionify(KMP_API_NAME_GOMP_CRITICAL_END, 10, "GOMP_1.0");
1553xversionify(KMP_API_NAME_GOMP_CRITICAL_NAME_END, 10, "GOMP_1.0");
1554xversionify(KMP_API_NAME_GOMP_CRITICAL_NAME_START, 10, "GOMP_1.0");
1555xversionify(KMP_API_NAME_GOMP_CRITICAL_START, 10, "GOMP_1.0");
1556xversionify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT, 10, "GOMP_1.0");
1557xversionify(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START, 10, "GOMP_1.0");
1558xversionify(KMP_API_NAME_GOMP_LOOP_END, 10, "GOMP_1.0");
1559xversionify(KMP_API_NAME_GOMP_LOOP_END_NOWAIT, 10, "GOMP_1.0");
1560xversionify(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT, 10, "GOMP_1.0");
1561xversionify(KMP_API_NAME_GOMP_LOOP_GUIDED_START, 10, "GOMP_1.0");
1562xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT, 10, "GOMP_1.0");
1563xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START, 10, "GOMP_1.0");
1564xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT, 10, "GOMP_1.0");
1565xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START, 10, "GOMP_1.0");
1566xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT, 10, "GOMP_1.0");
1567xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START, 10, "GOMP_1.0");
1568xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT, 10, "GOMP_1.0");
1569xversionify(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START, 10, "GOMP_1.0");
1570xversionify(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT, 10, "GOMP_1.0");
1571xversionify(KMP_API_NAME_GOMP_LOOP_RUNTIME_START, 10, "GOMP_1.0");
1572xversionify(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT, 10, "GOMP_1.0");
1573xversionify(KMP_API_NAME_GOMP_LOOP_STATIC_START, 10, "GOMP_1.0");
1574xversionify(KMP_API_NAME_GOMP_ORDERED_END, 10, "GOMP_1.0");
1575xversionify(KMP_API_NAME_GOMP_ORDERED_START, 10, "GOMP_1.0");
1576xversionify(KMP_API_NAME_GOMP_PARALLEL_END, 10, "GOMP_1.0");
1577xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START, 10, "GOMP_1.0");
1578xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START, 10, "GOMP_1.0");
1579xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START, 10, "GOMP_1.0");
1580xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START, 10, "GOMP_1.0");
1581xversionify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START, 10, "GOMP_1.0");
1582xversionify(KMP_API_NAME_GOMP_PARALLEL_START, 10, "GOMP_1.0");
1583xversionify(KMP_API_NAME_GOMP_SECTIONS_END, 10, "GOMP_1.0");
1584xversionify(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT, 10, "GOMP_1.0");
1585xversionify(KMP_API_NAME_GOMP_SECTIONS_NEXT, 10, "GOMP_1.0");
1586xversionify(KMP_API_NAME_GOMP_SECTIONS_START, 10, "GOMP_1.0");
1587xversionify(KMP_API_NAME_GOMP_SINGLE_COPY_END, 10, "GOMP_1.0");
1588xversionify(KMP_API_NAME_GOMP_SINGLE_COPY_START, 10, "GOMP_1.0");
1589xversionify(KMP_API_NAME_GOMP_SINGLE_START, 10, "GOMP_1.0");
1590
1591// GOMP_2.0 versioned symbols
Jim Cownie181b4bb2013-12-23 17:28:57 +00001592xversionify(KMP_API_NAME_GOMP_TASK, 20, "GOMP_2.0");
1593xversionify(KMP_API_NAME_GOMP_TASKWAIT, 20, "GOMP_2.0");
Jim Cownie181b4bb2013-12-23 17:28:57 +00001594xversionify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT, 20, "GOMP_2.0");
1595xversionify(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START, 20, "GOMP_2.0");
1596xversionify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT, 20, "GOMP_2.0");
1597xversionify(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START, 20, "GOMP_2.0");
1598xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT, 20, "GOMP_2.0");
1599xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START, 20, "GOMP_2.0");
1600xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT, 20, "GOMP_2.0");
1601xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START, 20, "GOMP_2.0");
1602xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT, 20, "GOMP_2.0");
1603xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START, 20, "GOMP_2.0");
1604xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT, 20, "GOMP_2.0");
1605xversionify(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START, 20, "GOMP_2.0");
1606xversionify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT, 20, "GOMP_2.0");
1607xversionify(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START, 20, "GOMP_2.0");
1608xversionify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT, 20, "GOMP_2.0");
1609xversionify(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START, 20, "GOMP_2.0");
1610
1611// GOMP_3.0 versioned symbols
1612xversionify(KMP_API_NAME_GOMP_TASKYIELD, 30, "GOMP_3.0");
1613
1614// GOMP_4.0 versioned symbols
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001615#if OMP_40_ENABLED
1616xversionify(KMP_API_NAME_GOMP_PARALLEL, 40, "GOMP_4.0");
1617xversionify(KMP_API_NAME_GOMP_PARALLEL_SECTIONS, 40, "GOMP_4.0");
1618xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC, 40, "GOMP_4.0");
1619xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED, 40, "GOMP_4.0");
1620xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME, 40, "GOMP_4.0");
1621xversionify(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC, 40, "GOMP_4.0");
1622xversionify(KMP_API_NAME_GOMP_TASKGROUP_START, 40, "GOMP_4.0");
1623xversionify(KMP_API_NAME_GOMP_TASKGROUP_END, 40, "GOMP_4.0");
1624xversionify(KMP_API_NAME_GOMP_BARRIER_CANCEL, 40, "GOMP_4.0");
1625xversionify(KMP_API_NAME_GOMP_CANCEL, 40, "GOMP_4.0");
1626xversionify(KMP_API_NAME_GOMP_CANCELLATION_POINT, 40, "GOMP_4.0");
1627xversionify(KMP_API_NAME_GOMP_LOOP_END_CANCEL, 40, "GOMP_4.0");
1628xversionify(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL, 40, "GOMP_4.0");
1629xversionify(KMP_API_NAME_GOMP_TARGET, 40, "GOMP_4.0");
1630xversionify(KMP_API_NAME_GOMP_TARGET_DATA, 40, "GOMP_4.0");
1631xversionify(KMP_API_NAME_GOMP_TARGET_END_DATA, 40, "GOMP_4.0");
1632xversionify(KMP_API_NAME_GOMP_TARGET_UPDATE, 40, "GOMP_4.0");
1633xversionify(KMP_API_NAME_GOMP_TEAMS, 40, "GOMP_4.0");
1634#endif
Jim Cownie181b4bb2013-12-23 17:28:57 +00001635
Jim Cownie4cc4bb42014-10-07 16:25:50 +00001636#endif // KMP_USE_VERSION_SYMBOLS
Jim Cownie181b4bb2013-12-23 17:28:57 +00001637
Jim Cownie5e8470a2013-09-27 10:38:44 +00001638#ifdef __cplusplus
1639 } //extern "C"
1640#endif // __cplusplus
1641
1642