Import pre-release gcc-5.0 to new vendor branch
[dragonfly.git] / contrib / gcc-5.0 / libgomp / oacc-host.c
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
29 /* This shares much of the implementation of the plugin-host.c "host_nonshm"
30    plugin.  */
31 #include "plugin/plugin-host.c"
32
33 static struct gomp_device_descr host_dispatch =
34   {
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,
41
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,
55
56     .mem_map.is_initialized = false,
57     .mem_map.splay_tree.root = NULL,
58     .is_initialized = false,
59     .offload_regions_registered = false,
60
61     .openacc = {
62       .open_device_func = GOMP_OFFLOAD_openacc_open_device,
63       .close_device_func = GOMP_OFFLOAD_openacc_close_device,
64
65       .get_device_num_func = GOMP_OFFLOAD_openacc_get_device_num,
66       .set_device_num_func = GOMP_OFFLOAD_openacc_set_device_num,
67
68       .exec_func = GOMP_OFFLOAD_openacc_parallel,
69
70       .register_async_cleanup_func
71         = GOMP_OFFLOAD_openacc_register_async_cleanup,
72
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,
80
81       .create_thread_data_func = GOMP_OFFLOAD_openacc_create_thread_data,
82       .destroy_thread_data_func = GOMP_OFFLOAD_openacc_destroy_thread_data,
83
84       .cuda = {
85         .get_current_device_func = NULL,
86         .get_current_context_func = NULL,
87         .get_stream_func = NULL,
88         .set_stream_func = NULL,
89       }
90     }
91   };
92
93 /* Register this device type.  */
94 static __attribute__ ((constructor))
95 void goacc_host_init (void)
96 {
97   gomp_mutex_init (&host_dispatch.mem_map.lock);
98   gomp_mutex_init (&host_dispatch.lock);
99   goacc_register (&host_dispatch);
100 }