OpenCL error codes (1.x and 2.x)

computer-says-no
Little Britain: “Compu’er says no”. (links to Youtube movie)

Knowing all errors by heart is good for quick programming, but not always the best option. Therefore I started to create a full list with extra info, taken from cl.h and the reference documentation.

The problem with many error-codes is that they are sometimes context-dependent and then become quite useless in helping the programmer out. Also some drivers return different error-codes. Notice also that different errors are given per OpenCL-version for the same function. If you find problems, help make OpenCL better and give feedback.

Want it on your wall? You can easily copy these two tables into Excel or alike software and print it out.

Run-time and JIT Compiler Errors (driver-dependent)

CodeOpenCL Error FlagFunction(s)Description
0CL_SUCCESSThe sweet spot.
-1CL_DEVICE_NOT_FOUNDclGetDeviceIDsif no OpenCL devices that matched device_type were found.
-2CL_DEVICE_NOT_AVAILABLEclCreateContextif a device in devices is currently not available even though the device was returned by clGetDeviceIDs.
-3CL_COMPILER_NOT _AVAILABLEclBuildProgramif program is created with clCreateProgramWithSource and a compiler is not available i.e. CL_DEVICE_COMPILER_AVAILABLE specified in the table of OpenCL Device Queries for clGetDeviceInfo is set to CL_FALSE.
-4CL_MEM_OBJECT _ALLOCATION_FAILUREif there is a failure to allocate memory for buffer object.
-5CL_OUT_OF_RESOURCESif there is a failure to allocate resources required by the OpenCL implementation on the device.
-6CL_OUT_OF_HOST_MEMORYif there is a failure to allocate resources required by the OpenCL implementation on the host.
-7CL_PROFILING_INFO_NOT _AVAILABLEclGetEventProfilingInfoif the CL_QUEUE_PROFILING_ENABLE flag is not set for the command-queue, if the execution status of the command identified by event is not CL_COMPLETE or if event is a user event object.
-8CL_MEM_COPY_OVERLAPclEnqueueCopyBuffer, clEnqueueCopyBufferRect, clEnqueueCopyImageif src_buffer and dst_buffer are the same buffer or subbuffer object and the source and destination regions overlap or if src_buffer and dst_buffer are different sub-buffers of the same associated buffer object and they overlap. The regions overlap if src_offset ≤ to dst_offset ≤ to src_offset + size – 1, or if dst_offset ≤ to src_offset ≤ to dst_offset + size – 1.
-9CL_IMAGE_FORMAT _MISMATCHclEnqueueCopyImageif src_image and dst_image do not use the same image format.
-10CL_IMAGE_FORMAT_NOT _SUPPORTEDclCreateImageif the image_format is not supported.
-11CL_BUILD_PROGRAM _FAILUREclBuildProgramif there is a failure to build the program executable. This error will be returned if clBuildProgram does not return until the build has completed.
-12CL_MAP_FAILUREclEnqueueMapBuffer, clEnqueueMapImage if there is a failure to map the requested region into the host address space. This error cannot occur for image objects created with CL_MEM_USE_HOST_PTR or CL_MEM_ALLOC_HOST_PTR.
-13CL_MISALIGNED_SUB _BUFFER_OFFSETif a sub-buffer object is specified as the value for an argument that is a buffer object and the offset specified when the sub-buffer object is created is not aligned to CL_DEVICE_MEM_BASE_ADDR_ALIGN value for device associated with queue.
-14CL_EXEC_STATUS_ERROR_ FOR_EVENTS_IN_WAIT_LISTif the execution status of any of the events in event_list is a negative integer value.
-15CL_COMPILE_PROGRAM _FAILUREclCompileProgramif there is a failure to compile the program source. This error will be returned if clCompileProgram does not return until the compile has completed.
-16CL_LINKER_NOT_AVAILABLEclLinkProgramif a linker is not available i.e. CL_DEVICE_LINKER_AVAILABLE specified in the table of allowed values for param_name for clGetDeviceInfo is set to CL_FALSE.
-17CL_LINK_PROGRAM_FAILUREclLinkProgramif there is a failure to link the compiled binaries and/or libraries.
-18CL_DEVICE_PARTITION _FAILEDclCreateSubDevices if the partition name is supported by the implementation but in_device could not be further partitioned.
-19CL_KERNEL_ARG_INFO _NOT_AVAILABLEclGetKernelArgInfoif the argument information is not available for kernel.

