@@ -352,14 +352,6 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle(
352
352
return result;
353
353
}
354
354
355
- try {
356
- // convert platform handle to loader handle
357
- *phNativePlatform = reinterpret_cast <ur_native_handle_t >(
358
- ur_native_factory.getInstance (*phNativePlatform, dditable));
359
- } catch (std::bad_alloc &) {
360
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
361
- }
362
-
363
355
return result;
364
356
}
365
357
@@ -673,14 +665,6 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle(
673
665
return result;
674
666
}
675
667
676
- try {
677
- // convert platform handle to loader handle
678
- *phNativeDevice = reinterpret_cast <ur_native_handle_t >(
679
- ur_native_factory.getInstance (*phNativeDevice, dditable));
680
- } catch (std::bad_alloc &) {
681
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
682
- }
683
-
684
668
return result;
685
669
}
686
670
@@ -699,17 +683,13 @@ __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle(
699
683
700
684
// extract platform's function pointer table
701
685
auto dditable =
702
- reinterpret_cast <ur_native_object_t *>(hNativeDevice )->dditable ;
686
+ reinterpret_cast <ur_platform_object_t *>(hPlatform )->dditable ;
703
687
auto pfnCreateWithNativeHandle =
704
688
dditable->ur .Device .pfnCreateWithNativeHandle ;
705
689
if (nullptr == pfnCreateWithNativeHandle) {
706
690
return UR_RESULT_ERROR_UNINITIALIZED;
707
691
}
708
692
709
- // convert loader handle to platform handle
710
- hNativeDevice =
711
- reinterpret_cast <ur_native_object_t *>(hNativeDevice)->handle ;
712
-
713
693
// convert loader handle to platform handle
714
694
hPlatform = reinterpret_cast <ur_platform_object_t *>(hPlatform)->handle ;
715
695
@@ -916,14 +896,6 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle(
916
896
return result;
917
897
}
918
898
919
- try {
920
- // convert platform handle to loader handle
921
- *phNativeContext = reinterpret_cast <ur_native_handle_t >(
922
- ur_native_factory.getInstance (*phNativeContext, dditable));
923
- } catch (std::bad_alloc &) {
924
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
925
- }
926
-
927
899
return result;
928
900
}
929
901
@@ -944,17 +916,13 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle(
944
916
945
917
// extract platform's function pointer table
946
918
auto dditable =
947
- reinterpret_cast <ur_native_object_t *>(hNativeContext )->dditable ;
919
+ reinterpret_cast <ur_device_object_t *>(*phDevices )->dditable ;
948
920
auto pfnCreateWithNativeHandle =
949
921
dditable->ur .Context .pfnCreateWithNativeHandle ;
950
922
if (nullptr == pfnCreateWithNativeHandle) {
951
923
return UR_RESULT_ERROR_UNINITIALIZED;
952
924
}
953
925
954
- // convert loader handle to platform handle
955
- hNativeContext =
956
- reinterpret_cast <ur_native_object_t *>(hNativeContext)->handle ;
957
-
958
926
// convert loader handles to platform handles
959
927
auto phDevicesLocal = std::vector<ur_device_handle_t >(numDevices);
960
928
for (size_t i = 0 ; i < numDevices; ++i) {
@@ -1207,14 +1175,6 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle(
1207
1175
return result;
1208
1176
}
1209
1177
1210
- try {
1211
- // convert platform handle to loader handle
1212
- *phNativeMem = reinterpret_cast <ur_native_handle_t >(
1213
- ur_native_factory.getInstance (*phNativeMem, dditable));
1214
- } catch (std::bad_alloc &) {
1215
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
1216
- }
1217
-
1218
1178
return result;
1219
1179
}
1220
1180
@@ -1232,17 +1192,13 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle(
1232
1192
ur_result_t result = UR_RESULT_SUCCESS;
1233
1193
1234
1194
// extract platform's function pointer table
1235
- auto dditable =
1236
- reinterpret_cast <ur_native_object_t *>(hNativeMem)->dditable ;
1195
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
1237
1196
auto pfnBufferCreateWithNativeHandle =
1238
1197
dditable->ur .Mem .pfnBufferCreateWithNativeHandle ;
1239
1198
if (nullptr == pfnBufferCreateWithNativeHandle) {
1240
1199
return UR_RESULT_ERROR_UNINITIALIZED;
1241
1200
}
1242
1201
1243
- // convert loader handle to platform handle
1244
- hNativeMem = reinterpret_cast <ur_native_object_t *>(hNativeMem)->handle ;
1245
-
1246
1202
// convert loader handle to platform handle
1247
1203
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
1248
1204
@@ -1282,17 +1238,13 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle(
1282
1238
ur_result_t result = UR_RESULT_SUCCESS;
1283
1239
1284
1240
// extract platform's function pointer table
1285
- auto dditable =
1286
- reinterpret_cast <ur_native_object_t *>(hNativeMem)->dditable ;
1241
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
1287
1242
auto pfnImageCreateWithNativeHandle =
1288
1243
dditable->ur .Mem .pfnImageCreateWithNativeHandle ;
1289
1244
if (nullptr == pfnImageCreateWithNativeHandle) {
1290
1245
return UR_RESULT_ERROR_UNINITIALIZED;
1291
1246
}
1292
1247
1293
- // convert loader handle to platform handle
1294
- hNativeMem = reinterpret_cast <ur_native_object_t *>(hNativeMem)->handle ;
1295
-
1296
1248
// convert loader handle to platform handle
1297
1249
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
1298
1250
@@ -1528,14 +1480,6 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle(
1528
1480
return result;
1529
1481
}
1530
1482
1531
- try {
1532
- // convert platform handle to loader handle
1533
- *phNativeSampler = reinterpret_cast <ur_native_handle_t >(
1534
- ur_native_factory.getInstance (*phNativeSampler, dditable));
1535
- } catch (std::bad_alloc &) {
1536
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
1537
- }
1538
-
1539
1483
return result;
1540
1484
}
1541
1485
@@ -1553,18 +1497,13 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle(
1553
1497
ur_result_t result = UR_RESULT_SUCCESS;
1554
1498
1555
1499
// extract platform's function pointer table
1556
- auto dditable =
1557
- reinterpret_cast <ur_native_object_t *>(hNativeSampler)->dditable ;
1500
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
1558
1501
auto pfnCreateWithNativeHandle =
1559
1502
dditable->ur .Sampler .pfnCreateWithNativeHandle ;
1560
1503
if (nullptr == pfnCreateWithNativeHandle) {
1561
1504
return UR_RESULT_ERROR_UNINITIALIZED;
1562
1505
}
1563
1506
1564
- // convert loader handle to platform handle
1565
- hNativeSampler =
1566
- reinterpret_cast <ur_native_object_t *>(hNativeSampler)->handle ;
1567
-
1568
1507
// convert loader handle to platform handle
1569
1508
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
1570
1509
@@ -2604,14 +2543,6 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle(
2604
2543
return result;
2605
2544
}
2606
2545
2607
- try {
2608
- // convert platform handle to loader handle
2609
- *phNativeProgram = reinterpret_cast <ur_native_handle_t >(
2610
- ur_native_factory.getInstance (*phNativeProgram, dditable));
2611
- } catch (std::bad_alloc &) {
2612
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
2613
- }
2614
-
2615
2546
return result;
2616
2547
}
2617
2548
@@ -2629,18 +2560,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle(
2629
2560
ur_result_t result = UR_RESULT_SUCCESS;
2630
2561
2631
2562
// extract platform's function pointer table
2632
- auto dditable =
2633
- reinterpret_cast <ur_native_object_t *>(hNativeProgram)->dditable ;
2563
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
2634
2564
auto pfnCreateWithNativeHandle =
2635
2565
dditable->ur .Program .pfnCreateWithNativeHandle ;
2636
2566
if (nullptr == pfnCreateWithNativeHandle) {
2637
2567
return UR_RESULT_ERROR_UNINITIALIZED;
2638
2568
}
2639
2569
2640
- // convert loader handle to platform handle
2641
- hNativeProgram =
2642
- reinterpret_cast <ur_native_object_t *>(hNativeProgram)->handle ;
2643
-
2644
2570
// convert loader handle to platform handle
2645
2571
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
2646
2572
@@ -3088,14 +3014,6 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle(
3088
3014
return result;
3089
3015
}
3090
3016
3091
- try {
3092
- // convert platform handle to loader handle
3093
- *phNativeKernel = reinterpret_cast <ur_native_handle_t >(
3094
- ur_native_factory.getInstance (*phNativeKernel, dditable));
3095
- } catch (std::bad_alloc &) {
3096
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
3097
- }
3098
-
3099
3017
return result;
3100
3018
}
3101
3019
@@ -3115,18 +3033,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle(
3115
3033
ur_result_t result = UR_RESULT_SUCCESS;
3116
3034
3117
3035
// extract platform's function pointer table
3118
- auto dditable =
3119
- reinterpret_cast <ur_native_object_t *>(hNativeKernel)->dditable ;
3036
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
3120
3037
auto pfnCreateWithNativeHandle =
3121
3038
dditable->ur .Kernel .pfnCreateWithNativeHandle ;
3122
3039
if (nullptr == pfnCreateWithNativeHandle) {
3123
3040
return UR_RESULT_ERROR_UNINITIALIZED;
3124
3041
}
3125
3042
3126
- // convert loader handle to platform handle
3127
- hNativeKernel =
3128
- reinterpret_cast <ur_native_object_t *>(hNativeKernel)->handle ;
3129
-
3130
3043
// convert loader handle to platform handle
3131
3044
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
3132
3045
@@ -3300,14 +3213,6 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle(
3300
3213
return result;
3301
3214
}
3302
3215
3303
- try {
3304
- // convert platform handle to loader handle
3305
- *phNativeQueue = reinterpret_cast <ur_native_handle_t >(
3306
- ur_native_factory.getInstance (*phNativeQueue, dditable));
3307
- } catch (std::bad_alloc &) {
3308
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
3309
- }
3310
-
3311
3216
return result;
3312
3217
}
3313
3218
@@ -3326,17 +3231,13 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle(
3326
3231
ur_result_t result = UR_RESULT_SUCCESS;
3327
3232
3328
3233
// extract platform's function pointer table
3329
- auto dditable =
3330
- reinterpret_cast <ur_native_object_t *>(hNativeQueue)->dditable ;
3234
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
3331
3235
auto pfnCreateWithNativeHandle =
3332
3236
dditable->ur .Queue .pfnCreateWithNativeHandle ;
3333
3237
if (nullptr == pfnCreateWithNativeHandle) {
3334
3238
return UR_RESULT_ERROR_UNINITIALIZED;
3335
3239
}
3336
3240
3337
- // convert loader handle to platform handle
3338
- hNativeQueue = reinterpret_cast <ur_native_object_t *>(hNativeQueue)->handle ;
3339
-
3340
3241
// convert loader handle to platform handle
3341
3242
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
3342
3243
@@ -3573,14 +3474,6 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle(
3573
3474
return result;
3574
3475
}
3575
3476
3576
- try {
3577
- // convert platform handle to loader handle
3578
- *phNativeEvent = reinterpret_cast <ur_native_handle_t >(
3579
- ur_native_factory.getInstance (*phNativeEvent, dditable));
3580
- } catch (std::bad_alloc &) {
3581
- result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
3582
- }
3583
-
3584
3477
return result;
3585
3478
}
3586
3479
@@ -3598,17 +3491,13 @@ __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle(
3598
3491
ur_result_t result = UR_RESULT_SUCCESS;
3599
3492
3600
3493
// extract platform's function pointer table
3601
- auto dditable =
3602
- reinterpret_cast <ur_native_object_t *>(hNativeEvent)->dditable ;
3494
+ auto dditable = reinterpret_cast <ur_context_object_t *>(hContext)->dditable ;
3603
3495
auto pfnCreateWithNativeHandle =
3604
3496
dditable->ur .Event .pfnCreateWithNativeHandle ;
3605
3497
if (nullptr == pfnCreateWithNativeHandle) {
3606
3498
return UR_RESULT_ERROR_UNINITIALIZED;
3607
3499
}
3608
3500
3609
- // convert loader handle to platform handle
3610
- hNativeEvent = reinterpret_cast <ur_native_object_t *>(hNativeEvent)->handle ;
3611
-
3612
3501
// convert loader handle to platform handle
3613
3502
hContext = reinterpret_cast <ur_context_object_t *>(hContext)->handle ;
3614
3503
0 commit comments