From 21424c0c7f9ebe396884f3c4c0151a2434af5612 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Wed, 16 Sep 2020 16:58:09 -0500
Subject: [PATCH] Add clSetDefaultDeviceCommandQueue

---
 doc/runtime_platform.rst |  2 ++
 src/wrap_cl.hpp          | 15 ++++++++++++++-
 src/wrap_cl_part_1.cpp   |  3 +++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/doc/runtime_platform.rst b/doc/runtime_platform.rst
index 96571685..d6e2ecb8 100644
--- a/doc/runtime_platform.rst
+++ b/doc/runtime_platform.rst
@@ -174,6 +174,8 @@ Context
     .. automethod:: from_int_ptr
     .. autoattribute:: int_ptr
 
+    .. method:: set_default_device_command_queue(dev, queue)
+
     |comparable|
 
 .. function:: create_some_context(interactive=True, answers=None, cache_dir=None)
diff --git a/src/wrap_cl.hpp b/src/wrap_cl.hpp
index 55f5e058..436317fe 100644
--- a/src/wrap_cl.hpp
+++ b/src/wrap_cl.hpp
@@ -34,7 +34,6 @@
 
 // CL 2.1 missing:
 // clGetKernelSubGroupInfo
-// clSetDefaultDeviceCommandQueue
 // clEnqueueSVMMigrateMem
 
 // CL 2.2 complete
@@ -437,6 +436,7 @@
 namespace pyopencl
 {
   class program;
+  class command_queue;
 
   // {{{ error
   class error : public std::runtime_error
@@ -1229,6 +1229,10 @@ namespace pyopencl
 
         return major_ver << 12 | minor_ver << 4;
       }
+
+#if PYOPENCL_CL_VERSION >= 0x2010
+      void set_default_device_command_queue(device const &dev, command_queue const &queue);
+#endif
   };
 
 
@@ -4912,6 +4916,15 @@ namespace pyopencl
 
   // {{{ deferred implementation bits
 
+#if PYOPENCL_CL_VERSION >= 0x2010
+  inline void context::set_default_device_command_queue(device const &dev, command_queue const &queue)
+  {
+    PYOPENCL_CALL_GUARDED(clSetDefaultDeviceCommandQueue,
+        (m_context, dev.data(), queue.data()));
+  }
+#endif
+
+
   inline program *error::get_program() const
   {
     return new program(m_program, /* retain */ true);
diff --git a/src/wrap_cl_part_1.cpp b/src/wrap_cl_part_1.cpp
index d62f6b40..4b0ec771 100644
--- a/src/wrap_cl_part_1.cpp
+++ b/src/wrap_cl_part_1.cpp
@@ -103,6 +103,9 @@ void pyopencl_expose_part_1(py::module &m)
       .def(py::self != py::self)
       .def("__hash__", &cls::hash)
       PYOPENCL_EXPOSE_TO_FROM_INT_PTR(cl_context)
+#if PYOPENCL_CL_VERSION >= 0x2010
+      .DEF_SIMPLE_METHOD(set_default_device_command_queue)
+#endif
       ;
   }
 
-- 
GitLab