Skip to content

Commit 9cacc0e

Browse files
added SyclDevice.platform property
1 parent d0e6bf5 commit 9cacc0e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

dpctl/_sycl_device.pyx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ from ._backend cimport ( # noqa: E211
5050
DPCTLDevice_GetMaxWriteImageArgs,
5151
DPCTLDevice_GetName,
5252
DPCTLDevice_GetParentDevice,
53+
DPCTLDevice_GetPlatform,
5354
DPCTLDevice_GetPreferredVectorWidthChar,
5455
DPCTLDevice_GetPreferredVectorWidthDouble,
5556
DPCTLDevice_GetPreferredVectorWidthFloat,
@@ -80,6 +81,7 @@ from ._backend cimport ( # noqa: E211
8081
DPCTLSize_t_Array_Delete,
8182
DPCTLSyclDeviceRef,
8283
DPCTLSyclDeviceSelectorRef,
84+
DPCTLSyclPlatformRef,
8385
_aspect_type,
8486
_backend_type,
8587
_device_type,
@@ -91,6 +93,8 @@ from .enum_types import backend_type, device_type
9193
from libc.stdint cimport int64_t, uint32_t
9294
from libc.stdlib cimport free, malloc
9395

96+
from ._sycl_platform cimport SyclPlatform
97+
9498
import collections
9599
import warnings
96100

@@ -639,6 +643,22 @@ cdef class SyclDevice(_SyclDevice):
639643
self._device_ref
640644
)
641645

646+
@property
647+
def platform(self):
648+
""" Returns the platform associated with this device.
649+
650+
Returns:
651+
:class:`dpctl.SyclPlatform`: The platform associated with this
652+
device.
653+
"""
654+
cdef DPCTLSyclPlatformRef PRef = (
655+
DPCTLDevice_GetPlatform(self._device_ref)
656+
)
657+
if (PRef == NULL):
658+
raise RuntimeError("Could not get platform for device.")
659+
else:
660+
return SyclPlatform._create(PRef)
661+
642662
@property
643663
def preferred_vector_width_char(self):
644664
""" Returns the preferred native vector width size for built-in scalar

0 commit comments

Comments
 (0)