@@ -308,9 +308,11 @@ ol_impl_result_t olMemAlloc_impl(ol_device_handle_t Device,
308
308
void **AllocationOut) {
309
309
auto Alloc =
310
310
Device->Device ->dataAlloc (Size , nullptr , convertOlToPluginAllocTy (Type));
311
- if (!Alloc)
311
+ if (!Alloc) {
312
+ llvm::consumeError (Alloc.takeError ());
312
313
return {OL_ERRC_OUT_OF_RESOURCES,
313
314
formatv (" Could not create allocation on device {0}" , Device).str ()};
315
+ }
314
316
315
317
*AllocationOut = *Alloc;
316
318
allocInfoMap ().insert_or_assign (*Alloc, AllocInfo{Device, Type});
@@ -327,8 +329,10 @@ ol_impl_result_t olMemFree_impl(void *Address) {
327
329
328
330
auto Res =
329
331
Device->Device ->dataDelete (Address, convertOlToPluginAllocTy (Type));
330
- if (Res)
332
+ if (Res) {
333
+ llvm::consumeError (std::move (Res));
331
334
return {OL_ERRC_OUT_OF_RESOURCES, " Could not free allocation" };
335
+ }
332
336
333
337
allocInfoMap ().erase (Address);
334
338
@@ -340,7 +344,7 @@ ol_impl_result_t olCreateQueue_impl(ol_device_handle_t Device,
340
344
auto CreatedQueue = std::make_unique<ol_queue_impl_t >(nullptr , Device);
341
345
auto Err = Device->Device ->initAsyncInfo (&(CreatedQueue->AsyncInfo ));
342
346
if (Err)
343
- return {OL_ERRC_UNKNOWN , " Could not initialize stream resource" };
347
+ return {std::move (Err) , " Could not initialize stream resource" };
344
348
345
349
*Queue = CreatedQueue.release ();
346
350
return OL_SUCCESS;
@@ -355,24 +359,28 @@ ol_impl_result_t olWaitQueue_impl(ol_queue_handle_t Queue) {
355
359
// on it, but we have nothing to synchronize in that situation anyway.
356
360
if (Queue->AsyncInfo ->Queue ) {
357
361
auto Err = Queue->Device ->Device ->synchronize (Queue->AsyncInfo );
358
- if (Err)
362
+ if (Err) {
363
+ llvm::consumeError (std::move (Err));
359
364
return {OL_ERRC_INVALID_QUEUE, " The queue failed to synchronize" };
365
+ }
360
366
}
361
367
362
368
// Recreate the stream resource so the queue can be reused
363
369
// TODO: Would be easier for the synchronization to (optionally) not release
364
370
// it to begin with.
365
371
auto Res = Queue->Device ->Device ->initAsyncInfo (&Queue->AsyncInfo );
366
372
if (Res)
367
- return {OL_ERRC_UNKNOWN , " Could not reinitialize the stream resource" };
373
+ return {std::move (Res) , " Could not reinitialize the stream resource" };
368
374
369
375
return OL_SUCCESS;
370
376
}
371
377
372
378
ol_impl_result_t olWaitEvent_impl (ol_event_handle_t Event) {
373
379
auto Res = Event->Queue ->Device ->Device ->syncEvent (Event->EventInfo );
374
- if (Res)
380
+ if (Res) {
381
+ llvm::consumeError (std::move (Res));
375
382
return {OL_ERRC_INVALID_EVENT, " The event failed to synchronize" };
383
+ }
376
384
377
385
return OL_SUCCESS;
378
386
}
@@ -384,13 +392,17 @@ ol_impl_result_t olDestroyEvent_impl(ol_event_handle_t Event) {
384
392
ol_event_handle_t makeEvent (ol_queue_handle_t Queue) {
385
393
auto EventImpl = std::make_unique<ol_event_impl_t >(nullptr , Queue);
386
394
auto Res = Queue->Device ->Device ->createEvent (&EventImpl->EventInfo );
387
- if (Res)
395
+ if (Res) {
396
+ llvm::consumeError (std::move (Res));
388
397
return nullptr ;
398
+ }
389
399
390
400
Res = Queue->Device ->Device ->recordEvent (EventImpl->EventInfo ,
391
401
Queue->AsyncInfo );
392
- if (Res)
402
+ if (Res) {
403
+ llvm::consumeError (std::move (Res));
393
404
return nullptr ;
405
+ }
394
406
395
407
return EventImpl.release ();
396
408
}
@@ -416,16 +428,16 @@ ol_impl_result_t olMemcpy_impl(ol_queue_handle_t Queue, void *DstPtr,
416
428
if (DstDevice == HostDevice ()) {
417
429
auto Res = SrcDevice->Device ->dataRetrieve (DstPtr, SrcPtr, Size , QueueImpl);
418
430
if (Res)
419
- return {OL_ERRC_UNKNOWN , " The data retrieve operation failed" };
431
+ return {std::move (Res) , " The data retrieve operation failed" };
420
432
} else if (SrcDevice == HostDevice ()) {
421
433
auto Res = DstDevice->Device ->dataSubmit (DstPtr, SrcPtr, Size , QueueImpl);
422
434
if (Res)
423
- return {OL_ERRC_UNKNOWN , " The data submit operation failed" };
435
+ return {std::move (Res) , " The data submit operation failed" };
424
436
} else {
425
437
auto Res = SrcDevice->Device ->dataExchange (SrcPtr, *DstDevice->Device ,
426
438
DstPtr, Size , QueueImpl);
427
439
if (Res)
428
- return {OL_ERRC_UNKNOWN , " The data exchange operation failed" };
440
+ return {std::move (Res) , " The data exchange operation failed" };
429
441
}
430
442
431
443
if (EventOut)
@@ -452,6 +464,7 @@ ol_impl_result_t olCreateProgram_impl(ol_device_handle_t Device,
452
464
auto Res =
453
465
Device->Device ->loadBinary (Device->Device ->Plugin , &Prog->DeviceImage );
454
466
if (!Res) {
467
+ llvm::consumeError (Res.takeError ());
455
468
delete Prog;
456
469
return OL_ERRC_INVALID_VALUE;
457
470
}
@@ -477,7 +490,7 @@ ol_impl_result_t olGetKernel_impl(ol_program_handle_t Program,
477
490
478
491
auto Err = KernelImpl->init (Device, *Program->Image );
479
492
if (Err)
480
- return {OL_ERRC_UNKNOWN , " Could not initialize the kernel" };
493
+ return {std::move (Err) , " Could not initialize the kernel" };
481
494
482
495
*Kernel = &*KernelImpl;
483
496
@@ -520,7 +533,7 @@ olLaunchKernel_impl(ol_queue_handle_t Queue, ol_device_handle_t Device,
520
533
521
534
AsyncInfoWrapper.finalize (Err);
522
535
if (Err)
523
- return {OL_ERRC_UNKNOWN , " Could not finalize the AsyncInfoWrapper" };
536
+ return {std::move (Err) , " Could not finalize the AsyncInfoWrapper" };
524
537
525
538
if (EventOut)
526
539
*EventOut = makeEvent (Queue);
0 commit comments