@@ -46,6 +46,7 @@ from ._backend cimport ( # noqa: E211
46
46
_device_type,
47
47
)
48
48
49
+ from ._sycl_device import SyclDeviceCreationError
49
50
from .enum_types import backend_type
50
51
from .enum_types import device_type as device_type_t
51
52
@@ -307,15 +308,15 @@ cpdef SyclDevice select_accelerator_device():
307
308
dpctl.SyclDevice: A Python object wrapping the SYCL ``device``
308
309
returned by the SYCL ``accelerator_selector``.
309
310
Raises:
310
- ValueError : If the SYCL ``accelerator_selector`` is unable to select a
311
- ``device``.
311
+ dpctl.SyclDeviceCreatioError : If the SYCL ``accelerator_selector`` is
312
+ unable to select a ``device``.
312
313
"""
313
314
cdef DPCTLSyclDeviceSelectorRef DSRef = DPCTLAcceleratorSelector_Create()
314
315
cdef DPCTLSyclDeviceRef DRef = DPCTLDevice_CreateFromSelector(DSRef)
315
316
# Free up the device selector
316
317
DPCTLDeviceSelector_Delete(DSRef)
317
318
if DRef is NULL :
318
- raise ValueError ( " Device unavailable." )
319
+ raise SyclDeviceCreationError( " Accelerator device is unavailable." )
319
320
Device = SyclDevice._create(DRef)
320
321
return Device
321
322
@@ -327,15 +328,15 @@ cpdef SyclDevice select_cpu_device():
327
328
dpctl.SyclDevice: A Python object wrapping the SYCL ``device``
328
329
returned by the SYCL ``cpu_selector``.
329
330
Raises:
330
- ValueError : If the SYCL ``cpu_selector`` is unable to select a
331
- ``device``.
331
+ dpctl.SyclDeviceCreationError : If the SYCL ``cpu_selector`` is
332
+ unable to select a ``device``.
332
333
"""
333
334
cdef DPCTLSyclDeviceSelectorRef DSRef = DPCTLCPUSelector_Create()
334
335
cdef DPCTLSyclDeviceRef DRef = DPCTLDevice_CreateFromSelector(DSRef)
335
336
# Free up the device selector
336
337
DPCTLDeviceSelector_Delete(DSRef)
337
338
if DRef is NULL :
338
- raise ValueError ( " Device unavailable." )
339
+ raise SyclDeviceCreationError( " CPU device is unavailable." )
339
340
Device = SyclDevice._create(DRef)
340
341
return Device
341
342
@@ -347,15 +348,15 @@ cpdef SyclDevice select_default_device():
347
348
dpctl.SyclDevice: A Python object wrapping the SYCL ``device``
348
349
returned by the SYCL ``default_selector``.
349
350
Raises:
350
- ValueError : If the SYCL ``default_selector`` is unable to select a
351
- ``device``.
351
+ dpctl.SyclDeviceCreationError : If the SYCL ``default_selector`` is
352
+ unable to select a ``device``.
352
353
"""
353
354
cdef DPCTLSyclDeviceSelectorRef DSRef = DPCTLDefaultSelector_Create()
354
355
cdef DPCTLSyclDeviceRef DRef = DPCTLDevice_CreateFromSelector(DSRef)
355
356
# Free up the device selector
356
357
DPCTLDeviceSelector_Delete(DSRef)
357
358
if DRef is NULL :
358
- raise ValueError ( " Device unavailable." )
359
+ raise SyclDeviceCreationError( " Default device is unavailable." )
359
360
Device = SyclDevice._create(DRef)
360
361
return Device
361
362
@@ -367,15 +368,15 @@ cpdef SyclDevice select_gpu_device():
367
368
dpctl.SyclDevice: A Python object wrapping the SYCL ``device``
368
369
returned by the SYCL ``gpu_selector``.
369
370
Raises:
370
- ValueError : If the SYCL ``gpu_selector`` is unable to select a
371
- ``device``.
371
+ dpctl.SyclDeviceCreationError : If the SYCL ``gpu_selector`` is
372
+ unable to select a ``device``.
372
373
"""
373
374
cdef DPCTLSyclDeviceSelectorRef DSRef = DPCTLGPUSelector_Create()
374
375
cdef DPCTLSyclDeviceRef DRef = DPCTLDevice_CreateFromSelector(DSRef)
375
376
# Free up the device selector
376
377
DPCTLDeviceSelector_Delete(DSRef)
377
378
if DRef is NULL :
378
- raise ValueError (" Device unavailable." )
379
+ raise SyclDeviceCreationError (" Device unavailable." )
379
380
Device = SyclDevice._create(DRef)
380
381
return Device
381
382
@@ -387,14 +388,14 @@ cpdef SyclDevice select_host_device():
387
388
dpctl.SyclDevice: A Python object wrapping the SYCL ``device``
388
389
returned by the SYCL ``host_selector``.
389
390
Raises:
390
- ValueError : If the SYCL ``host_selector`` is unable to select a
391
- ``device``.
391
+ dpctl.SyclDeviceCreationError : If the SYCL ``host_selector`` is
392
+ unable to select a ``device``.
392
393
"""
393
394
cdef DPCTLSyclDeviceSelectorRef DSRef = DPCTLHostSelector_Create()
394
395
cdef DPCTLSyclDeviceRef DRef = DPCTLDevice_CreateFromSelector(DSRef)
395
396
# Free up the device selector
396
397
DPCTLDeviceSelector_Delete(DSRef)
397
398
if DRef is NULL :
398
- raise ValueError ( " Device unavailable." )
399
+ raise SyclDeviceCreationError( " Host device is unavailable." )
399
400
Device = SyclDevice._create(DRef)
400
401
return Device
0 commit comments