@@ -31,14 +31,15 @@ from dpctl._backend cimport ( # noqa: E211, E402
3131 DPCTLCString_Delete,
3232 DPCTLKernel_Delete,
3333 DPCTLKernel_GetNumArgs,
34- DPCTLProgram_CreateFromOCLSource ,
35- DPCTLProgram_CreateFromSpirv ,
36- DPCTLProgram_Delete ,
37- DPCTLProgram_GetKernel ,
38- DPCTLProgram_HasKernel ,
34+ DPCTLKernelBundle_CreateFromOCLSource ,
35+ DPCTLKernelBundle_CreateFromSpirv ,
36+ DPCTLKernelBundle_Delete ,
37+ DPCTLKernelBundle_GetKernel ,
38+ DPCTLKernelBundle_HasKernel ,
3939 DPCTLSyclContextRef,
40+ DPCTLSyclDeviceRef,
41+ DPCTLSyclKernelBundleRef,
4042 DPCTLSyclKernelRef,
41- DPCTLSyclProgramRef,
4243)
4344
4445__all__ = [
@@ -50,8 +51,8 @@ __all__ = [
5051]
5152
5253cdef class SyclProgramCompilationError(Exception ):
53- """ This exception is raised when a ``sycl::program `` could not be built from
54- either a SPIR-V binary file or a string source.
54+ """ This exception is raised when a ``sycl::kernel_bundle `` could not be
55+ built from either a SPIR-V binary file or a string source.
5556 """
5657 pass
5758
@@ -105,33 +106,35 @@ cdef class SyclProgram:
105106 """
106107
107108 @staticmethod
108- cdef SyclProgram _create(DPCTLSyclProgramRef pref ):
109+ cdef SyclProgram _create(DPCTLSyclKernelBundleRef KBRef ):
109110 cdef SyclProgram ret = SyclProgram.__new__ (SyclProgram)
110- ret._program_ref = pref
111+ ret._program_ref = KBRef
111112 return ret
112113
113114 def __dealloc__ (self ):
114- DPCTLProgram_Delete (self ._program_ref)
115+ DPCTLKernelBundle_Delete (self ._program_ref)
115116
116- cdef DPCTLSyclProgramRef get_program_ref(self ):
117+ cdef DPCTLSyclKernelBundleRef get_program_ref(self ):
117118 return self ._program_ref
118119
119120 cpdef SyclKernel get_sycl_kernel(self , str kernel_name):
120121 name = kernel_name.encode(' utf8' )
121- return SyclKernel._create(DPCTLProgram_GetKernel(self ._program_ref,
122- name), kernel_name)
122+ return SyclKernel._create(
123+ DPCTLKernelBundle_GetKernel(self ._program_ref, name),
124+ kernel_name
125+ )
123126
124127 def has_sycl_kernel (self , str kernel_name ):
125128 name = kernel_name.encode(' utf8' )
126- return DPCTLProgram_HasKernel (self ._program_ref, name)
129+ return DPCTLKernelBundle_HasKernel (self ._program_ref, name)
127130
128131 def addressof_ref (self ):
129- """ Returns the address of the C API DPCTLSyclProgramRef pointer
132+ """ Returns the address of the C API DPCTLSyclKernelBundleRef pointer
130133 as a long.
131134
132135 Returns:
133- The address of the ``DPCTLSyclProgramRef `` pointer used to create
134- this :class:`dpctl.SyclProgram` object cast to a ``size_t``.
136+ The address of the ``DPCTLSyclKernelBundleRef `` pointer used to
137+ create this :class:`dpctl.SyclProgram` object cast to a ``size_t``.
135138 """
136139 return int (< size_t> self ._program_ref)
137140
@@ -140,9 +143,10 @@ cpdef create_program_from_source(SyclQueue q, unicode src, unicode copts=""):
140143 """
141144 Creates a Sycl interoperability program from an OpenCL source string.
142145
143- We use the ``DPCTLProgram_CreateFromOCLSource()`` C API function to
144- create a ``sycl::program`` from an OpenCL source program that can
145- contain multiple kernels. Note currently only supported for OpenCL.
146+ We use the ``DPCTLKernelBundle_CreateFromOCLSource()`` C API function
147+ to create a ``sycl::kernel_bundle<sycl::bundle_state::executable>``
148+ from an OpenCL source program that can contain multiple kernels.
149+ Note: This function is currently only supported for the OpenCL backend.
146150
147151 Parameters:
148152 q (SyclQueue) : The :class:`SyclQueue` for which the
@@ -153,33 +157,37 @@ cpdef create_program_from_source(SyclQueue q, unicode src, unicode copts=""):
153157
154158 Returns:
155159 program (SyclProgram): A :class:`SyclProgram` object wrapping the
156- ``sycl::program`` returned by the C API.
160+ ``sycl::kernel_bundle<sycl::bundle_state::executable>`` returned
161+ by the C API.
157162
158163 Raises:
159- SyclProgramCompilationError: If a SYCL program could not be created.
164+ SyclProgramCompilationError: If a SYCL kernel bundle could not be
165+ created.
160166 """
161167
162- cdef DPCTLSyclProgramRef Pref
168+ cdef DPCTLSyclKernelBundleRef KBref
163169 cdef bytes bSrc = src.encode(' utf8' )
164170 cdef bytes bCOpts = copts.encode(' utf8' )
165171 cdef const char * Src = < const char * > bSrc
166172 cdef const char * COpts = < const char * > bCOpts
167173 cdef DPCTLSyclContextRef CRef = q.get_sycl_context().get_context_ref()
168- Pref = DPCTLProgram_CreateFromOCLSource(CRef, Src, COpts)
174+ cdef DPCTLSyclDeviceRef DRef = q.get_sycl_device().get_device_ref()
175+ KBref = DPCTLKernelBundle_CreateFromOCLSource(CRef, DRef, Src, COpts)
169176
170- if Pref is NULL :
177+ if KBref is NULL :
171178 raise SyclProgramCompilationError()
172179
173- return SyclProgram._create(Pref )
180+ return SyclProgram._create(KBref )
174181
175182
176183cpdef create_program_from_spirv(SyclQueue q, const unsigned char [:] IL,
177184 unicode copts = " " ):
178185 """
179186 Creates a Sycl interoperability program from an SPIR-V binary.
180187
181- We use the ``DPCTLProgram_CreateFromOCLSpirv()`` C API function to
182- create a ``sycl::program`` object from an compiled SPIR-V binary file.
188+ We use the ``DPCTLKernelBundle_CreateFromOCLSpirv()`` C API function to
189+ create a ``sycl::kernel_bundle<sycl::bundle_state::executable>`` object
190+ from an compiled SPIR-V binary file.
183191
184192 Parameters:
185193 q (SyclQueue): The :class:`SyclQueue` for which the
@@ -190,20 +198,25 @@ cpdef create_program_from_spirv(SyclQueue q, const unsigned char[:] IL,
190198
191199 Returns:
192200 program (SyclProgram): A :class:`SyclProgram` object wrapping the
193- ``sycl::program`` returned by the C API.
201+ ``sycl::kernel_bundle<sycl::bundle_state::executable>`` returned by
202+ the C API.
194203
195204 Raises:
196- SyclProgramCompilationError: If a SYCL program could not be created.
205+ SyclProgramCompilationError: If a SYCL kernel bundle could not be
206+ created.
197207 """
198208
199- cdef DPCTLSyclProgramRef Pref
209+ cdef DPCTLSyclKernelBundleRef KBref
200210 cdef const unsigned char * dIL = & IL[0 ]
201211 cdef DPCTLSyclContextRef CRef = q.get_sycl_context().get_context_ref()
212+ cdef DPCTLSyclDeviceRef DRef = q.get_sycl_device().get_device_ref()
202213 cdef size_t length = IL.shape[0 ]
203214 cdef bytes bCOpts = copts.encode(' utf8' )
204215 cdef const char * COpts = < const char * > bCOpts
205- Pref = DPCTLProgram_CreateFromSpirv(CRef, < const void * > dIL, length, COpts)
206- if Pref is NULL :
216+ KBref = DPCTLKernelBundle_CreateFromSpirv(
217+ CRef, DRef, < const void * > dIL, length, COpts
218+ )
219+ if KBref is NULL :
207220 raise SyclProgramCompilationError()
208221
209- return SyclProgram._create(Pref )
222+ return SyclProgram._create(KBref )
0 commit comments