Skip to content

Commit a3a53dc

Browse files
authored
Merge pull request #2304 from IntelPython/feature/specialization-constants
Add support for specialization constants
2 parents baf89c9 + 9c9a7c4 commit a3a53dc

19 files changed

Lines changed: 889 additions & 57 deletions

docs/doc_sources/api_reference/dpctl/program.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,22 @@ execution via :py:meth:`dpctl.SyclQueue.submit`.
3131

3232
SyclKernelBundle
3333
SyclKernel
34+
SpecializationConstant
3435

3536
.. autosummary::
3637
:toctree: generated
3738
:nosignatures:
3839

3940
SyclKernelBundleCompilationError
41+
42+
:py:mod:`dpctl.program.utils`
43+
-----------------------------
44+
45+
.. py:module:: dpctl.program.utils
46+
47+
.. currentmodule:: dpctl.program.utils
48+
49+
.. autofunction:: parse_spirv_specializations
50+
51+
.. autoclass:: SpecializationConstantInfo
52+
:members:

dpctl/_backend.pxd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,18 @@ cdef extern from "syclinterface/dpctl_sycl_context_interface.h":
431431

432432

433433
cdef extern from "syclinterface/dpctl_sycl_kernel_bundle_interface.h":
434+
ctypedef struct _spec_const "DPCTLSpecConst":
435+
uint32_t id
436+
size_t size
437+
const void *value
434438
cdef DPCTLSyclKernelBundleRef DPCTLKernelBundle_CreateFromSpirv(
435439
const DPCTLSyclContextRef Ctx,
436440
const DPCTLSyclDeviceRef Dev,
437441
const void *IL,
438442
size_t Length,
439-
const char *CompileOpts)
443+
const char *CompileOpts,
444+
size_t NumSpecConsts,
445+
const _spec_const *SpecConsts)
440446
cdef DPCTLSyclKernelBundleRef DPCTLKernelBundle_CreateFromOCLSource(
441447
const DPCTLSyclContextRef Ctx,
442448
const DPCTLSyclDeviceRef Dev,

dpctl/_sycl_platform.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ cdef class SyclPlatform(_SyclPlatform):
237237
and filter string for each device is printed.
238238
239239
Args:
240-
verbosity (Literal[0, 1, 2], optional):.
240+
verbosity (Literal[0, 1, 2], optional):
241241
The verbosity controls how much information is printed by the
242242
function. Value ``0`` is the lowest level set by default and
243243
``2`` is the highest level to print the most verbose output.

dpctl/program/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
2222
"""
2323

24+
from . import utils
2425
from ._program import (
26+
SpecializationConstant,
2527
SyclKernel,
2628
SyclKernelBundle,
2729
SyclKernelBundleCompilationError,
@@ -41,6 +43,12 @@
4143
"SyclKernelBundleCompilationError",
4244
"SyclProgram",
4345
"SyclProgramCompilationError",
46+
"SpecializationConstant",
47+
]
48+
49+
# add submodules
50+
__all__ += [
51+
"utils",
4452
]
4553

4654

dpctl/program/_program.pxd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ cpdef create_kernel_bundle_from_source (
6363
SyclQueue q, unicode source, unicode copts=*
6464
)
6565
cpdef create_kernel_bundle_from_spirv (
66-
SyclQueue q, const unsigned char[:] IL, unicode copts=*
66+
SyclQueue q,
67+
const unsigned char[:] IL,
68+
unicode copts=*,
69+
list specializations=*,
6770
)
6871
cpdef create_program_from_source (SyclQueue q, unicode source, unicode copts=*)
6972
cpdef create_program_from_spirv (

0 commit comments

Comments
 (0)