Skip to content

Commit 2aca872

Browse files
Merge pull request #537 from IntelPython/feature/gh-381
Feature/gh 381
2 parents 0f96cb7 + 02ab1eb commit 2aca872

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

dpctl/_sycl_queue.pyx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,43 @@ cdef class SyclQueue(_SyclQueue):
932932

933933
return SyclEvent._create(ERef, [])
934934

935+
@property
936+
def backend(self):
937+
"""Returns the backend_type enum value for the device
938+
associated with this queue.
939+
940+
Returns:
941+
backend_type: The backend for the device.
942+
"""
943+
return self.sycl_device.backend
944+
945+
@property
946+
def name(self):
947+
"""Returns the device name for the device
948+
associated with this queue.
949+
950+
Returns:
951+
str: The name of the device as a string.
952+
"""
953+
return self.sycl_device.name
954+
955+
@property
956+
def driver_version(self):
957+
"""Returns the driver version for the device
958+
associated with this queue.
959+
960+
Returns:
961+
str: The driver version of the device as a string.
962+
"""
963+
return self.sycl_device.driver_version
964+
965+
def print_device_info(self):
966+
""" Print information about the SYCL device
967+
associated with this queue.
968+
"""
969+
self.sycl_device.print_device_info()
970+
971+
935972
cdef public DPCTLSyclQueueRef get_queue_ref(SyclQueue q):
936973
"""
937974
C-API function to get opaque queue reference from

dpctl/tests/test_sycl_queue.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,28 @@ def test_hashing_of_queue():
391391
assert queue_dict
392392

393393

394+
def test_channeling_device_properties():
395+
try:
396+
q = dpctl.SyclQueue()
397+
dev = q.sycl_device
398+
except dpctl.SyclQueueCreationError:
399+
pytest.fail("Failed to create device from default selector")
400+
import io
401+
from contextlib import redirect_stdout
402+
403+
f1 = io.StringIO()
404+
with redirect_stdout(f1):
405+
q.print_device_info() # should execute without raising
406+
f2 = io.StringIO()
407+
with redirect_stdout(f2):
408+
dev.print_device_info()
409+
assert f1.getvalue() == f2.getvalue(), "Mismatch in print_device_info"
410+
for pr in ["backend", "name", "driver_version"]:
411+
assert getattr(q, pr) == getattr(
412+
dev, pr
413+
), "Mismatch found for property {}".format(pr)
414+
415+
394416
def test_queue_submit_barrier(valid_filter):
395417
try:
396418
q = dpctl.SyclQueue(valid_filter)

0 commit comments

Comments
 (0)