title: Calculating the right number of workgroups and their size OpenCL
body: <p>I'm new with OpenCL and I'm trying to understand this example program written by Apple <a href="https://developer.apple.com/library/mac/samplecode/OpenCL_Hello_World_Example/Listings/hello_c.html" rel="nofollow">here</a>.</p>
  
  <p>The goal of the program is to calculate the square of each element of an input array and write the result in a new array. </p>
  
  <p>You can see that the input array has dimension: 1024. The number of work groups is 1024 and the size of each of those is the max CL_KERNEL_WORK_GROUP_SIZE. </p>
  
  <p>Can anybody explain me what's the point of using so many work-items in each work group if in the Kernel there's no get_local_id() call? Could they use 1 as the size of each work group? what would have been the difference?</p>
  
  <p>Thanks. </p>
  
  <p>Some code to show the point:</p>
  
  <pre><code>    // Get the maximum work group size for executing the kernel on the device
      //
      err = clGetKernelWorkGroupInfo(kernel, device_id, CL_KERNEL_WORK_GROUP_SIZE, sizeof(local), &amp;local, NULL);
  
  
      // Execute the kernel over the entire range of our 1d input data set
      // using the maximum number of work group items for this device
      //
      global = count;
      err = clEnqueueNDRangeKernel(commands, kernel, 1, NULL, &amp;global, &amp;local, 0, NULL, NULL);
  </code></pre>