Skip to content

Commit c44c8bc

Browse files
committed
address review feedback
1 parent 02c61a4 commit c44c8bc

4 files changed

Lines changed: 30 additions & 10 deletions

File tree

docs/doc_sources/api_reference/dpctl/program.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ execution via :py:meth:`dpctl.SyclQueue.submit`.
3131

3232
SyclKernelBundle
3333
SyclKernel
34+
SpecializationConstant
3435

3536
.. autosummary::
3637
:toctree: generated

dpctl/program/_program.pyx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,11 @@ cdef class SpecializationConstant:
288288
data in the buffer
289289
290290
- ``SpecializationConstant(spec_id, dtype, obj)``
291-
If the constructor is invoked with two variadic arguments, and the first
292-
argument is a string, it is interpreted as a NumPy ``dtype`` string and the
293-
second argument will be coerced to a NumPy array with that data type.
294-
The data type specified by the first argument must be a supported data
295-
type (bool, integral, or floating point).
291+
If the constructor is invoked with two variadic arguments, and the first
292+
argument is a string, it is interpreted as a NumPy ``dtype`` string and
293+
the second argument will be coerced to a NumPy array with that data type.
294+
The data type specified by the first argument must be a supported data
295+
type (bool, integral, or floating point).
296296
297297
- ``SpecializationConstant(spec_id, nbytes, raw_ptr)``
298298
If the constructor is invoked with two variadic arguments where both are
@@ -406,10 +406,11 @@ cdef class SpecializationConstant:
406406
cdef SpecializationConstant _other = <SpecializationConstant>other
407407
if (
408408
self._spec_const.id != _other._spec_const.id or
409-
self._spec_const.size != _other._spec_const.size or
410-
self._spec_const.value != _other._spec_const.value
409+
self._spec_const.size != _other._spec_const.size
411410
):
412411
return False
412+
if self._spec_const.value == _other._spec_const.value:
413+
return True
413414
return memcmp(
414415
self._spec_const.value,
415416
_other._spec_const.value,

dpctl/program/utils/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
A collection of utility functions for dpctl.program module.
1919
"""
2020

21-
from ._utils import parse_spirv_specializations
21+
from ._utils import SpecializationConstantInfo, parse_spirv_specializations
2222

2323
__all__ = [
2424
"parse_spirv_specializations",
25+
"SpecializationConstantInfo",
2526
]

libsyclinterface/source/dpctl_sycl_kernel_bundle_interface.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,25 @@ _CreateKernelBundleWithIL_ocl_impl(const context &ctx,
297297
auto clSetProgramSpecConstF = get_clSetProgramSpecializationConstant();
298298
if (clSetProgramSpecConstF) {
299299
for (size_t i = 0; i < NumSpecConsts; ++i) {
300-
clSetProgramSpecConstF(clProgram, SpecConsts[i].id,
301-
SpecConsts[i].size, SpecConsts[i].value);
300+
cl_int spec_err = clSetProgramSpecConstF(
301+
clProgram, SpecConsts[i].id, SpecConsts[i].size,
302+
SpecConsts[i].value);
303+
if (spec_err != CL_SUCCESS) {
304+
error_handler(
305+
"clSetProgramSpecializationConstant failed for "
306+
"spec constant id " +
307+
std::to_string(SpecConsts[i].id) +
308+
". OpenCL Error " +
309+
_GetErrorCode_ocl_impl(spec_err),
310+
__FILE__, __func__, __LINE__);
311+
312+
auto clReleaseProgramF = get_clReleaseProgram();
313+
if (clReleaseProgramF) {
314+
clReleaseProgramF(clProgram);
315+
}
316+
317+
return nullptr;
318+
}
302319
}
303320
}
304321
else {

0 commit comments

Comments
 (0)