* config.gcc (powerpc-ibm-aix[6789]) [default_use_cxa_atexit]:
[official-gcc.git] / libgomp / oacc-host.c
blob8e4ba04b465abe2d337814b393be11474e7634ee
1 /* OpenACC Runtime Library: acc_device_host.
3 Copyright (C) 2013-2015 Free Software Foundation, Inc.
5 Contributed by Mentor Embedded.
7 This file is part of the GNU Offloading and Multi Processing Library
8 (libgomp).
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.
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.
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.
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/>. */
29 #include "libgomp.h"
30 #include "oacc-int.h"
31 #include "gomp-constants.h"
33 #include <stdbool.h>
34 #include <stddef.h>
35 #include <stdint.h>
37 static struct gomp_device_descr host_dispatch;
39 static const char *
40 host_get_name (void)
42 return host_dispatch.name;
45 static unsigned int
46 host_get_caps (void)
48 return host_dispatch.capabilities;
51 static int
52 host_get_type (void)
54 return host_dispatch.type;
57 static int
58 host_get_num_devices (void)
60 return 1;
63 static void
64 host_init_device (int n __attribute__ ((unused)))
68 static void
69 host_fini_device (int n __attribute__ ((unused)))
73 static unsigned
74 host_version (void)
76 return GOMP_VERSION;
79 static int
80 host_load_image (int n __attribute__ ((unused)),
81 unsigned v __attribute__ ((unused)),
82 const void *t __attribute__ ((unused)),
83 struct addr_pair **r __attribute__ ((unused)))
85 return 0;
88 static void
89 host_unload_image (int n __attribute__ ((unused)),
90 unsigned v __attribute__ ((unused)),
91 const void *t __attribute__ ((unused)))
95 static void *
96 host_alloc (int n __attribute__ ((unused)), size_t s)
98 return gomp_malloc (s);
101 static void
102 host_free (int n __attribute__ ((unused)), void *p)
104 free (p);
107 static void *
108 host_dev2host (int n __attribute__ ((unused)),
109 void *h __attribute__ ((unused)),
110 const void *d __attribute__ ((unused)),
111 size_t s __attribute__ ((unused)))
113 return NULL;
116 static void *
117 host_host2dev (int n __attribute__ ((unused)),
118 void *d __attribute__ ((unused)),
119 const void *h __attribute__ ((unused)),
120 size_t s __attribute__ ((unused)))
122 return NULL;
125 static void
126 host_run (int n __attribute__ ((unused)), void *fn_ptr, void *vars)
128 void (*fn)(void *) = (void (*)(void *)) fn_ptr;
130 fn (vars);
133 static void
134 host_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 async __attribute__ ((unused)),
141 unsigned *dims __attribute ((unused)),
142 void *targ_mem_desc __attribute__ ((unused)))
144 fn (hostaddrs);
147 static void
148 host_openacc_register_async_cleanup (void *targ_mem_desc __attribute__ ((unused)))
152 static int
153 host_openacc_async_test (int async __attribute__ ((unused)))
155 return 1;
158 static int
159 host_openacc_async_test_all (void)
161 return 1;
164 static void
165 host_openacc_async_wait (int async __attribute__ ((unused)))
169 static void
170 host_openacc_async_wait_async (int async1 __attribute__ ((unused)),
171 int async2 __attribute__ ((unused)))
175 static void
176 host_openacc_async_wait_all (void)
180 static void
181 host_openacc_async_wait_all_async (int async __attribute__ ((unused)))
185 static void
186 host_openacc_async_set_async (int async __attribute__ ((unused)))
190 static void *
191 host_openacc_create_thread_data (int ord __attribute__ ((unused)))
193 return NULL;
196 static void
197 host_openacc_destroy_thread_data (void *tls_data __attribute__ ((unused)))
201 static struct gomp_device_descr host_dispatch =
203 .name = "host",
204 .capabilities = (GOMP_OFFLOAD_CAP_SHARED_MEM
205 | GOMP_OFFLOAD_CAP_NATIVE_EXEC
206 | GOMP_OFFLOAD_CAP_OPENACC_200),
207 .target_id = 0,
208 .type = OFFLOAD_TARGET_TYPE_HOST,
210 .get_name_func = host_get_name,
211 .get_caps_func = host_get_caps,
212 .get_type_func = host_get_type,
213 .get_num_devices_func = host_get_num_devices,
214 .init_device_func = host_init_device,
215 .fini_device_func = host_fini_device,
216 .version_func = host_version,
217 .load_image_func = host_load_image,
218 .unload_image_func = host_unload_image,
219 .alloc_func = host_alloc,
220 .free_func = host_free,
221 .dev2host_func = host_dev2host,
222 .host2dev_func = host_host2dev,
223 .run_func = host_run,
225 .mem_map = { NULL },
226 /* .lock initilized in goacc_host_init. */
227 .is_initialized = false,
229 .openacc = {
230 .data_environ = NULL,
232 .exec_func = host_openacc_exec,
234 .register_async_cleanup_func = host_openacc_register_async_cleanup,
236 .async_test_func = host_openacc_async_test,
237 .async_test_all_func = host_openacc_async_test_all,
238 .async_wait_func = host_openacc_async_wait,
239 .async_wait_async_func = host_openacc_async_wait_async,
240 .async_wait_all_func = host_openacc_async_wait_all,
241 .async_wait_all_async_func = host_openacc_async_wait_all_async,
242 .async_set_async_func = host_openacc_async_set_async,
244 .create_thread_data_func = host_openacc_create_thread_data,
245 .destroy_thread_data_func = host_openacc_destroy_thread_data,
247 .cuda = {
248 .get_current_device_func = NULL,
249 .get_current_context_func = NULL,
250 .get_stream_func = NULL,
251 .set_stream_func = NULL,
256 /* Initialize and register this device type. */
257 void
258 goacc_host_init (void)
260 gomp_mutex_init (&host_dispatch.lock);
261 goacc_register (&host_dispatch);