clover: Check the total work-group size provided to clEnqueueNDRangeKernel.
authorFrancisco Jerez <currojerez@riseup.net>
Sat, 12 May 2012 17:24:09 +0000 (19:24 +0200)
committerFrancisco Jerez <currojerez@riseup.net>
Sat, 12 May 2012 17:43:01 +0000 (19:43 +0200)
src/gallium/state_trackers/clover/api/kernel.cpp

index 44eeb27712735a7e3a9c03f71a71755248e50197..ab4982d2951af08214f4c61f0299c1fce1ec7110 100644 (file)
@@ -223,16 +223,23 @@ namespace {
       if (!grid_size || any_of(is_zero<size_t>(), grid_size, grid_size + dims))
          throw error(CL_INVALID_GLOBAL_WORK_SIZE);
 
-      if (block_size && any_of([](size_t b, size_t max) {
-               return b == 0 || b > max;
-            }, block_size, block_size + dims,
-            q->dev.max_block_size().begin()))
-         throw error(CL_INVALID_WORK_ITEM_SIZE);
-
-      if (block_size && any_of([](size_t b, size_t g) {
-               return g % b;
-            }, block_size, block_size + dims, grid_size))
-         throw error(CL_INVALID_WORK_GROUP_SIZE);
+      if (block_size) {
+         if (any_of([](size_t b, size_t max) {
+                  return b == 0 || b > max;
+               }, block_size, block_size + dims,
+               q->dev.max_block_size().begin()))
+            throw error(CL_INVALID_WORK_ITEM_SIZE);
+
+         if (any_of([](size_t b, size_t g) {
+                  return g % b;
+               }, block_size, block_size + dims, grid_size))
+            throw error(CL_INVALID_WORK_GROUP_SIZE);
+
+         if (fold(std::multiplies<size_t>(), 1u,
+                  block_size, block_size + dims) >
+             q->dev.max_threads_per_block())
+            throw error(CL_INVALID_WORK_GROUP_SIZE);
+      }
    }
 
    ///