Skip to content

Commit ecbe8fb

Browse files
Merge pull request #1075 from IntelPython/native-vector-width-device-descriptors
Native vector width device descriptors
2 parents 0a8abd8 + a7c468c commit ecbe8fb

File tree

6 files changed

+365
-80
lines changed

6 files changed

+365
-80
lines changed

dpctl/_backend.pxd

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,14 @@ cdef extern from "syclinterface/dpctl_sycl_device_interface.h":
186186
cdef uint32_t DPCTLDevice_GetPreferredVectorWidthFloat(const DPCTLSyclDeviceRef DRef)
187187
cdef uint32_t DPCTLDevice_GetPreferredVectorWidthDouble(const DPCTLSyclDeviceRef DRef)
188188
cdef uint32_t DPCTLDevice_GetPreferredVectorWidthHalf(const DPCTLSyclDeviceRef DRef)
189-
cpdef bool DPCTLDevice_HasAspect(const DPCTLSyclDeviceRef, _aspect_type)
189+
cdef uint32_t DPCTLDevice_GetNativeVectorWidthChar(const DPCTLSyclDeviceRef DRef)
190+
cdef uint32_t DPCTLDevice_GetNativeVectorWidthShort(const DPCTLSyclDeviceRef DRef)
191+
cdef uint32_t DPCTLDevice_GetNativeVectorWidthInt(const DPCTLSyclDeviceRef DRef)
192+
cdef uint32_t DPCTLDevice_GetNativeVectorWidthLong(const DPCTLSyclDeviceRef DRef)
193+
cdef uint32_t DPCTLDevice_GetNativeVectorWidthFloat(const DPCTLSyclDeviceRef DRef)
194+
cdef uint32_t DPCTLDevice_GetNativeVectorWidthDouble(const DPCTLSyclDeviceRef DRef)
195+
cdef uint32_t DPCTLDevice_GetNativeVectorWidthHalf(const DPCTLSyclDeviceRef DRef)
196+
cdef bool DPCTLDevice_HasAspect(const DPCTLSyclDeviceRef, _aspect_type)
190197
cdef uint32_t DPCTLDevice_GetMaxReadImageArgs(const DPCTLSyclDeviceRef DRef)
191198
cdef uint32_t DPCTLDevice_GetMaxWriteImageArgs(const DPCTLSyclDeviceRef DRef)
192199
cdef size_t DPCTLDevice_GetImage2dMaxWidth(const DPCTLSyclDeviceRef DRef)

