1 /* OpenACC Runtime Library: acc_device_host.
3 Copyright (C) 2013-2019 Free Software Foundation, Inc.
5 Contributed by Mentor Embedded.
7 This file is part of the GNU Offloading and Multi Processing Library
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)
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
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/>. */
31 #include "gomp-constants.h"
36 static struct gomp_device_descr host_dispatch
;
41 return host_dispatch
.name
;
47 return host_dispatch
.capabilities
;
53 return host_dispatch
.type
;
57 host_get_num_devices (void)
63 host_init_device (int n
__attribute__ ((unused
)))
69 host_fini_device (int n
__attribute__ ((unused
)))
81 host_load_image (int n
__attribute__ ((unused
)),
82 unsigned v
__attribute__ ((unused
)),
83 const void *t
__attribute__ ((unused
)),
84 struct addr_pair
**r
__attribute__ ((unused
)))
90 host_unload_image (int n
__attribute__ ((unused
)),
91 unsigned v
__attribute__ ((unused
)),
92 const void *t
__attribute__ ((unused
)))
98 host_alloc (int n
__attribute__ ((unused
)), size_t s
)
100 return gomp_malloc (s
);
104 host_free (int n
__attribute__ ((unused
)), void *p
)
111 host_dev2host (int n
__attribute__ ((unused
)),
112 void *h
__attribute__ ((unused
)),
113 const void *d
__attribute__ ((unused
)),
114 size_t s
__attribute__ ((unused
)))
120 host_host2dev (int n
__attribute__ ((unused
)),
121 void *d
__attribute__ ((unused
)),
122 const void *h
__attribute__ ((unused
)),
123 size_t s
__attribute__ ((unused
)))
129 host_run (int n
__attribute__ ((unused
)), void *fn_ptr
, void *vars
,
130 void **args
__attribute__((unused
)))
132 void (*fn
)(void *) = (void (*)(void *)) fn_ptr
;
138 host_openacc_exec (void (*fn
) (void *),
139 size_t mapnum
__attribute__ ((unused
)),
141 void **devaddrs
__attribute__ ((unused
)),
142 unsigned *dims
__attribute__ ((unused
)),
143 void *targ_mem_desc
__attribute__ ((unused
)))
149 host_openacc_async_exec (void (*fn
) (void *),
150 size_t mapnum
__attribute__ ((unused
)),
152 void **devaddrs
__attribute__ ((unused
)),
153 unsigned *dims
__attribute__ ((unused
)),
154 void *targ_mem_desc
__attribute__ ((unused
)),
155 struct goacc_asyncqueue
*aq
__attribute__ ((unused
)))
161 host_openacc_async_test (struct goacc_asyncqueue
*aq
__attribute__ ((unused
)))
167 host_openacc_async_synchronize (struct goacc_asyncqueue
*aq
168 __attribute__ ((unused
)))
174 host_openacc_async_serialize (struct goacc_asyncqueue
*aq1
175 __attribute__ ((unused
)),
176 struct goacc_asyncqueue
*aq2
177 __attribute__ ((unused
)))
183 host_openacc_async_host2dev (int ord
__attribute__ ((unused
)),
184 void *dst
__attribute__ ((unused
)),
185 const void *src
__attribute__ ((unused
)),
186 size_t n
__attribute__ ((unused
)),
187 struct goacc_asyncqueue
*aq
188 __attribute__ ((unused
)))
194 host_openacc_async_dev2host (int ord
__attribute__ ((unused
)),
195 void *dst
__attribute__ ((unused
)),
196 const void *src
__attribute__ ((unused
)),
197 size_t n
__attribute__ ((unused
)),
198 struct goacc_asyncqueue
*aq
199 __attribute__ ((unused
)))
205 host_openacc_async_queue_callback (struct goacc_asyncqueue
*aq
206 __attribute__ ((unused
)),
207 void (*callback_fn
)(void *)
208 __attribute__ ((unused
)),
209 void *userptr
__attribute__ ((unused
)))
213 static struct goacc_asyncqueue
*
214 host_openacc_async_construct (void)
216 /* Non-NULL 0xffff... value as opaque dummy. */
217 return (struct goacc_asyncqueue
*) -1;
221 host_openacc_async_destruct (struct goacc_asyncqueue
*aq
222 __attribute__ ((unused
)))
228 host_openacc_create_thread_data (int ord
__attribute__ ((unused
)))
234 host_openacc_destroy_thread_data (void *tls_data
__attribute__ ((unused
)))
238 static struct gomp_device_descr host_dispatch
=
241 .capabilities
= (GOMP_OFFLOAD_CAP_SHARED_MEM
242 | GOMP_OFFLOAD_CAP_NATIVE_EXEC
243 | GOMP_OFFLOAD_CAP_OPENACC_200
),
245 .type
= OFFLOAD_TARGET_TYPE_HOST
,
247 .get_name_func
= host_get_name
,
248 .get_caps_func
= host_get_caps
,
249 .get_type_func
= host_get_type
,
250 .get_num_devices_func
= host_get_num_devices
,
251 .init_device_func
= host_init_device
,
252 .fini_device_func
= host_fini_device
,
253 .version_func
= host_version
,
254 .load_image_func
= host_load_image
,
255 .unload_image_func
= host_unload_image
,
256 .alloc_func
= host_alloc
,
257 .free_func
= host_free
,
258 .dev2host_func
= host_dev2host
,
259 .host2dev_func
= host_host2dev
,
260 .run_func
= host_run
,
263 /* .lock initilized in goacc_host_init. */
264 .state
= GOMP_DEVICE_UNINITIALIZED
,
267 .data_environ
= NULL
,
269 .exec_func
= host_openacc_exec
,
271 .create_thread_data_func
= host_openacc_create_thread_data
,
272 .destroy_thread_data_func
= host_openacc_destroy_thread_data
,
275 .construct_func
= host_openacc_async_construct
,
276 .destruct_func
= host_openacc_async_destruct
,
277 .test_func
= host_openacc_async_test
,
278 .synchronize_func
= host_openacc_async_synchronize
,
279 .serialize_func
= host_openacc_async_serialize
,
280 .queue_callback_func
= host_openacc_async_queue_callback
,
281 .exec_func
= host_openacc_async_exec
,
282 .dev2host_func
= host_openacc_async_dev2host
,
283 .host2dev_func
= host_openacc_async_host2dev
,
287 .get_current_device_func
= NULL
,
288 .get_current_context_func
= NULL
,
289 .get_stream_func
= NULL
,
290 .set_stream_func
= NULL
,
295 /* Initialize and register this device type. */
297 goacc_host_init (void)
299 gomp_mutex_init (&host_dispatch
.lock
);
300 goacc_register (&host_dispatch
);