Skip to content

Commit a6dcf40

Browse files
Added DPCTLDevice_GetNativeVectorWidth* descriptor accessors
API with doxygen strings, and tests were added.
1 parent 0a8abd8 commit a6dcf40

File tree

3 files changed

+245
-79
lines changed

3 files changed

+245
-79
lines changed

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>

libsyclinterface/source/dpctl_sycl_device_interface.cpp

Lines changed: 73 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -430,116 +430,117 @@ bool DPCTLDevice_GetSubGroupIndependentForwardProgress(
430430
return SubGroupProgress;
431431
}
432432

433-
uint32_t DPCTLDevice_GetPreferredVectorWidthChar(
434-
__dpctl_keep const DPCTLSyclDeviceRef DRef)
433+
namespace
435434
{
436-
size_t vector_width_char = 0;
435+
436+
template <typename descriptorT>
437+
uint32_t get_uint32_descriptor(__dpctl_keep const DPCTLSyclDeviceRef DRef)
438+
{
439+
uint32_t descr_val = 0;
437440
auto D = unwrap<device>(DRef);
438441
if (D) {
439442
try {
440-
vector_width_char =
441-
D->get_info<info::device::preferred_vector_width_char>();
443+
descr_val = D->get_info<descriptorT>();
442444
} catch (std::exception const &e) {
443445
error_handler(e, __FILE__, __func__, __LINE__);
444446
}
445447
}
446-
return vector_width_char;
448+
return descr_val;
449+
}
450+
451+
} // end of anonymous namespace
452+
453+
uint32_t DPCTLDevice_GetPreferredVectorWidthChar(
454+
__dpctl_keep const DPCTLSyclDeviceRef DRef)
455+
{
456+
return get_uint32_descriptor<info::device::preferred_vector_width_char>(
457+
DRef);
447458
}
448459

449460
uint32_t DPCTLDevice_GetPreferredVectorWidthShort(
450461
__dpctl_keep const DPCTLSyclDeviceRef DRef)
451462
{
452-
size_t vector_width_short = 0;
453-
auto D = unwrap<device>(DRef);
454-
if (D) {
455-
try {
456-
vector_width_short =
457-
D->get_info<info::device::preferred_vector_width_short>();
458-
} catch (std::exception const &e) {
459-
error_handler(e, __FILE__, __func__, __LINE__);
460-
}
461-
}
462-
return vector_width_short;
463+
return get_uint32_descriptor<info::device::preferred_vector_width_short>(
464+
DRef);
463465
}
464466

465467
uint32_t DPCTLDevice_GetPreferredVectorWidthInt(
466468
__dpctl_keep const DPCTLSyclDeviceRef DRef)
467469
{
468-
size_t vector_width_int = 0;
469-
auto D = unwrap<device>(DRef);
470-
if (D) {
471-
try {
472-
vector_width_int =
473-
D->get_info<info::device::preferred_vector_width_int>();
474-
} catch (std::exception const &e) {
475-
error_handler(e, __FILE__, __func__, __LINE__);
476-
}
477-
}
478-
return vector_width_int;
470+
return get_uint32_descriptor<info::device::preferred_vector_width_int>(
471+
DRef);
479472
}
480473

481474
uint32_t DPCTLDevice_GetPreferredVectorWidthLong(
482475
__dpctl_keep const DPCTLSyclDeviceRef DRef)
483476
{
484-
size_t vector_width_long = 0;
485-
auto D = unwrap<device>(DRef);
486-
if (D) {
487-
try {
488-
vector_width_long =
489-
D->get_info<info::device::preferred_vector_width_long>();
490-
} catch (std::exception const &e) {
491-
error_handler(e, __FILE__, __func__, __LINE__);
492-
}
493-
}
494-
return vector_width_long;
477+
return get_uint32_descriptor<info::device::preferred_vector_width_long>(
478+
DRef);
495479
}
496480

