2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / liboffloadmic / runtime / compiler_if_host.h
blob025f6fb2dba70d4be3c2eb9754bfa0dbd93ee2b4
1 /*
2 Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 /*! \file
32 \brief The interface between compiler-generated host code and runtime library
35 #ifndef COMPILER_IF_HOST_H_INCLUDED
36 #define COMPILER_IF_HOST_H_INCLUDED
38 #include "offload_host.h"
40 #define OFFLOAD_TARGET_ACQUIRE OFFLOAD_PREFIX(target_acquire)
41 #define OFFLOAD_TARGET_ACQUIRE1 OFFLOAD_PREFIX(target_acquire1)
42 #define OFFLOAD_TARGET_ACQUIRE2 OFFLOAD_PREFIX(target_acquire2)
43 #define OFFLOAD_OFFLOAD OFFLOAD_PREFIX(offload)
44 #define OFFLOAD_OFFLOAD1 OFFLOAD_PREFIX(offload1)
45 #define OFFLOAD_OFFLOAD2 OFFLOAD_PREFIX(offload2)
46 #define OFFLOAD_OFFLOAD3 OFFLOAD_PREFIX(offload3)
47 #define OFFLOAD_CALL_COUNT OFFLOAD_PREFIX(offload_call_count)
50 /*! \fn OFFLOAD_TARGET_ACQUIRE
51 \brief Attempt to acquire the target.
52 \param target_type The type of target.
53 \param target_number The device number.
54 \param is_optional Whether CPU fall-back is allowed.
55 \param status Address of variable to hold offload status.
56 \param file Filename in which this offload occurred.
57 \param line Line number in the file where this offload occurred.
59 extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE(
60 TARGET_TYPE target_type,
61 int target_number,
62 int is_optional,
63 _Offload_status* status,
64 const char* file,
65 uint64_t line
68 /*! \fn OFFLOAD_TARGET_ACQUIRE1
69 \brief Acquire the target for offload (OpenMP).
70 \param device_number Device number or null if not specified.
71 \param file Filename in which this offload occurred
72 \param line Line number in the file where this offload occurred.
74 extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE1(
75 const int* device_number,
76 const char* file,
77 uint64_t line
80 /*! \fn OFFLOAD_TARGET_ACQUIRE2
81 \brief Attempt to acquire the target.
82 \param target_type The type of target.
83 \param target_number The device number.
84 \param is_optional Whether CPU fall-back is allowed.
85 \param status Address of variable to hold offload status.
86 \param file Filename in which this offload occurred.
87 \param line Line number in the file where this offload occurred.
88 \param stream Pointer to stream value.
90 extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE2(
91 TARGET_TYPE target_type,
92 int target_number,
93 int is_optional,
94 _Offload_status* status,
95 const char* file,
96 uint64_t line,
97 const void** stream
100 /*! \fn OFFLOAD_OFFLOAD1
101 \brief Run function on target using interface for old data persistence.
102 \param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE.
103 \param name Name of offload entry point.
104 \param is_empty If no code to execute (e.g. offload_transfer)
105 \param num_vars Number of variable descriptors.
106 \param vars Pointer to VarDesc array.
107 \param vars2 Pointer to VarDesc2 array.
108 \param num_waits Number of "wait" values.
109 \param waits Pointer to array of wait values.
110 \param signal Pointer to signal value or NULL.
112 extern "C" int OFFLOAD_OFFLOAD1(
113 OFFLOAD o,
114 const char *name,
115 int is_empty,
116 int num_vars,
117 VarDesc *vars,
118 VarDesc2 *vars2,
119 int num_waits,
120 const void** waits,
121 const void** signal
124 /*! \fn OFFLOAD_OFFLOAD2
125 \brief Run function on target using interface for new data persistence.
126 \param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE.
127 \param name Name of offload entry point.
128 \param is_empty If no code to execute (e.g. offload_transfer)
129 \param num_vars Number of variable descriptors.
130 \param vars Pointer to VarDesc array.
131 \param vars2 Pointer to VarDesc2 array.
132 \param num_waits Number of "wait" values.
133 \param waits Pointer to array of wait values.
134 \param signal Pointer to signal value or NULL.
135 \param entry_id A signature for the function doing the offload.
136 \param stack_addr The stack frame address of the function doing offload.
138 extern "C" int OFFLOAD_OFFLOAD2(
139 OFFLOAD o,
140 const char *name,
141 int is_empty,
142 int num_vars,
143 VarDesc *vars,
144 VarDesc2 *vars2,
145 int num_waits,
146 const void** waits,
147 const void** signal,
148 int entry_id,
149 const void *stack_addr
153 /*! \fn OFFLOAD_OFFLOAD3
154 \brief Run function on target, API introduced in 15.0 Update 1
155 \brief when targetptr, preallocated feature was introduced.
156 \param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE.
157 \param name Name of offload entry point.
158 \param is_empty If no code to execute (e.g. offload_transfer)
159 \param num_vars Number of variable descriptors.
160 \param vars Pointer to VarDesc array.
161 \param vars2 Pointer to VarDesc2 array.
162 \param num_waits Number of "wait" values.
163 \param waits Pointer to array of wait values.
164 \param signal Pointer to signal value or NULL.
165 \param entry_id A signature for the function doing the offload.
166 \param stack_addr The stack frame address of the function doing offload.
167 \param offload_flags Flags to indicate Fortran traceback, OpenMP async.
168 \param stream Pointer to stream value or NULL.
170 extern "C" int OFFLOAD_OFFLOAD3(
171 OFFLOAD ofld,
172 const char *name,
173 int is_empty,
174 int num_vars,
175 VarDesc *vars,
176 VarDesc2 *vars2,
177 int num_waits,
178 const void** waits,
179 const void** signal,
180 int entry_id,
181 const void *stack_addr,
182 OffloadFlags offload_flags,
183 const void** stream
186 // Run function on target (obsolete).
187 // @param o OFFLOAD object
188 // @param name function name
189 extern "C" int OFFLOAD_OFFLOAD(
190 OFFLOAD o,
191 const char *name,
192 int is_empty,
193 int num_vars,
194 VarDesc *vars,
195 VarDesc2 *vars2,
196 int num_waits,
197 const void** waits,
198 const void* signal,
199 int entry_id = 0,
200 const void *stack_addr = NULL
203 // Global counter on host.
204 // This variable is used if P2OPT_offload_do_data_persistence == 2.
205 // The variable used to identify offload constructs contained in one procedure.
206 // Call to OFFLOAD_CALL_COUNT() is inserted at HOST on entry of the routine.
207 extern "C" int OFFLOAD_CALL_COUNT();
209 #endif // COMPILER_IF_HOST_H_INCLUDED