diff --git a/doc/make_constants.py b/doc/make_constants.py index 803a52d04a4a5c9d86d95f11bea7a100a9dd12ad..28eebe6cb26a9c3ef562c25cb9fcc8613cd389d3 100644 --- a/doc/make_constants.py +++ b/doc/make_constants.py @@ -31,6 +31,7 @@ cl_12 = ("CL_1.2", "2011.2") cl_12_2015 = ("CL_1.2", "2015.2") cl_20 = ("CL_2.0", "2015.2") cl_21 = ("CL_2.1", "2016.2") +cl_22 = ("CL_2.1", "2020.3") cl_30 = ("CL_3.0", "2020.3") amd_devattr = ("cl_amd_device_attribute_query", "2013.2") qcom_hp_devattr = ("cl_qcom_ext_host_ptr", "2016.2") @@ -83,6 +84,9 @@ const_ext_lookup = { "INVALID_PIPE_SIZE": cl_20, "INVALID_DEVICE_QUEUE": cl_20, + "INVALID_SPEC_ID": cl_22, + "MAX_SIZE_RESTRICTION_EXCEEDED": cl_22, + }, cl.device_info: { diff --git a/doc/runtime_program.rst b/doc/runtime_program.rst index 18d831eb88ac6d3971651242aeb6367220dc3d9a..31de0ac2dfcdedb390c754cb9195e4ba0cb3ec53 100644 --- a/doc/runtime_program.rst +++ b/doc/runtime_program.rst @@ -110,6 +110,12 @@ Program Returns a list of all :class:`Kernel` objects in the :class:`Program`. + .. method:: set_specialization_constant(spec_id, buffer) + + Only available with CL 2.2 and newer. + + .. versionadded:: 2020.3 + .. automethod:: from_int_ptr .. autoattribute:: int_ptr diff --git a/src/wrap_cl.hpp b/src/wrap_cl.hpp index ded51a426d039eb746353fe53055a46c2d4b543f..05c746a5ae3568bb3865cb2347f313e6baa09137 100644 --- a/src/wrap_cl.hpp +++ b/src/wrap_cl.hpp @@ -41,6 +41,8 @@ // clCloneKernel // clEnqueueSVMMigrateMem +// CL 2.2 complete + // CL 3.0 missing: // clCreateBufferWithProperties // clCreateImageWithProperties @@ -3858,6 +3860,16 @@ namespace pyopencl 0, 0)); } #endif + +#if PYOPENCL_CL_VERSION >= 0x2020 + void set_specialization_constant(cl_uint spec_id, py::object py_buffer) + { + py_buffer_wrapper bufwrap; + bufwrap.get(py_buffer.ptr(), PyBUF_ANY_CONTIGUOUS); + PYOPENCL_CALL_GUARDED(clSetProgramSpecializationConstant, + (m_program, spec_id, bufwrap.m_buf.len, bufwrap.m_buf.buf)); + } +#endif }; diff --git a/src/wrap_cl_part_2.cpp b/src/wrap_cl_part_2.cpp index 175b5aa5932a16ac0528bb7656778f179b490f6f..6735d41fd7a348d9f76332d5ef8d36cd31906544 100644 --- a/src/wrap_cl_part_2.cpp +++ b/src/wrap_cl_part_2.cpp @@ -400,6 +400,11 @@ void pyopencl_expose_part_2(py::module &m) py::arg("options")="", py::arg("devices")=py::none() ) +#endif +#if PYOPENCL_CL_VERSION >= 0x2020 + .def("set_specialization_constant", &cls::set_specialization_constant, + py::arg("spec_id"), + py::arg("buffer")) #endif .def(py::self == py::self) .def(py::self != py::self) diff --git a/src/wrap_constants.cpp b/src/wrap_constants.cpp index dcda80d19d5b6a8789c52346f86f21f00154f289..a5abb38aa480c92a474af217ce81269377384bd9 100644 --- a/src/wrap_constants.cpp +++ b/src/wrap_constants.cpp @@ -240,6 +240,11 @@ void pyopencl_expose_constants(py::module &m) ADD_ATTR(, INVALID_DEVICE_QUEUE); #endif +#if PYOPENCL_CL_VERSION >= 0x2020 + ADD_ATTR(, INVALID_SPEC_ID); + ADD_ATTR(, MAX_SIZE_RESTRICTION_EXCEEDED); +#endif + #if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION) ADD_ATTR(, DEVICE_PARTITION_FAILED_EXT); ADD_ATTR(, INVALID_PARTITION_COUNT_EXT);