oacc-async.c revision 1.1.1.1 1 1.1 mrg /* OpenACC Runtime Library Definitions.
2 1.1 mrg
3 1.1 mrg Copyright (C) 2013-2015 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.1 mrg void
74 1.1 mrg acc_wait_async (int async1, int async2)
75 1.1 mrg {
76 1.1 mrg struct goacc_thread *thr = goacc_thread ();
77 1.1 mrg
78 1.1 mrg if (!thr || !thr->dev)
79 1.1 mrg gomp_fatal ("no device active");
80 1.1 mrg
81 1.1 mrg thr->dev->openacc.async_wait_async_func (async1, async2);
82 1.1 mrg }
83 1.1 mrg
84 1.1 mrg void
85 1.1 mrg acc_wait_all (void)
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_all_func ();
93 1.1 mrg }
94 1.1 mrg
95 1.1 mrg void
96 1.1 mrg acc_wait_all_async (int async)
97 1.1 mrg {
98 1.1 mrg if (async < acc_async_sync)
99 1.1 mrg gomp_fatal ("invalid async argument: %d", async);
100 1.1 mrg
101 1.1 mrg struct goacc_thread *thr = goacc_thread ();
102 1.1 mrg
103 1.1 mrg if (!thr || !thr->dev)
104 1.1 mrg gomp_fatal ("no device active");
105 1.1 mrg
106 1.1 mrg thr->dev->openacc.async_wait_all_async_func (async);
107 1.1 mrg }
108