PR ipa/65237
[official-gcc.git] / libgomp / oacc-host.c
blob6aeb1e765d5e5562ac58bc4aa12c09043c5f5899
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 /* This shares much of the implementation of the plugin-host.c "host_nonshm"
30 plugin. */
31 #include "plugin/plugin-host.c"
33 static struct gomp_device_descr host_dispatch =
35 .name = "host",
36 .capabilities = (GOMP_OFFLOAD_CAP_OPENACC_200
37 | GOMP_OFFLOAD_CAP_NATIVE_EXEC
38 | GOMP_OFFLOAD_CAP_SHARED_MEM),
39 .target_id = 0,
40 .type = OFFLOAD_TARGET_TYPE_HOST,
42 .get_name_func = GOMP_OFFLOAD_get_name,
43 .get_caps_func = GOMP_OFFLOAD_get_caps,
44 .get_type_func = GOMP_OFFLOAD_get_type,
45 .get_num_devices_func = GOMP_OFFLOAD_get_num_devices,
46 .register_image_func = GOMP_OFFLOAD_register_image,
47 .init_device_func = GOMP_OFFLOAD_init_device,
48 .fini_device_func = GOMP_OFFLOAD_fini_device,
49 .get_table_func = GOMP_OFFLOAD_get_table,
50 .alloc_func = GOMP_OFFLOAD_alloc,
51 .free_func = GOMP_OFFLOAD_free,
52 .dev2host_func = GOMP_OFFLOAD_dev2host,
53 .host2dev_func = GOMP_OFFLOAD_host2dev,
54 .run_func = GOMP_OFFLOAD_run,
56 .mem_map.is_initialized = false,
57 .mem_map.splay_tree.root = NULL,
58 .is_initialized = false,
59 .offload_regions_registered = false,
61 .openacc = {
62 .open_device_func = GOMP_OFFLOAD_openacc_open_device,
63 .close_device_func = GOMP_OFFLOAD_openacc_close_device,
65 .get_device_num_func = GOMP_OFFLOAD_openacc_get_device_num,
66 .set_device_num_func = GOMP_OFFLOAD_openacc_set_device_num,
68 .exec_func = GOMP_OFFLOAD_openacc_parallel,
70 .register_async_cleanup_func
71 = GOMP_OFFLOAD_openacc_register_async_cleanup,
73 .async_set_async_func = GOMP_OFFLOAD_openacc_async_set_async,
74 .async_test_func = GOMP_OFFLOAD_openacc_async_test,
75 .async_test_all_func = GOMP_OFFLOAD_openacc_async_test_all,
76 .async_wait_func = GOMP_OFFLOAD_openacc_async_wait,
77 .async_wait_async_func = GOMP_OFFLOAD_openacc_async_wait_async,
78 .async_wait_all_func = GOMP_OFFLOAD_openacc_async_wait_all,
79 .async_wait_all_async_func = GOMP_OFFLOAD_openacc_async_wait_all_async,
81 .create_thread_data_func = GOMP_OFFLOAD_openacc_create_thread_data,
82 .destroy_thread_data_func = GOMP_OFFLOAD_openacc_destroy_thread_data,
84 .cuda = {
85 .get_current_device_func = NULL,
86 .get_current_context_func = NULL,
87 .get_stream_func = NULL,
88 .set_stream_func = NULL,
93 /* Register this device type. */
94 static __attribute__ ((constructor))
95 void goacc_host_init (void)
97 gomp_mutex_init (&host_dispatch.mem_map.lock);
98 gomp_mutex_init (&host_dispatch.lock);
99 goacc_register (&host_dispatch);