user27653
user27653

Reputation: 11

Why does OpenCL's clEnqueueNDRangeKernel uses const size_t * as arguments?

is there any reason that the OpenCL standard opted to use the argument type const size_t * instead of just passing a const size_t in the clEnqueueNDRangeKernel function?

What is the reasoning behind this decision?

Would there be any changes in performance or any other metric if the standard defined clEnqueueNDRangeKernel as using const size_t instead of a const size_t *?

Thanks

Upvotes: 1

Views: 323

Answers (1)

doqtor
doqtor

Reputation: 8494

Everything is explained in the manual. Basically const size_t * arguments are for passing arrays. Array is needed for passing number of work items for when using 2 and 3 dimensions. Below some important fragments extracted:

cl_int clEnqueueNDRangeKernel (   cl_command_queue command_queue,
  cl_kernel kernel,
  cl_uint work_dim,
  const size_t *global_work_offset,
  const size_t *global_work_size,
  const size_t *local_work_size,
  cl_uint num_events_in_wait_list,
  const cl_event *event_wait_list,
  cl_event *event)

global_work_offset - Must currently be a NULL value. In a future revision of OpenCL, global_work_offset can be used to specify an array of work_dim unsigned values...

global_work_size - Points to an array of work_dim unsigned values that describe the number of global work-items in work_dim dimensions that will execute the kernel function...

local_work_size - Points to an array of work_dim unsigned values that describe the number of work-items that make up a work-group (also referred to as the size of the work-group) that will execute the kernel specified by kernel...

Example:

size_t global[2] = {1024, 1024};
size_t local[2]  = {64, 64};
clEnqueueNDRangeKernel(queue, kernel, 2, NULL, global, local, 0, NULL, NULL);

Upvotes: 3

Related Questions