From 43aae17f7bcf2fff30b4297c52629f67503f050f Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Sun, 3 Jul 2011 12:52:27 -0400
Subject: [PATCH] Allow non-matching global/local dimensions in g_times_l mode.

---
 src/wrapper/wrap_cl.hpp | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/wrapper/wrap_cl.hpp b/src/wrapper/wrap_cl.hpp
index 7132b278..0228e75b 100644
--- a/src/wrapper/wrap_cl.hpp
+++ b/src/wrapper/wrap_cl.hpp
@@ -2807,12 +2807,20 @@ namespace pyopencl
     std::vector<size_t> local_work_size;
     if (py_local_work_size.ptr() != Py_None)
     {
-      if (work_dim != unsigned(len(py_local_work_size)))
-        throw error("enqueue_nd_range_kernel", CL_INVALID_VALUE,
-            "global/work work sizes have differing dimensions");
+      if (g_times_l)
+        work_dim = std::max(work_dim, unsigned(len(py_local_work_size)));
+      else
+        if (work_dim != unsigned(len(py_local_work_size)))
+          throw error("enqueue_nd_range_kernel", CL_INVALID_VALUE,
+              "global/local work sizes have differing dimensions");
 
       COPY_PY_LIST(size_t, local_work_size);
 
+      while (local_work_size.size() < work_dim)
+        local_work_size.push_back(1);
+      while (global_work_size.size() < work_dim)
+        global_work_size.push_back(1);
+
       local_work_size_ptr = local_work_size.empty( ) ? NULL : &local_work_size.front();
     }
 
-- 
GitLab