Update 'Q' constraint documentation.
[official-gcc.git] / libgomp / libgomp-plugin.h
blob2559ce0ea3a7b49998c52a8f67b20120d788a74d
1 /* The libgomp plugin API.
3 Copyright (C) 2014-2020 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 #ifndef LIBGOMP_PLUGIN_H
30 #define LIBGOMP_PLUGIN_H 1
32 #include <stdbool.h>
33 #include <stddef.h>
34 #include <stdint.h>
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 /* Capabilities of offloading devices. */
41 #define GOMP_OFFLOAD_CAP_SHARED_MEM (1 << 0)
42 #define GOMP_OFFLOAD_CAP_NATIVE_EXEC (1 << 1)
43 #define GOMP_OFFLOAD_CAP_OPENMP_400 (1 << 2)
44 #define GOMP_OFFLOAD_CAP_OPENACC_200 (1 << 3)
46 /* Type of offload target device. Keep in sync with include/gomp-constants.h. */
47 enum offload_target_type
49 OFFLOAD_TARGET_TYPE_HOST = 2,
50 /* OFFLOAD_TARGET_TYPE_HOST_NONSHM = 3 removed. */
51 OFFLOAD_TARGET_TYPE_NVIDIA_PTX = 5,
52 OFFLOAD_TARGET_TYPE_INTEL_MIC = 6,
53 OFFLOAD_TARGET_TYPE_HSA = 7,
54 OFFLOAD_TARGET_TYPE_GCN = 8
57 /* Container type for passing device properties. */
58 union gomp_device_property_value
60 const char *ptr;
61 size_t val;
64 /* Opaque type to represent plugin-dependent implementation of an
65 OpenACC asynchronous queue. */
66 struct goacc_asyncqueue;
68 /* Used to keep a list of active asynchronous queues. */
69 struct goacc_asyncqueue_list
71 struct goacc_asyncqueue *aq;
72 struct goacc_asyncqueue_list *next;
75 typedef struct goacc_asyncqueue *goacc_aq;
76 typedef struct goacc_asyncqueue_list *goacc_aq_list;
78 /* Auxiliary struct, used for transferring pairs of addresses from plugin
79 to libgomp. */
80 struct addr_pair
82 uintptr_t start;
83 uintptr_t end;
86 /* Miscellaneous functions. */
87 extern void *GOMP_PLUGIN_malloc (size_t) __attribute__ ((malloc));
88 extern void *GOMP_PLUGIN_malloc_cleared (size_t) __attribute__ ((malloc));
89 extern void *GOMP_PLUGIN_realloc (void *, size_t);
90 void GOMP_PLUGIN_target_task_completion (void *);
92 extern void GOMP_PLUGIN_debug (int, const char *, ...)
93 __attribute__ ((format (printf, 2, 3)));
94 extern void GOMP_PLUGIN_error (const char *, ...)
95 __attribute__ ((format (printf, 1, 2)));
96 extern void GOMP_PLUGIN_fatal (const char *, ...)
97 __attribute__ ((noreturn, format (printf, 1, 2)));
99 /* Prototypes for functions implemented by libgomp plugins. */
100 extern const char *GOMP_OFFLOAD_get_name (void);
101 extern unsigned int GOMP_OFFLOAD_get_caps (void);
102 extern int GOMP_OFFLOAD_get_type (void);
103 extern int GOMP_OFFLOAD_get_num_devices (void);
104 extern union gomp_device_property_value GOMP_OFFLOAD_get_property (int, int);
105 extern bool GOMP_OFFLOAD_init_device (int);
106 extern bool GOMP_OFFLOAD_fini_device (int);
107 extern unsigned GOMP_OFFLOAD_version (void);
108 extern int GOMP_OFFLOAD_load_image (int, unsigned, const void *,
109 struct addr_pair **);
110 extern bool GOMP_OFFLOAD_unload_image (int, unsigned, const void *);
111 extern void *GOMP_OFFLOAD_alloc (int, size_t);
112 extern bool GOMP_OFFLOAD_free (int, void *);
113 extern bool GOMP_OFFLOAD_dev2host (int, void *, const void *, size_t);
114 extern bool GOMP_OFFLOAD_host2dev (int, void *, const void *, size_t);
115 extern bool GOMP_OFFLOAD_dev2dev (int, void *, const void *, size_t);
116 extern bool GOMP_OFFLOAD_can_run (void *);
117 extern void GOMP_OFFLOAD_run (int, void *, void *, void **);
118 extern void GOMP_OFFLOAD_async_run (int, void *, void *, void **, void *);
120 extern void GOMP_OFFLOAD_openacc_exec (void (*) (void *), size_t, void **,
121 void **, unsigned *, void *);
122 extern void *GOMP_OFFLOAD_openacc_create_thread_data (int);
123 extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *);
124 extern struct goacc_asyncqueue *GOMP_OFFLOAD_openacc_async_construct (int);
125 extern bool GOMP_OFFLOAD_openacc_async_destruct (struct goacc_asyncqueue *);
126 extern int GOMP_OFFLOAD_openacc_async_test (struct goacc_asyncqueue *);
127 extern bool GOMP_OFFLOAD_openacc_async_synchronize (struct goacc_asyncqueue *);
128 extern bool GOMP_OFFLOAD_openacc_async_serialize (struct goacc_asyncqueue *,
129 struct goacc_asyncqueue *);
130 extern void GOMP_OFFLOAD_openacc_async_queue_callback (struct goacc_asyncqueue *,
131 void (*)(void *), void *);
132 extern void GOMP_OFFLOAD_openacc_async_exec (void (*) (void *), size_t, void **,
133 void **, unsigned *, void *,
134 struct goacc_asyncqueue *);
135 extern bool GOMP_OFFLOAD_openacc_async_dev2host (int, void *, const void *, size_t,
136 struct goacc_asyncqueue *);
137 extern bool GOMP_OFFLOAD_openacc_async_host2dev (int, void *, const void *, size_t,
138 struct goacc_asyncqueue *);
139 extern void *GOMP_OFFLOAD_openacc_cuda_get_current_device (void);
140 extern void *GOMP_OFFLOAD_openacc_cuda_get_current_context (void);
141 extern void *GOMP_OFFLOAD_openacc_cuda_get_stream (struct goacc_asyncqueue *);
142 extern int GOMP_OFFLOAD_openacc_cuda_set_stream (struct goacc_asyncqueue *,
143 void *);
145 #ifdef __cplusplus
147 #endif
149 #endif