'\" t .\" Title: clCreateContext .\" Author: The Khronos Group .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 02/03/2019 .\" Manual: OpenCL Manual .\" Source: The Khronos Group .\" Language: English .\" .TH "CLCREATECONTEXT" "3clc" "02/03/2019" "The Khronos Group" "OpenCL Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" clCreateContext \- Creates an OpenCL context\&. .SH "" .HP \w'cl_context\ clCreateContext('u .BI "cl_context clCreateContext(const\ cl_context_properties\ *" "properties" ", cl_uint\ " "num_devices" ", const\ cl_device_id\ *" "devices" ", (void\ CL_CALLBACK\ *" "pfn_notify)" "\ (\ .sp\ .nf\ const\ char\ *errinfo,\ const\ void\ *private_info,\ size_t\ cb,\ void\ *user_data\ .fi\ ), void\ *" "user_data" ", cl_int\ *" "errcode_ret" ");" .SH "DESCRIPTION" .PP An OpenCL context is created with one or more devices\&. Contexts are used by the OpenCL runtime for managing objects such as command\-queues, memory, program and kernel objects and for executing kernels on one or more devices specified in the context\&. .SH "PARAMETERS" .PP properties .RS 4 Specifies a list of context property names and their corresponding values\&. Each property name is immediately followed by the corresponding desired value\&. The list is terminated with 0\&. \fIproperties\fR can be NULL in which case the platform that is selected is implementation\-defined\&. The list of supported \fIproperties\fR is described in the table below\&. .sp If the extension \fBcl_khr_dx9_media_sharing\fR(3clc) is enabled, then \fIproperties\fR specifies a list of context property names and their corresponding values\&. Each property is followed immediately by the corresponding desired value\&. The list is terminated with zero\&. If a property is not specified in \fIproperties\fR, then its default value (listed in the table below) is used (it is said to be specified implicitly)\&. If \fIproperties\fR is NULL or empty (points to a list whose first value is zero), all attributes take on their default values\&. .sp If the extension \fBcl_khr_d3d10_sharing\fR(3clc) is enabled, then \fIproperties\fR specifies a list of context property names and their corresponding values\&. Each property is followed immediately by the corresponding desired value\&. The list is terminated with zero\&. if a property is not specified in \fIproperties\fR, then its default value is used (it is said to be specified implicitly)\&. If \fIproperties\fR is NULL or empty (points to a list whose first value is zero), all attributes take on their default value\&. .sp If the extension \fBcl_khr_gl_sharing\fR(3clc) is enabled, then \fIproperties\fR points to an attribute list, which is a array of ordered pairs terminated with zero\&. If an attribute is not specified in \fIproperties\fR, then its default value is used (it is said to be specified implicitly)\&. If \fIproperties\fR is NULL or empty (points to a list whose first value is zero), all attributes take on their default values\&.\&. .TS allbox tab(:); lB lB lB. T{ cl_context_properties enum T}:T{ Property value T}:T{ Description T} .T& l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l. T{ \fBCL_CONTEXT_PLATFORM\fR T}:T{ cl_platform_id T}:T{ Specifies the platform to use\&. T} T{ \fBCL_CONTEXT_INTEROP_USER_SYNC\fR T}:T{ cl_bool T}:T{ Specifies whether the user is responsible for synchronization between OpenCL and other APIs\&. Please refer to the specific sections in the OpenCL 1\&.2 extension specification that describe sharing with other APIs for restrictions on using this flag\&. If \fBCL_CONTEXT_INTEROP_USER_\fR SYNC is not specified, a default of \fBCL_FALSE\fR is assumed\&. T} T{ \fBCL_CONTEXT_D3D10_DEVICE_KHR\fR T}:T{ ID3D10Device* T}:T{ If the \fBcl_khr_d3d10_sharing\fR(3clc) extension is enabled, specifies the \fBID3D10Device\fR* to use for Direct3D 10 interoperability\&. The default value is NULL\&. T} T{ \fBCL_GL_CONTEXT_KHR\fR T}:T{ 0, OpenGL context handle T}:T{ OpenGL context to associated the OpenCL context with (available if the \fBcl_khr_gl_sharing\fR(3clc) extension is enabled) T} T{ \fBCL_EGL_DISPLAY_KHR\fR T}:T{ \fBEGL_NO_DISPLAY\fR, \fBEGLDisplay\fR handle T}:T{ EGLDisplay an OpenGL context was created with respect to (available if the \fBcl_khr_gl_sharing\fR(3clc) extension is enabled) T} T{ \fBCL_GLX_DISPLAY_KHR\fR T}:T{ None, X handle T}:T{ X Display an OpenGL context was created with respect to (available if the \fBcl_khr_gl_sharing\fR(3clc) extension is enabled) T} T{ \fBCL_CGL_SHAREGROUP_KHR\fR T}:T{ 0, CGL share group handle T}:T{ CGL share group to associate the OpenCL context with (available if the \fBcl_khr_gl_sharing\fR(3clc) extension is enabled) T} T{ \fBCL_WGL_HDC_KHR\fR T}:T{ 0, HDC handle T}:T{ HDC an OpenGL context was created with respect to (available if the \fBcl_khr_gl_sharing\fR(3clc) extension is enabled) T} T{ \fBCL_CONTEXT_ADAPTER_D3D9_KHR\fR T}:T{ IDirect3DDevice9 * T}:T{ Specifies an \fBIDirect3DDevice9\fR to use for D3D9 interop (if the \fBcl_khr_dx9_media_sharing\fR(3clc) extension is supported)\&. T} T{ \fBCL_CONTEXT_ADAPTER_D3D9EX_KHR\fR T}:T{ IDirect3DDeviceEx* T}:T{ Specifies an \fBIDirect3DDevice9Ex\fR to use for D3D9 interop (if the \fBcl_khr_dx9_media_sharing\fR(3clc) extension is supported)\&. T} T{ \fBCL_CONTEXT_ADAPTER_DXVA_KHR\fR T}:T{ IDXVAHD_Device * T}:T{ Specifies an \fBIDXVAHD_Device\fR to use for DXVA interop (if the \fBcl_khr_dx9_media_sharing\fR(3clc) extension is supported)\&. T} T{ \fBCL_CONTEXT_D3D11_DEVICE_KHR\fR T}:T{ ID3D11Device * T}:T{ Specifies the \fBID3D11Device\fR * to use for Direct3D 11 interoperability\&. The default value is NULL\&. T} .TE .sp 1 .RE .PP \fInum_devices\fR .RS 4 The number of devices specified in the \fIdevices\fR argument\&. .RE .PP \fIdevices\fR .RS 4 A pointer to a list of unique devices returned by \fBclGetDeviceIDs\fR(3clc) or sub\-devices created by \fBclCreateSubDevices\fR(3clc) for a platform\&. .RE .PP \fIpfn_notify\fR .RS 4 A callback function that can be registered by the application\&. This callback function will be used by the OpenCL implementation to report information on errors during context creation as well as errors that occur at runtime in this context\&. This callback function may be called asynchronously by the OpenCL implementation\&. It is the application\*(Aqs responsibility to ensure that the callback function is thread\-safe\&. If \fIpfn_notify\fR is NULL, no callback function is registered\&. The parameters to this callback function are: .sp \fIerrinfo\fR is a pointer to an error string\&. .sp \fIprivate_info\fR and \fIcb\fR represent a pointer to binary data that is returned by the OpenCL implementation that can be used to log additional information helpful in debugging the error\&. .sp \fIuser_data\fR is a pointer to user supplied data\&. .sp NOTE: There are a number of cases where error notifications need to be delivered due to an error that occurs outside a context\&. Such notifications may not be delivered through the \fIpfn_notify\fR callback\&. Where these notifications go is implementation\-defined\&. .RE .PP \fIuser_data\fR .RS 4 Passed as the \fIuser_data\fR argument when \fIpfn_notify\fR is called\&. \fIuser_data\fR can be NULL\&. .RE .PP \fIerrcode_ret\fR .RS 4 Returns an appropriate error code\&. If \fIerrcode_ret\fR is NULL, no error code is returned\&. .RE .SH "NOTES" .PP \fBclCreateContext\fR and \fBclCreateContextFromType\fR(3clc) perform an implicit retain\&. This is very helpful for 3rd party libraries, which typically get a context passed to them by the application\&. However, it is possible that the application may delete the context without informing the library\&. Allowing functions to attach to (i\&.e\&. retain) and release a context solves the problem of a context being used by a library no longer being valid\&. .SH "ERRORS" .PP \fBclCreateContext\fR returns a valid non\-zero context and \fIerrcode_ret\fR is set to CL_SUCCESS if the context is created successfully\&. Otherwise, it returns NULL value with the following error values returned in \fIerrcode_ret\fR: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_PLATFORM if \fIproperties\fR is NULL and no platform could be selected or if platform value specified in \fIproperties\fR is not a valid platform\&. (If the extension \fBcl_khr_gl_sharing\fR(3clc) is enabled, then this error is replaced with \fBCL_INVALID_GL_SHAREGROUP_REFERENCE_KHR\fR; see below\&.) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_PROPERTY if context property name in \fIproperties\fR is not a supported property name, if the value specified for a supported property name is not valid, or if the same property name is specified more than once\&. However if the extension \fBcl_khr_gl_sharing\fR(3clc) is enabled, then \fBCL_INVALID_PROPERTY\fR is returned if an attribute name other than those listed in the table for \fIproperties\fR above or if \fBCL_CONTEXT_INTEROP_USER_SYNC\fR is specified in \fIproperties\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_PROPERTY if an attribute name other than those specified in table 4\&.5 or if \fBCL_CONTEXT_INTEROP_USER_SYNC\fR is specified in properties\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if \fIdevices\fR is NULL; if \fInum_devices\fR is equal to zero; or if \fIpfn_notify\fR is NULL but \fIuser_data\fR is not NULL\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_DEVICE if \fIdevices\fR contains an invalid device\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_OPERATION if Direct3D 10 interoperability is specified by setting \fBCL_INVALID_D3D10_DEVICE_KHR\fR to a non\-NULL value, and interoperability with another graphics API is also specified (if the \fBcl_khr_d3d10_sharing\fR(3clc) extension is enabled)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_DEVICE_NOT_AVAILABLE if a device in \fIdevices\fR is currently not available even though the device was returned by \fBclGetDeviceIDs\fR(3clc)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_D3D10_DEVICE_KHR if the Direct3D 10 device specified for interoperability is not compatible with the devices against which the context is to be created (if the \fBcl_khr_d3d10_sharing\fR(3clc) extension is enabled)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_D3D10_DEVICE_KHR if the value of the property \fBCL_CONTEXT_D3D10_DEVICE_KHR\fR is non\-NULL and does not specify a valid Direct3D 10 device with which the \fIcl_device_ids\fR against which this context is to be created may interoperate (if the \fBcl_khr_d3d10_sharing\fR(3clc) extension is enabled)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR when an invalid OpenGL context or share group object handle is specified in \fIproperties\fR (only if the \fBcl_khr_gl_sharing\fR(3clc) extension is enabled)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR if no OpenGL or OpenGL ES context or share group is specified in the attribute list given to \fBclCreateContext\fR(3clc) and any of the commands in section 9\&.7 are called\&. (if the \fBcl_khr_gl_sharing\fR(3clc) extension is enabled) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR if the \fBcl_khr_gl_sharing\fR(3clc) extension is enabled and if a context was specified by any of the following means: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A context specified for an EGL\-based OpenGL ES or OpenGL implementation by setting the attributes \fBCL_GL_CONTEXT_KHR\fR and \fBCL_EGL_DISPLAY_KHR\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A context was specified for a GLX\-based OpenGL implementation by setting the attributes \fBCL_GL_CONTEXT_KHR\fR and \fBCL_GLX_DISPLAY_KHR\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A context was specified for a WGL\-based OpenGL implementation by setting the attributes \fBCL_GL_CONTEXT_KHR\fR and \fBCL_WGL_HDC_KHR\fR\&. .RE .sp and any of the following conditions hold: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The specified display and context attributes do not identify a valid OpenGL or OpenGL ES context\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The specified context does not support buffer and renderbuffer objects\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The specified context is not compatible with the OpenCL context being created (for example, it exists in a physically distinct address space, such as another hardware device, or does not support sharing data with OpenCL due to implementation restrictions)\&. .RE .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR if a share group was specified for a CGL\-based OpenGL implementation by setting the attribute \fBCL_CGL_SHAREGROUP_KHR\fR, and the specified share group does not identify a valid CGL share group object (if the \fBcl_khr_gl_sharing\fR(3clc) extension is enabled)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_OPERATION if a context was specified as described above and any of the following conditions hold: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A context or share group object was specified for one of CGL, EGL, GLX, or WGL and the OpenGL implementation does not support that window\-system binding API\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} More than one of the attributes \fBCL_CGL_SHAREGROUP_KHR\fR, \fBCL_EGL_DISPLAY_KHR\fR, \fBCL_GLX_DISPLAY_KHR\fR, and \fBCL_WGL_HDC_KHR\fR is set to a non\-default value\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Both of the attributes \fBCL_CGL_SHAREGROUP_KHR\fR and \fBCL_GL_CONTEXT_KHR\fR are set to non\-default values\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Any of the devices specified in the devices argument cannot support OpenCL objects which share the data store of an OpenGL object, as described in section 9\&.7\&. .RE .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_DX9_MEDIA_ADAPTER_KHR if the media adapter specified for interoperability is not compatible with the devices against which the context is to be created (only if the \fBcl_khr_dx9_media_sharing\fR(3clc) extension is supported)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_ADAPTER_KHR if any of the values of the properties \fBCL_CONTEXT_ADAPTER_D3D9_KHR\fR, \fBCL_CONTEXT_ADAPTER_D3D9EX_KHR\fR or \fBCL_CONTEXT_ADAPTER_DXVA_KHR\fR is non\-NULL and does not specify a valid media adapter with which the cl_device_ids against which this context is to be created may interoperate (only if the \fBcl_khr_dx9_media_sharing\fR(3clc) extension is supported)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_OPERATION if interoperability is specified by setting \fBCL_CONTEXT_ADAPTER_D3D9_KHR\fR, \fBCL_CONTEXT_ADAPTER_D3D9EX_KHR\fR or \fBCL_CONTEXT_ADAPTER_DXVA_KHR\fR to a non\-NULL value, and interoperability with another graphics API is also specified (only if the \fBcl_khr_dx9_media_sharing\fR(3clc) extension is supported)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_OPERATION if Direct3D 11 interoperability is specified by setting \fBCL_INVALID_D3D11_DEVICE_KHR\fR to a non\-NULL value, and interoperability with another graphics API is also specified (only if the \fBcl_khr_d3d11_sharing\fR(3clc) extension is supported)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_D3D11_DEVICE_KHR if the value of the property \fBCL_CONTEXT_D3D11_DEVICE_KHR\fR is non\-NULL and does not specify a valid Direct3D 11 device with which the \fIcl_device_ids\fR against which this context is to be created may interoperate (only if the \fBcl_khr_d3d11_sharing\fR(3clc) extension is supported)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_D3D11_DEVICE_KHR if the Direct3D 11 device specified for interoperability is not compatible with the devices against which the context is to be created (only if the \fBcl_khr_d3d11_sharing\fR(3clc) extension is supported)\&. .RE .SH "SPECIFICATION" .PP \m[blue]\fBOpenCL Specification\fR\m[]\&\s-2\u[1]\d\s+2 .SH "SEE ALSO" .PP \fBclGetDeviceIDs\fR(3clc), \fBclCreateContextFromType\fR(3clc), \fBclRetainContext\fR(3clc), \fBclReleaseContext\fR(3clc), \fBclGetContextInfo\fR(3clc), \fBclassDiagram\fR(3clc) .SH "AUTHORS" .PP \fBThe Khronos Group\fR .SH "COPYRIGHT" .br Copyright \(co 2007-2011 The Khronos Group Inc. .br Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials. .sp .SH "NOTES" .IP " 1." 4 OpenCL Specification .RS 4 \%page 54, section 4.4 - Contexts .RE