annotate libgomp/libgomp-plugin.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* The libgomp plugin API.
kono
parents:
diff changeset
2
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
3 Copyright (C) 2014-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 Contributed by Mentor Embedded.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 This file is part of the GNU Offloading and Multi Processing Library
kono
parents:
diff changeset
8 (libgomp).
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 Libgomp is free software; you can redistribute it and/or modify it
kono
parents:
diff changeset
11 under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
12 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
13 any later version.
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
kono
parents:
diff changeset
17 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
kono
parents:
diff changeset
18 more details.
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
21 permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
22 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
25 a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
26 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
27 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 #ifndef LIBGOMP_PLUGIN_H
kono
parents:
diff changeset
30 #define LIBGOMP_PLUGIN_H 1
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 #include <stdbool.h>
kono
parents:
diff changeset
33 #include <stddef.h>
kono
parents:
diff changeset
34 #include <stdint.h>
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 #ifdef __cplusplus
kono
parents:
diff changeset
37 extern "C" {
kono
parents:
diff changeset
38 #endif
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 /* Capabilities of offloading devices. */
kono
parents:
diff changeset
41 #define GOMP_OFFLOAD_CAP_SHARED_MEM (1 << 0)
kono
parents:
diff changeset
42 #define GOMP_OFFLOAD_CAP_NATIVE_EXEC (1 << 1)
kono
parents:
diff changeset
43 #define GOMP_OFFLOAD_CAP_OPENMP_400 (1 << 2)
kono
parents:
diff changeset
44 #define GOMP_OFFLOAD_CAP_OPENACC_200 (1 << 3)
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 /* Type of offload target device. Keep in sync with include/gomp-constants.h. */
kono
parents:
diff changeset
47 enum offload_target_type
kono
parents:
diff changeset
48 {
kono
parents:
diff changeset
49 OFFLOAD_TARGET_TYPE_HOST = 2,
kono
parents:
diff changeset
50 /* OFFLOAD_TARGET_TYPE_HOST_NONSHM = 3 removed. */
kono
parents:
diff changeset
51 OFFLOAD_TARGET_TYPE_NVIDIA_PTX = 5,
kono
parents:
diff changeset
52 OFFLOAD_TARGET_TYPE_INTEL_MIC = 6,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
53 OFFLOAD_TARGET_TYPE_HSA = 7,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
54 OFFLOAD_TARGET_TYPE_GCN = 8
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
55 };
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
56
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
57 /* Opaque type to represent plugin-dependent implementation of an
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
58 OpenACC asynchronous queue. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
59 struct goacc_asyncqueue;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
60
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
61 /* Used to keep a list of active asynchronous queues. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
62 struct goacc_asyncqueue_list
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
63 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
64 struct goacc_asyncqueue *aq;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
65 struct goacc_asyncqueue_list *next;
111
kono
parents:
diff changeset
66 };
kono
parents:
diff changeset
67
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
68 typedef struct goacc_asyncqueue *goacc_aq;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
69 typedef struct goacc_asyncqueue_list *goacc_aq_list;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
70
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
71
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
72 /* OpenACC 'acc_get_property' support. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
73
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
74 /* Device property values. Keep in sync with
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
75 'libgomp/{openacc.h,openacc.f90}:acc_device_property_t'. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
76 enum goacc_property
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
77 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
78 /* Mask to tell numeric and string values apart. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
79 #define GOACC_PROPERTY_STRING_MASK 0x10000
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
80
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
81 /* Start from 1 to catch uninitialized use. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
82 GOACC_PROPERTY_MEMORY = 1,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
83 GOACC_PROPERTY_FREE_MEMORY = 2,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
84 GOACC_PROPERTY_NAME = GOACC_PROPERTY_STRING_MASK | 1,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
85 GOACC_PROPERTY_VENDOR = GOACC_PROPERTY_STRING_MASK | 2,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
86 GOACC_PROPERTY_DRIVER = GOACC_PROPERTY_STRING_MASK | 3
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
87 };
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
88
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
89 /* Container type for passing device properties. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
90 union goacc_property_value
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
91 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
92 const char *ptr;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
93 size_t val;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
94 };
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
95
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
96
111
kono
parents:
diff changeset
97 /* Auxiliary struct, used for transferring pairs of addresses from plugin
kono
parents:
diff changeset
98 to libgomp. */
kono
parents:
diff changeset
99 struct addr_pair
kono
parents:
diff changeset
100 {
kono
parents:
diff changeset
101 uintptr_t start;
kono
parents:
diff changeset
102 uintptr_t end;
kono
parents:
diff changeset
103 };
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 /* Miscellaneous functions. */
kono
parents:
diff changeset
106 extern void *GOMP_PLUGIN_malloc (size_t) __attribute__ ((malloc));
kono
parents:
diff changeset
107 extern void *GOMP_PLUGIN_malloc_cleared (size_t) __attribute__ ((malloc));
kono
parents:
diff changeset
108 extern void *GOMP_PLUGIN_realloc (void *, size_t);
kono
parents:
diff changeset
109 void GOMP_PLUGIN_target_task_completion (void *);
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 extern void GOMP_PLUGIN_debug (int, const char *, ...)
kono
parents:
diff changeset
112 __attribute__ ((format (printf, 2, 3)));
kono
parents:
diff changeset
113 extern void GOMP_PLUGIN_error (const char *, ...)
kono
parents:
diff changeset
114 __attribute__ ((format (printf, 1, 2)));
kono
parents:
diff changeset
115 extern void GOMP_PLUGIN_fatal (const char *, ...)
kono
parents:
diff changeset
116 __attribute__ ((noreturn, format (printf, 1, 2)));
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 /* Prototypes for functions implemented by libgomp plugins. */
kono
parents:
diff changeset
119 extern const char *GOMP_OFFLOAD_get_name (void);
kono
parents:
diff changeset
120 extern unsigned int GOMP_OFFLOAD_get_caps (void);
kono
parents:
diff changeset
121 extern int GOMP_OFFLOAD_get_type (void);
kono
parents:
diff changeset
122 extern int GOMP_OFFLOAD_get_num_devices (void);
kono
parents:
diff changeset
123 extern bool GOMP_OFFLOAD_init_device (int);
kono
parents:
diff changeset
124 extern bool GOMP_OFFLOAD_fini_device (int);
kono
parents:
diff changeset
125 extern unsigned GOMP_OFFLOAD_version (void);
kono
parents:
diff changeset
126 extern int GOMP_OFFLOAD_load_image (int, unsigned, const void *,
kono
parents:
diff changeset
127 struct addr_pair **);
kono
parents:
diff changeset
128 extern bool GOMP_OFFLOAD_unload_image (int, unsigned, const void *);
kono
parents:
diff changeset
129 extern void *GOMP_OFFLOAD_alloc (int, size_t);
kono
parents:
diff changeset
130 extern bool GOMP_OFFLOAD_free (int, void *);
kono
parents:
diff changeset
131 extern bool GOMP_OFFLOAD_dev2host (int, void *, const void *, size_t);
kono
parents:
diff changeset
132 extern bool GOMP_OFFLOAD_host2dev (int, void *, const void *, size_t);
kono
parents:
diff changeset
133 extern bool GOMP_OFFLOAD_dev2dev (int, void *, const void *, size_t);
kono
parents:
diff changeset
134 extern bool GOMP_OFFLOAD_can_run (void *);
kono
parents:
diff changeset
135 extern void GOMP_OFFLOAD_run (int, void *, void *, void **);
kono
parents:
diff changeset
136 extern void GOMP_OFFLOAD_async_run (int, void *, void *, void **, void *);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
137
111
kono
parents:
diff changeset
138 extern void GOMP_OFFLOAD_openacc_exec (void (*) (void *), size_t, void **,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
139 void **, unsigned *, void *);
111
kono
parents:
diff changeset
140 extern void *GOMP_OFFLOAD_openacc_create_thread_data (int);
kono
parents:
diff changeset
141 extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
142 extern struct goacc_asyncqueue *GOMP_OFFLOAD_openacc_async_construct (int);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
143 extern bool GOMP_OFFLOAD_openacc_async_destruct (struct goacc_asyncqueue *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
144 extern int GOMP_OFFLOAD_openacc_async_test (struct goacc_asyncqueue *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
145 extern bool GOMP_OFFLOAD_openacc_async_synchronize (struct goacc_asyncqueue *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
146 extern bool GOMP_OFFLOAD_openacc_async_serialize (struct goacc_asyncqueue *,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
147 struct goacc_asyncqueue *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
148 extern void GOMP_OFFLOAD_openacc_async_queue_callback (struct goacc_asyncqueue *,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
149 void (*)(void *), void *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
150 extern void GOMP_OFFLOAD_openacc_async_exec (void (*) (void *), size_t, void **,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
151 void **, unsigned *, void *,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
152 struct goacc_asyncqueue *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
153 extern bool GOMP_OFFLOAD_openacc_async_dev2host (int, void *, const void *, size_t,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
154 struct goacc_asyncqueue *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
155 extern bool GOMP_OFFLOAD_openacc_async_host2dev (int, void *, const void *, size_t,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
156 struct goacc_asyncqueue *);
111
kono
parents:
diff changeset
157 extern void *GOMP_OFFLOAD_openacc_cuda_get_current_device (void);
kono
parents:
diff changeset
158 extern void *GOMP_OFFLOAD_openacc_cuda_get_current_context (void);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
159 extern void *GOMP_OFFLOAD_openacc_cuda_get_stream (struct goacc_asyncqueue *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
160 extern int GOMP_OFFLOAD_openacc_cuda_set_stream (struct goacc_asyncqueue *,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
161 void *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
162 extern union goacc_property_value
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
163 GOMP_OFFLOAD_openacc_get_property (int, enum goacc_property);
111
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 #ifdef __cplusplus
kono
parents:
diff changeset
166 }
kono
parents:
diff changeset
167 #endif
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 #endif