Skip to content

Native vector width device descriptors #1075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 8 additions & 1 deletion dpctl/_backend.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,14 @@ cdef extern from "syclinterface/dpctl_sycl_device_interface.h":
cdef uint32_t DPCTLDevice_GetPreferredVectorWidthFloat(const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLDevice_GetPreferredVectorWidthDouble(const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLDevice_GetPreferredVectorWidthHalf(const DPCTLSyclDeviceRef DRef)
cpdef bool DPCTLDevice_HasAspect(const DPCTLSyclDeviceRef, _aspect_type)
cdef uint32_t DPCTLDevice_GetNativeVectorWidthChar(const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLDevice_GetNativeVectorWidthShort(const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLDevice_GetNativeVectorWidthInt(const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLDevice_GetNativeVectorWidthLong(const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLDevice_GetNativeVectorWidthFloat(const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLDevice_GetNativeVectorWidthDouble(const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLDevice_GetNativeVectorWidthHalf(const DPCTLSyclDeviceRef DRef)
cdef bool DPCTLDevice_HasAspect(const DPCTLSyclDeviceRef, _aspect_type)
cdef uint32_t DPCTLDevice_GetMaxReadImageArgs(const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLDevice_GetMaxWriteImageArgs(const DPCTLSyclDeviceRef DRef)
cdef size_t DPCTLDevice_GetImage2dMaxWidth(const DPCTLSyclDeviceRef DRef)
Expand Down
56 changes: 56 additions & 0 deletions dpctl/_sycl_device.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ from ._backend cimport ( # noqa: E211
DPCTLDevice_GetMaxWorkItemSizes3d,
DPCTLDevice_GetMaxWriteImageArgs,
DPCTLDevice_GetName,
DPCTLDevice_GetNativeVectorWidthChar,
DPCTLDevice_GetNativeVectorWidthDouble,
DPCTLDevice_GetNativeVectorWidthFloat,
DPCTLDevice_GetNativeVectorWidthHalf,
DPCTLDevice_GetNativeVectorWidthInt,
DPCTLDevice_GetNativeVectorWidthLong,
DPCTLDevice_GetNativeVectorWidthShort,
DPCTLDevice_GetParentDevice,
DPCTLDevice_GetPartitionMaxSubDevices,
DPCTLDevice_GetPlatform,
Expand Down Expand Up @@ -942,6 +949,55 @@ cdef class SyclDevice(_SyclDevice):
"""
return DPCTLDevice_GetPreferredVectorWidthHalf(self._device_ref)

@property
def native_vector_width_char(self):
""" Returns the native ISA vector width size for built-in scalar
types that can be put into vectors.
"""
return DPCTLDevice_GetNativeVectorWidthChar(self._device_ref)

@property
def native_vector_width_short(self):
""" Returns the native ISA vector width size for built-in scalar
types that can be put into vectors.
"""
return DPCTLDevice_GetNativeVectorWidthShort(self._device_ref)

@property
def native_vector_width_int(self):
""" Returns the native ISA vector width size for built-in scalar
types that can be put into vectors.
"""
return DPCTLDevice_GetNativeVectorWidthInt(self._device_ref)

@property
def native_vector_width_long(self):
""" Returns the native ISA vector width size for built-in scalar
types that can be put into vectors.
"""
return DPCTLDevice_GetNativeVectorWidthLong(self._device_ref)

@property
def native_vector_width_float(self):
""" Returns the native ISA vector width size for built-in scalar
types that can be put into vectors.
"""
return DPCTLDevice_GetNativeVectorWidthFloat(self._device_ref)

@property
def native_vector_width_double(self):
""" Returns the native ISA vector width size for built-in scalar
types that can be put into vectors.
"""
return DPCTLDevice_GetNativeVectorWidthDouble(self._device_ref)

@property
def native_vector_width_half(self):
""" Returns the native ISA vector width size for built-in scalar
types that can be put into vectors.
"""
return DPCTLDevice_GetNativeVectorWidthHalf(self._device_ref)

@property
def global_mem_size(self):
""" Returns the size of global memory on this device in bytes.
Expand Down
56 changes: 56 additions & 0 deletions dpctl/tests/_device_attributes_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,55 @@ def check_preferred_vector_width_half(device):
pytest.fail("preferred_vector_width_half call failed")


def check_native_vector_width_char(device):
try:
device.native_vector_width_char
except Exception:
pytest.fail("native_vector_width_char call failed")


def check_native_vector_width_short(device):
try:
device.native_vector_width_short
except Exception:
pytest.fail("native_vector_width_short call failed")


def check_native_vector_width_int(device):
try:
device.native_vector_width_int
except Exception:
pytest.fail("native_vector_width_int call failed")


def check_native_vector_width_long(device):
try:
device.native_vector_width_long
except Exception:
pytest.fail("native_vector_width_long call failed")


def check_native_vector_width_float(device):
try:
device.native_vector_width_float
except Exception:
pytest.fail("native_vector_width_float call failed")


def check_native_vector_width_double(device):
try:
device.native_vector_width_double
except Exception:
pytest.fail("native_vector_width_double call failed")


def check_native_vector_width_half(device):
try:
device.native_vector_width_half
except Exception:
pytest.fail("native_vector_width_half call failed")


def check_create_sub_devices_equally(device):
try:
n = int(device.max_compute_units / 2)
Expand Down Expand Up @@ -618,6 +667,13 @@ def check_global_mem_cache_line_size(device):
check_preferred_vector_width_float,
check_preferred_vector_width_double,
check_preferred_vector_width_half,
check_native_vector_width_char,
check_native_vector_width_short,
check_native_vector_width_int,
check_native_vector_width_long,
check_native_vector_width_float,
check_native_vector_width_double,
check_native_vector_width_half,
check_has_aspect_cpu,
check_has_aspect_gpu,
check_has_aspect_accelerator,
Expand Down
91 changes: 91 additions & 0 deletions libsyclinterface/include/dpctl_sycl_device_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,97 @@ DPCTL_API
uint32_t DPCTLDevice_GetPreferredVectorWidthHalf(
__dpctl_keep const DPCTLSyclDeviceRef DRef);

/*!
* @brief Wrapper over
* device.get_info<info::device::native_vector_width_char>.
*
* @param DRef Opaque pointer to a ``sycl::device``
* @return Returns the native ISA vector width size for built-in scalar
* types that can be put into vectors.
* @ingroup DeviceInterface
*/
DPCTL_API
uint32_t DPCTLDevice_GetNativeVectorWidthChar(
__dpctl_keep const DPCTLSyclDeviceRef DRef);

/*!
* @brief Wrapper over
* device.get_info<info::device::native_vector_width_short>.
*
* @param DRef Opaque pointer to a ``sycl::device``
* @return Returns the native ISA vector width size for built-in scalar
* types that can be put into vectors.
* @ingroup DeviceInterface
*/
DPCTL_API
uint32_t DPCTLDevice_GetNativeVectorWidthShort(
__dpctl_keep const DPCTLSyclDeviceRef DRef);

/*!
* @brief Wrapper over
* device.get_info<info::device::native_vector_width_int>.
*
* @param DRef Opaque pointer to a ``sycl::device``
* @return Returns the native ISA vector width size for built-in scalar
* types that can be put into vectors.
* @ingroup DeviceInterface
*/
DPCTL_API
uint32_t
DPCTLDevice_GetNativeVectorWidthInt(__dpctl_keep const DPCTLSyclDeviceRef DRef);

/*!
* @brief Wrapper over
* device.get_info<info::device::native_vector_width_long>.
*
* @param DRef Opaque pointer to a ``sycl::device``
* @return Returns the native ISA vector width size for built-in scalar
* types that can be put into vectors.
* @ingroup DeviceInterface
*/
DPCTL_API
uint32_t DPCTLDevice_GetNativeVectorWidthLong(
__dpctl_keep const DPCTLSyclDeviceRef DRef);

/*!
* @brief Wrapper over
* device.get_info<info::device::native_vector_width_float>.
*
* @param DRef Opaque pointer to a ``sycl::device``
* @return Returns the native ISA vector width size for built-in scalar
* type.
* @ingroup DeviceInterface
*/
DPCTL_API
uint32_t DPCTLDevice_GetNativeVectorWidthFloat(
__dpctl_keep const DPCTLSyclDeviceRef DRef);

/*!
* @brief Wrapper over
* device.get_info<info::device::native_vector_width_double>.
*
* @param DRef Opaque pointer to a ``sycl::device``
* @return Returns the native ISA vector width size for built-in scalar
* types that can be put into vectors.
* @ingroup DeviceInterface
*/
DPCTL_API
uint32_t DPCTLDevice_GetNativeVectorWidthDouble(
__dpctl_keep const DPCTLSyclDeviceRef DRef);

/*!
* @brief Wrapper over
* ``device.get_info<info::device::native_vector_width_half>``.
*
* @param DRef Opaque pointer to a ``sycl::device``
* @return Returns the native ISA vector width size for built-in scalar
* types that can be put into vectors.
* @ingroup DeviceInterface
*/
DPCTL_API
uint32_t DPCTLDevice_GetNativeVectorWidthHalf(
__dpctl_keep const DPCTLSyclDeviceRef DRef);

/*!
* @brief Wrapper over
* device.get_info<info::device::parent_device>
Expand Down
Loading