The last four (-16 till -19) are new in OpenCL 1.2.

Compile-time Errors (driver-independent)

CodeOpenCL Error FlagFunction(s)Description
-30CL_INVALID_VALUEclGetDeviceIDs, clCreateContextThis depends on the function: two or more coupled parameters had errors.
-31CL_INVALID_DEVICE_TYPEclGetDeviceIDsif an invalid device_type is given
-32CL_INVALID_PLATFORMclGetDeviceIDsif an invalid platform was given
-33CL_INVALID_DEVICEclCreateContext, clBuildProgramif devices contains an invalid device or are not associated with the specified platform.
-34CL_INVALID_CONTEXTif context is not a valid context.
-35CL_INVALID_QUEUE_PROPERTIESclCreateCommandQueueif specified command-queue-properties are valid but are not supported by the device.
-36CL_INVALID_COMMAND_QUEUEif command_queue is not a valid command-queue.
-37CL_INVALID_HOST_PTRclCreateImage, clCreateBufferThis flag is valid only if host_ptr is not NULL. If specified, it indicates that the application wants the OpenCL implementation to allocate memory for the memory object and copy the data from memory referenced by host_ptr.CL_MEM_COPY_HOST_PTR and CL_MEM_USE_HOST_PTR are mutually exclusive.CL_MEM_COPY_HOST_PTR can be used with CL_MEM_ALLOC_HOST_PTR to initialize the contents of the cl_mem object allocated using host-accessible (e.g. PCIe) memory.
-38CL_INVALID_MEM_OBJECTif memobj is not a valid OpenCL memory object.
-39CL_INVALID_IMAGE_FORMAT_DESCRIPTORif the OpenGL/DirectX texture internal format does not map to a supported OpenCL image format.
-40CL_INVALID_IMAGE_SIZEif an image object is specified as an argument value and the image dimensions (image width, height, specified or compute row and/or slice pitch) are not supported by device associated with queue.
-41CL_INVALID_SAMPLERclGetSamplerInfo, clReleaseSampler, clRetainSampler, clSetKernelArgif sampler is not a valid sampler object.
-42CL_INVALID_BINARYclCreateProgramWithBinary, clBuildProgram
The provided binary is unfit for the selected device.
if program is created with clCreateProgramWithBinary and devices listed in device_list do not have a valid program binary loaded.
-43CL_INVALID_BUILD_OPTIONSclBuildProgramif the build options specified by options are invalid.
-44CL_INVALID_PROGRAMif program is a not a valid program object.
-45CL_INVALID_PROGRAM_EXECUTABLEif there is no successfully built program executable available for device associated with command_queue.
-46CL_INVALID_KERNEL_NAMEclCreateKernelif kernel_name is not found in program.
-47CL_INVALID_KERNEL_DEFINITIONclCreateKernelif the function definition for __kernel function given by kernel_name such as the number of arguments, the argument types are not the same for all devices for which the program executable has been built.
-48CL_INVALID_KERNELif kernel is not a valid kernel object.
-49CL_INVALID_ARG_INDEXclSetKernelArg, clGetKernelArgInfoif arg_index is not a valid argument index.
-50CL_INVALID_ARG_VALUEclSetKernelArg, clGetKernelArgInfoif arg_value specified is not a valid value.
-51CL_INVALID_ARG_SIZEclSetKernelArgif arg_size does not match the size of the data type for an argument that is not a memory object or if the argument is a memory object and arg_size != sizeof(cl_mem) or if arg_size is zero and the argument is declared with the __local qualifier or if the argument is a sampler and arg_size != sizeof(cl_sampler).
-52CL_INVALID_KERNEL_ARGSif the kernel argument values have not been specified.
-53CL_INVALID_WORK_DIMENSIONif work_dim is not a valid value (i.e. a value between 1 and 3).
-54CL_INVALID_WORK_GROUP_SIZEif local_work_size is specified and number of work-items specified by global_work_size is not evenly divisable by size of work-group given by local_work_size or does not match the work-group size specified for kernel using the __attribute__ ((reqd_work_group_size(X, Y, Z))) qualifier in program source.if local_work_size is specified and the total number of work-items in the work-group computed as local_work_size[0] *… local_work_size[work_dim – 1] is greater than the value specified by CL_DEVICE_MAX_WORK_GROUP_SIZE in the table of OpenCL Device Queries for clGetDeviceInfo.if local_work_size is NULL and the __attribute__ ((reqd_work_group_size(X, Y, Z))) qualifier is used to declare the work-group size for kernel in the program source.
-55CL_INVALID_WORK_ITEM_SIZEif the number of work-items specified in any of local_work_size[0], … local_work_size[work_dim – 1] is greater than the corresponding values specified by CL_DEVICE_MAX_WORK_ITEM_SIZES[0], …. CL_DEVICE_MAX_WORK_ITEM_SIZES[work_dim – 1].
-56CL_INVALID_GLOBAL_OFFSETif the value specified in global_work_size + the corresponding values in global_work_offset for any dimensions is greater than the sizeof(size_t) for the device on which the kernel execution will be enqueued.
-57CL_INVALID_EVENT_WAIT_LISTif event_wait_list is NULL and num_events_in_wait_list > 0, or event_wait_list is not NULL and num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events.
-58CL_INVALID_EVENTif event objects specified in event_list are not valid event objects.
-59CL_INVALID_OPERATIONif interoperability is specified by setting CL_CONTEXT_ADAPTER_D3D9_KHR, CL_CONTEXT_ADAPTER_D3D9EX_KHR or CL_CONTEXT_ADAPTER_DXVA_KHR to a non-NULL value, and interoperability with another graphics API is also specified. (only if the cl_khr_dx9_media_sharing extension is supported).
-60CL_INVALID_GL_OBJECTif texture is not a GL texture object whose type matches texture_target, if the specified miplevel of texture is not defined, or if the width or height of the specified miplevel is zero.
-61CL_INVALID_BUFFER_SIZEclCreateBuffer, clCreateSubBufferif size is 0.Implementations may return CL_INVALID_BUFFER_SIZE if size is greater than the CL_DEVICE_MAX_MEM_ALLOC_SIZE value specified in the table of allowed values for param_name for clGetDeviceInfo for all devices in context.
-62CL_INVALID_MIP_LEVELOpenGL-functionsif miplevel is greater than zero and the OpenGL implementation does not support creating from non-zero mipmap levels.
-63CL_INVALID_GLOBAL_WORK_SIZEif global_work_size is NULL, or if any of the values specified in global_work_size[0], …global_work_size [work_dim – 1] are 0 or exceed the range given by the sizeof(size_t) for the device on which the kernel execution will be enqueued.
-64CL_INVALID_PROPERTYclCreateContextVague error, depends on the function
-65CL_INVALID_IMAGE_DESCRIPTORclCreateImageif values specified in image_desc are not valid or if image_desc is NULL.
-66CL_INVALID_COMPILER_OPTIONSclCompileProgramif the compiler options specified by options are invalid.
-67CL_INVALID_LINKER_OPTIONSclLinkProgramif the linker options specified by options are invalid.
-68CL_INVALID_DEVICE_PARTITION_COUNTclCreateSubDevicesif the partition name specified in properties is CL_DEVICE_PARTITION_BY_COUNTS and the number of sub-devices requested exceeds CL_DEVICE_PARTITION_MAX_SUB_DEVICES or the total number of compute units requested exceeds CL_DEVICE_PARTITION_MAX_COMPUTE_UNITS for in_device, or the number of compute units requested for one or more sub-devices is less than zero or the number of sub-devices requested exceeds CL_DEVICE_PARTITION_MAX_COMPUTE_UNITS for in_device.
-69CL_INVALID_PIPE_SIZEclCreatePipeif pipe_packet_size is 0 or the pipe_packet_size exceeds CL_DEVICE_PIPE_MAX_PACKET_SIZE value for all devices in context or if pipe_max_packets is 0.
-70CL_INVALID_DEVICE_QUEUEclSetKernelArgwhen an argument is of type queue_t when it’s not a valid device queue object.

