diff --git a/doc/source/runtime.rst b/doc/source/runtime.rst index 978f83e2fc2ec77b0b31cde133e91f9d99634b77..3dff4bae28b8820ff0d871696909dc4b8eb93ca4 100644 --- a/doc/source/runtime.rst +++ b/doc/source/runtime.rst @@ -281,6 +281,11 @@ Command Queues and Events .. method:: get_ward() + .. method:: wait() + + In addition to performing the same wait as :meth:`Event.wait()`, this + method also releases the reference to the guarded object. + Memory ------ diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index e689051cf8f800a0b0f47fe392cfc80f8155b6a3..72f57e34a2768ec187785b8d7d34f905ff6b2ea8 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -315,16 +315,6 @@ def _add_functionality(): # }}} - # {{{ Event - - def event_wait(self): - wait_for_events([self]) - return self - - Event.wait = event_wait - - # }}} - # {{{ Error def error_str(self): diff --git a/src/wrapper/wrap_cl.hpp b/src/wrapper/wrap_cl.hpp index aa3a940978a51e0a6b1a74fc54d5c88285ab46cd..fd1f947bcce35def42e8d89026762799b888ad45 100644 --- a/src/wrapper/wrap_cl.hpp +++ b/src/wrapper/wrap_cl.hpp @@ -1060,6 +1060,11 @@ namespace pyopencl throw error("Event.get_profiling_info", CL_INVALID_VALUE); } } + + virtual void wait() + { + PYOPENCL_CALL_GUARDED_THREADED(clWaitForEvents, (1, &m_event)); + } }; class nanny_event : public event @@ -1085,6 +1090,12 @@ namespace pyopencl py::object get_ward() const { return m_ward; } + + virtual void wait() + { + event::wait(); + m_ward = py::object(); + } }; diff --git a/src/wrapper/wrap_cl_part_1.cpp b/src/wrapper/wrap_cl_part_1.cpp index 3ea3709478654a9a7f9a772424939f2b2f41abe4..bb8cdda097aaf08a7eba809026c3449c91d3b09c 100644 --- a/src/wrapper/wrap_cl_part_1.cpp +++ b/src/wrapper/wrap_cl_part_1.cpp @@ -97,6 +97,7 @@ void pyopencl_expose_part_1() py::class_<cls, boost::noncopyable>("Event", py::no_init) .DEF_SIMPLE_METHOD(get_info) .DEF_SIMPLE_METHOD(get_profiling_info) + .DEF_SIMPLE_METHOD(wait) .add_property("obj_ptr", &cls::obj_ptr) .def(py::self == py::self) .def(py::self != py::self)