From 9ea47a0e2c19e6e59dbb081ea858f9c1d191c3a8 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 25 Jun 2015 23:50:26 -0500 Subject: [PATCH] Tweak cffi's enqueue_nd_range_kernel's ability to accept tuples for global_work_size --- pyopencl/cffi_cl.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pyopencl/cffi_cl.py b/pyopencl/cffi_cl.py index 7fe18c54..f238fccd 100644 --- a/pyopencl/cffi_cl.py +++ b/pyopencl/cffi_cl.py @@ -638,6 +638,10 @@ class CommandQueue(_Common): def flush(self): _handle_error(_lib.command_queue__flush(self.ptr)) +# }}} + + +# {{{ memory objects def _norm_shape_dtype(shape, dtype, order="C", strides=None, name=""): dtype = np.dtype(dtype) @@ -803,6 +807,8 @@ else: with Py_buffer.from_object(obj, flags) as buf: return _ffi.cast('void*', buf.buf), buf.len, obj + # }}} + # }}} @@ -1049,7 +1055,6 @@ def enqueue_nd_range_kernel(queue, kernel, global_work_size, local_work_size, work_dim = len(global_work_size) if local_work_size is not None: - global_size_copied = False if g_times_l: work_dim = max(work_dim, len(local_work_size)) elif work_dim != len(local_work_size): @@ -1059,16 +1064,14 @@ def enqueue_nd_range_kernel(queue, kernel, global_work_size, local_work_size, if len(local_work_size) < work_dim: local_work_size = (local_work_size + - [1] * (work_dim - len(local_work_size))) + (1,) * (work_dim - len(local_work_size))) if len(global_work_size) < work_dim: - global_size_copied = True global_work_size = (global_work_size + - [1] * (work_dim - len(global_work_size))) + (1,) * (work_dim - len(global_work_size))) if g_times_l: - if not global_size_copied: - global_work_size = list(global_work_size) - for i in range(work_dim): - global_work_size[i] *= local_work_size[i] + global_work_size = tuple( + global_work_size[i] * local_work_size[i] + for i in range(work_dim)) if global_work_offset is not None: raise NotImplementedError("global_work_offset") -- GitLab