@@ -349,14 +349,6 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle(
349
349
return result;
350
350
}
351
351
352
- try {
353
- // convert platform handle to loader handle
354
- *phNativePlatform = reinterpret_cast <ur_native_handle_t >(
355
- ur_native_factory.getInstance (*phNativePlatform, dditable));
356
- } catch (std::bad_alloc &) {
357
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
358
- }
359
-
360
352
return result;
361
353
}
362
354
@@ -670,14 +662,6 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle(
670
662
return result;
671
663
}
672
664
673
- try {
674
- // convert platform handle to loader handle
675
- *phNativeDevice = reinterpret_cast <ur_native_handle_t >(
676
- ur_native_factory.getInstance (*phNativeDevice, dditable));
677
- } catch (std::bad_alloc &) {
678
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
679
- }
680
-
681
665
return result;
682
666
}
683
667
@@ -696,17 +680,13 @@ __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle(
696
680
697
681
// extract platform's function pointer table
698
682
auto dditable =
699
- reinterpret_cast <ur_native_object_t *>(hNativeDevice )->dditable ;
683
+ reinterpret_cast <ur_platform_object_t *>(hPlatform )->dditable ;
700
684
auto pfnCreateWithNativeHandle =
701
685
dditable->ur .Device .pfnCreateWithNativeHandle ;
702
686
if (nullptr == pfnCreateWithNativeHandle) {
703
687
return UR_RESULT_ERROR_UNINITIALIZED;
704
688
}
705
689
706
- // convert loader handle to platform handle
707
- hNativeDevice =
708
- reinterpret_cast <ur_native_object_t *>(hNativeDevice)->handle ;
709
-
710
690
// convert loader handle to platform handle
711
691
hPlatform = reinterpret_cast <ur_platform_object_t *>(hPlatform)->handle ;
712
692
@@ -913,14 +893,6 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle(
913
893
return result;
914
894
}
915
895
916
- try {
917
- // convert platform handle to loader handle
918
- *phNativeContext = reinterpret_cast <ur_native_handle_t >(
919
- ur_native_factory.getInstance (*phNativeContext, dditable));
920
- } catch (std::bad_alloc &) {
921
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
922
- }
923
-
924
896
return result;
925
897
}
926
898
@@ -941,17 +913,13 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle(
941
913
942
914
// extract platform's function pointer table
943
915
auto dditable =
944
- reinterpret_cast <ur_native_object_t *>(hNativeContext )->dditable ;
916
+ reinterpret_cast <ur_device_object_t *>(*phDevices )->dditable ;
945
917
auto pfnCreateWithNativeHandle =
946
918
dditable->ur .Context .pfnCreateWithNativeHandle ;
947
919
if (nullptr == pfnCreateWithNativeHandle) {
948
920
return UR_RESULT_ERROR_UNINITIALIZED;
949
921
}
950
922
951
- // convert loader handle to platform handle
952
- hNativeContext =
953
- reinterpret_cast <ur_native_object_t *>(hNativeContext)->handle ;
954
-
955
923
// convert loader handles to platform handles
956
924
auto phDevicesLocal = std::vector<ur_device_handle_t >(numDevices);
957
925
for (size_t i = 0 ; i < numDevices; ++i) {
@@ -1204,14 +1172,6 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle(
1204
1172
return result;
1205
1173
}
1206
1174
1207
- try {
1208
- // convert platform handle to loader handle
1209
- *phNativeMem = reinterpret_cast <ur_native_handle_t >(
1210
- ur_native_factory.getInstance (*phNativeMem, dditable));
1211
- } catch (std::bad_alloc &) {
1212
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
1213
- }
1214
-
1215
1175
return result;
1216
1176
}
1217
1177
@@ -1229,17 +1189,13 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle(
1229
1189
ur_result_t result = UR_RESULT_SUCCESS;
1230
1190
1231
1191
// extract platform's function pointer table
1232
- auto dditable =
1233
- reinterpret_cast <ur_native_object_t *>(hNativeMem)->dditable ;
1192
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
1234
1193
auto pfnBufferCreateWithNativeHandle =
1235
1194
dditable->ur .Mem .pfnBufferCreateWithNativeHandle ;
1236
1195
if (nullptr == pfnBufferCreateWithNativeHandle) {
1237
1196
return UR_RESULT_ERROR_UNINITIALIZED;
1238
1197
}
1239
1198
1240
- // convert loader handle to platform handle
1241
- hNativeMem = reinterpret_cast <ur_native_object_t *>(hNativeMem)->handle ;
1242
-
1243
1199
// convert loader handle to platform handle
1244
1200
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
1245
1201
@@ -1279,17 +1235,13 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle(
1279
1235
ur_result_t result = UR_RESULT_SUCCESS;
1280
1236
1281
1237
// extract platform's function pointer table
1282
- auto dditable =
1283
- reinterpret_cast <ur_native_object_t *>(hNativeMem)->dditable ;
1238
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
1284
1239
auto pfnImageCreateWithNativeHandle =
1285
1240
dditable->ur .Mem .pfnImageCreateWithNativeHandle ;
1286
1241
if (nullptr == pfnImageCreateWithNativeHandle) {
1287
1242
return UR_RESULT_ERROR_UNINITIALIZED;
1288
1243
}
1289
1244
1290
- // convert loader handle to platform handle
1291
- hNativeMem = reinterpret_cast <ur_native_object_t *>(hNativeMem)->handle ;
1292
-
1293
1245
// convert loader handle to platform handle
1294
1246
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
1295
1247
@@ -1525,14 +1477,6 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle(
1525
1477
return result;
1526
1478
}
1527
1479
1528
- try {
1529
- // convert platform handle to loader handle
1530
- *phNativeSampler = reinterpret_cast <ur_native_handle_t >(
1531
- ur_native_factory.getInstance (*phNativeSampler, dditable));
1532
- } catch (std::bad_alloc &) {
1533
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
1534
- }
1535
-
1536
1480
return result;
1537
1481
}
1538
1482
@@ -1550,18 +1494,13 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle(
1550
1494
ur_result_t result = UR_RESULT_SUCCESS;
1551
1495
1552
1496
// extract platform's function pointer table
1553
- auto dditable =
1554
- reinterpret_cast <ur_native_object_t *>(hNativeSampler)->dditable ;
1497
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
1555
1498
auto pfnCreateWithNativeHandle =
1556
1499
dditable->ur .Sampler .pfnCreateWithNativeHandle ;
1557
1500
if (nullptr == pfnCreateWithNativeHandle) {
1558
1501
return UR_RESULT_ERROR_UNINITIALIZED;
1559
1502
}
1560
1503
1561
- // convert loader handle to platform handle
1562
- hNativeSampler =
1563
- reinterpret_cast <ur_native_object_t *>(hNativeSampler)->handle ;
1564
-
1565
1504
// convert loader handle to platform handle
1566
1505
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
1567
1506
@@ -2601,14 +2540,6 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle(
2601
2540
return result;
2602
2541
}
2603
2542
2604
- try {
2605
- // convert platform handle to loader handle
2606
- *phNativeProgram = reinterpret_cast <ur_native_handle_t >(
2607
- ur_native_factory.getInstance (*phNativeProgram, dditable));
2608
- } catch (std::bad_alloc &) {
2609
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
2610
- }
2611
-
2612
2543
return result;
2613
2544
}
2614
2545
@@ -2626,18 +2557,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle(
2626
2557
ur_result_t result = UR_RESULT_SUCCESS;
2627
2558
2628
2559
// extract platform's function pointer table
2629
- auto dditable =
2630
- reinterpret_cast <ur_native_object_t *>(hNativeProgram)->dditable ;
2560
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
2631
2561
auto pfnCreateWithNativeHandle =
2632
2562
dditable->ur .Program .pfnCreateWithNativeHandle ;
2633
2563
if (nullptr == pfnCreateWithNativeHandle) {
2634
2564
return UR_RESULT_ERROR_UNINITIALIZED;
2635
2565
}
2636
2566
2637
- // convert loader handle to platform handle
2638
- hNativeProgram =
2639
- reinterpret_cast <ur_native_object_t *>(hNativeProgram)->handle ;
2640
-
2641
2567
// convert loader handle to platform handle
2642
2568
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
2643
2569
@@ -3085,14 +3011,6 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle(
3085
3011
return result;
3086
3012
}
3087
3013
3088
- try {
3089
- // convert platform handle to loader handle
3090
- *phNativeKernel = reinterpret_cast <ur_native_handle_t >(
3091
- ur_native_factory.getInstance (*phNativeKernel, dditable));
3092
- } catch (std::bad_alloc &) {
3093
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
3094
- }
3095
-
3096
3014
return result;
3097
3015
}
3098
3016
@@ -3112,18 +3030,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle(
3112
3030
ur_result_t result = UR_RESULT_SUCCESS;
3113
3031
3114
3032
// extract platform's function pointer table
3115
- auto dditable =
3116
- reinterpret_cast <ur_native_object_t *>(hNativeKernel)->dditable ;
3033
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
3117
3034
auto pfnCreateWithNativeHandle =
3118
3035
dditable->ur .Kernel .pfnCreateWithNativeHandle ;
3119
3036
if (nullptr == pfnCreateWithNativeHandle) {
3120
3037
return UR_RESULT_ERROR_UNINITIALIZED;
3121
3038
}
3122
3039
3123
- // convert loader handle to platform handle
3124
- hNativeKernel =
3125
- reinterpret_cast <ur_native_object_t *>(hNativeKernel)->handle ;
3126
-
3127
3040
// convert loader handle to platform handle
3128
3041
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
3129
3042
@@ -3297,14 +3210,6 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle(
3297
3210
return result;
3298
3211
}
3299
3212
3300
- try {
3301
- // convert platform handle to loader handle
3302
- *phNativeQueue = reinterpret_cast <ur_native_handle_t >(
3303
- ur_native_factory.getInstance (*phNativeQueue, dditable));
3304
- } catch (std::bad_alloc &) {
3305
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
3306
- }
3307
-
3308
3213
return result;
3309
3214
}
3310
3215
@@ -3323,17 +3228,13 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle(
3323
3228
ur_result_t result = UR_RESULT_SUCCESS;
3324
3229
3325
3230
// extract platform's function pointer table
3326
- auto dditable =
3327
- reinterpret_cast <ur_native_object_t *>(hNativeQueue)->dditable ;
3231
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
3328
3232
auto pfnCreateWithNativeHandle =
3329
3233
dditable->ur .Queue .pfnCreateWithNativeHandle ;
3330
3234
if (nullptr == pfnCreateWithNativeHandle) {
3331
3235
return UR_RESULT_ERROR_UNINITIALIZED;
3332
3236
}
3333
3237
3334
- // convert loader handle to platform handle
3335
- hNativeQueue = reinterpret_cast <ur_native_object_t *>(hNativeQueue)->handle ;
3336
-
3337
3238
// convert loader handle to platform handle
3338
3239
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
3339
3240
@@ -3570,14 +3471,6 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle(
3570
3471
return result;
3571
3472
}
3572
3473
3573
- try {
3574
- // convert platform handle to loader handle
3575
- *phNativeEvent = reinterpret_cast <ur_native_handle_t >(
3576
- ur_native_factory.getInstance (*phNativeEvent, dditable));
3577
- } catch (std::bad_alloc &) {
3578
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
3579
- }
3580
-
3581
3474
return result;
3582
3475
}
3583
3476
@@ -3595,17 +3488,13 @@ __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle(
3595
3488
ur_result_t result = UR_RESULT_SUCCESS;
3596
3489
3597
3490
// extract platform's function pointer table
3598
- auto dditable =
3599
- reinterpret_cast <ur_native_object_t *>(hNativeEvent)->dditable ;
3491
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
3600
3492
auto pfnCreateWithNativeHandle =
3601
3493
dditable->ur .Event .pfnCreateWithNativeHandle ;
3602
3494
if (nullptr == pfnCreateWithNativeHandle) {
3603
3495
return UR_RESULT_ERROR_UNINITIALIZED;
3604
3496
}
3605
3497
3606
- // convert loader handle to platform handle
3607
- hNativeEvent = reinterpret_cast <ur_native_object_t *>(hNativeEvent)->handle ;
3608
-
3609
3498
// convert loader handle to platform handle
3610
3499
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
3611
3500
0 commit comments