@@ -97,6 +97,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary(
97
97
Program->URContext = hContext;
98
98
Program->Binary = RealBinary;
99
99
Program->BinarySizeInBytes = RealLength;
100
+ Program->BinaryType = UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT;
100
101
101
102
// Parse properties
102
103
if (pProperties) {
@@ -160,24 +161,68 @@ urProgramCreateWithIL(ur_context_handle_t hContext, const void *pIL,
160
161
}
161
162
162
163
UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild (ur_context_handle_t ,
163
- ur_program_handle_t ,
164
- const char *) {
164
+ ur_program_handle_t hProgram ,
165
+ const char *pOptions ) {
165
166
// Do nothing, program is built upon creation
167
+ if (pOptions && *pOptions) {
168
+ hProgram->Error = " Liboffload doesn't support link options" ;
169
+ return UR_RESULT_ERROR_PROGRAM_LINK_FAILURE;
170
+ }
171
+ hProgram->BinaryType = UR_PROGRAM_BINARY_TYPE_EXECUTABLE;
166
172
return UR_RESULT_SUCCESS;
167
173
}
168
174
169
- UR_APIEXPORT ur_result_t UR_APICALL urProgramBuildExp (ur_program_handle_t ,
170
- uint32_t ,
171
- ur_device_handle_t *,
172
- const char *) {
175
+ UR_APIEXPORT ur_result_t UR_APICALL
176
+ urProgramBuildExp (ur_program_handle_t hProgram, uint32_t , ur_device_handle_t *,
177
+ const char *pOptions) {
173
178
// Do nothing, program is built upon creation
179
+ if (pOptions && *pOptions) {
180
+ hProgram->Error = " Liboffload doesn't support link options" ;
181
+ return UR_RESULT_ERROR_PROGRAM_LINK_FAILURE;
182
+ }
183
+ hProgram->BinaryType = UR_PROGRAM_BINARY_TYPE_EXECUTABLE;
174
184
return UR_RESULT_SUCCESS;
175
185
}
176
186
177
- UR_APIEXPORT ur_result_t UR_APICALL urProgramCompile (ur_context_handle_t ,
178
- ur_program_handle_t ,
179
- const char *) {
187
+ UR_APIEXPORT ur_result_t UR_APICALL urProgramCompile (
188
+ ur_context_handle_t , ur_program_handle_t hProgram, const char *pOptions) {
180
189
// Do nothing, program is built upon creation
190
+ if (pOptions && *pOptions) {
191
+ hProgram->Error = " Liboffload doesn't support link options" ;
192
+ return UR_RESULT_ERROR_PROGRAM_LINK_FAILURE;
193
+ }
194
+ hProgram->BinaryType = UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT;
195
+ return UR_RESULT_SUCCESS;
196
+ }
197
+
198
+ UR_APIEXPORT ur_result_t UR_APICALL
199
+ urProgramLink (ur_context_handle_t hContext, uint32_t count,
200
+ const ur_program_handle_t *phPrograms, const char *pOptions,
201
+ ur_program_handle_t *phProgram) {
202
+ if (count > 1 ) {
203
+ *phProgram = ur_program_handle_t_::newErrorProgram (
204
+ hContext, nullptr , 0 ,
205
+ " Liboffload does not support linking multiple binaries" );
206
+ return UR_RESULT_ERROR_PROGRAM_LINK_FAILURE;
207
+ }
208
+ if (pOptions) {
209
+ *phProgram = ur_program_handle_t_::newErrorProgram (
210
+ hContext, nullptr , 0 , " Liboffload does not support linker options" );
211
+ return UR_RESULT_ERROR_PROGRAM_LINK_FAILURE;
212
+ }
213
+ assert (count == 1 );
214
+
215
+ // Offload programs are already fully linked on creation, just create a new
216
+ // program containing it
217
+ auto *InProgram = *phPrograms;
218
+ ur_program_handle_t Program = new ur_program_handle_t_{};
219
+ Program->URContext = hContext;
220
+ Program->Binary = InProgram->Binary ;
221
+ Program->BinarySizeInBytes = InProgram->BinarySizeInBytes ;
222
+ Program->GlobalIDMD = InProgram->GlobalIDMD ;
223
+ Program->BinaryType = UR_PROGRAM_BINARY_TYPE_EXECUTABLE;
224
+ *phProgram = Program;
225
+
181
226
return UR_RESULT_SUCCESS;
182
227
}
183
228
@@ -230,6 +275,28 @@ urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName,
230
275
return UR_RESULT_SUCCESS;
231
276
}
232
277
278
+ UR_APIEXPORT ur_result_t UR_APICALL
279
+ urProgramGetBuildInfo (ur_program_handle_t hProgram, ur_device_handle_t ,
280
+ ur_program_build_info_t propName, size_t propSize,
281
+ void *pPropValue, size_t *pPropSizeRet) {
282
+ UrReturnHelper ReturnValue (propSize, pPropValue, pPropSizeRet);
283
+ switch (propName) {
284
+ case UR_PROGRAM_BUILD_INFO_STATUS:
285
+ return ReturnValue (hProgram->Error .empty () ? UR_PROGRAM_BUILD_STATUS_SUCCESS
286
+ : UR_PROGRAM_BUILD_STATUS_ERROR);
287
+ case UR_PROGRAM_BUILD_INFO_OPTIONS:
288
+ return ReturnValue (" " );
289
+ case UR_PROGRAM_BUILD_INFO_LOG:
290
+ return ReturnValue (hProgram->Error .c_str ());
291
+ case UR_PROGRAM_BUILD_INFO_BINARY_TYPE:
292
+ return ReturnValue (hProgram->BinaryType );
293
+ default :
294
+ return UR_RESULT_ERROR_INVALID_ENUMERATION;
295
+ }
296
+
297
+ return UR_RESULT_SUCCESS;
298
+ }
299
+
233
300
UR_APIEXPORT ur_result_t UR_APICALL
234
301
urProgramRetain (ur_program_handle_t hProgram) {
235
302
hProgram->RefCount ++;
@@ -239,11 +306,12 @@ urProgramRetain(ur_program_handle_t hProgram) {
239
306
UR_APIEXPORT ur_result_t UR_APICALL
240
307
urProgramRelease (ur_program_handle_t hProgram) {
241
308
if (--hProgram->RefCount == 0 ) {
242
- auto Res = olDestroyProgram (hProgram->OffloadProgram );
243
- if (Res) {
244
- return offloadResultToUR (Res);
309
+ if (hProgram->OffloadProgram ) {
310
+ if (auto Res = olDestroyProgram (hProgram->OffloadProgram )) {
311
+ return offloadResultToUR (Res);
312
+ }
313
+ delete hProgram;
245
314
}
246
- delete hProgram;
247
315
}
248
316
249
317
return UR_RESULT_SUCCESS;
0 commit comments