497481
uint32_t DPCTLDevice_GetPreferredVectorWidthFloat(
498482
__dpctl_keep const DPCTLSyclDeviceRef DRef)
499483
{
500-
size_t vector_width_float = 0;
501-
auto D = unwrap<device>(DRef);
502-
if (D) {
503-
try {
504-
vector_width_float =
505-
D->get_info<info::device::preferred_vector_width_float>();
506-
} catch (std::exception const &e) {
507-
error_handler(e, __FILE__, __func__, __LINE__);
508-
}
509-
}
510-
return vector_width_float;
484+
return get_uint32_descriptor<info::device::preferred_vector_width_float>(
485+
DRef);
511486
}
512487

513488
uint32_t DPCTLDevice_GetPreferredVectorWidthDouble(
514489
__dpctl_keep const DPCTLSyclDeviceRef DRef)
515490
{
516-
size_t vector_width_double = 0;
517-
auto D = unwrap<device>(DRef);
518-
if (D) {
519-
try {
520-
vector_width_double =
521-
D->get_info<info::device::preferred_vector_width_double>();
522-
} catch (std::exception const &e) {
523-
error_handler(e, __FILE__, __func__, __LINE__);
524-
}
525-
}
526-
return vector_width_double;
491+
return get_uint32_descriptor<info::device::preferred_vector_width_double>(
492+
DRef);
527493
}
528494

529495
uint32_t DPCTLDevice_GetPreferredVectorWidthHalf(
530496
__dpctl_keep const DPCTLSyclDeviceRef DRef)
531497
{
532-
size_t vector_width_half = 0;
533-
auto D = unwrap<device>(DRef);
534-
if (D) {
535-
try {
536-
vector_width_half =
537-
D->get_info<info::device::preferred_vector_width_half>();
538-
} catch (std::exception const &e) {
539-
error_handler(e, __FILE__, __func__, __LINE__);
540-
}
541-
}
542-
return vector_width_half;
498+
return get_uint32_descriptor<info::device::preferred_vector_width_half>(
499+
DRef);
500+
}
501+
502+
//
503+
uint32_t
504+
DPCTLDevice_GetNativeVectorWidthChar(__dpctl_keep const DPCTLSyclDeviceRef DRef)
505+
{
506+
return get_uint32_descriptor<info::device::native_vector_width_char>(DRef);
507+
}
508+
509+
uint32_t DPCTLDevice_GetNativeVectorWidthShort(
510+
__dpctl_keep const DPCTLSyclDeviceRef DRef)
511+
{
512+
return get_uint32_descriptor<info::device::native_vector_width_short>(DRef);
513+
}
514+
515+
uint32_t
516+
DPCTLDevice_GetNativeVectorWidthInt(__dpctl_keep const DPCTLSyclDeviceRef DRef)
517+
{
518+
return get_uint32_descriptor<info::device::native_vector_width_int>(DRef);
519+
}
520+
521+
uint32_t
522+
DPCTLDevice_GetNativeVectorWidthLong(__dpctl_keep const DPCTLSyclDeviceRef DRef)
523+
{
524+
return get_uint32_descriptor<info::device::native_vector_width_long>(DRef);
525+
}
526+
527+
uint32_t DPCTLDevice_GetNativeVectorWidthFloat(
528+
__dpctl_keep const DPCTLSyclDeviceRef DRef)
529+
{
530+
return get_uint32_descriptor<info::device::native_vector_width_float>(DRef);
531+
}
532+
533+
uint32_t DPCTLDevice_GetNativeVectorWidthDouble(
534+
__dpctl_keep const DPCTLSyclDeviceRef DRef)
535+
{
536+
return get_uint32_descriptor<info::device::native_vector_width_double>(
537+
DRef);
538+
}
539+
540+
uint32_t
541+
DPCTLDevice_GetNativeVectorWidthHalf(__dpctl_keep const DPCTLSyclDeviceRef DRef)
542+
{
543+
return get_uint32_descriptor<info::device::native_vector_width_half>(DRef);
543544
}
544545

545546
__dpctl_give DPCTLSyclDeviceRef

0 commit comments

Comments
 (0)