@@ -54,7 +54,7 @@ ur_result_t cl_adapter::checkDeviceExtensions(
5454
5555UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet (ur_platform_handle_t hPlatform,
5656 ur_device_type_t DeviceType,
57- uint32_t NumEntries,
57+ [[maybe_unused]] uint32_t NumEntries,
5858 ur_device_handle_t *phDevices,
5959 uint32_t *pNumDevices) {
6060
@@ -75,24 +75,26 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet(ur_platform_handle_t hPlatform,
7575 Type = CL_DEVICE_TYPE_ACCELERATOR;
7676 break ;
7777 case UR_DEVICE_TYPE_DEFAULT:
78- Type = UR_DEVICE_TYPE_DEFAULT ;
78+ Type = CL_DEVICE_TYPE_DEFAULT ;
7979 break ;
8080 default :
8181 return UR_RESULT_ERROR_INVALID_ENUMERATION;
8282 }
83-
84- CL_RETURN_ON_FAILURE (hPlatform->GetDevices (Type));
85- size_t NumDevices = hPlatform->Devices .size ();
8683 try {
87- if (pNumDevices) {
88- *pNumDevices = NumDevices;
89- }
90-
91- if (phDevices) {
92- for (size_t i = 0 ; i < std::min (size_t (NumEntries), NumDevices); ++i) {
93- phDevices[i] = hPlatform->Devices [i];
84+ uint32_t AllDevicesNum = hPlatform->Devices .size ();
85+ uint32_t DeviceNumIter = 0 ;
86+ for (uint32_t i = 0 ; i < AllDevicesNum; i++) {
87+ cl_device_type DeviceType = hPlatform->Devices [i]->Type ;
88+ if (DeviceType == Type || Type == CL_DEVICE_TYPE_ALL) {
89+ if (phDevices) {
90+ phDevices[DeviceNumIter] = hPlatform->Devices [i];
91+ }
92+ DeviceNumIter++;
9493 }
9594 }
95+ if (pNumDevices) {
96+ *pNumDevices = DeviceNumIter;
97+ }
9698
9799 return UR_RESULT_SUCCESS;
98100 } catch (ur_result_t Err) {
@@ -329,9 +331,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
329331 * to UR */
330332 switch (static_cast <uint32_t >(propName)) {
331333 case UR_DEVICE_INFO_TYPE: {
332- cl_device_type CLType;
333- CL_RETURN_ON_FAILURE (clGetDeviceInfo (
334- hDevice->get (), CLPropName, sizeof (cl_device_type), &CLType, nullptr ));
334+ cl_device_type CLType = hDevice->Type ;
335335
336336 /* TODO UR: If the device is an Accelerator (FPGA, VPU, etc.), there is not
337337 * enough information in the OpenCL runtime to know exactly which type it
@@ -861,7 +861,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
861861 case UR_DEVICE_INFO_MAX_PARAMETER_SIZE:
862862 case UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION:
863863 case UR_DEVICE_INFO_PRINTF_BUFFER_SIZE:
864- case UR_DEVICE_INFO_PARENT_DEVICE:
865864 case UR_DEVICE_INFO_IL_VERSION:
866865 case UR_DEVICE_INFO_NAME:
867866 case UR_DEVICE_INFO_VENDOR:
@@ -895,6 +894,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
895894 }
896895 return UR_RESULT_ERROR_INVALID_DEVICE;
897896 }
897+ case UR_DEVICE_INFO_PARENT_DEVICE: {
898+ return ReturnValue (hDevice->ParentDevice );
899+ }
898900 case UR_DEVICE_INFO_EXTENSIONS: {
899901 cl_device_id Dev = hDevice->get ();
900902 size_t ExtSize = 0 ;
@@ -997,9 +999,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDevicePartition(
997999 CL_RETURN_ON_FAILURE (clCreateSubDevices (hDevice->get (), CLProperties.data (),
9981000 CLNumDevicesRet,
9991001 CLSubDevices.data (), nullptr ));
1000-
1001- std::memcpy ( phSubDevices, CLSubDevices. data (),
1002- sizeof (cl_device_id) * NumDevices);
1002+ for ( uint32_t i = 0 ; i < NumDevices; i++) {
1003+ phSubDevices[i] = new ur_device_handle_t_ (CLSubDevices[i], hDevice-> Platform , hDevice);
1004+ }
10031005 }
10041006
10051007 return UR_RESULT_SUCCESS;
@@ -1031,7 +1033,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceCreateWithNativeHandle(
10311033 ur_native_handle_t hNativeDevice, ur_platform_handle_t hPlatform,
10321034 const ur_device_native_properties_t *, ur_device_handle_t *phDevice) {
10331035 cl_device_id NativeHandle = reinterpret_cast <cl_device_id>(hNativeDevice);
1034- *phDevice = new ur_device_handle_t_ (NativeHandle, hPlatform);
1036+ *phDevice = new ur_device_handle_t_ (NativeHandle, hPlatform, nullptr );
10351037 return UR_RESULT_SUCCESS;
10361038}
10371039
0 commit comments