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 clGetContextInfo
Context Info Return Type Description

CL_CONTEXT_REFERENCE_COUNT [1]

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 was not NULL, the implementation must return the values specified in the properties argument in the same order and without including additional properties.

If the properties argument specified in clCreateContext or clCreateContextFromType used to create context was NULL, the implementation must return param_value_size_ret equal to 0, indicating that there are no properties to be returned.

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 2014-2023 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0


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