23 #ifndef _CLSPARSE_ERROR_H_
24 #define _CLSPARSE_ERROR_H_
26 #if defined(__APPLE__) || defined(__MACOSX)
27 # include <OpenCL/cl.h>
32 #if !defined( NDEBUG )
37 #if defined( _WIN32 ) && !defined( __cplusplus )
38 #define inline __inline
47 static inline const char*
48 stringifyStatus(
const cl_int status )
52 case CL_INVALID_GLOBAL_WORK_SIZE:
53 return "CL_INVALID_GLOBAL_WORK_SIZE";
54 case CL_INVALID_MIP_LEVEL:
55 return "CL_INVALID_MIP_LEVEL";
56 case CL_INVALID_BUFFER_SIZE:
57 return "CL_INVALID_BUFFER_SIZE";
58 case CL_INVALID_GL_OBJECT:
59 return "CL_INVALID_GL_OBJECT";
60 case CL_INVALID_OPERATION:
61 return "CL_INVALID_OPERATION";
62 case CL_INVALID_EVENT:
63 return "CL_INVALID_EVENT";
64 case CL_INVALID_EVENT_WAIT_LIST:
65 return "CL_INVALID_EVENT_WAIT_LIST";
66 case CL_INVALID_GLOBAL_OFFSET:
67 return "CL_INVALID_GLOBAL_OFFSET";
68 case CL_INVALID_WORK_ITEM_SIZE:
69 return "CL_INVALID_WORK_ITEM_SIZE";
70 case CL_INVALID_WORK_GROUP_SIZE:
71 return "CL_INVALID_WORK_GROUP_SIZE";
72 case CL_INVALID_WORK_DIMENSION:
73 return "CL_INVALID_WORK_DIMENSION";
74 case CL_INVALID_KERNEL_ARGS:
75 return "CL_INVALID_KERNEL_ARGS";
76 case CL_INVALID_ARG_SIZE:
77 return "CL_INVALID_ARG_SIZE";
78 case CL_INVALID_ARG_VALUE:
79 return "CL_INVALID_ARG_VALUE";
80 case CL_INVALID_ARG_INDEX:
81 return "CL_INVALID_ARG_INDEX";
82 case CL_INVALID_KERNEL:
83 return "CL_INVALID_KERNEL";
84 case CL_INVALID_KERNEL_DEFINITION:
85 return "CL_INVALID_KERNEL_DEFINITION";
86 case CL_INVALID_KERNEL_NAME:
87 return "CL_INVALID_KERNEL_NAME";
88 case CL_INVALID_PROGRAM_EXECUTABLE:
89 return "CL_INVALID_PROGRAM_EXECUTABLE";
90 case CL_INVALID_PROGRAM:
91 return "CL_INVALID_PROGRAM";
92 case CL_INVALID_BUILD_OPTIONS:
93 return "CL_INVALID_BUILD_OPTIONS";
94 case CL_INVALID_BINARY:
95 return "CL_INVALID_BINARY";
96 case CL_INVALID_SAMPLER:
97 return "CL_INVALID_SAMPLER";
98 case CL_INVALID_IMAGE_SIZE:
99 return "CL_INVALID_IMAGE_SIZE";
100 case CL_INVALID_IMAGE_FORMAT_DESCRIPTOR:
101 return "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR";
102 case CL_INVALID_MEM_OBJECT:
103 return "CL_INVALID_MEM_OBJECT";
104 case CL_INVALID_HOST_PTR:
105 return "CL_INVALID_HOST_PTR";
106 case CL_INVALID_COMMAND_QUEUE:
107 return "CL_INVALID_COMMAND_QUEUE";
108 case CL_INVALID_QUEUE_PROPERTIES:
109 return "CL_INVALID_QUEUE_PROPERTIES";
110 case CL_INVALID_CONTEXT:
111 return "CL_INVALID_CONTEXT";
112 case CL_INVALID_DEVICE:
113 return "CL_INVALID_DEVICE";
114 case CL_INVALID_PLATFORM:
115 return "CL_INVALID_PLATFORM";
116 case CL_INVALID_DEVICE_TYPE:
117 return "CL_INVALID_DEVICE_TYPE";
118 case CL_INVALID_VALUE:
119 return "CL_INVALID_VALUE";
121 return "CL_MAP_FAILURE";
122 case CL_BUILD_PROGRAM_FAILURE:
123 return "CL_BUILD_PROGRAM_FAILURE";
124 case CL_IMAGE_FORMAT_NOT_SUPPORTED:
125 return "CL_IMAGE_FORMAT_NOT_SUPPORTED";
126 case CL_IMAGE_FORMAT_MISMATCH:
127 return "CL_IMAGE_FORMAT_MISMATCH";
128 case CL_MEM_COPY_OVERLAP:
129 return "CL_MEM_COPY_OVERLAP";
130 case CL_PROFILING_INFO_NOT_AVAILABLE:
131 return "CL_PROFILING_INFO_NOT_AVAILABLE";
132 case CL_OUT_OF_HOST_MEMORY:
133 return "CL_OUT_OF_HOST_MEMORY";
134 case CL_OUT_OF_RESOURCES:
135 return "CL_OUT_OF_RESOURCES";
136 case CL_MEM_OBJECT_ALLOCATION_FAILURE:
137 return "CL_MEM_OBJECT_ALLOCATION_FAILURE";
138 case CL_COMPILER_NOT_AVAILABLE:
139 return "CL_COMPILER_NOT_AVAILABLE";
140 case CL_DEVICE_NOT_AVAILABLE:
141 return "CL_DEVICE_NOT_AVAILABLE";
142 case CL_DEVICE_NOT_FOUND:
143 return "CL_DEVICE_NOT_FOUND";
147 return "Unrecognized status code";
158 clSPARSE_V( cl_int res,
const char* msg,
const char* file,
size_t lineno )
166 #if !defined( NDEBUG )
167 #if defined( _WIN32 )
168 printf(
"[%s:%Iu]\nCLSPARSE_V( %s ) - %s", file, lineno, stringifyStatus( res ), msg );
170 printf(
"[%s:%zu]\nCLSPARSE_V( %s ) - %s", file, lineno, stringifyStatus( res ), msg );
182 #define CLSPARSE_V( _status, _message ) clSPARSE_V( _status, _message, __FILE__, __LINE__ )