diff --git a/doc/runtime_program.rst b/doc/runtime_program.rst index 31de0ac2dfcdedb390c754cb9195e4ba0cb3ec53..1c28a78cce300ce9dd6238b57ab4d6e0fe9688a4 100644 --- a/doc/runtime_program.rst +++ b/doc/runtime_program.rst @@ -150,6 +150,12 @@ Kernel may be used as attributes on instances of this class to directly query info attributes. + .. method:: clone() + + Only available with CL 2.1. + + .. versionadded:: 2020.3 + .. method:: get_info(param) See :class:`kernel_info` for values of *param*. diff --git a/src/wrap_cl.hpp b/src/wrap_cl.hpp index 7cf2dc07f4332d7122dff0b17d4d88014362ebd3..d506a99f9a6f585eb32b89128b1589bfc00dcbe5 100644 --- a/src/wrap_cl.hpp +++ b/src/wrap_cl.hpp @@ -4258,6 +4258,28 @@ namespace pyopencl PYOPENCL_EQUALITY_TESTS(kernel); +#if PYOPENCL_CL_VERSION >= 0x2010 + kernel *clone() + { + cl_int status_code; + + PYOPENCL_PRINT_CALL_TRACE("clCloneKernel"); + cl_kernel result = clCloneKernel(m_kernel, &status_code); + if (status_code != CL_SUCCESS) + throw pyopencl::error("clCloneKernel", status_code); + + try + { + return new kernel(result, /* retain */ false); + } + catch (...) + { + PYOPENCL_CALL_GUARDED_CLEANUP(clReleaseKernel, (result)); + throw; + } + } +#endif + void set_arg_null(cl_uint arg_index) { cl_mem m = 0; diff --git a/src/wrap_cl_part_2.cpp b/src/wrap_cl_part_2.cpp index df56d0afac33399b826de33872cd5819497f367e..a69c9299b46cc3c4bca107bd6a319638496a5249 100644 --- a/src/wrap_cl_part_2.cpp +++ b/src/wrap_cl_part_2.cpp @@ -462,6 +462,9 @@ void pyopencl_expose_part_2(py::module &m) .def(py::init()) .DEF_SIMPLE_METHOD(get_info) .DEF_SIMPLE_METHOD(get_work_group_info) +#if PYOPENCL_CL_VERSION >= 0x2000 + .DEF_SIMPLE_METHOD(clone) +#endif .def("_set_arg_null", &cls::set_arg_null) .def("_set_arg_buf", &cls::set_arg_buf) #if PYOPENCL_CL_VERSION >= 0x2000