@@ -61,15 +61,6 @@ using pi_bool = pi_uint32;
61
61
using pi_bitfield = pi_uint64;
62
62
using pi_native_handle = uintptr_t ;
63
63
64
- enum pi_handle_type {
65
- PI_NATIVE_HANDLE_CONTEXT,
66
- PI_NATIVE_HANDLE_DEVICE,
67
- PI_NATIVE_HANDLE_QUEUE,
68
- PI_NATIVE_HANDLE_EVENT,
69
- PI_NATIVE_HANDLE_MEM,
70
- PI_NATIVE_HANDLE_PLATFORM
71
- };
72
-
73
64
//
74
65
// NOTE: prefer to map 1:1 to OpenCL so that no translation is needed
75
66
// for PI <-> OpenCL ways. The PI <-> to other BE translation is almost
@@ -772,19 +763,6 @@ pi_result piPlatformGetInfo(pi_platform platform, pi_platform_info param_name,
772
763
size_t param_value_size, void *param_value,
773
764
size_t *param_value_size_ret);
774
765
775
- //
776
- // Device
777
- //
778
- // /
779
- // / Create PI device from the given raw device handle (if the "device"
780
- // / points to null), or, vice versa, extract the raw device handle into
781
- // / the "handle" (if it was pointing to a null) from the given PI device.
782
- // / NOTE: The instance of the PI device created is retained.
783
- // /
784
- pi_result piextDeviceConvert (
785
- pi_device *device, // /< [in,out] the pointer to PI device
786
- void **handle); // /< [in,out] the pointer to the raw device handle
787
-
788
766
pi_result piDevicesGet (pi_platform platform, pi_device_type device_type,
789
767
pi_uint32 num_entries, pi_device *devices,
790
768
pi_uint32 *num_devices);
@@ -802,6 +780,23 @@ pi_result piDevicePartition(pi_device device,
802
780
pi_uint32 num_devices, pi_device *out_devices,
803
781
pi_uint32 *out_num_devices);
804
782
783
+ // / Gets the native handle of a PI device object.
784
+ // /
785
+ // / \param device is the PI device to get the native handle of.
786
+ // / \param nativeHandle is the native handle of device.
787
+ pi_result piextDeviceGetNativeHandle (pi_device device,
788
+ pi_native_handle *nativeHandle);
789
+
790
+ // / Creates PI device object from a native handle.
791
+ // / NOTE: If the created PI object shares reference count with the native object
792
+ // / the reference count is increased by one. Otherwise the newly created
793
+ // / PI object has a reference count of 1.
794
+ // /
795
+ // / \param nativeHandle is the native handle to create PI device from.
796
+ // / \param device is the PI device created from the native handle.
797
+ pi_result piextDeviceCreateWithNativeHandle (pi_native_handle nativeHandle,
798
+ pi_device *device);
799
+
805
800
// / Selects the most appropriate device binary based on runtime information
806
801
// / and the IR characteristics.
807
802
// /
@@ -845,6 +840,23 @@ pi_result piextContextSetExtendedDeleter(pi_context context,
845
840
pi_context_extended_deleter func,
846
841
void *user_data);
847
842
843
+ // / Gets the native handle of a PI context object.
844
+ // /
845
+ // / \param context is the PI context to get the native handle of.
846
+ // / \param nativeHandle is the native handle of context.
847
+ pi_result piextContextGetNativeHandle (pi_context context,
848
+ pi_native_handle *nativeHandle);
849
+
850
+ // / Creates PI context object from a native handle.
851
+ // / NOTE: If the created PI object shares reference count with the native object
852
+ // / the reference count is increased by one. Otherwise the newly created
853
+ // / PI object has a reference count of 1.
854
+ // /
855
+ // / \param nativeHandle is the native handle to create PI context from.
856
+ // / \param context is the PI context created from the native handle.
857
+ pi_result piextContextCreateWithNativeHandle (pi_native_handle nativeHandle,
858
+ pi_context *context);
859
+
848
860
//
849
861
// Queue
850
862
//
@@ -861,6 +873,23 @@ pi_result piQueueRelease(pi_queue command_queue);
861
873
862
874
pi_result piQueueFinish (pi_queue command_queue);
863
875
876
+ // / Gets the native handle of a PI queue object.
877
+ // /
878
+ // / \param queue is the PI queue to get the native handle of.
879
+ // / \param nativeHandle is the native handle of queue.
880
+ pi_result piextQueueGetNativeHandle (pi_queue queue,
881
+ pi_native_handle *nativeHandle);
882
+
883
+ // / Creates PI queue object from a native handle.
884
+ // / NOTE: If the created PI object shares reference count with the native object
885
+ // / the reference count is increased by one. Otherwise the newly created
886
+ // / PI object has a reference count of 1.
887
+ // /
888
+ // / \param nativeHandle is the native handle to create PI queue from.
889
+ // / \param queue is the PI queue created from the native handle.
890
+ pi_result piextQueueCreateWithNativeHandle (pi_native_handle nativeHandle,
891
+ pi_queue *queue);
892
+
864
893
//
865
894
// Memory
866
895
//
@@ -888,19 +917,26 @@ pi_result piMemRelease(pi_mem mem);
888
917
pi_result piMemBufferPartition (pi_mem buffer, pi_mem_flags flags,
889
918
pi_buffer_create_type buffer_create_type,
890
919
void *buffer_create_info, pi_mem *ret_mem);
920
+
921
+ // / Gets the native handle of a PI mem object.
922
+ // /
923
+ // / \param mem is the PI mem to get the native handle of.
924
+ // / \param nativeHandle is the native handle of mem.
925
+ pi_result piextMemGetNativeHandle (pi_mem mem, pi_native_handle *nativeHandle);
926
+
927
+ // / Creates PI mem object from a native handle.
928
+ // / NOTE: If the created PI object shares reference count with the native object
929
+ // / the reference count is increased by one. Otherwise the newly created
930
+ // / PI object has a reference count of 1.
931
+ // /
932
+ // / \param nativeHandle is the native handle to create PI mem from.
933
+ // / \param mem is the PI mem created from the native handle.
934
+ pi_result piextMemCreateWithNativeHandle (pi_native_handle nativeHandle,
935
+ pi_mem *mem);
936
+
891
937
//
892
938
// Program
893
939
//
894
- // /
895
- // / Create PI program from the given raw program handle (if the "program"
896
- // / points to null), or, vice versa, extract the raw program handle into
897
- // / the "handle" (if it was pointing to a null) from the given PI program.
898
- // / NOTE: The instance of the PI program created is retained.
899
- // /
900
- pi_result piextProgramConvert (
901
- pi_context context, // /< [in] the PI context of the program
902
- pi_program *program, // /< [in,out] the pointer to PI program
903
- void **handle); // /< [in,out] the pointer to the raw program handle
904
940
905
941
pi_result piProgramCreate (pi_context context, const void *il, size_t length,
906
942
pi_program *res_program);
@@ -960,6 +996,23 @@ pi_result piextProgramSetSpecializationConstant(pi_program prog,
960
996
size_t spec_size,
961
997
const void *spec_value);
962
998
999
+ // / Gets the native handle of a PI program object.
1000
+ // /
1001
+ // / \param program is the PI program to get the native handle of.
1002
+ // / \param nativeHandle is the native handle of program.
1003
+ pi_result piextProgramGetNativeHandle (pi_program program,
1004
+ pi_native_handle *nativeHandle);
1005
+
1006
+ // / Creates PI program object from a native handle.
1007
+ // / NOTE: If the created PI object shares reference count with the native object
1008
+ // / the reference count is increased by one. Otherwise the newly created
1009
+ // / PI object has a reference count of 1.
1010
+ // /
1011
+ // / \param nativeHandle is the native handle to create PI program from.
1012
+ // / \param program is the PI program created from the native handle.
1013
+ pi_result piextProgramCreateWithNativeHandle (pi_native_handle nativeHandle,
1014
+ pi_program *program);
1015
+
963
1016
//
964
1017
// Kernel
965
1018
//
@@ -1051,6 +1104,23 @@ pi_result piEventRetain(pi_event event);
1051
1104
1052
1105
pi_result piEventRelease (pi_event event);
1053
1106
1107
+ // / Gets the native handle of a PI event object.
1108
+ // /
1109
+ // / \param event is the PI event to get the native handle of.
1110
+ // / \param nativeHandle is the native handle of event.
1111
+ pi_result piextEventGetNativeHandle (pi_event event,
1112
+ pi_native_handle *nativeHandle);
1113
+
1114
+ // / Creates PI event object from a native handle.
1115
+ // / NOTE: If the created PI object shares reference count with the native object
1116
+ // / the reference count is increased by one. Otherwise the newly created
1117
+ // / PI object has a reference count of 1.
1118
+ // /
1119
+ // / \param nativeHandle is the native handle to create PI event from.
1120
+ // / \param event is the PI event created from the native handle.
1121
+ pi_result piextEventCreateWithNativeHandle (pi_native_handle nativeHandle,
1122
+ pi_event *event);
1123
+
1054
1124
//
1055
1125
// Sampler
1056
1126
//
@@ -1356,14 +1426,6 @@ pi_result piextUSMGetMemAllocInfo(pi_context context, const void *ptr,
1356
1426
size_t param_value_size, void *param_value,
1357
1427
size_t *param_value_size_ret);
1358
1428
1359
- // / Gets the native handle of a SYCL object.
1360
- // /
1361
- // / \param handleType is a representation of the native handle.
1362
- // / \param piObject is the PI object to get the native handle of.
1363
- // / \param nativeHandle is the native handle of piObject.
1364
- pi_result piGetNativeHandle (pi_handle_type handleType, void *piObject,
1365
- pi_native_handle *nativeHandle);
1366
-
1367
1429
struct _pi_plugin {
1368
1430
// PI version supported by host passed to the plugin. The Plugin
1369
1431
// checks and writes the appropriate Function Pointers in
0 commit comments