oacc-async.c revision 1.4 1 1.1 mrg /* OpenACC Runtime Library Definitions.
2 1.1 mrg
3 1.4 mrg Copyright (C) 2013-2018 Free Software Foundation, Inc.
4 1.1 mrg
5 1.1 mrg Contributed by Mentor Embedded.
6 1.1 mrg
7 1.1 mrg This file is part of the GNU Offloading and Multi Processing Library
8 1.1 mrg (libgomp).
9 1.1 mrg
10 1.1 mrg Libgomp is free software; you can redistribute it and/or modify it
11 1.1 mrg under the terms of the GNU General Public License as published by
12 1.1 mrg the Free Software Foundation; either version 3, or (at your option)
13 1.1 mrg any later version.
14 1.1 mrg
15 1.1 mrg Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
16 1.1 mrg WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 1.1 mrg FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 1.1 mrg more details.
19 1.1 mrg
20 1.1 mrg Under Section 7 of GPL version 3, you are granted additional
21 1.1 mrg permissions described in the GCC Runtime Library Exception, version
22 1.1 mrg 3.1, as published by the Free Software Foundation.
23 1.1 mrg
24 1.1 mrg You should have received a copy of the GNU General Public License and
25 1.1 mrg a copy of the GCC Runtime Library Exception along with this program;
26 1.1 mrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
27 1.1 mrg <http://www.gnu.org/licenses/>. */
28 1.1 mrg
29 1.1 mrg #include <assert.h>
30 1.1 mrg #include "openacc.h"
31 1.1 mrg #include "libgomp.h"
32 1.1 mrg #include "oacc-int.h"
33 1.1 mrg
34 1.1 mrg int
35 1.1 mrg acc_async_test (int async)
36 1.1 mrg {
37 1.1 mrg if (async < acc_async_sync)
38 1.1 mrg gomp_fatal ("invalid async argument: %d", async);
39 1.1 mrg
40 1.1 mrg struct goacc_thread *thr = goacc_thread ();
41 1.1 mrg
42 1.1 mrg if (!thr || !thr->dev)
43 1.1 mrg gomp_fatal ("no device active");
44 1.1 mrg
45 1.1 mrg return thr->dev->openacc.async_test_func (async);
46 1.1 mrg }
47 1.1 mrg
48 1.1 mrg int
49 1.1 mrg acc_async_test_all (void)
50 1.1 mrg {
51 1.1 mrg struct goacc_thread *thr = goacc_thread ();
52 1.1 mrg
53 1.1 mrg if (!thr || !thr->dev)
54 1.1 mrg gomp_fatal ("no device active");
55 1.1 mrg
56 1.1 mrg return thr->dev->openacc.async_test_all_func ();
57 1.1 mrg }
58 1.1 mrg
59 1.1 mrg void
60 1.1 mrg acc_wait (int async)
61 1.1 mrg {
62 1.1 mrg if (async < acc_async_sync)
63 1.1 mrg gomp_fatal ("invalid async argument: %d", async);
64 1.1 mrg
65 1.1 mrg struct goacc_thread *thr = goacc_thread ();
66 1.1 mrg
67 1.1 mrg if (!thr || !thr->dev)
68 1.1 mrg gomp_fatal ("no device active");
69 1.1 mrg
70 1.1 mrg thr->dev->openacc.async_wait_func (async);
71 1.1 mrg }
72 1.1 mrg
73 1.4 mrg /* acc_async_wait is an OpenACC 1.0 compatibility name for acc_wait. */
74 1.4 mrg #ifdef HAVE_ATTRIBUTE_ALIAS
75 1.4 mrg strong_alias (acc_wait, acc_async_wait)
76 1.4 mrg #else
77 1.4 mrg void
78 1.4 mrg acc_async_wait (int async)
79 1.4 mrg {
80 1.4 mrg acc_wait (async);
81 1.4 mrg }
82 1.4 mrg #endif
83 1.4 mrg
84 1.1 mrg void
85 1.1 mrg acc_wait_async (int async1, int async2)
86 1.1 mrg {
87 1.1 mrg struct goacc_thread *thr = goacc_thread ();
88 1.1 mrg
89 1.1 mrg if (!thr || !thr->dev)
90 1.1 mrg gomp_fatal ("no device active");
91 1.1 mrg
92 1.1 mrg thr->dev->openacc.async_wait_async_func (async1, async2);
93 1.1 mrg }
94 1.1 mrg
95 1.1 mrg void
96 1.1 mrg acc_wait_all (void)
97 1.1 mrg {
98 1.1 mrg struct goacc_thread *thr = goacc_thread ();
99 1.1 mrg
100 1.1 mrg if (!thr || !thr->dev)
101 1.1 mrg gomp_fatal ("no device active");
102 1.1 mrg
103 1.1 mrg thr->dev->openacc.async_wait_all_func ();
104 1.1 mrg }
105 1.1 mrg
106 1.4 mrg /* acc_async_wait_all is an OpenACC 1.0 compatibility name for acc_wait_all. */
107 1.4 mrg #ifdef HAVE_ATTRIBUTE_ALIAS
108 1.4 mrg strong_alias (acc_wait_all, acc_async_wait_all)
109 1.4 mrg #else
110 1.4 mrg void
111 1.4 mrg acc_async_wait_all (void)
112 1.4 mrg {
113 1.4 mrg acc_wait_all ();
114 1.4 mrg }
115 1.4 mrg #endif
116 1.4 mrg
117 1.1 mrg void
118 1.1 mrg acc_wait_all_async (int async)
119 1.1 mrg {
120 1.1 mrg if (async < acc_async_sync)
121 1.1 mrg gomp_fatal ("invalid async argument: %d", async);
122 1.1 mrg
123 1.1 mrg struct goacc_thread *thr = goacc_thread ();
124 1.1 mrg
125 1.1 mrg if (!thr || !thr->dev)
126 1.1 mrg gomp_fatal ("no device active");
127 1.1 mrg
128 1.1 mrg thr->dev->openacc.async_wait_all_async_func (async);
129 1.1 mrg }
130