Errors -65 till -68 are new in OpenCL 1.2. Errors -69 en -70 are introduced in 2.0.

Errors thrown by extensions

CodeOpenCL Error FlagFunction(s)Description
-1000CL_INVALID_GL_SHAREGROUP_REFERENCE_KHRclGetGLContextInfoKHR, clCreateContextCL and GL not on the same device (only when using a GPU).
-1001 CL_PLATFORM_NOT_FOUND_KHRclGetPlatformNo valid ICDs found
-1002CL_INVALID_D3D10_DEVICE_KHRclCreateContext, clCreateContextFromTypeif the Direct3D 10 device specified for interoperability is not compatible with the devices against which the context is to be created.
-1003CL_INVALID_D3D10_RESOURCE_KHRclCreateFromD3D10BufferKHR, clCreateFromD3D10Texture2DKHR, clCreateFromD3D10Texture3DKHRIf the resource is not a Direct3D 10 buffer or texture object
-1004CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHRclEnqueueAcquireD3D10ObjectsKHRIf a mem_object is already acquired by OpenCL
-1005CL_D3D10_RESOURCE_NOT_ACQUIRED_KHRclEnqueueReleaseD3D10ObjectsKHRIf a mem_object is not acquired by OpenCL
-1006CL_INVALID_D3D11_DEVICE_KHRclCreateContext, clCreateContextFromTypeif the Direct3D 11 device specified for interoperability is not compatible with the devices against which the context is to be created.
-1007CL_INVALID_D3D11_RESOURCE_KHRclCreateFromD3D11BufferKHR, clCreateFromD3D11Texture2DKHR, clCreateFromD3D11Texture3DKHRIf the resource is not a Direct3D 11 buffer or texture object
-1008CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHRclEnqueueAcquireD3D11ObjectsKHRIf a mem_object is already acquired by OpenCL
-1009CL_D3D11_RESOURCE_NOT_ACQUIRED_KHRclEnqueueReleaseD3D11ObjectsKHRIf a ‘mem_object’ is not acquired by OpenCL
-1010CL_INVALID_D3D9_DEVICE_NV CL_INVALID_DX9_DEVICE_INTELclCreateContext, clCreateContextFromTypeIf the Direct3D 9 device specified for interoperability is not compatible with the devices against which the context is to be created
-1011CL_INVALID_D3D9_RESOURCE_NV CL_INVALID_DX9_RESOURCE_INTELclCreateFromD3D9VertexBufferNV, clCreateFromD3D9IndexBufferNV, clCreateFromD3D9SurfaceNV, clCreateFromD3D9TextureNV, clCreateFromD3D9CubeTextureNV, clCreateFromD3D9VolumeTextureNVIf a ‘mem_object’ is not a Direct3D 9 resource of the required type
-1012CL_D3D9_RESOURCE_ALREADY_ACQUIRED_NV CL_DX9_RESOURCE_ALREADY_ACQUIRED_INTELclEnqueueAcquireD3D9ObjectsNVIf any of the ‘mem_objects’ is currently already acquired by OpenCL
-1013CL_D3D9_RESOURCE_NOT_ACQUIRED_NV CL_DX9_RESOURCE_NOT_ACQUIRED_INTELclEnqueueReleaseD3D9ObjectsNVIf any of the ‘mem_objects’ is currently not acquired by OpenCL
-1092CL_EGL_RESOURCE_NOT_ACQUIRED_KHRclEnqueueReleaseEGLObjectsKHRIf a ‘mem_object’ is not acquired by OpenCL
-1093CL_INVALID_EGL_OBJECT_KHRclCreateFromEGLImageKHR, clEnqueueAcquireEGLObjectsKHRIf a ‘mem_object’ is not a EGL resource of the required type
-1094CL_INVALID_ACCELERATOR_INTELclSetKernelArgwhen ‘arg_value’ is not a valid accelerator object, and by clRetainAccelerator, clReleaseAccelerator, and clGetAcceleratorInfo when ‘accelerator’ is not a valid accelerator object
-1095CL_INVALID_ACCELERATOR_TYPE_INTELclSetKernelArg, clCreateAcceleratorwhen ‘arg_value’ is not an accelerator object of the correct type, or when ‘accelerator_type’ is not a valid accelerator type
-1096CL_INVALID_ACCELERATOR_DESCRIPTOR_INTELclCreateAcceleratorwhen values described by ‘descriptor’ are not valid, or if a combination of values is not valid
-1097CL_ACCELERATOR_TYPE_NOT_SUPPORTED_INTELclCreateAcceleratorwhen ‘accelerator_type’ is a valid accelerator type, but it not supported by any device in ‘context’
-1098CL_INVALID_VA_API_MEDIA_ADAPTER_INTELclCreateContext, clCreateContextFromTypeIf the VA API display specified for interoperability is not compatible with the devices against which the context is to be created
-1099CL_INVALID_VA_API_MEDIA_SURFACE_INTELclEnqueueReleaseVA_APIMediaSurfacesINTELIf ‘surface’ is not a VA API surface of the required type, by clGetMemObjectInfo when ‘param_name’ is CL_MEM_VA_API_MEDIA_SURFACE_INTEL when was not created from a VA API surface, and from clGetImageInfo when ‘param_name’ is CL_IMAGE_VA_API_PLANE_INTEL and ‘image’ was not created from a VA API surface
-1100CL_VA_API_MEDIA_SURFACE_ALREADY_ACQUIRED_INTELclEnqueueReleaseVA_APIMediaSurfacesINTELIf any of the ‘mem_objects’ is already acquired by OpenCL
-1101CL_VA_API_MEDIA_SURFACE_NOT_ACQUIRED_INTELclEnqueueReleaseVA_APIMediaSurfacesINTELIf any of the ‘mem_objects’ are not currently acquired by OpenCL

 

