Skip to content

Commit

Permalink
Adds get_unpartitioned_parent_device method to SyclDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
ndgrigorian committed Jan 14, 2025
1 parent 472d28b commit 7a9c6a8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions dpctl/_sycl_device.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,30 @@ cdef class SyclDevice(_SyclDevice):
else:
return str(relId)

def get_unpartitioned_parent_device(self):
""" get_unpartitioned_parent_device(self)
Returns the unpartitioned parent device of this device, or None for a
root device.
Returns:
dpctl.SyclDevice:
A parent, unpartitioned :class:`dpctl.SyclDevice` instance if
the device is a sub-device, ``None`` otherwise.
"""
cdef DPCTLSyclDeviceRef pDRef = NULL
cdef DPCTLSyclDeviceRef tDRef = NULL
pDRef = DPCTLDevice_GetParentDevice(self._device_ref)
if pDRef is NULL:
return None
else:
tDRef = DPCTLDevice_GetParentDevice(pDRef)
while tDRef is not NULL:
DPCTLDevice_Delete(pDRef)
pDRef = tDRef
tDRef = DPCTLDevice_GetParentDevice(pDRef)
return SyclDevice._create(pDRef)

def get_device_id(self):
""" get_device_id()
For an unpartitioned device, returns the canonical index of this device
Expand Down

0 comments on commit 7a9c6a8

Please sign in to comment.