From 4c0521913881ac6e284b38c9aab79708dfb522db Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 5 Oct 2018 09:58:29 -0500 Subject: [PATCH] Allow for passing on-device queues to kernels --- pyopencl/__init__.py | 1 + src/wrap_cl.hpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index 65132c17..50cdd954 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -2041,6 +2041,7 @@ def fsvm_empty_like(ctx, ary, alignment=None): _KERNEL_ARG_CLASSES = ( MemoryObjectHolder, Sampler, + CommandQueue, LocalMemory, ) if get_cl_header_version() >= (2, 0): diff --git a/src/wrap_cl.hpp b/src/wrap_cl.hpp index 425bf1d6..bdd24796 100644 --- a/src/wrap_cl.hpp +++ b/src/wrap_cl.hpp @@ -4215,6 +4215,13 @@ namespace pyopencl (m_kernel, arg_index, sizeof(cl_sampler), &s)); } + void set_arg_command_queue(cl_uint arg_index, command_queue const &queue) + { + cl_command_queue q = queue.data(); + PYOPENCL_CALL_GUARDED(clSetKernelArg, + (m_kernel, arg_index, sizeof(cl_command_queue), &q)); + } + void set_arg_buf(cl_uint arg_index, py::object py_buffer) { const void *buf; @@ -4295,6 +4302,13 @@ namespace pyopencl } catch (py::cast_error &) { } + try + { + set_arg_command_queue(arg_index, arg.cast()); + return; + } + catch (py::cast_error &) { } + set_arg_buf(arg_index, arg); } -- GitLab