From f94941ec2c094019ecc7a91cb45007bf7ceae2b5 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Mon, 22 Apr 2013 20:55:17 -0400
Subject: [PATCH] More event/wait_for tidbits.

---
 pyopencl/array.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pyopencl/array.py b/pyopencl/array.py
index b11a87ef..65c8f008 100644
--- a/pyopencl/array.py
+++ b/pyopencl/array.py
@@ -952,6 +952,7 @@ class Array(object):
     def finish(self):
         # undoc
         cl.wait_for_events(self.events)
+        del self.events[:]
 
 # }}}
 
@@ -1136,7 +1137,7 @@ def _take(result, ary, indices):
 
 
 
-def take(a, indices, out=None, queue=None):
+def take(a, indices, out=None, queue=None, wait_for=None):
     """Return the :class:`Array` ``[a[indices[0]], ..., a[indices[n]]]``.
     For the moment, *a* must be a type that can be bound to a texture.
     """
@@ -1146,7 +1147,8 @@ def take(a, indices, out=None, queue=None):
         out = Array(queue, indices.shape, a.dtype, allocator=a.allocator)
 
     assert len(indices.shape) == 1
-    _take(out, a, indices, queue=queue)
+    out.events.append(
+            _take(out, a, indices, queue=queue, wait_for=wait_for))
     return out
 
 
-- 
GitLab