runtime: Fix runtime/pprof test when libgo is not optimized.
[official-gcc.git] / libgomp / plugin / plugin-host.c
blob1faf5bc194eb452e1cc9065d67749010fe56eee2
1 /* OpenACC Runtime Library: acc_device_host, acc_device_host_nonshm.
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 /* 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. */
33 #include "openacc.h"
34 #include "config.h"
35 #ifdef HOST_NONSHM_PLUGIN
36 #include "libgomp-plugin.h"
37 #include "oacc-plugin.h"
38 #else
39 #include "libgomp.h"
40 #include "oacc-int.h"
41 #endif
43 #include <stdint.h>
44 #include <stdlib.h>
45 #include <string.h>
46 #include <stdio.h>
48 #ifdef HOST_NONSHM_PLUGIN
49 #define STATIC
50 #define GOMP(X) GOMP_PLUGIN_##X
51 #define SELF "host_nonshm plugin: "
52 #else
53 #define STATIC static
54 #define GOMP(X) gomp_##X
55 #define SELF "host: "
56 #endif
58 STATIC const char *
59 GOMP_OFFLOAD_get_name (void)
61 #ifdef HOST_NONSHM_PLUGIN
62 return "host_nonshm";
63 #else
64 return "host";
65 #endif
68 STATIC unsigned int
69 GOMP_OFFLOAD_get_caps (void)
71 unsigned int caps = (GOMP_OFFLOAD_CAP_OPENACC_200
72 | GOMP_OFFLOAD_CAP_NATIVE_EXEC);
74 #ifndef HOST_NONSHM_PLUGIN
75 caps |= GOMP_OFFLOAD_CAP_SHARED_MEM;
76 #endif
78 return caps;
81 STATIC int
82 GOMP_OFFLOAD_get_type (void)
84 #ifdef HOST_NONSHM_PLUGIN
85 return OFFLOAD_TARGET_TYPE_HOST_NONSHM;
86 #else
87 return OFFLOAD_TARGET_TYPE_HOST;
88 #endif
91 STATIC int
92 GOMP_OFFLOAD_get_num_devices (void)
94 return 1;
97 STATIC void
98 GOMP_OFFLOAD_init_device (int n __attribute__ ((unused)))
102 STATIC void
103 GOMP_OFFLOAD_fini_device (int n __attribute__ ((unused)))
107 STATIC int
108 GOMP_OFFLOAD_load_image (int n __attribute__ ((unused)),
109 void *i __attribute__ ((unused)),
110 struct addr_pair **r __attribute__ ((unused)))
112 return 0;
115 STATIC void
116 GOMP_OFFLOAD_unload_image (int n __attribute__ ((unused)),
117 void *i __attribute__ ((unused)))
121 STATIC void *
122 GOMP_OFFLOAD_alloc (int n __attribute__ ((unused)), size_t s)
124 return GOMP (malloc) (s);
127 STATIC void
128 GOMP_OFFLOAD_free (int n __attribute__ ((unused)), void *p)
130 free (p);
133 STATIC void *
134 GOMP_OFFLOAD_host2dev (int n __attribute__ ((unused)), void *d, const void *h,
135 size_t s)
137 #ifdef HOST_NONSHM_PLUGIN
138 memcpy (d, h, s);
139 #endif
141 return 0;
144 STATIC void *
145 GOMP_OFFLOAD_dev2host (int n __attribute__ ((unused)), void *h, const void *d,
146 size_t s)
148 #ifdef HOST_NONSHM_PLUGIN
149 memcpy (h, d, s);
150 #endif
152 return 0;
155 STATIC void
156 GOMP_OFFLOAD_run (int n __attribute__ ((unused)), void *fn_ptr, void *vars)
158 void (*fn)(void *) = (void (*)(void *)) fn_ptr;
160 fn (vars);
163 STATIC void
164 GOMP_OFFLOAD_openacc_parallel (void (*fn) (void *),
165 size_t mapnum __attribute__ ((unused)),
166 void **hostaddrs __attribute__ ((unused)),
167 void **devaddrs __attribute__ ((unused)),
168 size_t *sizes __attribute__ ((unused)),
169 unsigned short *kinds __attribute__ ((unused)),
170 int num_gangs __attribute__ ((unused)),
171 int num_workers __attribute__ ((unused)),
172 int vector_length __attribute__ ((unused)),
173 int async __attribute__ ((unused)),
174 void *targ_mem_desc __attribute__ ((unused)))
176 #ifdef HOST_NONSHM_PLUGIN
177 fn (devaddrs);
178 #else
179 fn (hostaddrs);
180 #endif
183 STATIC void
184 GOMP_OFFLOAD_openacc_register_async_cleanup (void *targ_mem_desc)
186 #ifdef HOST_NONSHM_PLUGIN
187 /* "Asynchronous" launches are executed synchronously on the (non-SHM) host,
188 so there's no point in delaying host-side cleanup -- just do it now. */
189 GOMP_PLUGIN_async_unmap_vars (targ_mem_desc);
190 #endif
193 STATIC void
194 GOMP_OFFLOAD_openacc_async_set_async (int async __attribute__ ((unused)))
198 STATIC int
199 GOMP_OFFLOAD_openacc_async_test (int async __attribute__ ((unused)))
201 return 1;
204 STATIC int
205 GOMP_OFFLOAD_openacc_async_test_all (void)
207 return 1;
210 STATIC void
211 GOMP_OFFLOAD_openacc_async_wait (int async __attribute__ ((unused)))
215 STATIC void
216 GOMP_OFFLOAD_openacc_async_wait_all (void)
220 STATIC void
221 GOMP_OFFLOAD_openacc_async_wait_async (int async1 __attribute__ ((unused)),
222 int async2 __attribute__ ((unused)))
226 STATIC void
227 GOMP_OFFLOAD_openacc_async_wait_all_async (int async __attribute__ ((unused)))
231 STATIC void *
232 GOMP_OFFLOAD_openacc_create_thread_data (int ord
233 __attribute__ ((unused)))
235 return NULL;
238 STATIC void
239 GOMP_OFFLOAD_openacc_destroy_thread_data (void *tls_data
240 __attribute__ ((unused)))