Support non-16 multiple group size.
authorRuiling Song <ruiling.song@intel.com>
Fri, 31 May 2013 07:58:08 +0000 (15:58 +0800)
committerZhigang Gong <zhigang.gong@linux.intel.com>
Fri, 31 May 2013 08:49:37 +0000 (16:49 +0800)
Signed-off-by: Ruiling Song <ruiling.song@intel.com>
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
src/cl_command_queue_gen7.c
src/cl_kernel.c
src/intel/intel_gpgpu.c

index 770af4a..bc1a322 100644 (file)
@@ -209,7 +209,7 @@ cl_command_queue_ND_range_gen7(cl_command_queue queue,
 
   /* Compute the number of HW threads we need */
   TRY (cl_kernel_work_group_sz, ker, local_wk_sz, 3, &local_sz);
-  kernel.thread_n = thread_n = local_sz / simd_sz;
+  kernel.thread_n = thread_n = (local_sz + simd_sz - 1) / simd_sz;
   kernel.cst_sz = cst_sz;
 
   /* Curbe step 1: fill the constant buffer data shared by all threads */
index 90aa0c2..851acfa 100644 (file)
@@ -292,7 +292,7 @@ cl_kernel_work_group_sz(cl_kernel ker,
   sz = local_wk_sz[0];
   for (i = 1; i < wk_dim; ++i)
     sz *= local_wk_sz[i];
-  FATAL_IF (sz % 16, "Work group size must be a multiple of 16");
+
   if (sz > ker->program->ctx->device->max_work_group_size) {
     err = CL_INVALID_WORK_ITEM_SIZE;
     goto error;
index b0f556d..b19dae5 100644 (file)
@@ -748,7 +748,15 @@ intel_gpgpu_walker(intel_gpgpu_t *gpgpu,
     global_wk_sz[1] / local_wk_sz[1],
     global_wk_sz[2] / local_wk_sz[2]
   };
+  uint32_t right_mask = ~0x0;
+  size_t group_sz = local_wk_sz[0] * local_wk_sz[1] * local_wk_sz[2];
+
   assert(simd_sz == 8 || simd_sz == 16);
+
+  uint32_t shift = (group_sz & (simd_sz - 1));
+  shift = (shift == 0) ? simd_sz : shift;
+  right_mask = (1 << shift) - 1;
+
   BEGIN_BATCH(gpgpu->batch, 11);
   OUT_BATCH(gpgpu->batch, CMD_GPGPU_WALKER | 9);
   OUT_BATCH(gpgpu->batch, 0);                        /* kernel index == 0 */
@@ -762,8 +770,8 @@ intel_gpgpu_walker(intel_gpgpu_t *gpgpu,
   OUT_BATCH(gpgpu->batch, global_wk_dim[1]);
   OUT_BATCH(gpgpu->batch, global_wk_off[2]);
   OUT_BATCH(gpgpu->batch, global_wk_dim[2]);
-  OUT_BATCH(gpgpu->batch, ~0x0);
-  OUT_BATCH(gpgpu->batch, ~0x0);
+  OUT_BATCH(gpgpu->batch, right_mask);
+  OUT_BATCH(gpgpu->batch, ~0x0);                     /* we always set height as 1, so set bottom mask as all 1*/
   ADVANCE_BATCH(gpgpu->batch);
 
   BEGIN_BATCH(gpgpu->batch, 2);