C Specification

To return information about the kernel object that may be specific to a device, call the function

cl_int clGetKernelWorkGroupInfo(
    cl_kernel kernel,
    cl_device_id device,
    cl_kernel_work_group_info param_name,
    size_t param_value_size,
    void* param_value,
    size_t* param_value_size_ret);

Parameters

  • kernel specifies the kernel object being queried.

  • device identifies a specific device in the list of devices associated with kernel. The list of devices is the list of devices in the OpenCL context that is associated with kernel. If the list of devices associated with kernel is a single device, device can be a NULL value.

  • param_name specifies the information to query. The list of supported param_name types and the information returned in param_value by clGetKernelWorkGroupInfo is described in the Kernel Object Device Queries table.

  • param_value is a pointer to memory where the appropriate result being queried is returned. If param_value is NULL, it is ignored.

  • param_value_size is used to specify the size in bytes of memory pointed to by param_value. This size must be ≥ size of return type as described in the Kernel Object Device Queries table.

  • param_value_size_ret returns the actual size in bytes of data being queried by param_name. If param_value_size_ret is NULL, it is ignored.

Description

Table 1. List of supported param_names by https://www.khronos.org/registry/OpenCL/specs/2.2/html/OpenCL_API.html#clGetKernelWorkGroupInfo
cl_kernel_work_group_info Return Type Info. returned in param_value

CL_​KERNEL_​GLOBAL_​WORK_​SIZE

Missing before version 1.2.

size_t[3]

This provides a mechanism for the application to query the maximum global size that can be used to execute a kernel (i.e. global_work_size argument to clEnqueueNDRangeKernel) on a custom device given by device or a built-in kernel on an OpenCL device given by device.

If device is not a custom device and kernel is not a built-in kernel, clGetKernelWorkGroupInfo returns the error CL_​INVALID_​VALUE.

CL_​KERNEL_​WORK_​GROUP_​SIZE

size_t

This provides a mechanism for the application to query the maximum workgroup size that can be used to execute the 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.

As a result and unlike CL_​DEVICE_​MAX_​WORK_​GROUP_​SIZE this value may vary from one kernel to another as well as one device to another.

CL_​KERNEL_​WORK_​GROUP_​SIZE will be less than or equal to CL_​DEVICE_​MAX_​WORK_​GROUP_​SIZE for a given kernel object.

CL_​KERNEL_​COMPILE_​WORK_​GROUP_​SIZE

size_t[3]

Returns the work-group size specified in the kernel source or IL.

If the work-group size is not specified in the kernel source or IL, (0, 0, 0) is returned.

CL_​KERNEL_​LOCAL_​MEM_​SIZE

cl_ulong

Returns the amount of local memory in bytes being used by a kernel. This includes local memory that may be needed by an implementation to execute the kernel, variables declared inside the kernel with the __local address qualifier and local memory to be allocated for arguments to the kernel declared as pointers with the __local address qualifier and whose size is specified with clSetKernelArg.

If the local memory size, for any pointer argument to the kernel declared with the __local address qualifier, is not specified, its size is assumed to be 0.

CL_​KERNEL_​PREFERRED_​WORK_​GROUP_​SIZE_​MULTIPLE

size_t

Returns the preferred multiple of work-group size for launch. This is a performance hint. Specifying a work-group size that is not a multiple of the value returned by this query as the value of the local work size argument to clEnqueueNDRangeKernel will not fail to enqueue the kernel for execution unless the work-group size specified is larger than the device maximum.

CL_​KERNEL_​PRIVATE_​MEM_​SIZE

cl_ulong

Returns the minimum amount of private memory, in bytes, used by each work-item in the kernel. This value may include any private memory needed by an implementation to execute the kernel, including that used by the language built-ins and variable declared inside the kernel with the __private qualifier.

clGetKernelWorkGroupInfo returns CL_​SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:

  • CL_​INVALID_​DEVICE if device is not in the list of devices associated with kernel or if device is NULL but there is more than one device associated with kernel.

  • CL_​INVALID_​VALUE if param_name is not valid, or if size in bytes specified by param_value_size is < size of return type as described in the Kernel Object Device Queries table and param_value is not NULL.

  • CL_​INVALID_​VALUE if param_name is CL_​KERNEL_​GLOBAL_​WORK_​SIZE and device is not a custom device and kernel is not a built-in kernel.

  • CL_​INVALID_​KERNEL if kernel is a not a valid kernel object.

  • CL_​OUT_​OF_​RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_​OUT_​OF_​HOST_​MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

See Also

Document Notes

For more information, see the OpenCL Specification

This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.

Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.