6

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!

Simbi
  • 992
  • 3
  • 13
  • 29
  • 1
    Have you by now found the answer to the question? Both answers so far don't say how to find out the work group size that OpenCL chooses at runtime. – nh2 Aug 29 '15 at 22:31

2 Answers2

2

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.

Pragmateek
  • 13,174
  • 9
  • 74
  • 108
  • Yes, but how can i then get to the value OpenCL chose for me? In the documentation of clGetKernelWorkGroupInfo it says: [link](http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clGetKernelWorkGroupInfo.html) _This provides a mechanism for the application to query the work-group size that can be used to execute a kernel on a specific device given by device. The OpenCL implementation uses the resource requirements of the kernel (register usage etc.) to determine what this work-group size should be._ Here it doesn't say anything about the maximum – Simbi Nov 21 '12 at 18:04
0

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]"

mfa
  • 5,017
  • 2
  • 23
  • 28
  • Thank you for your response, but this didn't answer my question. – Simbi Nov 21 '12 at 18:05
  • http://stackoverflow.com/questions/10096443/what-is-the-algorithm-to-determine-optimal-work-group-size-and-number-of-workgro/10098063#10098063 – mfa Nov 21 '12 at 18:12
  • 1
    This also doesn't really answer my question. I **don't want to know how to find a good work group size**, I want to know **how to get the work group size OpenCL is choosing** for a certain kernel/device combination if I use NULL as the local_work_size parameter in the clEnqueueNDRange kernel. I hope this makes it a little bit clearer. – Simbi Nov 22 '12 at 15:49
  • It doesn't choose for you. You choose by telling it the number of items and the number of groups to use when you call clEnqueueNDRangeKernel. – mfa Nov 22 '12 at 16:41
  • 1
    The OpenCL documentation tells me: _The OpenCL implementation uses the resource requirements of the kernel (register usage etc.) to determine what this work-group size should be._ So the OpenCL implementation determines the work-group size. Am I missing something here? – Simbi Nov 22 '12 at 16:46
  • I think that is how the maximum work group size for the kernel is determined when the kernel is compiled. It could tell you a value, but you would still need to specify the actual size when you run your kernel. Also, the maximum isn't always optimal. – mfa Nov 22 '12 at 16:54