问题
I read that when not specifying the work group size when enqueueing a kernel, OpenCL chooses one for me.
e.g:
//don't know which workgroup size OpenCl will use!
clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global_size, NULL, 0, NULL, NULL);
Is there a way to get the workgroup size OpenCL is using here? Is the workgroup size OpenCL chooses the one which is returned by clGetKernelWorkGroupInfo?
Thank you in advance!
回答1:
CL_KERNEL_GLOBAL_WORK_SIZE is the MAXIMUM work-group size you can get, which depends on the memory requirements of your kernel.
If you do not specify a work-group size when executing a kernel OpenCL will try to choose the best one for you, which MAY or MAY NOT be the maximum size.
Indeed using the maximum size is optimal only if you have a lot of work-items compared to the number of compute-units of the device.
回答2:
You specify the size when you call clEnqueueNDRangeKernel. documentation is here. The parameter that matters in this case is 'local_work_size'.
"The total number of work-items in a work-group is computed as local_work_size[0] *... * local_work_size[work_dim - 1]"
来源:https://stackoverflow.com/questions/13496681/is-clgetkernelworkgroupinfo-cl-kernel-work-group-size-the-size-opencl-uses-whe