@@ -75,7 +75,7 @@ urToHipImageChannelFormat(ur_image_channel_type_t image_channel_type,
75
75
size_t pixel_size_bytes = 0 ;
76
76
unsigned int num_channels = 0 ;
77
77
unsigned int normalized_dtype_flag = 0 ;
78
- UR_CHECK_ERROR (urCalculateNumChannels (image_channel_order, &num_channels));
78
+ UR_CALL (urCalculateNumChannels (image_channel_order, &num_channels));
79
79
80
80
switch (image_channel_type) {
81
81
#define CASE (FROM, TO, SIZE, NORM ) \
@@ -293,8 +293,15 @@ urBindlessImagesUnsampledImageHandleDestroyExp(
293
293
hDevice) != hContext->getDevices ().end (),
294
294
UR_RESULT_ERROR_INVALID_CONTEXT);
295
295
296
- UR_CHECK_ERROR (
297
- hipDestroySurfaceObject (reinterpret_cast <hipSurfaceObject_t>(hImage)));
296
+ try {
297
+ UR_CHECK_ERROR (
298
+ hipDestroySurfaceObject (reinterpret_cast <hipSurfaceObject_t>(hImage)));
299
+ } catch (ur_result_t error) {
300
+ return error;
301
+ } catch (...) {
302
+ return UR_RESULT_ERROR_UNKNOWN;
303
+ }
304
+
298
305
return UR_RESULT_SUCCESS;
299
306
}
300
307
@@ -306,9 +313,15 @@ urBindlessImagesSampledImageHandleDestroyExp(
306
313
hContext->getDevices ().end (),
307
314
hDevice) != hContext->getDevices ().end (),
308
315
UR_RESULT_ERROR_INVALID_CONTEXT);
316
+ try {
317
+ UR_CHECK_ERROR (
318
+ hipTexObjectDestroy (reinterpret_cast <hipTextureObject_t>(hImage)));
319
+ } catch (ur_result_t error) {
320
+ return error;
321
+ } catch (...) {
322
+ return UR_RESULT_ERROR_UNKNOWN;
323
+ }
309
324
310
- UR_CHECK_ERROR (
311
- hipTexObjectDestroy (reinterpret_cast <hipTextureObject_t>(hImage)));
312
325
return UR_RESULT_SUCCESS;
313
326
}
314
327
@@ -324,12 +337,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageAllocateExp(
324
337
// Populate descriptor
325
338
HIP_ARRAY3D_DESCRIPTOR array_desc = {};
326
339
327
- UR_CHECK_ERROR (urCalculateNumChannels (pImageFormat->channelOrder ,
328
- &array_desc.NumChannels ));
340
+ UR_CALL (urCalculateNumChannels (pImageFormat->channelOrder ,
341
+ &array_desc.NumChannels ));
329
342
330
- UR_CHECK_ERROR (urToHipImageChannelFormat (
331
- pImageFormat-> channelType , pImageFormat->channelOrder , &array_desc. Format ,
332
- nullptr , nullptr ));
343
+ UR_CALL (urToHipImageChannelFormat (pImageFormat-> channelType ,
344
+ pImageFormat->channelOrder ,
345
+ &array_desc. Format , nullptr , nullptr ));
333
346
334
347
array_desc.Flags = 0 ; // No flags required
335
348
array_desc.Width = pImageDesc->width ;
@@ -377,12 +390,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageAllocateExp(
377
390
reinterpret_cast <ur_exp_image_mem_native_handle_t >(ImageArray);
378
391
} catch (ur_result_t Err) {
379
392
if (ImageArray) {
380
- UR_CHECK_ERROR ( hipArrayDestroy (ImageArray) );
393
+ ( void ) hipArrayDestroy (ImageArray);
381
394
}
382
395
return Err;
383
396
} catch (...) {
384
397
if (ImageArray) {
385
- UR_CHECK_ERROR ( hipArrayDestroy (ImageArray) );
398
+ ( void ) hipArrayDestroy (ImageArray);
386
399
}
387
400
return UR_RESULT_ERROR_UNKNOWN;
388
401
}
@@ -398,12 +411,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageAllocateExp(
398
411
reinterpret_cast <ur_exp_image_mem_native_handle_t >(mip_array);
399
412
} catch (ur_result_t Err) {
400
413
if (mip_array) {
401
- UR_CHECK_ERROR ( hipMipmappedArrayDestroy (mip_array) );
414
+ ( void ) hipMipmappedArrayDestroy (mip_array);
402
415
}
403
416
return Err;
404
417
} catch (...) {
405
418
if (mip_array) {
406
- UR_CHECK_ERROR ( hipMipmappedArrayDestroy (mip_array) );
419
+ ( void ) hipMipmappedArrayDestroy (mip_array);
407
420
}
408
421
return UR_RESULT_ERROR_UNKNOWN;
409
422
}
@@ -444,14 +457,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp(
444
457
UR_RESULT_ERROR_INVALID_CONTEXT);
445
458
446
459
unsigned int NumChannels = 0 ;
447
- UR_CHECK_ERROR (
448
- urCalculateNumChannels (pImageFormat->channelOrder , &NumChannels));
460
+ UR_CALL (urCalculateNumChannels (pImageFormat->channelOrder , &NumChannels));
449
461
450
462
hipArray_Format format;
451
463
size_t PixelSizeBytes;
452
- UR_CHECK_ERROR (urToHipImageChannelFormat (pImageFormat->channelType ,
453
- pImageFormat->channelOrder , &format,
454
- &PixelSizeBytes, nullptr ));
464
+ UR_CALL (urToHipImageChannelFormat (pImageFormat->channelType ,
465
+ pImageFormat->channelOrder , &format,
466
+ &PixelSizeBytes, nullptr ));
455
467
456
468
try {
457
469
@@ -491,15 +503,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
491
503
ScopedDevice Active (hDevice);
492
504
493
505
unsigned int NumChannels = 0 ;
494
- UR_CHECK_ERROR (
495
- urCalculateNumChannels (pImageFormat->channelOrder , &NumChannels));
506
+ UR_CALL (urCalculateNumChannels (pImageFormat->channelOrder , &NumChannels));
496
507
497
508
hipArray_Format format;
498
509
size_t PixelSizeBytes;
499
510
unsigned int normalized_dtype_flag;
500
- UR_CHECK_ERROR (urToHipImageChannelFormat (
501
- pImageFormat-> channelType , pImageFormat->channelOrder , &format,
502
- &PixelSizeBytes, &normalized_dtype_flag));
511
+ UR_CALL (urToHipImageChannelFormat (pImageFormat-> channelType ,
512
+ pImageFormat->channelOrder , &format,
513
+ &PixelSizeBytes, &normalized_dtype_flag));
503
514
504
515
try {
505
516
HIP_RESOURCE_DESC image_res_desc = {};
@@ -583,14 +594,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
583
594
unsigned int NumChannels = 0 ;
584
595
size_t PixelSizeBytes = 0 ;
585
596
586
- UR_CHECK_ERROR (
587
- urCalculateNumChannels (pSrcImageFormat->channelOrder , &NumChannels));
597
+ UR_CALL (urCalculateNumChannels (pSrcImageFormat->channelOrder , &NumChannels));
588
598
589
599
// We need to get this now in bytes for calculating the total image size
590
600
// later.
591
- UR_CHECK_ERROR (urToHipImageChannelFormat (pSrcImageFormat->channelType ,
592
- pSrcImageFormat->channelOrder ,
593
- nullptr , &PixelSizeBytes, nullptr ));
601
+ UR_CALL (urToHipImageChannelFormat (pSrcImageFormat->channelType ,
602
+ pSrcImageFormat->channelOrder , nullptr ,
603
+ &PixelSizeBytes, nullptr ));
594
604
595
605
try {
596
606
ScopedDevice Active (hQueue->getDevice ());
@@ -927,21 +937,27 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp(
927
937
// ROCm 5.6.0, so we can't query image array information for older versions.
928
938
#if HIP_VERSION >= 50600000
929
939
unsigned int memType{};
930
- UR_CHECK_ERROR (
940
+ hipError_t Err =
931
941
hipPointerGetAttribute (&memType, HIP_POINTER_ATTRIBUTE_MEMORY_TYPE,
932
- reinterpret_cast <hipDeviceptr_t>(hImageMem)));
942
+ reinterpret_cast <hipDeviceptr_t>(hImageMem));
943
+ if (Err != hipSuccess) {
944
+ return mapErrorUR (Err);
945
+ }
933
946
UR_ASSERT (memType == hipMemoryTypeArray, UR_RESULT_ERROR_INVALID_VALUE);
934
947
935
948
hipArray_t ImageArray;
936
949
// If hipMipmappedArrayGetLevel failed, hImageMem is already hipArray_t.
937
- if (hipError_t Err = hipMipmappedArrayGetLevel (
938
- &ImageArray, reinterpret_cast <hipMipmappedArray_t>(hImageMem), 0 );
939
- Err != hipSuccess) {
950
+ Err = hipMipmappedArrayGetLevel (
951
+ &ImageArray, reinterpret_cast <hipMipmappedArray_t>(hImageMem), 0 );
952
+ if ( Err != hipSuccess) {
940
953
ImageArray = reinterpret_cast <hipArray_t>(hImageMem);
941
954
}
942
955
943
956
HIP_ARRAY3D_DESCRIPTOR ArrayDesc;
944
- UR_CHECK_ERROR (hipArray3DGetDescriptor (&ArrayDesc, ImageArray));
957
+ Err = hipArray3DGetDescriptor (&ArrayDesc, ImageArray);
958
+ if (Err != hipSuccess) {
959
+ return mapErrorUR (Err);
960
+ }
945
961
946
962
switch (propName) {
947
963
case UR_IMAGE_INFO_WIDTH:
@@ -971,7 +987,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp(
971
987
case UR_IMAGE_INFO_FORMAT: {
972
988
ur_image_channel_type_t ChannelType{};
973
989
ur_image_channel_order_t ChannelOrder{};
974
- UR_CHECK_ERROR (hipToUrImageChannelFormat (ArrayDesc.Format , &ChannelType));
990
+ UR_CALL (hipToUrImageChannelFormat (ArrayDesc.Format , &ChannelType));
975
991
// HIP does not have a notion of channel "order" in the same way that
976
992
// SYCL 1.2.1 does.
977
993
switch (ArrayDesc.NumChannels ) {
0 commit comments