is clGetKernelWorkGroupInfo - CL_KERNEL_WORK_GROUP_SIZE the size OpenCL uses when not specifying it in clEnqueueNDRange Kernel?

元气小坏坏 提交于 2019-12-09 16:43:34

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!