Errors thrown by Vendors

CodeVendorFunction(s)Description
-9999NVidiaclEnqueueNDRangeKernelIllegal read or write to a buffer

 


Hope you find this useful. Let me know how I could improve this list!

Have this in code-form? Supply a link in comments.

 

Related Posts

windows-start-opencl

How to install OpenCL on Windows

...  your Windows machine ready for OpenCL is rather straightforward. In short, you only need the latest drivers for your OpenCL device(s) ...

Selectie_235

NVIDIA ended their industry-leading support for OpenCL in 2012

...  for the samples in one zip-file, scroll down. The removed OpenCL-PDFs are also available for download.This sentence ...

<!--:en-->library_60022<!--:-->

Install OpenCL on Debian, Ubuntu and Mint orderly

...  you read different types of manuals how to compile OpenCL software on Linux, then you can get dizzy of all the LD-parameters. ...

IWOCL-logo

IWOCL 2017 – all the talks

...  the PDF. Heterogeneous Computing Using Modern C++ with OpenCL Devices - Rod Burns and Ruyman Reyes (Codeplay) This hands-on ...

  • maxim

    better then if (err!=CL_SUCCESS) XD

  • ET3D

    Thanks for updating the page with 2.0 errors.

  • ET3D

    From cl_d3d11.h:

    #define CL_INVALID_D3D11_DEVICE_KHR -1006
    #define CL_INVALID_D3D11_RESOURCE_KHR -1007
    #define CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR -1008
    #define CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR -1009

    • StreamHPC

      Thanks! Forgot those and just saw your comment. I have updated it.

  • Tom Mason

    clEnqueueReadBuffer can return CL_INVALID_VALUE :
    CL_INVALID_VALUE if the region being read specified by (offset, cb) is out of bounds or if ptr is a NULL value.
    https://www.khronos.org/registry/OpenCL/sdk/1.0/docs/man/xhtml/clEnqueueReadBuffer.html

    This has caused me pain :p

    • StreamHPC

      On those moments, tell yourself that errors are better than segfaults.