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