Line data Source code
1 : // Copyright (c) 2009-2011 Organic Vectory B.V.
2 : // Written by George van Venrooij
3 : //
4 : // Distributed under the Boost Software License, Version 1.0.
5 : // (See accompanying file license.txt)
6 :
7 :
8 : #include "clew.h"
9 :
10 : //! \file clew.c
11 : //! \brief OpenCL run-time loader source
12 :
13 : #ifndef CLCC_GENERATE_DOCUMENTATION
14 : #ifdef _WIN32
15 : #define WIN32_LEAN_AND_MEAN
16 : #define VC_EXTRALEAN
17 : #include <windows.h>
18 :
19 : typedef HMODULE CLCC_DYNLIB_HANDLE;
20 :
21 : #define CLCC_DYNLIB_OPEN LoadLibrary
22 : #define CLCC_DYNLIB_CLOSE FreeLibrary
23 : #define CLCC_DYNLIB_IMPORT GetProcAddress
24 : #else
25 : #include <dlfcn.h>
26 :
27 : typedef void* CLCC_DYNLIB_HANDLE;
28 :
29 : #define CLCC_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
30 : #define CLCC_DYNLIB_CLOSE dlclose
31 : #define CLCC_DYNLIB_IMPORT dlsym
32 : #endif
33 : #else
34 : //typedef implementation_defined CLCC_DYNLIB_HANDLE;
35 : //#define CLCC_DYNLIB_OPEN(path) implementation_defined
36 : //#define CLCC_DYNLIB_CLOSE implementation_defined
37 : //#define CLCC_DYNLIB_IMPORT implementation_defined
38 : #endif
39 :
40 : #include <stdlib.h>
41 :
42 : //! \brief module handle
43 : static CLCC_DYNLIB_HANDLE module = NULL;
44 :
45 : // Variables holding function entry points
46 : #ifndef CLCC_GENERATE_DOCUMENTATION
47 : PFNCLGETPLATFORMIDS __clewGetPlatformIDs = NULL;
48 : PFNCLGETPLATFORMINFO __clewGetPlatformInfo = NULL;
49 : PFNCLGETDEVICEIDS __clewGetDeviceIDs = NULL;
50 : PFNCLGETDEVICEINFO __clewGetDeviceInfo = NULL;
51 : PFNCLCREATECONTEXT __clewCreateContext = NULL;
52 : PFNCLCREATECONTEXTFROMTYPE __clewCreateContextFromType = NULL;
53 : PFNCLRETAINCONTEXT __clewRetainContext = NULL;
54 : PFNCLRELEASECONTEXT __clewReleaseContext = NULL;
55 : PFNCLGETCONTEXTINFO __clewGetContextInfo = NULL;
56 : PFNCLCREATECOMMANDQUEUE __clewCreateCommandQueue = NULL;
57 : PFNCLRETAINCOMMANDQUEUE __clewRetainCommandQueue = NULL;
58 : PFNCLRELEASECOMMANDQUEUE __clewReleaseCommandQueue = NULL;
59 : PFNCLGETCOMMANDQUEUEINFO __clewGetCommandQueueInfo = NULL;
60 : PFNCLSETCOMMANDQUEUEPROPERTY __clewSetCommandQueueProperty = NULL;
61 : PFNCLCREATEBUFFER __clewCreateBuffer = NULL;
62 : PFNCLCREATEIMAGE2D __clewCreateImage2D = NULL;
63 : PFNCLCREATEIMAGE3D __clewCreateImage3D = NULL;
64 : PFNCLRETAINMEMOBJECT __clewRetainMemObject = NULL;
65 : PFNCLRELEASEMEMOBJECT __clewReleaseMemObject = NULL;
66 : PFNCLGETSUPPORTEDIMAGEFORMATS __clewGetSupportedImageFormats = NULL;
67 : PFNCLGETMEMOBJECTINFO __clewGetMemObjectInfo = NULL;
68 : PFNCLGETIMAGEINFO __clewGetImageInfo = NULL;
69 : PFNCLCREATESAMPLER __clewCreateSampler = NULL;
70 : PFNCLRETAINSAMPLER __clewRetainSampler = NULL;
71 : PFNCLRELEASESAMPLER __clewReleaseSampler = NULL;
72 : PFNCLGETSAMPLERINFO __clewGetSamplerInfo = NULL;
73 : PFNCLCREATEPROGRAMWITHSOURCE __clewCreateProgramWithSource = NULL;
74 : PFNCLCREATEPROGRAMWITHBINARY __clewCreateProgramWithBinary = NULL;
75 : PFNCLRETAINPROGRAM __clewRetainProgram = NULL;
76 : PFNCLRELEASEPROGRAM __clewReleaseProgram = NULL;
77 : PFNCLBUILDPROGRAM __clewBuildProgram = NULL;
78 : PFNCLUNLOADCOMPILER __clewUnloadCompiler = NULL;
79 : PFNCLGETPROGRAMINFO __clewGetProgramInfo = NULL;
80 : PFNCLGETPROGRAMBUILDINFO __clewGetProgramBuildInfo = NULL;
81 : PFNCLCREATEKERNEL __clewCreateKernel = NULL;
82 : PFNCLCREATEKERNELSINPROGRAM __clewCreateKernelsInProgram = NULL;
83 : PFNCLRETAINKERNEL __clewRetainKernel = NULL;
84 : PFNCLRELEASEKERNEL __clewReleaseKernel = NULL;
85 : PFNCLSETKERNELARG __clewSetKernelArg = NULL;
86 : PFNCLGETKERNELINFO __clewGetKernelInfo = NULL;
87 : PFNCLGETKERNELWORKGROUPINFO __clewGetKernelWorkGroupInfo = NULL;
88 : PFNCLWAITFOREVENTS __clewWaitForEvents = NULL;
89 : PFNCLGETEVENTINFO __clewGetEventInfo = NULL;
90 : PFNCLRETAINEVENT __clewRetainEvent = NULL;
91 : PFNCLRELEASEEVENT __clewReleaseEvent = NULL;
92 : PFNCLGETEVENTPROFILINGINFO __clewGetEventProfilingInfo = NULL;
93 : PFNCLFLUSH __clewFlush = NULL;
94 : PFNCLFINISH __clewFinish = NULL;
95 : PFNCLENQUEUEREADBUFFER __clewEnqueueReadBuffer = NULL;
96 : PFNCLENQUEUEWRITEBUFFER __clewEnqueueWriteBuffer = NULL;
97 : PFNCLENQUEUECOPYBUFFER __clewEnqueueCopyBuffer = NULL;
98 : PFNCLENQUEUEREADIMAGE __clewEnqueueReadImage = NULL;
99 : PFNCLENQUEUEWRITEIMAGE __clewEnqueueWriteImage = NULL;
100 : PFNCLENQUEUECOPYIMAGE __clewEnqueueCopyImage = NULL;
101 : PFNCLENQUEUECOPYIMAGETOBUFFER __clewEnqueueCopyImageToBuffer = NULL;
102 : PFNCLENQUEUECOPYBUFFERTOIMAGE __clewEnqueueCopyBufferToImage = NULL;
103 : PFNCLENQUEUEMAPBUFFER __clewEnqueueMapBuffer = NULL;
104 : PFNCLENQUEUEMAPIMAGE __clewEnqueueMapImage = NULL;
105 : PFNCLENQUEUEUNMAPMEMOBJECT __clewEnqueueUnmapMemObject = NULL;
106 : PFNCLENQUEUENDRANGEKERNEL __clewEnqueueNDRangeKernel = NULL;
107 : PFNCLENQUEUETASK __clewEnqueueTask = NULL;
108 : PFNCLENQUEUENATIVEKERNEL __clewEnqueueNativeKernel = NULL;
109 : PFNCLENQUEUEMARKER __clewEnqueueMarker = NULL;
110 : PFNCLENQUEUEWAITFOREVENTS __clewEnqueueWaitForEvents = NULL;
111 : PFNCLENQUEUEBARRIER __clewEnqueueBarrier = NULL;
112 : PFNCLGETEXTENSIONFUNCTIONADDRESS __clewGetExtensionFunctionAddress = NULL;
113 : #endif // CLCC_GENERATE_DOCUMENTATION
114 :
115 :
116 : //! \brief Unloads OpenCL dynamic library, should not be called directly
117 0 : static void clewExit(void)
118 : {
119 0 : if (module != NULL)
120 : {
121 : // Ignore errors
122 0 : CLCC_DYNLIB_CLOSE(module);
123 0 : module = NULL;
124 : }
125 0 : }
126 :
127 : #define CLEW_CHECK_FUNCTION(f) \
128 : if ((f) == NULL) \
129 : { \
130 : CLCC_DYNLIB_CLOSE(module); \
131 : module = NULL; \
132 : return CLEW_ERROR_IMPORT_FAILED; \
133 : } \
134 :
135 : //! \param path path to dynamic library to load
136 : //! \return CLEW_ERROR_OPEN_FAILED if the library could not be opened
137 : //! CLEW_ERROR_ATEXIT_FAILED if atexit(clewExit) failed
138 : //! CLEW_SUCCESS when the library was successfully loaded
139 0 : int clewInit(const char* path)
140 : {
141 0 : int error = 0;
142 :
143 : // Check if already initialized
144 0 : if (module != NULL)
145 : {
146 0 : return CLEW_SUCCESS;
147 : }
148 :
149 : // Load library
150 0 : module = CLCC_DYNLIB_OPEN(path);
151 :
152 : // Check for errors
153 0 : if (module == NULL)
154 : {
155 0 : return CLEW_ERROR_OPEN_FAILED;
156 : }
157 :
158 : // Set unloading
159 0 : error = atexit(clewExit);
160 :
161 0 : if (error)
162 : {
163 : // Failure queing atexit, shutdown with error
164 0 : CLCC_DYNLIB_CLOSE(module);
165 0 : module = NULL;
166 :
167 0 : return CLEW_ERROR_ATEXIT_FAILED;
168 : }
169 :
170 : // Determine function entry-points
171 0 : CLEW_CHECK_FUNCTION(__clewGetPlatformIDs = (PFNCLGETPLATFORMIDS )CLCC_DYNLIB_IMPORT(module, "clGetPlatformIDs"));
172 0 : CLEW_CHECK_FUNCTION(__clewGetPlatformInfo = (PFNCLGETPLATFORMINFO )CLCC_DYNLIB_IMPORT(module, "clGetPlatformInfo"));
173 0 : CLEW_CHECK_FUNCTION(__clewGetDeviceIDs = (PFNCLGETDEVICEIDS )CLCC_DYNLIB_IMPORT(module, "clGetDeviceIDs"));
174 0 : CLEW_CHECK_FUNCTION(__clewGetDeviceInfo = (PFNCLGETDEVICEINFO )CLCC_DYNLIB_IMPORT(module, "clGetDeviceInfo"));
175 0 : CLEW_CHECK_FUNCTION(__clewCreateContext = (PFNCLCREATECONTEXT )CLCC_DYNLIB_IMPORT(module, "clCreateContext"));
176 0 : CLEW_CHECK_FUNCTION(__clewCreateContextFromType = (PFNCLCREATECONTEXTFROMTYPE )CLCC_DYNLIB_IMPORT(module, "clCreateContextFromType"));
177 0 : CLEW_CHECK_FUNCTION(__clewRetainContext = (PFNCLRETAINCONTEXT )CLCC_DYNLIB_IMPORT(module, "clRetainContext"));
178 0 : CLEW_CHECK_FUNCTION(__clewReleaseContext = (PFNCLRELEASECONTEXT )CLCC_DYNLIB_IMPORT(module, "clReleaseContext"));
179 0 : CLEW_CHECK_FUNCTION(__clewGetContextInfo = (PFNCLGETCONTEXTINFO )CLCC_DYNLIB_IMPORT(module, "clGetContextInfo"));
180 0 : CLEW_CHECK_FUNCTION(__clewCreateCommandQueue = (PFNCLCREATECOMMANDQUEUE )CLCC_DYNLIB_IMPORT(module, "clCreateCommandQueue"));
181 0 : CLEW_CHECK_FUNCTION(__clewRetainCommandQueue = (PFNCLRETAINCOMMANDQUEUE )CLCC_DYNLIB_IMPORT(module, "clRetainCommandQueue"));
182 0 : CLEW_CHECK_FUNCTION(__clewReleaseCommandQueue = (PFNCLRELEASECOMMANDQUEUE )CLCC_DYNLIB_IMPORT(module, "clReleaseCommandQueue"));
183 0 : CLEW_CHECK_FUNCTION(__clewGetCommandQueueInfo = (PFNCLGETCOMMANDQUEUEINFO )CLCC_DYNLIB_IMPORT(module, "clGetCommandQueueInfo"));
184 0 : CLEW_CHECK_FUNCTION(__clewSetCommandQueueProperty = (PFNCLSETCOMMANDQUEUEPROPERTY )CLCC_DYNLIB_IMPORT(module, "clSetCommandQueueProperty"));
185 0 : CLEW_CHECK_FUNCTION(__clewCreateBuffer = (PFNCLCREATEBUFFER )CLCC_DYNLIB_IMPORT(module, "clCreateBuffer"));
186 0 : CLEW_CHECK_FUNCTION(__clewCreateImage2D = (PFNCLCREATEIMAGE2D )CLCC_DYNLIB_IMPORT(module, "clCreateImage2D"));
187 0 : CLEW_CHECK_FUNCTION(__clewCreateImage3D = (PFNCLCREATEIMAGE3D )CLCC_DYNLIB_IMPORT(module, "clCreateImage3D"));
188 0 : CLEW_CHECK_FUNCTION(__clewRetainMemObject = (PFNCLRETAINMEMOBJECT )CLCC_DYNLIB_IMPORT(module, "clRetainMemObject"));
189 0 : CLEW_CHECK_FUNCTION(__clewReleaseMemObject = (PFNCLRELEASEMEMOBJECT )CLCC_DYNLIB_IMPORT(module, "clReleaseMemObject"));
190 0 : CLEW_CHECK_FUNCTION(__clewGetSupportedImageFormats = (PFNCLGETSUPPORTEDIMAGEFORMATS )CLCC_DYNLIB_IMPORT(module, "clGetSupportedImageFormats"));
191 0 : CLEW_CHECK_FUNCTION(__clewGetMemObjectInfo = (PFNCLGETMEMOBJECTINFO )CLCC_DYNLIB_IMPORT(module, "clGetMemObjectInfo"));
192 0 : CLEW_CHECK_FUNCTION(__clewGetImageInfo = (PFNCLGETIMAGEINFO )CLCC_DYNLIB_IMPORT(module, "clGetImageInfo"));
193 0 : CLEW_CHECK_FUNCTION(__clewCreateSampler = (PFNCLCREATESAMPLER )CLCC_DYNLIB_IMPORT(module, "clCreateSampler"));
194 0 : CLEW_CHECK_FUNCTION(__clewRetainSampler = (PFNCLRETAINSAMPLER )CLCC_DYNLIB_IMPORT(module, "clRetainSampler"));
195 0 : CLEW_CHECK_FUNCTION(__clewReleaseSampler = (PFNCLRELEASESAMPLER )CLCC_DYNLIB_IMPORT(module, "clReleaseSampler"));
196 0 : CLEW_CHECK_FUNCTION(__clewGetSamplerInfo = (PFNCLGETSAMPLERINFO )CLCC_DYNLIB_IMPORT(module, "clGetSamplerInfo"));
197 0 : CLEW_CHECK_FUNCTION(__clewCreateProgramWithSource = (PFNCLCREATEPROGRAMWITHSOURCE )CLCC_DYNLIB_IMPORT(module, "clCreateProgramWithSource"));
198 0 : CLEW_CHECK_FUNCTION(__clewCreateProgramWithBinary = (PFNCLCREATEPROGRAMWITHBINARY )CLCC_DYNLIB_IMPORT(module, "clCreateProgramWithBinary"));
199 0 : CLEW_CHECK_FUNCTION(__clewRetainProgram = (PFNCLRETAINPROGRAM )CLCC_DYNLIB_IMPORT(module, "clRetainProgram"));
200 0 : CLEW_CHECK_FUNCTION(__clewReleaseProgram = (PFNCLRELEASEPROGRAM )CLCC_DYNLIB_IMPORT(module, "clReleaseProgram"));
201 0 : CLEW_CHECK_FUNCTION(__clewBuildProgram = (PFNCLBUILDPROGRAM )CLCC_DYNLIB_IMPORT(module, "clBuildProgram"));
202 0 : CLEW_CHECK_FUNCTION(__clewUnloadCompiler = (PFNCLUNLOADCOMPILER )CLCC_DYNLIB_IMPORT(module, "clUnloadCompiler"));
203 0 : CLEW_CHECK_FUNCTION(__clewGetProgramInfo = (PFNCLGETPROGRAMINFO )CLCC_DYNLIB_IMPORT(module, "clGetProgramInfo"));
204 0 : CLEW_CHECK_FUNCTION(__clewGetProgramBuildInfo = (PFNCLGETPROGRAMBUILDINFO )CLCC_DYNLIB_IMPORT(module, "clGetProgramBuildInfo"));
205 0 : CLEW_CHECK_FUNCTION(__clewCreateKernel = (PFNCLCREATEKERNEL )CLCC_DYNLIB_IMPORT(module, "clCreateKernel"));
206 0 : CLEW_CHECK_FUNCTION(__clewCreateKernelsInProgram = (PFNCLCREATEKERNELSINPROGRAM )CLCC_DYNLIB_IMPORT(module, "clCreateKernelsInProgram"));
207 0 : CLEW_CHECK_FUNCTION(__clewRetainKernel = (PFNCLRETAINKERNEL )CLCC_DYNLIB_IMPORT(module, "clRetainKernel"));
208 0 : CLEW_CHECK_FUNCTION(__clewReleaseKernel = (PFNCLRELEASEKERNEL )CLCC_DYNLIB_IMPORT(module, "clReleaseKernel"));
209 0 : CLEW_CHECK_FUNCTION(__clewSetKernelArg = (PFNCLSETKERNELARG )CLCC_DYNLIB_IMPORT(module, "clSetKernelArg"));
210 0 : CLEW_CHECK_FUNCTION(__clewGetKernelInfo = (PFNCLGETKERNELINFO )CLCC_DYNLIB_IMPORT(module, "clGetKernelInfo"));
211 0 : CLEW_CHECK_FUNCTION(__clewGetKernelWorkGroupInfo = (PFNCLGETKERNELWORKGROUPINFO )CLCC_DYNLIB_IMPORT(module, "clGetKernelWorkGroupInfo"));
212 0 : CLEW_CHECK_FUNCTION(__clewWaitForEvents = (PFNCLWAITFOREVENTS )CLCC_DYNLIB_IMPORT(module, "clWaitForEvents"));
213 0 : CLEW_CHECK_FUNCTION(__clewGetEventInfo = (PFNCLGETEVENTINFO )CLCC_DYNLIB_IMPORT(module, "clGetEventInfo"));
214 0 : CLEW_CHECK_FUNCTION(__clewRetainEvent = (PFNCLRETAINEVENT )CLCC_DYNLIB_IMPORT(module, "clRetainEvent"));
215 0 : CLEW_CHECK_FUNCTION(__clewReleaseEvent = (PFNCLRELEASEEVENT )CLCC_DYNLIB_IMPORT(module, "clReleaseEvent"));
216 0 : CLEW_CHECK_FUNCTION(__clewGetEventProfilingInfo = (PFNCLGETEVENTPROFILINGINFO )CLCC_DYNLIB_IMPORT(module, "clGetEventProfilingInfo"));
217 0 : CLEW_CHECK_FUNCTION(__clewFlush = (PFNCLFLUSH )CLCC_DYNLIB_IMPORT(module, "clFlush"));
218 0 : CLEW_CHECK_FUNCTION(__clewFinish = (PFNCLFINISH )CLCC_DYNLIB_IMPORT(module, "clFinish"));
219 0 : CLEW_CHECK_FUNCTION(__clewEnqueueReadBuffer = (PFNCLENQUEUEREADBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueReadBuffer"));
220 0 : CLEW_CHECK_FUNCTION(__clewEnqueueWriteBuffer = (PFNCLENQUEUEWRITEBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueWriteBuffer"));
221 0 : CLEW_CHECK_FUNCTION(__clewEnqueueCopyBuffer = (PFNCLENQUEUECOPYBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyBuffer"));
222 0 : CLEW_CHECK_FUNCTION(__clewEnqueueReadImage = (PFNCLENQUEUEREADIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueReadImage"));
223 0 : CLEW_CHECK_FUNCTION(__clewEnqueueWriteImage = (PFNCLENQUEUEWRITEIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueWriteImage"));
224 0 : CLEW_CHECK_FUNCTION(__clewEnqueueCopyImage = (PFNCLENQUEUECOPYIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyImage"));
225 0 : CLEW_CHECK_FUNCTION(__clewEnqueueCopyImageToBuffer = (PFNCLENQUEUECOPYIMAGETOBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyImageToBuffer"));
226 0 : CLEW_CHECK_FUNCTION(__clewEnqueueCopyBufferToImage = (PFNCLENQUEUECOPYBUFFERTOIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyBufferToImage"));
227 0 : CLEW_CHECK_FUNCTION(__clewEnqueueMapBuffer = (PFNCLENQUEUEMAPBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueMapBuffer"));
228 0 : CLEW_CHECK_FUNCTION(__clewEnqueueMapImage = (PFNCLENQUEUEMAPIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueMapImage"));
229 0 : CLEW_CHECK_FUNCTION(__clewEnqueueUnmapMemObject = (PFNCLENQUEUEUNMAPMEMOBJECT )CLCC_DYNLIB_IMPORT(module, "clEnqueueUnmapMemObject"));
230 0 : CLEW_CHECK_FUNCTION(__clewEnqueueNDRangeKernel = (PFNCLENQUEUENDRANGEKERNEL )CLCC_DYNLIB_IMPORT(module, "clEnqueueNDRangeKernel"));
231 0 : CLEW_CHECK_FUNCTION(__clewEnqueueTask = (PFNCLENQUEUETASK )CLCC_DYNLIB_IMPORT(module, "clEnqueueTask"));
232 0 : CLEW_CHECK_FUNCTION(__clewEnqueueNativeKernel = (PFNCLENQUEUENATIVEKERNEL )CLCC_DYNLIB_IMPORT(module, "clEnqueueNativeKernel"));
233 0 : CLEW_CHECK_FUNCTION(__clewEnqueueMarker = (PFNCLENQUEUEMARKER )CLCC_DYNLIB_IMPORT(module, "clEnqueueMarker"));
234 0 : CLEW_CHECK_FUNCTION(__clewEnqueueWaitForEvents = (PFNCLENQUEUEWAITFOREVENTS )CLCC_DYNLIB_IMPORT(module, "clEnqueueWaitForEvents"));
235 0 : CLEW_CHECK_FUNCTION(__clewEnqueueBarrier = (PFNCLENQUEUEBARRIER )CLCC_DYNLIB_IMPORT(module, "clEnqueueBarrier"));
236 0 : CLEW_CHECK_FUNCTION(__clewGetExtensionFunctionAddress = (PFNCLGETEXTENSIONFUNCTIONADDRESS )CLCC_DYNLIB_IMPORT(module, "clGetExtensionFunctionAddress"));
237 :
238 0 : return CLEW_SUCCESS;
239 : }
240 :
241 : //! \param error CL error code
242 : //! \return a string representation of the error code
243 0 : const char* clewErrorString(cl_int error)
244 : {
245 : static const char* strings[] =
246 : {
247 : // Error Codes
248 : "CL_SUCCESS" // 0
249 : , "CL_DEVICE_NOT_FOUND" // -1
250 : , "CL_DEVICE_NOT_AVAILABLE" // -2
251 : , "CL_COMPILER_NOT_AVAILABLE" // -3
252 : , "CL_MEM_OBJECT_ALLOCATION_FAILURE" // -4
253 : , "CL_OUT_OF_RESOURCES" // -5
254 : , "CL_OUT_OF_HOST_MEMORY" // -6
255 : , "CL_PROFILING_INFO_NOT_AVAILABLE" // -7
256 : , "CL_MEM_COPY_OVERLAP" // -8
257 : , "CL_IMAGE_FORMAT_MISMATCH" // -9
258 : , "CL_IMAGE_FORMAT_NOT_SUPPORTED" // -10
259 : , "CL_BUILD_PROGRAM_FAILURE" // -11
260 : , "CL_MAP_FAILURE" // -12
261 :
262 : , "" // -13
263 : , "" // -14
264 : , "" // -15
265 : , "" // -16
266 : , "" // -17
267 : , "" // -18
268 : , "" // -19
269 :
270 : , "" // -20
271 : , "" // -21
272 : , "" // -22
273 : , "" // -23
274 : , "" // -24
275 : , "" // -25
276 : , "" // -26
277 : , "" // -27
278 : , "" // -28
279 : , "" // -29
280 :
281 : , "CL_INVALID_VALUE" // -30
282 : , "CL_INVALID_DEVICE_TYPE" // -31
283 : , "CL_INVALID_PLATFORM" // -32
284 : , "CL_INVALID_DEVICE" // -33
285 : , "CL_INVALID_CONTEXT" // -34
286 : , "CL_INVALID_QUEUE_PROPERTIES" // -35
287 : , "CL_INVALID_COMMAND_QUEUE" // -36
288 : , "CL_INVALID_HOST_PTR" // -37
289 : , "CL_INVALID_MEM_OBJECT" // -38
290 : , "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR" // -39
291 : , "CL_INVALID_IMAGE_SIZE" // -40
292 : , "CL_INVALID_SAMPLER" // -41
293 : , "CL_INVALID_BINARY" // -42
294 : , "CL_INVALID_BUILD_OPTIONS" // -43
295 : , "CL_INVALID_PROGRAM" // -44
296 : , "CL_INVALID_PROGRAM_EXECUTABLE" // -45
297 : , "CL_INVALID_KERNEL_NAME" // -46
298 : , "CL_INVALID_KERNEL_DEFINITION" // -47
299 : , "CL_INVALID_KERNEL" // -48
300 : , "CL_INVALID_ARG_INDEX" // -49
301 : , "CL_INVALID_ARG_VALUE" // -50
302 : , "CL_INVALID_ARG_SIZE" // -51
303 : , "CL_INVALID_KERNEL_ARGS" // -52
304 : , "CL_INVALID_WORK_DIMENSION" // -53
305 : , "CL_INVALID_WORK_GROUP_SIZE" // -54
306 : , "CL_INVALID_WORK_ITEM_SIZE" // -55
307 : , "CL_INVALID_GLOBAL_OFFSET" // -56
308 : , "CL_INVALID_EVENT_WAIT_LIST" // -57
309 : , "CL_INVALID_EVENT" // -58
310 : , "CL_INVALID_OPERATION" // -59
311 : , "CL_INVALID_GL_OBJECT" // -60
312 : , "CL_INVALID_BUFFER_SIZE" // -61
313 : , "CL_INVALID_MIP_LEVEL" // -62
314 : , "CL_INVALID_GLOBAL_WORK_SIZE" // -63
315 : };
316 :
317 0 : if ( (error > 0)
318 0 : || (error < -63)
319 : )
320 : {
321 0 : return "unknown error code (no OpenCL driver?)";
322 : }
323 :
324 0 : return strings[-error];
325 : }
|