1 /* OpenACC Runtime Library: acc_device_host, acc_device_host_nonshm.
3 Copyright (C) 2013-2014 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/>. */
29 /* Simple implementation of support routines for a shared-memory
30 acc_device_host, and a non-shared memory acc_device_host_nonshm, with the
31 latter built as a plugin. */
36 #include "libgomp_target.h"
37 #ifdef HOST_NONSHM_PLUGIN
38 #include "libgomp-plugin.h"
39 #include "oacc-plugin.h"
49 #ifdef HOST_NONSHM_PLUGIN
51 #define GOMP(X) GOMP_PLUGIN_##X
52 #define SELF "host_nonshm plugin: "
55 #define GOMP(X) gomp_##X
59 #ifndef HOST_NONSHM_PLUGIN
60 static struct gomp_device_descr host_dispatch
;
64 GOMP_OFFLOAD_get_name (void)
66 #ifdef HOST_NONSHM_PLUGIN
74 GOMP_OFFLOAD_get_caps (void)
76 unsigned int caps
= (GOMP_OFFLOAD_CAP_OPENACC_200
77 | GOMP_OFFLOAD_CAP_NATIVE_EXEC
);
79 #ifndef HOST_NONSHM_PLUGIN
80 caps
|= GOMP_OFFLOAD_CAP_SHARED_MEM
;
87 GOMP_OFFLOAD_get_type (void)
89 #ifdef HOST_NONSHM_PLUGIN
90 return OFFLOAD_TARGET_TYPE_HOST_NONSHM
;
92 return OFFLOAD_TARGET_TYPE_HOST
;
97 GOMP_OFFLOAD_get_num_devices (void)
103 GOMP_OFFLOAD_register_image (void *host_table
__attribute__((unused
)),
104 void *target_data
__attribute__((unused
)))
109 GOMP_OFFLOAD_init_device (int n
__attribute__((unused
)))
114 GOMP_OFFLOAD_fini_device (int n
__attribute__((unused
)))
119 GOMP_OFFLOAD_get_table (int n
__attribute__((unused
)),
120 struct mapping_table
**table
__attribute__((unused
)))
126 GOMP_OFFLOAD_openacc_open_device (int n
)
128 return (void *) (intptr_t) n
;
132 GOMP_OFFLOAD_openacc_close_device (void *hnd
)
138 GOMP_OFFLOAD_openacc_get_device_num (void)
144 GOMP_OFFLOAD_openacc_set_device_num (int n
)
147 GOMP(fatal
) ("device number %u out of range for host execution", n
);
151 GOMP_OFFLOAD_alloc (int n
__attribute__((unused
)), size_t s
)
153 return GOMP(malloc
) (s
);
157 GOMP_OFFLOAD_free (int n
__attribute__((unused
)), void *p
)
163 GOMP_OFFLOAD_host2dev (int n
__attribute__((unused
)), void *d
, const void *h
,
166 #ifdef HOST_NONSHM_PLUGIN
174 GOMP_OFFLOAD_dev2host (int n
__attribute__((unused
)), void *h
, const void *d
,
177 #ifdef HOST_NONSHM_PLUGIN
185 GOMP_OFFLOAD_run (int n
__attribute__((unused
)), void *fn_ptr
, void *vars
)
187 void (*fn
)(void *) = (void (*)(void *)) fn_ptr
;
193 GOMP_OFFLOAD_openacc_parallel (void (*fn
) (void *),
194 size_t mapnum
__attribute__((unused
)),
195 void **hostaddrs
__attribute__((unused
)),
196 void **devaddrs
__attribute__((unused
)),
197 size_t *sizes
__attribute__((unused
)),
198 unsigned short *kinds
__attribute__((unused
)),
199 int num_gangs
__attribute__((unused
)),
200 int num_workers
__attribute__((unused
)),
201 int vector_length
__attribute__((unused
)),
202 int async
__attribute__((unused
)),
203 void *targ_mem_desc
__attribute__((unused
)))
205 #ifdef HOST_NONSHM_PLUGIN
213 GOMP_OFFLOAD_openacc_register_async_cleanup (void *targ_mem_desc
)
215 #ifdef HOST_NONSHM_PLUGIN
216 /* "Asynchronous" launches are executed synchronously on the (non-SHM) host,
217 so there's no point in delaying host-side cleanup -- just do it now. */
218 GOMP_PLUGIN_async_unmap_vars (targ_mem_desc
);
223 GOMP_OFFLOAD_openacc_async_set_async (int async
__attribute__((unused
)))
228 GOMP_OFFLOAD_openacc_async_test (int async
__attribute__((unused
)))
234 GOMP_OFFLOAD_openacc_async_test_all (void)
240 GOMP_OFFLOAD_openacc_async_wait (int async
__attribute__((unused
)))
245 GOMP_OFFLOAD_openacc_async_wait_all (void)
250 GOMP_OFFLOAD_openacc_async_wait_async (int async1
__attribute__((unused
)),
251 int async2
__attribute__((unused
)))
256 GOMP_OFFLOAD_openacc_async_wait_all_async (int async
__attribute__((unused
)))
261 GOMP_OFFLOAD_openacc_create_thread_data (void *targ_data
262 __attribute__((unused
)))
268 GOMP_OFFLOAD_openacc_destroy_thread_data (void *tls_data
269 __attribute__((unused
)))