]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgomp/oacc-int.h
AVR: target/114835 - Tweak popcountqi2
[thirdparty/gcc.git] / libgomp / oacc-int.h
CommitLineData
41dbbb37
TS
1/* OpenACC Runtime - internal declarations
2
a945c346 3 Copyright (C) 2013-2024 Free Software Foundation, Inc.
41dbbb37
TS
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 file contains data types and function declarations that are not
30 part of the official OpenACC user interface. There are declarations
31 in here that are part of the GNU OpenACC ABI, in that the compiler is
32 required to know about them and use them.
33
34 The convention is that the all caps prefix "GOACC" is used group items
35 that are part of the external ABI, and the lower case prefix "goacc"
36 is used group items that are completely private to the library. */
37
38#ifndef OACC_INT_H
39#define OACC_INT_H 1
40
41#include "openacc.h"
42#include "config.h"
5fae049d 43#include "acc_prof.h"
41dbbb37
TS
44#include <stddef.h>
45#include <stdbool.h>
46#include <stdarg.h>
47
48#ifdef HAVE_ATTRIBUTE_VISIBILITY
49# pragma GCC visibility push(hidden)
50#endif
51
52static inline enum acc_device_t
53acc_device_type (enum offload_target_type type)
54{
55 return (enum acc_device_t) type;
56}
57
58struct goacc_thread
59{
d93bdab5
JB
60 /* The base device for the current thread. */
61 struct gomp_device_descr *base_dev;
62
41dbbb37
TS
63 /* The device for the current thread. */
64 struct gomp_device_descr *dev;
65
66 struct gomp_device_descr *saved_bound_dev;
67
68 /* This is a linked list of data mapped by the "acc data" pragma, following
69 strictly push/pop semantics according to lexical scope. */
70 struct target_mem_desc *mapped_data;
71
5fae049d
TS
72 /* Data of the OpenACC Profiling Interface. */
73 acc_prof_info *prof_info;
74 acc_api_info *api_info;
75 /* Per-thread toggle of OpenACC Profiling Interface callbacks. */
76 bool prof_callbacks_enabled;
77
41dbbb37
TS
78 /* These structures form a list: this is the next thread in that list. */
79 struct goacc_thread *next;
80
81 /* Target-specific data (used by plugin). */
82 void *target_tls;
83};
84
fa499995
AS
85#ifdef __AMDGCN__
86static inline struct goacc_thread *
87goacc_thread (void)
88{
89 /* Unused in the offload libgomp for OpenACC: return a dummy value. */
90 return 0;
91}
92#elif defined HAVE_TLS || defined USE_EMUTLS
41dbbb37
TS
93extern __thread struct goacc_thread *goacc_tls_data;
94static inline struct goacc_thread *
95goacc_thread (void)
96{
97 return goacc_tls_data;
98}
99#else
100extern pthread_key_t goacc_tls_key;
101static inline struct goacc_thread *
102goacc_thread (void)
103{
104 return pthread_getspecific (goacc_tls_key);
105}
106#endif
107
108void goacc_register (struct gomp_device_descr *) __GOACC_NOTHROW;
d93bdab5 109void goacc_attach_host_thread_to_device (int);
41dbbb37
TS
110void goacc_runtime_initialize (void);
111void goacc_save_and_set_bind (acc_device_t);
112void goacc_restore_bind (void);
113void goacc_lazy_initialize (void);
6bb4c3e2 114void goacc_host_init (void);
41dbbb37 115
c5578b56 116void goacc_wait (int, int, va_list *);
1f4c5b9b
CLT
117void goacc_init_asyncqueues (struct gomp_device_descr *);
118bool goacc_fini_asyncqueues (struct gomp_device_descr *);
119void goacc_async_free (struct gomp_device_descr *, struct goacc_asyncqueue *,
120 void *);
121struct goacc_asyncqueue *get_goacc_asyncqueue (int);
122struct goacc_asyncqueue *lookup_goacc_asyncqueue (struct goacc_thread *, bool,
123 int);
edbd038a
TV
124static inline bool
125async_valid_stream_id_p (int async)
126{
127 return async >= 0;
128}
129
130static inline bool
131async_valid_p (int async)
132{
133 return (async == acc_async_noval || async == acc_async_sync
134 || async_valid_stream_id_p (async));
135}
136
137static inline bool
138async_synchronous_p (int async)
139{
140 if (!async_valid_p (async))
141 return true;
142
143 return async == acc_async_sync;
144}
145
5fae049d
TS
146
147extern bool goacc_prof_enabled;
148/* Tune for the (very common) case that profiling is not enabled. */
149#define GOACC_PROF_ENABLED \
150 (__builtin_expect (__atomic_load_n (&goacc_prof_enabled, \
151 MEMMODEL_ACQUIRE) == true, false))
152
153void goacc_profiling_initialize (void);
154bool _goacc_profiling_dispatch_p (bool);
155/* Tune for the (very common) case that profiling is not enabled. */
156#define GOACC_PROFILING_DISPATCH_P(...) \
157 (GOACC_PROF_ENABLED \
158 && _goacc_profiling_dispatch_p (__VA_ARGS__))
159bool _goacc_profiling_setup_p (struct goacc_thread *,
160 acc_prof_info *, acc_api_info *);
161/* Tune for the (very common) case that profiling is not enabled. */
162#define GOACC_PROFILING_SETUP_P(...) \
163 (GOACC_PROFILING_DISPATCH_P (false) \
164 && _goacc_profiling_setup_p (__VA_ARGS__))
165void goacc_profiling_dispatch (acc_prof_info *, acc_event_info *,
166 acc_api_info *);
167
41dbbb37
TS
168#ifdef HAVE_ATTRIBUTE_VISIBILITY
169# pragma GCC visibility pop
170#endif
171
172#endif