dpctl.program

dpctl.program provides a way to create a SYCL kernel from either an OpenCL* program source code represented as a string or a SPIR-V binary file.

It implements creation of interoperability sycl::kernel_bundle<sycl::bundle_state_executable> (a collection of kernels), as well as creation of individual sycl::kernel, suitable for submission for execution via dpctl.SyclQueue.submit().

create_kernel_bundle_from_source

Creates a Sycl interoperability kernel bundle from an OpenCL source string.

create_kernel_bundle_from_spirv

Creates a Sycl interoperability kernel bundle from an SPIR-V binary.

create_program_from_source

This function is a deprecated alias for dpctl.program.create_kernel_bundle_from_source().

create_program_from_spirv

This function is a deprecated alias for dpctl.program.create_kernel_bundle_from_spirv().

SyclKernelBundle

Wraps a sycl::kernel_bundle<sycl::bundle_state::executable> object created using SYCL interoperability layer with underlying backends.

SyclKernel

SpecializationConstant

Python class representing SYCL specialization constants that can be used when creating a dpctl.program.SyclKernelBundle from SPIR-V.

SyclKernelBundleCompilationError

This exception is raised when a sycl::kernel_bundle could not be built from either a SPIR-V binary file or a string source.

dpctl.program.utils

dpctl.program.utils.parse_spirv_specializations(spv_bytes: bytes | bytearray | memoryview) tuple[dpctl.program.utils._utils.SpecializationConstantInfo][source]

Parses SPIR-V byte stream to extract information about specializations, including the specialization IDs, types, names, and default values.

Note that the dtype information may be imprecise, as the compiler may choose to, for example, represent a bool as char, or may represent both signed and unsigned integers as unsigned integer bit buckets of the same length.

Parameters:

spv_bytes (bytes | bytearray | memoryview) – the SPIR-V byte stream.

Returns:

a tuple of parsed constants and their information represented by SpecializationConstantInfo objects, sorted by their specialization IDs. The length of the tuple is equal to the number of specialization constants found. Each SpecializationConstantInfo object contains the following attributes:

  • spec_id (int): The specialization ID.

  • dtype (str): A NumPy style string representing the data type.

  • itemsize (int): The size of the specialization constant in

    bytes.

  • name (str): The variable name. If not preserved in the binary,

    a default name in the format unnamed_spec_const_{spec_id} is used.

  • default_value (int | float | bool | None): The default value of

    the specialization constant. If not specified, None is used.

Return type:

tuple[SpecializationConstantInfo]

class dpctl.program.utils.SpecializationConstantInfo(spec_id: int, dtype: str, name: str, itemsize: int, default_value: int | float | bool | None)[source]

Data class representing specialization constant information.