Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add python api
  • Loading branch information
etotmeni committed Mar 2, 2021
commit e153c768ff9785ff51d8588e9ec0a680008fb2d0
2 changes: 2 additions & 0 deletions dpctl/_backend.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ cdef extern from "dpctl_sycl_device_interface.h":
cdef bool DPCTLDevice_IsGPU(const DPCTLSyclDeviceRef DRef)
cdef bool DPCTLDevice_IsHost(const DPCTLSyclDeviceRef DRef)
cdef bool DPCTLDevice_IsHostUnifiedMemory(const DPCTLSyclDeviceRef DRef)
cdef bool DPCTLDevice_GetSubGroupIndependentForwardProgress(const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLDevice_GetPreferredVectorWidthChar(const DPCTLSyclDeviceRef DRef)


cdef extern from "dpctl_sycl_device_selector_interface.h":
Expand Down
2 changes: 2 additions & 0 deletions dpctl/_sycl_device.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ cdef class _SyclDevice:
cpdef is_cpu(self)
cpdef is_gpu(self)
cpdef is_host(self)
cpdef get_sub_group_independent_forward_progress(self)
cpdef get_preferred_vector_width_char(self)


cdef class SyclDevice(_SyclDevice):
Expand Down
26 changes: 26 additions & 0 deletions dpctl/_sycl_device.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ from ._backend cimport (
DPCTLSyclDeviceRef,
DPCTLSyclDeviceSelectorRef,
DPCTLSyclDeviceType,
DPCTLDevice_GetSubGroupIndependentForwardProgress,
DPCTLDevice_GetPreferredVectorWidthChar
)
from . import backend_type, device_type
import warnings
Expand Down Expand Up @@ -259,6 +261,18 @@ cdef class _SyclDevice:
"""
return int(<size_t>self._device_ref)

cpdef get_sub_group_independent_forward_progress(self):
""" Returns true if the device supports independent forward progress of
sub-groups with respect to other sub-groups in the same work-group.
"""
return self._get_sub_group_independent_forward_progress

cpdef get_preferred_vector_width_char(self):
""" Returns the preferred native vector width size for built-in scalar
types that can be put into vectors.
"""
return self._get_preferred_vector_width_char

@property
def __name__(self):
return "SyclDevice"
Expand Down Expand Up @@ -325,6 +339,12 @@ cdef class SyclDevice(_SyclDevice):
device._cpu_device = DPCTLDevice_IsCPU(DRef)
device._gpu_device = DPCTLDevice_IsGPU(DRef)
device._host_device = DPCTLDevice_IsHost(DRef)
device._get_sub_group_independent_forward_progress = (
DPCTLDevice_GetSubGroupIndependentForwardProgress(DRef)
)
device._get_preferred_vector_width_char = (
DPCTLDevice_GetPreferredVectorWidthChar(DRef)
)

@staticmethod
cdef SyclDevice _create(DPCTLSyclDeviceRef dref):
Expand All @@ -351,6 +371,12 @@ cdef class SyclDevice(_SyclDevice):
self._cpu_device = other._cpu_device
self._gpu_device = other._gpu_device
self._host_device = other._host_device
self._get_sub_group_independent_forward_progress = (
other._get_sub_group_independent_forward_progress
)
self._get_preferred_vector_width_char = (
other._get_preferred_vector_width_char
)

cdef int _init_from_selector(self, DPCTLSyclDeviceSelectorRef DSRef):
# Initialize the attributes of the SyclDevice object
Expand Down
14 changes: 14 additions & 0 deletions dpctl/tests/test_sycl_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ def check_is_host(device):
pytest.fail("is_hostcall failed")


def check_get_sub_group_independent_forward_progress(device):
try:
device.get_sub_group_independent_forward_progress()
except Exception:
pytest.fail("get_sub_group_independent_forward_progress call failed")


def check_get_preferred_vector_width_char(device):
try:
device.get_preferred_vector_width_char()
except Exception:
pytest.fail("get_preferred_vector_width_char call failed")


list_of_checks = [
check_get_max_compute_units,
check_get_max_work_item_dims,
Expand Down