Skip to content

Commit 489656c

Browse files
committed
rename SyclProgram to SyclKernelBundle
deprecates SyclProgram
1 parent ad14818 commit 489656c

16 files changed

Lines changed: 205 additions & 134 deletions

File tree

docs/doc_sources/api_reference/dpctl/program.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@ execution via :py:meth:`dpctl.SyclQueue.submit`.
2020
:toctree: generated
2121
:nosignatures:
2222

23+
create_kernel_bundle_from_source
24+
create_kernel_bundle_from_spirv
2325
create_program_from_source
2426
create_program_from_spirv
2527

2628
.. autosummary::
2729
:toctree: generated
2830
:nosignatures:
2931

30-
SyclProgram
32+
SyclKernelBundle
3133
SyclKernel
3234

3335
.. autosummary::
3436
:toctree: generated
3537
:nosignatures:
3638

37-
SyclProgramCompilationError
39+
SyclKernelBundleCompilationError

docs/doc_sources/api_reference/dpctl_capi.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ Exported typedefs
3333
3434
.. c:struct:: PySyclKernelType
3535
36-
.. c:struct:: PySyclProgramObject
36+
.. c:struct:: PySyclKernelBundleObject
3737
38-
.. c:struct:: PySyclProgramType
38+
.. c:struct:: PySyclKernelBundleType
3939
4040
To check whether a particular Python object is an instance of :py:class:`dpctl.SyclQueue`:
4141

@@ -176,19 +176,19 @@ API for :c:struct:`PySyclKernelObject`
176176
the caller remains responsible for freeing ``KRef`` as appropriate.
177177
178178
179-
API for :c:struct:`PySyclProgramObject`
179+
API for :c:struct:`PySyclKernelBundleObject`
180180
---------------------------------------
181181
182-
.. c:function:: DPCTLSyclKernelBundleRef SyclProgram_GetKernelBundleRef(struct PySyclProgramObject *prog)
182+
.. c:function:: DPCTLSyclKernelBundleRef SyclKernelBundle_GetKernelBundleRef(struct PySyclKernelBundleObject *prog)
183183
184184
:param prog: Input object
185185
:returns: borrowed instance of :c:struct:`DPCTLSyclKernelBundleRef` corresponding
186186
to ``sycl::kernel_bundle<sycl::bundle_state::executable>``
187187
188-
.. c:function:: struct PySyclProgramObject * SyclProgram_Make(DPCTLSyclKernelBundleRef KBRef)
188+
.. c:function:: struct PySyclKernelBundleObject * SyclKernelBundle_Make(DPCTLSyclKernelBundleRef KBRef)
189189
190190
:param KBRef: instance of :c:struct:`DPCTLSyclKernelBundleRef`
191-
:returns: new Python object of type :c:struct:`PySyclProgramType`
191+
:returns: new Python object of type :c:struct:`PySyclKernelBundleType`
192192
193193
Note that function does not change the ownership of the ``KBRef`` instance and
194194
the caller remains responsible for freeing ``KBRef`` as appropriate.

docs/doc_sources/known_words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ SyclQueue
5959
SyclContext
6060
SyclEvent
6161
SyclKernel
62+
SyclKernelBundle
6263
SyclProgram
6364
SyclPlatform
6465
dtype

dpctl/apis/include/dpctl4pybind11.hpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class dpctl_capi
5959
PyTypeObject *PyMemoryUSMDeviceType_;
6060
PyTypeObject *PyMemoryUSMSharedType_;
6161
PyTypeObject *PyMemoryUSMHostType_;
62-
PyTypeObject *PySyclProgramType_;
62+
PyTypeObject *PySyclKernelBundleType_;
6363
PyTypeObject *PySyclKernelType_;
6464

6565
DPCTLSyclDeviceRef (*SyclDevice_GetDeviceRef_)(PySyclDeviceObject *);
@@ -89,9 +89,10 @@ class dpctl_capi
8989
DPCTLSyclKernelRef (*SyclKernel_GetKernelRef_)(PySyclKernelObject *);
9090
PySyclKernelObject *(*SyclKernel_Make_)(DPCTLSyclKernelRef, const char *);
9191

92-
DPCTLSyclKernelBundleRef (*SyclProgram_GetKernelBundleRef_)(
93-
PySyclProgramObject *);
94-
PySyclProgramObject *(*SyclProgram_Make_)(DPCTLSyclKernelBundleRef);
92+
DPCTLSyclKernelBundleRef (*SyclKernelBundle_GetKernelBundleRef_)(
93+
PySyclKernelBundleObject *);
94+
PySyclKernelBundleObject *(*SyclKernelBundle_Make_)(
95+
DPCTLSyclKernelBundleRef);
9596

