/* 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 */
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;
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 */
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);