@@ -31,14 +31,15 @@ from dpctl._backend cimport ( # noqa: E211, E402
31
31
DPCTLCString_Delete,
32
32
DPCTLKernel_Delete,
33
33
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 ,
39
39
DPCTLSyclContextRef,
40
+ DPCTLSyclDeviceRef,
41
+ DPCTLSyclKernelBundleRef,
40
42
DPCTLSyclKernelRef,
41
- DPCTLSyclProgramRef,
42
43
)
43
44
44
45
__all__ = [
@@ -50,8 +51,8 @@ __all__ = [
50
51
]
51
52
52
53
cdef 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.
55
56
"""
56
57
pass
57
58
@@ -105,33 +106,35 @@ cdef class SyclProgram:
105
106
"""
106
107
107
108
@staticmethod
108
- cdef SyclProgram _create(DPCTLSyclProgramRef pref ):
109
+ cdef SyclProgram _create(DPCTLSyclKernelBundleRef KBRef ):
109
110
cdef SyclProgram ret = SyclProgram.__new__ (SyclProgram)
110
- ret._program_ref = pref
111
+ ret._program_ref = KBRef
111
112
return ret
112
113
113
114
def __dealloc__ (self ):
114
- DPCTLProgram_Delete (self ._program_ref)
115
+ DPCTLKernelBundle_Delete (self ._program_ref)
115
116
116
- cdef DPCTLSyclProgramRef get_program_ref(self ):
117
+ cdef DPCTLSyclKernelBundleRef get_program_ref(self ):
117
118
return self ._program_ref
118
119
119
120
cpdef SyclKernel get_sycl_kernel(self , str kernel_name):
120
121
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
+ )
123
126
124
127
def has_sycl_kernel (self , str kernel_name ):
125
128
name = kernel_name.encode(' utf8' )
126
- return DPCTLProgram_HasKernel (self ._program_ref, name)
129
+ return DPCTLKernelBundle_HasKernel (self ._program_ref, name)
127
130
128
131
def addressof_ref (self ):
129
- """ Returns the address of the C API DPCTLSyclProgramRef pointer
132
+ """ Returns the address of the C API DPCTLSyclKernelBundleRef pointer
130
133
as a long.
131
134
132
135
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``.
135
138
"""
136
139
return int (< size_t> self ._program_ref)
137
140
@@ -140,9 +143,10 @@ cpdef create_program_from_source(SyclQueue q, unicode src, unicode copts=""):
140
143
"""
141
144
Creates a Sycl interoperability program from an OpenCL source string.
142
145
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.
146
150
147
151
Parameters:
148
152
q (SyclQueue) : The :class:`SyclQueue` for which the
@@ -153,33 +157,37 @@ cpdef create_program_from_source(SyclQueue q, unicode src, unicode copts=""):
153
157
154
158
Returns:
155
159
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.
157
162
158
163
Raises:
159
- SyclProgramCompilationError: If a SYCL program could not be created.
164
+ SyclProgramCompilationError: If a SYCL kernel bundle could not be
165
+ created.
160
166
"""
161
167
162
- cdef DPCTLSyclProgramRef Pref
168
+ cdef DPCTLSyclKernelBundleRef KBref
163
169
cdef bytes bSrc = src.encode(' utf8' )
164
170
cdef bytes bCOpts = copts.encode(' utf8' )
165
171
cdef const char * Src = < const char * > bSrc
166
172
cdef const char * COpts = < const char * > bCOpts
167
173
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)
169
176
170
- if Pref is NULL :
177
+ if KBref is NULL :
171
178
raise SyclProgramCompilationError()
172
179
173
- return SyclProgram._create(Pref )
180
+ return SyclProgram._create(KBref )
174
181
175
182
176
183
cpdef create_program_from_spirv(SyclQueue q, const unsigned char [:] IL,
177
184
unicode copts = " " ):
178
185
"""
179
186
Creates a Sycl interoperability program from an SPIR-V binary.
180
187
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.
183
191
184
192
Parameters:
185
193
q (SyclQueue): The :class:`SyclQueue` for which the
@@ -190,20 +198,25 @@ cpdef create_program_from_spirv(SyclQueue q, const unsigned char[:] IL,
190
198
191
199
Returns:
192
200
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.
194
203
195
204
Raises:
196
- SyclProgramCompilationError: If a SYCL program could not be created.
205
+ SyclProgramCompilationError: If a SYCL kernel bundle could not be
206
+ created.
197
207
"""
198
208
199
- cdef DPCTLSyclProgramRef Pref
209
+ cdef DPCTLSyclKernelBundleRef KBref
200
210
cdef const unsigned char * dIL = & IL[0 ]
201
211
cdef DPCTLSyclContextRef CRef = q.get_sycl_context().get_context_ref()
212
+ cdef DPCTLSyclDeviceRef DRef = q.get_sycl_device().get_device_ref()
202
213
cdef size_t length = IL.shape[0 ]
203
214
cdef bytes bCOpts = copts.encode(' utf8' )
204
215
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 :
207
220
raise SyclProgramCompilationError()
208
221
209
- return SyclProgram._create(Pref )
222
+ return SyclProgram._create(KBref )
0 commit comments