9697
bool PySyclDevice_Check_(PyObject *obj) const
9798
{
@@ -113,9 +114,9 @@ class dpctl_capi
113114
{
114115
return PyObject_TypeCheck(obj, PySyclKernelType_) != 0;
115116
}
116-
bool PySyclProgram_Check_(PyObject *obj) const
117+
bool PySyclKernelBundle_Check_(PyObject *obj) const
117118
{
118-
return PyObject_TypeCheck(obj, PySyclProgramType_) != 0;
119+
return PyObject_TypeCheck(obj, PySyclKernelBundleType_) != 0;
119120
}
120121

121122
~dpctl_capi()
@@ -165,7 +166,7 @@ class dpctl_capi
165166
Py_SyclQueueType_(nullptr), PySyclQueueType_(nullptr),
166167
Py_MemoryType_(nullptr), PyMemoryUSMDeviceType_(nullptr),
167168
PyMemoryUSMSharedType_(nullptr), PyMemoryUSMHostType_(nullptr),
168-
PySyclProgramType_(nullptr), PySyclKernelType_(nullptr),
169+
PySyclKernelBundleType_(nullptr), PySyclKernelType_(nullptr),
169170
SyclDevice_GetDeviceRef_(nullptr), SyclDevice_Make_(nullptr),
170171
SyclContext_GetContextRef_(nullptr), SyclContext_Make_(nullptr),
171172
SyclEvent_GetEventRef_(nullptr), SyclEvent_Make_(nullptr),
@@ -174,8 +175,9 @@ class dpctl_capi
174175
Memory_GetContextRef_(nullptr), Memory_GetQueueRef_(nullptr),
175176
Memory_GetNumBytes_(nullptr), Memory_Make_(nullptr),
176177
SyclKernel_GetKernelRef_(nullptr), SyclKernel_Make_(nullptr),
177-
SyclProgram_GetKernelBundleRef_(nullptr), SyclProgram_Make_(nullptr),
178-
default_sycl_queue_{}, default_usm_memory_{}, as_usm_memory_{}
178+
SyclKernelBundle_GetKernelBundleRef_(nullptr),
179+
SyclKernelBundle_Make_(nullptr), default_sycl_queue_{},
180+
default_usm_memory_{}, as_usm_memory_{}
179181

180182
{
181183
// Import Cython-generated C-API for dpctl
@@ -198,7 +200,7 @@ class dpctl_capi
198200
this->PyMemoryUSMDeviceType_ = &PyMemoryUSMDeviceType;
199201
this->PyMemoryUSMSharedType_ = &PyMemoryUSMSharedType;
200202
this->PyMemoryUSMHostType_ = &PyMemoryUSMHostType;
201-
this->PySyclProgramType_ = &PySyclProgramType;
203+
this->PySyclKernelBundleType_ = &PySyclKernelBundleType;
202204
this->PySyclKernelType_ = &PySyclKernelType;
203205

204206
// SyclDevice API
@@ -228,8 +230,9 @@ class dpctl_capi
228230
// dpctl.program API
229231
this->SyclKernel_GetKernelRef_ = SyclKernel_GetKernelRef;
230232
this->SyclKernel_Make_ = SyclKernel_Make;
231-
this->SyclProgram_GetKernelBundleRef_ = SyclProgram_GetKernelBundleRef;
232-
this->SyclProgram_Make_ = SyclProgram_Make;
233+
this->SyclKernelBundle_GetKernelBundleRef_ =
234+
SyclKernelBundle_GetKernelBundleRef;
235+
this->SyclKernelBundle_Make_ = SyclKernelBundle_Make;
233236

234237
// create shared pointers to python objects used in type-casters
235238
// for dpctl::memory::usm_memory
@@ -484,7 +487,7 @@ template <> struct type_caster<sycl::kernel>
484487

485488
/* This type caster associates
486489
* ``sycl::kernel_bundle<sycl::bundle_state::executable>`` C++ class with
487-
* :class:`dpctl.program.SyclProgram` for the purposes of generation of
490+
* :class:`dpctl.program.SyclKernelBundle` for the purposes of generation of
488491
* Python bindings by pybind11.
489492
*/
490493
template <>
@@ -495,10 +498,10 @@ struct type_caster<sycl::kernel_bundle<sycl::bundle_state::executable>>
495498
{
496499
PyObject *source = src.ptr();
497500
auto const &api = ::dpctl::detail::dpctl_capi::get();
498-
if (api.PySyclProgram_Check_(source)) {
501+
if (api.PySyclKernelBundle_Check_(source)) {
499502
DPCTLSyclKernelBundleRef KBRef =
500-
api.SyclProgram_GetKernelBundleRef_(
501-
reinterpret_cast<PySyclProgramObject *>(source));
503+
api.SyclKernelBundle_GetKernelBundleRef_(
504+
reinterpret_cast<PySyclKernelBundleObject *>(source));
502505
value = std::make_unique<
503506
sycl::kernel_bundle<sycl::bundle_state::executable>>(
504507
*(reinterpret_cast<
@@ -508,7 +511,7 @@ struct type_caster<sycl::kernel_bundle<sycl::bundle_state::executable>>
508511
}
509512
else {
510513
throw py::type_error("Input is of unexpected type, expected "
511-
"dpctl.program.SyclProgram");
514+
"dpctl.program.SyclKernelBundle");
512515
}
513516
}
514517

@@ -517,13 +520,13 @@ struct type_caster<sycl::kernel_bundle<sycl::bundle_state::executable>>
517520
handle)
518521
{
519522
auto const &api = ::dpctl::detail::dpctl_capi::get();
520-
auto tmp = api.SyclProgram_Make_(
523+
auto tmp = api.SyclKernelBundle_Make_(
521524
reinterpret_cast<DPCTLSyclKernelBundleRef>(&src));
522525
return handle(reinterpret_cast<PyObject *>(tmp));
523526
}
524527

525528
DPCTL_TYPE_CASTER(sycl::kernel_bundle<sycl::bundle_state::executable>,
526-
_("dpctl.program.SyclProgram"));
529+
_("dpctl.program.SyclKernelBundle"));
527530
};
528531

529532
/* This type caster associates

dpctl/program/__init__.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,35 @@
2323

2424
from ._program import (
2525
SyclKernel,
26-
SyclProgram,
27-
SyclProgramCompilationError,
26+
SyclKernelBundle,
27+
SyclKernelBundleCompilationError,
28+
create_kernel_bundle_from_source,
29+
create_kernel_bundle_from_spirv,
2830
create_program_from_source,
2931
create_program_from_spirv,
3032
)
3133

3234
__all__ = [
35+
"create_kernel_bundle_from_source",
36+
"create_kernel_bundle_from_spirv",
3337
"create_program_from_source",
3438
"create_program_from_spirv",
3539
"SyclKernel",
40+
"SyclKernelBundle",
41+
"SyclKernelBundleCompilationError",
3642
"SyclProgram",
37-
"SyclProgramCompilationError",
3843
]
44+
45+
46+
def __getattr__(name):
47+
if name == "SyclProgram":
48+
from warnings import warn
49+
50+
warn(
51+
"dpctl.program.SyclProgram is deprecated and will be removed in a "
52+
"future release. Use dpctl.program.SyclKernelBundle instead.",
53+
DeprecationWarning,
54+
stacklevel=2,
55+
)
56+
return SyclKernelBundle
57+
raise AttributeError(f"module {__name__} has no attribute {name}")

dpctl/program/_program.pxd

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,32 @@ cdef api class SyclKernel [object PySyclKernelObject, type PySyclKernelType]:
4040
cdef SyclKernel _create (DPCTLSyclKernelRef kref, str name)
4141

4242

43-
cdef api class SyclProgram [object PySyclProgramObject, type PySyclProgramType]:
43+
cdef api class SyclKernelBundle [
44+
object PySyclKernelBundleObject, type PySyclKernelBundleType
45+
]:
4446
"""
4547
Wraps a sycl::kernel_bundle<sycl::bundle_state::executable> object created
4648
by using SYCL interoperability layer for OpenCL and Level-Zero backends.
47-
SyclProgram exposes the C API from dpctl_sycl_kernel_bundle_interface.h.
48-
A SyclProgram can be created from either a source string or a SPIR-V
49+
SyclKernelBundle exposes the C API from
50+
dpctl_sycl_kernel_bundle_interface.h.
51+
A SyclKernelBundle can be created from either a source string or a SPIR-V
4952
binary file.
5053
"""
51-
cdef DPCTLSyclKernelBundleRef _program_ref
54+
cdef DPCTLSyclKernelBundleRef _kernel_bundle_ref
5255

5356
@staticmethod
54-
cdef SyclProgram _create (DPCTLSyclKernelBundleRef pref)
55-
cdef DPCTLSyclKernelBundleRef get_program_ref (self)
57+
cdef SyclKernelBundle _create (DPCTLSyclKernelBundleRef kbref)
58+
cdef DPCTLSyclKernelBundleRef get_kernel_bundle_ref (self)
5659
cpdef SyclKernel get_sycl_kernel(self, str kernel_name)
5760

5861

62+
cpdef create_kernel_bundle_from_source (
63+
SyclQueue q, unicode source, unicode copts=*
64+
)
65+
cpdef create_kernel_bundle_from_spirv (
66+
SyclQueue q, const unsigned char[:] IL, unicode copts=*
67+
)
5968
cpdef create_program_from_source (SyclQueue q, unicode source, unicode copts=*)
60-
cpdef create_program_from_spirv (SyclQueue q, const unsigned char[:] IL,
61-
unicode copts=*)
69+
cpdef create_program_from_spirv (
70+
SyclQueue q, const unsigned char[:] IL, unicode copts=*
71+
)

0 commit comments

Comments
 (0)