Skip to content

Commit e5f56a4

Browse files
committed
Handle unknown device type in DPCTLPlatform_GetDevices
1 parent d765291 commit e5f56a4

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

dpctl/_sycl_platform.pyx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,6 @@ cdef class SyclPlatform(_SyclPlatform):
398398
If `device_type` is not a str or :class:`dpctl.device_type`
399399
enum.
400400
ValueError:
401-
If the value of `device_type` is not supported.
402-
403401
If the ``DPCTLPlatform_GetDevices`` call returned
404402
``NULL`` instead of a ``DPCTLDeviceVectorRef`` object.
405403
"""
@@ -424,9 +422,7 @@ cdef class SyclPlatform(_SyclPlatform):
424422
elif dty_str == "gpu":
425423
DTy = _device_type._GPU
426424
else:
427-
raise ValueError(
428-
"Unexpected value of `device_type`."
429-
)
425+
DTy = _device_type._UNKNOWN_DEVICE
430426
elif isinstance(device_type, device_type_t):
431427
if device_type == device_type_t.all:
432428
DTy = _device_type._ALL_DEVICES
@@ -441,9 +437,7 @@ cdef class SyclPlatform(_SyclPlatform):
441437
elif device_type == device_type_t.gpu:
442438
DTy = _device_type._GPU
443439
else:
444-
raise ValueError(
445-
"Unexpected value of `device_type`."
446-
)
440+
DTy = _device_type._UNKNOWN_DEVICE
447441
else:
448442
raise TypeError(
449443
"device type should be specified as a str or an "

libsyclinterface/source/dpctl_sycl_platform_interface.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ DPCTLPlatform_GetDevices(__dpctl_keep const DPCTLSyclPlatformRef PRef,
282282
__FILE__, __func__, __LINE__);
283283
return nullptr;
284284
}
285+
285286
using vecTy = std::vector<DPCTLSyclDeviceRef>;
286287
vecTy *DevicesVectorPtr = nullptr;
287288
try {
@@ -291,6 +292,12 @@ DPCTLPlatform_GetDevices(__dpctl_keep const DPCTLSyclPlatformRef PRef,
291292
error_handler(e, __FILE__, __func__, __LINE__);
292293
return nullptr;
293294
}
295+
296+
// handle unknown device
297+
if (!DTy) {
298+
return wrap<vecTy>(DevicesVectorPtr);
299+
}
300+
294301
try {
295302
auto SyclDTy = DPCTL_DPCTLDeviceTypeToSyclDeviceType(DTy);
296303
auto Devices = P->get_devices(SyclDTy);

0 commit comments

Comments
 (0)