From 1c829b4bddb4a956b8cfcfd99cff56f784016ca5 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 28 Jun 2013 23:19:32 -0400 Subject: [PATCH] Support by-value numpy array/buffer proto objects in capture_call --- pyopencl/capture_call.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pyopencl/capture_call.py b/pyopencl/capture_call.py index 7ecfa248..b45e3102 100644 --- a/pyopencl/capture_call.py +++ b/pyopencl/capture_call.py @@ -90,8 +90,14 @@ def capture_kernel_call(kernel, filename, queue, g_size, l_size, *args, **kwargs kernel_args.append("np.%s(%s)" % ( arg.dtype.type.__name__, repr(complex(arg)))) else: - raise RuntimeError("cannot capture: " - "unsupported arg nr %d (0-based)" % i) + try: + arg_buf = buffer(arg) + except: + raise RuntimeError("cannot capture: " + "unsupported arg nr %d (0-based)" % i) + + arg_data.append(("arg%d_data" % i, arg_buf)) + kernel_args.append("decompress(b64decode(arg%d_data))" % i) cg("") -- GitLab