]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgomp/oacc-host.c
libgomp.map: Add 4.0.2 version.
[thirdparty/gcc.git] / libgomp / oacc-host.c
CommitLineData
41dbbb37
TS
1/* OpenACC Runtime Library: acc_device_host.
2
3 Copyright (C) 2013-2015 Free Software Foundation, Inc.
4
5 Contributed by Mentor Embedded.
6
7 This file is part of the GNU Offloading and Multi Processing Library
8 (libgomp).
9
10 Libgomp is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3, or (at your option)
13 any later version.
14
15 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 more details.
19
20 Under Section 7 of GPL version 3, you are granted additional
21 permissions described in the GCC Runtime Library Exception, version
22 3.1, as published by the Free Software Foundation.
23
24 You should have received a copy of the GNU General Public License and
25 a copy of the GCC Runtime Library Exception along with this program;
26 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
27 <http://www.gnu.org/licenses/>. */
28
b97e78b7
TS
29#include "libgomp.h"
30#include "oacc-int.h"
2a21ff19 31#include "gomp-constants.h"
b97e78b7
TS
32
33#include <stdbool.h>
34#include <stddef.h>
35#include <stdint.h>
36
37static struct gomp_device_descr host_dispatch;
38
39static const char *
40host_get_name (void)
41{
42 return host_dispatch.name;
43}
44
45static unsigned int
46host_get_caps (void)
47{
48 return host_dispatch.capabilities;
49}
50
51static int
52host_get_type (void)
53{
54 return host_dispatch.type;
55}
56
57static int
58host_get_num_devices (void)
59{
60 return 1;
61}
62
63static void
64host_init_device (int n __attribute__ ((unused)))
65{
66}
67
68static void
69host_fini_device (int n __attribute__ ((unused)))
70{
71}
72
2a21ff19
NS
73static unsigned
74host_version (void)
75{
76 return GOMP_VERSION;
77}
78
b97e78b7
TS
79static int
80host_load_image (int n __attribute__ ((unused)),
2a21ff19 81 unsigned v __attribute__ ((unused)),
b97e78b7
TS
82 const void *t __attribute__ ((unused)),
83 struct addr_pair **r __attribute__ ((unused)))
84{
85 return 0;
86}
87
88static void
89host_unload_image (int n __attribute__ ((unused)),
2a21ff19 90 unsigned v __attribute__ ((unused)),
b97e78b7
TS
91 const void *t __attribute__ ((unused)))
92{
93}
94
95static void *
96host_alloc (int n __attribute__ ((unused)), size_t s)
97{
98 return gomp_malloc (s);
99}
100
101static void
102host_free (int n __attribute__ ((unused)), void *p)
103{
104 free (p);
105}
106
107static void *
108host_dev2host (int n __attribute__ ((unused)),
109 void *h __attribute__ ((unused)),
110 const void *d __attribute__ ((unused)),
111 size_t s __attribute__ ((unused)))
112{
113 return NULL;
114}
115
116static void *
117host_host2dev (int n __attribute__ ((unused)),
118 void *d __attribute__ ((unused)),
119 const void *h __attribute__ ((unused)),
120 size_t s __attribute__ ((unused)))
121{
122 return NULL;
123}
124
125static void
126host_run (int n __attribute__ ((unused)), void *fn_ptr, void *vars)
127{
128 void (*fn)(void *) = (void (*)(void *)) fn_ptr;
129
130 fn (vars);
131}
132
133static void
134host_openacc_exec (void (*fn) (void *),
135 size_t mapnum __attribute__ ((unused)),
136 void **hostaddrs,
137 void **devaddrs __attribute__ ((unused)),
138 size_t *sizes __attribute__ ((unused)),
139 unsigned short *kinds __attribute__ ((unused)),
140 int num_gangs __attribute__ ((unused)),
141 int num_workers __attribute__ ((unused)),
142 int vector_length __attribute__ ((unused)),
143 int async __attribute__ ((unused)),
144 void *targ_mem_desc __attribute__ ((unused)))
145{
146 fn (hostaddrs);
147}
148
149static void
150host_openacc_register_async_cleanup (void *targ_mem_desc __attribute__ ((unused)))
151{
152}
153
154static int
155host_openacc_async_test (int async __attribute__ ((unused)))
156{
157 return 1;
158}
159
160static int
161host_openacc_async_test_all (void)
162{
163 return 1;
164}
165
166static void
167host_openacc_async_wait (int async __attribute__ ((unused)))
168{
169}
170
171static void
172host_openacc_async_wait_async (int async1 __attribute__ ((unused)),
173 int async2 __attribute__ ((unused)))
174{
175}
176
177static void
178host_openacc_async_wait_all (void)
179{
180}
181
182static void
183host_openacc_async_wait_all_async (int async __attribute__ ((unused)))
184{
185}
186
187static void
188host_openacc_async_set_async (int async __attribute__ ((unused)))
189{
190}
191
192static void *
193host_openacc_create_thread_data (int ord __attribute__ ((unused)))
194{
195 return NULL;
196}
197
198static void
199host_openacc_destroy_thread_data (void *tls_data __attribute__ ((unused)))
200{
201}
41dbbb37
TS
202
203static struct gomp_device_descr host_dispatch =
204 {
205 .name = "host",
b97e78b7 206 .capabilities = (GOMP_OFFLOAD_CAP_SHARED_MEM
41dbbb37 207 | GOMP_OFFLOAD_CAP_NATIVE_EXEC
b97e78b7 208 | GOMP_OFFLOAD_CAP_OPENACC_200),
41dbbb37
TS
209 .target_id = 0,
210 .type = OFFLOAD_TARGET_TYPE_HOST,
211
b97e78b7
TS
212 .get_name_func = host_get_name,
213 .get_caps_func = host_get_caps,
214 .get_type_func = host_get_type,
215 .get_num_devices_func = host_get_num_devices,
216 .init_device_func = host_init_device,
217 .fini_device_func = host_fini_device,
2a21ff19 218 .version_func = host_version,
b97e78b7
TS
219 .load_image_func = host_load_image,
220 .unload_image_func = host_unload_image,
221 .alloc_func = host_alloc,
222 .free_func = host_free,
223 .dev2host_func = host_dev2host,
224 .host2dev_func = host_host2dev,
225 .run_func = host_run,
226
227 .mem_map = { NULL },
228 /* .lock initilized in goacc_host_init. */
41dbbb37 229 .is_initialized = false,
41dbbb37
TS
230
231 .openacc = {
b97e78b7
TS
232 .data_environ = NULL,
233
234 .exec_func = host_openacc_exec,
41dbbb37 235
b97e78b7 236 .register_async_cleanup_func = host_openacc_register_async_cleanup,
41dbbb37 237
b97e78b7
TS
238 .async_test_func = host_openacc_async_test,
239 .async_test_all_func = host_openacc_async_test_all,
240 .async_wait_func = host_openacc_async_wait,
241 .async_wait_async_func = host_openacc_async_wait_async,
242 .async_wait_all_func = host_openacc_async_wait_all,
243 .async_wait_all_async_func = host_openacc_async_wait_all_async,
244 .async_set_async_func = host_openacc_async_set_async,
41dbbb37 245
b97e78b7
TS
246 .create_thread_data_func = host_openacc_create_thread_data,
247 .destroy_thread_data_func = host_openacc_destroy_thread_data,
41dbbb37
TS
248
249 .cuda = {
250 .get_current_device_func = NULL,
251 .get_current_context_func = NULL,
252 .get_stream_func = NULL,
253 .set_stream_func = NULL,
254 }
255 }
256 };
257
b97e78b7
TS
258/* Initialize and register this device type. */
259static __attribute__ ((constructor)) void
260goacc_host_init (void)
41dbbb37 261{
41dbbb37
TS
262 gomp_mutex_init (&host_dispatch.lock);
263 goacc_register (&host_dispatch);
264}