dpctl/_sycl_device.pyx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ from ._backend cimport ( # noqa: E211
5454
DPCTLDevice_GetMaxWorkItemSizes3d,
5555
DPCTLDevice_GetMaxWriteImageArgs,
5656
DPCTLDevice_GetName,
57+
DPCTLDevice_GetNativeVectorWidthChar,
58+
DPCTLDevice_GetNativeVectorWidthDouble,
59+
DPCTLDevice_GetNativeVectorWidthFloat,
60+
DPCTLDevice_GetNativeVectorWidthHalf,
61+
DPCTLDevice_GetNativeVectorWidthInt,
62+
DPCTLDevice_GetNativeVectorWidthLong,
63+
DPCTLDevice_GetNativeVectorWidthShort,
5764
DPCTLDevice_GetParentDevice,
5865
DPCTLDevice_GetPartitionMaxSubDevices,
5966
DPCTLDevice_GetPlatform,
@@ -942,6 +949,55 @@ cdef class SyclDevice(_SyclDevice):
942949
"""
943950
return DPCTLDevice_GetPreferredVectorWidthHalf(self._device_ref)
944951

952+
@property
953+
def native_vector_width_char(self):
954+
""" Returns the native ISA vector width size for built-in scalar
955+
types that can be put into vectors.
956+
"""
957+
return DPCTLDevice_GetNativeVectorWidthChar(self._device_ref)
958+
959+
@property
960+
def native_vector_width_short(self):
961+
""" Returns the native ISA vector width size for built-in scalar
962+
types that can be put into vectors.
963+
"""
964+
return DPCTLDevice_GetNativeVectorWidthShort(self._device_ref)
965+
966+
@property
967+
def native_vector_width_int(self):
968+
""" Returns the native ISA vector width size for built-in scalar
969+
types that can be put into vectors.
970+
"""
971+
return DPCTLDevice_GetNativeVectorWidthInt(self._device_ref)
972+
973+
@property
974+
def native_vector_width_long(self):
975+
""" Returns the native ISA vector width size for built-in scalar
976+
types that can be put into vectors.
977+
"""
978+
return DPCTLDevice_GetNativeVectorWidthLong(self._device_ref)
979+
980+
@property
981+
def native_vector_width_float(self):
982+
""" Returns the native ISA vector width size for built-in scalar
983+
types that can be put into vectors.
984+
"""
985+
return DPCTLDevice_GetNativeVectorWidthFloat(self._device_ref)
986+
987+
@property
988+
def native_vector_width_double(self):
989+
""" Returns the native ISA vector width size for built-in scalar
990+
types that can be put into vectors.
991+
"""
992+
return DPCTLDevice_GetNativeVectorWidthDouble(self._device_ref)
993+
994+
@property
995+
def native_vector_width_half(self):
996+
""" Returns the native ISA vector width size for built-in scalar
997+
types that can be put into vectors.
998+
"""
999+
return DPCTLDevice_GetNativeVectorWidthHalf(self._device_ref)
1000+
9451001
@property
9461002
def global_mem_size(self):
9471003
""" Returns the size of global memory on this device in bytes.

dpctl/tests/_device_attributes_checks.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,55 @@ def check_preferred_vector_width_half(device):
378378
pytest.fail("preferred_vector_width_half call failed")
379379

380380

381+
def check_native_vector_width_char(device):
382+
try:
383+
device.native_vector_width_char
384+
except Exception:
385+
pytest.fail("native_vector_width_char call failed")
386+
387+
388+
def check_native_vector_width_short(device):
389+
try:
390+
device.native_vector_width_short
391+
except Exception:
392+
pytest.fail("native_vector_width_short call failed")
393+
394+
395+
def check_native_vector_width_int(device):
396+
try:
397+
device.native_vector_width_int
398+
except Exception:
399+
pytest.fail("native_vector_width_int call failed")
400+
401+
402+
def check_native_vector_width_long(device):
403+
try:
404+
device.native_vector_width_long
405+
except Exception:
406+
pytest.fail("native_vector_width_long call failed")
407+
408+
409+
def check_native_vector_width_float(device):
410+
try:
411+
device.native_vector_width_float
412+
except Exception:
413+
pytest.fail("native_vector_width_float call failed")
414+
415+
416+
def check_native_vector_width_double(device):
417+
try:
418+
device.native_vector_width_double
419+
except Exception:
420+
pytest.fail("native_vector_width_double call failed")
421+
422+
423+
def check_native_vector_width_half(device):
424+
try:
425+
device.native_vector_width_half
426+
except Exception:
427+
pytest.fail("native_vector_width_half call failed")
428+
429+
381430
def check_create_sub_devices_equally(device):
382431
try:
383432
n = int(device.max_compute_units / 2)
@@ -618,6 +667,13 @@ def check_global_mem_cache_line_size(device):
618667
check_preferred_vector_width_float,
619668
check_preferred_vector_width_double,
620669
check_preferred_vector_width_half,
670+
check_native_vector_width_char,
671+
check_native_vector_width_short,
672+
check_native_vector_width_int,
673+
check_native_vector_width_long,
674+
check_native_vector_width_float,
675+
check_native_vector_width_double,
676+
check_native_vector_width_half,
621677
check_has_aspect_cpu,
622678
check_has_aspect_gpu,
623679
check_has_aspect_accelerator,

libsyclinterface/include/dpctl_sycl_device_interface.h

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,97 @@ DPCTL_API
575575
uint32_t DPCTLDevice_GetPreferredVectorWidthHalf(
576576
__dpctl_keep const DPCTLSyclDeviceRef DRef);
577577

578+
/*!
579+
* @brief Wrapper over
580+
* device.get_info<info::device::native_vector_width_char>.
581+
*
582+
* @param DRef Opaque pointer to a ``sycl::device``
583+
* @return Returns the native ISA vector width size for built-in scalar
584+
* types that can be put into vectors.
585+
* @ingroup DeviceInterface
586+
*/
587+
DPCTL_API
588+
uint32_t DPCTLDevice_GetNativeVectorWidthChar(
589+
__dpctl_keep const DPCTLSyclDeviceRef DRef);
590+
591+
/*!
592+
* @brief Wrapper over
593+
* device.get_info<info::device::native_vector_width_short>.
594+
*
595+
* @param DRef Opaque pointer to a ``sycl::device``
596+
* @return Returns the native ISA vector width size for built-in scalar
597+
* types that can be put into vectors.
598+
* @ingroup DeviceInterface
599+
*/
600+
DPCTL_API
601+
uint32_t DPCTLDevice_GetNativeVectorWidthShort(
602+
__dpctl_keep const DPCTLSyclDeviceRef DRef);
603+
604+
/*!
605+
* @brief Wrapper over
606+
* device.get_info<info::device::native_vector_width_int>.
607+
*
608+
* @param DRef Opaque pointer to a ``sycl::device``
609+
* @return Returns the native ISA vector width size for built-in scalar
610+
* types that can be put into vectors.
611+
* @ingroup DeviceInterface
612+
*/
613+
DPCTL_API
614+
uint32_t
615+
DPCTLDevice_GetNativeVectorWidthInt(__dpctl_keep const DPCTLSyclDeviceRef DRef);
616+
617+
/*!
618+
* @brief Wrapper over
619+
* device.get_info<info::device::native_vector_width_long>.
620+
*
621+
* @param DRef Opaque pointer to a ``sycl::device``
622+
* @return Returns the native ISA vector width size for built-in scalar
623+
* types that can be put into vectors.
624+
* @ingroup DeviceInterface
625+
*/
626+
DPCTL_API
627+
uint32_t DPCTLDevice_GetNativeVectorWidthLong(
628+
__dpctl_keep const DPCTLSyclDeviceRef DRef);
629+
630+
/*!
631+
* @brief Wrapper over
632+
* device.get_info<info::device::native_vector_width_float>.
633+
*
634+
* @param DRef Opaque pointer to a ``sycl::device``
635+
* @return Returns the native ISA vector width size for built-in scalar
636+
* type.
637+
* @ingroup DeviceInterface
638+
*/
639+
DPCTL_API
640+
uint32_t DPCTLDevice_GetNativeVectorWidthFloat(
641+
__dpctl_keep const DPCTLSyclDeviceRef DRef);
642+
643+
/*!
644+
* @brief Wrapper over
645+
* device.get_info<info::device::native_vector_width_double>.
646+
*
647+
* @param DRef Opaque pointer to a ``sycl::device``
648+
* @return Returns the native ISA vector width size for built-in scalar
649+
* types that can be put into vectors.
650+
* @ingroup DeviceInterface
651+
*/
652+
DPCTL_API
653+
uint32_t DPCTLDevice_GetNativeVectorWidthDouble(
654+
__dpctl_keep const DPCTLSyclDeviceRef DRef);
655+
656+
/*!
657+
* @brief Wrapper over
658+
* ``device.get_info<info::device::native_vector_width_half>``.
659+
*
660+
* @param DRef Opaque pointer to a ``sycl::device``
661+
* @return Returns the native ISA vector width size for built-in scalar
662+
* types that can be put into vectors.
663+
* @ingroup DeviceInterface
664+
*/
665+
DPCTL_API
666+
uint32_t DPCTLDevice_GetNativeVectorWidthHalf(
667+
__dpctl_keep const DPCTLSyclDeviceRef DRef);
668+
578669
/*!
579670
* @brief Wrapper over
580671
* device.get_info<info::device::parent_device>

0 commit comments

Comments
 (0)