C Specification

To query information about a context, call the function:

cl_int clGetContextInfo(
    cl_context context,
    cl_context_info param_name,
    size_t param_value_size,
    void* param_value,
    size_t* param_value_size_ret);

Parameters

  • context specifies the OpenCL context being queried.

  • param_name is an enumeration constant that specifies the information to query.

  • 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 specifies the size in bytes of memory pointed to by param_value. This size must be greater than or equal to the size of return type as described in the Context Attributes 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

The list of supported param_name values and the information returned in param_value by clGetContextInfo is described in the Context Attributes table.

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

CL_​CONTEXT_​REFERENCE_​COUNT11

cl_uint

Return the context reference count.

CL_​CONTEXT_​NUM_​DEVICES

Missing before version 1.1.

cl_uint

Return the number of devices in context.

CL_​CONTEXT_​DEVICES

cl_device_id[]

Return the list of devices and sub-devices in context.

CL_​CONTEXT_​PROPERTIES

cl_context_properties[]

Return the properties argument specified in clCreateContext or clCreateContextFromType.

If the properties argument specified in clCreateContext or clCreateContextFromType used to create context is not NULL, the implementation must return the values specified in the properties argument.

If the properties argument specified in clCreateContext or clCreateContextFromType used to create context is NULL, the implementation may return either a param_value_size_ret of 0 i.e. there is no context property value to be returned or can return a context property value of 0 (where 0 is used to terminate the context properties list) in the memory that param_value points to.

11

The reference count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks.

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

  • CL_​INVALID_​CONTEXT if context is not a valid context.

  • CL_​INVALID_​VALUE if param_name is not one of the supported values or if size in bytes specified by param_value_size is < size of return type as specified in the Context Attributes table and param_value is not a NULL value.

  • 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.