Stream HPC

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

computer-says-noLittle 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)

    ***Code*** ***OpenCL Error Flag*** ***Function(s)*** ***Description***   0 CL\_SUCCESS  The sweet spot.   -1 CL\_DEVICE\_NOT\_FOUND clGetDeviceIDs if no OpenCL devices that matched device\_type were found.   -2 CL\_DEVICE\_NOT\_AVAILABLE clCreateContext if a device in devices is currently not available even though the device was returned by clGetDeviceIDs.   -3 CL\_COMPILER\_NOT \_AVAILABLE clBuildProgram if 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.   -4 CL\_MEM\_OBJECT \_ALLOCATION\_FAILURE  if there is a failure to allocate memory for buffer object.   -5 CL\_OUT\_OF\_RESOURCES  if there is a failure to allocate resources required by the OpenCL implementation on the device.   -6 CL\_OUT\_OF\_HOST\_MEMORY  if there is a failure to allocate resources required by the OpenCL implementation on the host.   -7 CL\_PROFILING\_INFO\_NOT \_AVAILABLE clGetEventProfilingInfo if 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.   -8 CL\_MEM\_COPY\_OVERLAP clEnqueueCopyBuffer, clEnqueueCopyBufferRect, clEnqueueCopyImage if 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.   -9 CL\_IMAGE\_FORMAT \_MISMATCH clEnqueueCopyImage if src\_image and dst\_image do not use the same image format.   -10 CL\_IMAGE\_FORMAT\_NOT \_SUPPORTED clCreateImage if the image\_format is not supported.   -11 CL\_BUILD\_PROGRAM \_FAILURE clBuildProgram if there is a failure to build the program executable. This error will be returned if clBuildProgram does not return until the build has completed.   -12 CL\_MAP\_FAILURE clEnqueueMapBuffer, 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.   -13 CL\_MISALIGNED\_SUB \_BUFFER\_OFFSET  if 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.   -14 CL\_EXEC\_STATUS\_ERROR\_ FOR\_EVENTS\_IN\_WAIT\_LIST  if the execution status of any of the events in event\_list is a negative integer value.   -15 CL\_COMPILE\_PROGRAM \_FAILURE clCompileProgram if there is a failure to compile the program source. This error will be returned if clCompileProgram does not return until the compile has completed.   -16 CL\_LINKER\_NOT\_AVAILABLE clLinkProgram if 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.   -17 CL\_LINK\_PROGRAM\_FAILURE clLinkProgram if there is a failure to link the compiled binaries and/or libraries.   -18 CL\_DEVICE\_PARTITION \_FAILED clCreateSubDevices  if the partition name is supported by the implementation but in\_device could not be further partitioned.   -19 CL\_KERNEL\_ARG\_INFO \_NOT\_AVAILABLE clGetKernelArgInfo if 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)

    ***Code*** ***OpenCL Error Flag*** ***Function(s)*** ***Description***   -30 CL\_INVALID\_VALUE clGetDeviceIDs, clCreateContext This depends on the function: two or more coupled parameters had errors.   -31 CL\_INVALID\_DEVICE\_TYPE clGetDeviceIDs if an invalid device\_type is given   -32 CL\_INVALID\_PLATFORM clGetDeviceIDs if an invalid platform was given   -33 CL\_INVALID\_DEVICE clCreateContext, clBuildProgram if devices contains an invalid device or are not associated with the specified platform.   -34 CL\_INVALID\_CONTEXT  if context is not a valid context.   -35 CL\_INVALID\_QUEUE\_PROPERTIES clCreateCommandQueue if specified command-queue-properties are valid but are not supported by the device.   -36 CL\_INVALID\_COMMAND\_QUEUE  if `command_queue` is not a valid command-queue.   -37 CL\_INVALID\_HOST\_PTR clCreateImage, clCreateBuffer This 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.   -38 CL\_INVALID\_MEM\_OBJECT  if memobj is not a valid OpenCL memory object.   -39 CL\_INVALID\_IMAGE\_FORMAT\_DESCRIPTOR  if the OpenGL/DirectX texture internal format does not map to a supported OpenCL image format.   -40 CL\_INVALID\_IMAGE\_SIZE  if 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.   -41 CL\_INVALID\_SAMPLER clGetSamplerInfo, clReleaseSampler, clRetainSampler, clSetKernelArg if sampler is not a valid sampler object.   -42 CL\_INVALID\_BINARY clCreateProgramWithBinary, 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. -43 CL_INVALID_BUILD_OPTIONS clBuildProgram if the build options specified by options are invalid. -44 CL_INVALID_PROGRAM if program is a not a valid program object. -45 CL_INVALID_PROGRAM_EXECUTABLE if there is no successfully built program executable available for device associated with command_queue. -46 CL_INVALID_KERNEL_NAME clCreateKernel if kernel_name is not found in program. -47 CL_INVALID_KERNEL_DEFINITION clCreateKernel if 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. -48 CL_INVALID_KERNEL if kernel is not a valid kernel object. -49 CL_INVALID_ARG_INDEX clSetKernelArg, clGetKernelArgInfo if arg_index is not a valid argument index. -50 CL_INVALID_ARG_VALUE clSetKernelArg, clGetKernelArgInfo if arg_value specified is not a valid value. -51 CL_INVALID_ARG_SIZE clSetKernelArg if 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). -52 CL_INVALID_KERNEL_ARGS if the kernel argument values have not been specified. -53 CL_INVALID_WORK_DIMENSION if work_dim is not a valid value (i.e. a value between 1 and 3). -54 CL_INVALID_WORK_GROUP_SIZE if 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. -55 CL_INVALID_WORK_ITEM_SIZE if 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]. -56 CL_INVALID_GLOBAL_OFFSET if 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. -57 CL_INVALID_EVENT_WAIT_LIST if 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. -58 CL_INVALID_EVENT if event objects specified in event_list are not valid event objects. -59 CL_INVALID_OPERATION if 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). -60 CL_INVALID_GL_OBJECT if 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. -61 CL_INVALID_BUFFER_SIZE clCreateBuffer, clCreateSubBuffer if 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. -62 CL_INVALID_MIP_LEVEL OpenGL-functions if miplevel is greater than zero and the OpenGL implementation does not support creating from non-zero mipmap levels. -63 CL_INVALID_GLOBAL_WORK_SIZE if 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. -64 CL_INVALID_PROPERTY clCreateContext Vague error, depends on the function -65 CL_INVALID_IMAGE_DESCRIPTOR clCreateImage if values specified in image_desc are not valid or if image_desc is NULL. -66 CL_INVALID_COMPILER_OPTIONS clCompileProgram if the compiler options specified by options are invalid. -67 CL_INVALID_LINKER_OPTIONS clLinkProgram if the linker options specified by options are invalid. -68 CL_INVALID_DEVICE_PARTITION_COUNT clCreateSubDevices if 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. -69 CL_INVALID_PIPE_SIZE clCreatePipe if 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. -70 CL_INVALID_DEVICE_QUEUE clSetKernelArg when 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

    ***Code*** ***OpenCL Error Flag*** ***Function(s)*** ***Description***   -1000 CL\_INVALID\_GL\_SHAREGROUP\_REFERENCE\_KHR clGetGLContextInfoKHR, clCreateContext CL and GL not on the same device (only when using a GPU).   -1001  CL\_PLATFORM\_NOT\_FOUND\_KHR clGetPlatform No valid ICDs found   -1002 CL\_INVALID\_D3D10\_DEVICE\_KHR clCreateContext, clCreateContextFromType if the Direct3D 10 device specified for interoperability is not compatible with the devices against which the context is to be created.   -1003 CL\_INVALID\_D3D10\_RESOURCE\_KHR clCreateFromD3D10BufferKHR, clCreateFromD3D10Texture2DKHR, clCreateFromD3D10Texture3DKHR If the resource is not a Direct3D 10 buffer or texture object   -1004 CL\_D3D10\_RESOURCE\_ALREADY\_ACQUIRED\_KHR clEnqueueAcquireD3D10ObjectsKHR If a mem\_object is already acquired by OpenCL   -1005 CL\_D3D10\_RESOURCE\_NOT\_ACQUIRED\_KHR clEnqueueReleaseD3D10ObjectsKHR If a mem\_object is not acquired by OpenCL   -1006 CL\_INVALID\_D3D11\_DEVICE\_KHR clCreateContext, clCreateContextFromType if the Direct3D 11 device specified for interoperability is not compatible with the devices against which the context is to be created.   -1007 CL\_INVALID\_D3D11\_RESOURCE\_KHR clCreateFromD3D11BufferKHR, clCreateFromD3D11Texture2DKHR, clCreateFromD3D11Texture3DKHR If the resource is not a Direct3D 11 buffer or texture object   -1008 CL\_D3D11\_RESOURCE\_ALREADY\_ACQUIRED\_KHR clEnqueueAcquireD3D11ObjectsKHR If a mem\_object is already acquired by OpenCL   -1009 CL\_D3D11\_RESOURCE\_NOT\_ACQUIRED\_KHR clEnqueueReleaseD3D11ObjectsKHR If a ‘mem\_object’ is not acquired by OpenCL   -1010 CL\_INVALID\_D3D9\_DEVICE\_NV CL\_INVALID\_DX9\_DEVICE\_INTEL clCreateContext, clCreateContextFromType If the Direct3D 9 device specified for interoperability is not compatible with the devices against which the context is to be created   -1011 CL\_INVALID\_D3D9\_RESOURCE\_NV CL\_INVALID\_DX9\_RESOURCE\_INTEL clCreateFromD3D9VertexBufferNV, clCreateFromD3D9IndexBufferNV, clCreateFromD3D9SurfaceNV, clCreateFromD3D9TextureNV, clCreateFromD3D9CubeTextureNV, clCreateFromD3D9VolumeTextureNV If a ‘mem\_object’ is not a Direct3D 9 resource of the required type   -1012 CL\_D3D9\_RESOURCE\_ALREADY\_ACQUIRED\_NV CL\_DX9\_RESOURCE\_ALREADY\_ACQUIRED\_INTEL clEnqueueAcquireD3D9ObjectsNV If any of the ‘mem\_objects’ is currently already acquired by OpenCL   -1013 CL\_D3D9\_RESOURCE\_NOT\_ACQUIRED\_NV CL\_DX9\_RESOURCE\_NOT\_ACQUIRED\_INTEL clEnqueueReleaseD3D9ObjectsNV If any of the ‘mem\_objects’ is currently not acquired by OpenCL   -1092 CL\_EGL\_RESOURCE\_NOT\_ACQUIRED\_KHR clEnqueueReleaseEGLObjectsKHR If a ‘mem\_object’ is not acquired by OpenCL   -1093 CL\_INVALID\_EGL\_OBJECT\_KHR clCreateFromEGLImageKHR, clEnqueueAcquireEGLObjectsKHR If a ‘mem\_object’ is not a EGL resource of the required type   -1094 CL\_INVALID\_ACCELERATOR\_INTEL clSetKernelArg when ‘arg\_value’ is not a valid accelerator object, and by clRetainAccelerator, clReleaseAccelerator, and clGetAcceleratorInfo when ‘accelerator’ is not a valid accelerator object   -1095 CL\_INVALID\_ACCELERATOR\_TYPE\_INTEL clSetKernelArg, clCreateAccelerator when ‘arg\_value’ is not an accelerator object of the correct type, or when ‘accelerator\_type’ is not a valid accelerator type   -1096 CL\_INVALID\_ACCELERATOR\_DESCRIPTOR\_INTEL clCreateAccelerator when values described by ‘descriptor’ are not valid, or if a combination of values is not valid   -1097 CL\_ACCELERATOR\_TYPE\_NOT\_SUPPORTED\_INTEL clCreateAccelerator when ‘accelerator\_type’ is a valid accelerator type, but it not supported by any device in ‘context’   -1098 CL\_INVALID\_VA\_API\_MEDIA\_ADAPTER\_INTEL clCreateContext, clCreateContextFromType If the VA API display specified for interoperability is not compatible with the devices against which the context is to be created   -1099 CL\_INVALID\_VA\_API\_MEDIA\_SURFACE\_INTEL clEnqueueReleaseVA\_APIMediaSurfacesINTEL If ‘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   -1100 CL\_VA\_API\_MEDIA\_SURFACE\_ALREADY\_ACQUIRED\_INTEL clEnqueueReleaseVA\_APIMediaSurfacesINTEL If any of the ‘mem\_objects’ is already acquired by OpenCL   -1101 CL\_VA\_API\_MEDIA\_SURFACE\_NOT\_ACQUIRED\_INTEL clEnqueueReleaseVA\_APIMediaSurfacesINTEL If any of the ‘mem\_objects’ are not currently acquired by OpenCL    

Errors thrown by Vendors

    ***Code*** ***Vendor*** ***Function(s)*** ***Description***   -9999 NVidia clEnqueueNDRangeKernel Illegal 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.