Skip to content

CLGetInfoInteger

CLGetInfoInteger

Returns the value of an integer property for an OpenCL object or device.

long  CLGetInfoInteger(
   int  handle,                           // The handle of the OpenCL object or the number of the OpenCL device
   ENUM_OPENCL_PROPERTY_INTEGER  prop     // Requested property
   );

Parameters

handle

[in] A handle to the OpenCL object or number of the OpenCL device. Numbering of OpenCL devices starts with zero.

prop

[in] The type of a requested property from the ENUM_OPENCL_PROPERTY_INTEGER enumeration, the value of which you want to obtain.

Return Value

The value of the property if successful or -1 in case of an error. For information about the error, use the GetLastError() function.

ENUM_OPENCL_PROPERTY_INTEGER

IdentifierDescriptionType
CL_DEVICE_COUNTThe number of devices with OpenCL support. This property does not require specification of the first parameter, i.e. you can pass a zero value for the handle parameter.int
CL_DEVICE_TYPEType of deviceENUM_CL_DEVICE_TYPE
CL_DEVICE_VENDOR_IDUnique vendor identifieruint
CL_DEVICE_MAX_COMPUTE_UNITSNumber of parallel calculated tasks in OpenCL device. One working group solves one computational task. The lowest value is 1uint
CL_DEVICE_MAX_CLOCK_FREQUENCYHighest set frequency of the device in MHz.uint
CL_DEVICE_GLOBAL_MEM_SIZESize of the global memory of the device in bytesulong
CL_DEVICE_LOCAL_MEM_SIZESize of the processed data (scene) local memory in bytesuint
CL_BUFFER_SIZEActual size of the OpenCL buffer in bytesulong
CL_DEVICE_MAX_WORK_GROUP_SIZEThe total number of the local working groups available for an OpenCL device.ulong
CL_KERNEL_WORK_GROUP_SIZEThe total number of the local working groups available for an OpenCL program.ulong
CL_KERNEL_LOCAL_MEM_SIZESize of the local memory (in bytes) used by an OpenCL program for solving all parallel tasks in a group. Use CL_DEVICE_LOCAL_MEM_SIZE to receive the maximum available valueulong
CL_KERNEL_PRIVATE_MEM_SIZEThe minimum size of the private memory (in bytes) used by each task in the OpenCL program kernel.ulong
CL_LAST_ERRORThe value of the last OpenCL errorint

The ENUM_CL_DEVICE_TYPE enumeration contains possible types of devices supporting OpenCL. You can receive the type of device by its number or the handle of the OpenCL object by calling CLGetInfoInteger(handle_or_deviceN, CL_DEVICE_TYPE).

ENUM_CL_DEVICE_TYPE

IdentifierDescription
CL_DEVICE_ACCELERATORDedicated OpenCL accelerators (for example, the IBM CELL Blade). These devices communicate with the host processor using a peripheral interconnect such as PCIe.
CL_DEVICE_CPUAn OpenCL device that is the host processor. The host processor runs the OpenCL implementations and is a single or multi-core CPU.
CL_DEVICE_GPUAn OpenCL device that is a GPU.
CL_DEVICE_DEFAULTThe default OpenCL device in the system. The default device cannot be a CL_DEVICE_TYPE_CUSTOM device.
CL_DEVICE_CUSTOMDedicated accelerators that do not support programs written in OpenCL C.

Example:

void OnStart()
  {
   int cl_ctx;
//--- initialize OpenCL context
   if((cl_ctx=CLContextCreate(CL_USE_GPU_ONLY))==INVALID_HANDLE)
     {
      Print("OpenCL not found");
      return;
     }
//--- Display general information about OpenCL device
   Print("OpenCL type: ",EnumToString((ENUM_CL_DEVICE_TYPE)CLGetInfoInteger(cl_ctx,CL_DEVICE_TYPE)));
   Print("OpenCL vendor ID: ",CLGetInfoInteger(cl_ctx,CL_DEVICE_VENDOR_ID));
   Print("OpenCL units: ",CLGetInfoInteger(cl_ctx,CL_DEVICE_MAX_COMPUTE_UNITS));
   Print("OpenCL freq: ",CLGetInfoInteger(cl_ctx,CL_DEVICE_MAX_CLOCK_FREQUENCY)," MHz");
   Print("OpenCL global mem: ",CLGetInfoInteger(cl_ctx,CL_DEVICE_GLOBAL_MEM_SIZE)," bytes");
   Print("OpenCL local mem: ",CLGetInfoInteger(cl_ctx,CL_DEVICE_LOCAL_MEM_SIZE)," bytes");
//--- free OpenCL context
   CLContextFree(cl_ctx);
  }
Last updated on