#include <ext_OpenCL.h>
+const char *
+val2cstr_cl (cl_int CL_err)
+{
+#define CLERR(a) case a: return #a
+ switch (CL_err) {
+ CLERR(CL_BUILD_PROGRAM_FAILURE);
+ CLERR(CL_COMPILER_NOT_AVAILABLE);
+ CLERR(CL_DEVICE_NOT_FOUND);
+ CLERR(CL_INVALID_ARG_INDEX);
+ CLERR(CL_INVALID_ARG_SIZE);
+ CLERR(CL_INVALID_ARG_VALUE);
+ CLERR(CL_INVALID_BINARY);
+ CLERR(CL_INVALID_BUFFER_SIZE);
+ CLERR(CL_INVALID_BUILD_OPTIONS);
+ CLERR(CL_INVALID_COMMAND_QUEUE);
+ CLERR(CL_INVALID_CONTEXT);
+ CLERR(CL_INVALID_DEVICE);
+ CLERR(CL_INVALID_DEVICE_TYPE);
+ CLERR(CL_INVALID_EVENT);
+ CLERR(CL_INVALID_EVENT_WAIT_LIST);
+ CLERR(CL_INVALID_GLOBAL_OFFSET);
+ CLERR(CL_INVALID_HOST_PTR);
+ CLERR(CL_INVALID_KERNEL);
+ CLERR(CL_INVALID_KERNEL_ARGS);
+ CLERR(CL_INVALID_KERNEL_DEFINITION);
+ CLERR(CL_INVALID_KERNEL_NAME);
+ CLERR(CL_INVALID_MEM_OBJECT);
+ CLERR(CL_INVALID_OPERATION);
+ CLERR(CL_INVALID_PLATFORM);
+ CLERR(CL_INVALID_PROGRAM);
+ CLERR(CL_INVALID_PROGRAM_EXECUTABLE);
+ CLERR(CL_INVALID_QUEUE_PROPERTIES);
+ CLERR(CL_INVALID_SAMPLER);
+ CLERR(CL_INVALID_VALUE);
+ CLERR(CL_INVALID_WORK_DIMENSION);
+ CLERR(CL_INVALID_WORK_GROUP_SIZE);
+ CLERR(CL_INVALID_WORK_ITEM_SIZE);
+ CLERR(CL_MISALIGNED_SUB_BUFFER_OFFSET);
+ CLERR(CL_MAP_FAILURE);
+ CLERR(CL_MEM_COPY_OVERLAP);
+ CLERR(CL_MEM_OBJECT_ALLOCATION_FAILURE);
+ CLERR(CL_OUT_OF_HOST_MEMORY);
+ CLERR(CL_OUT_OF_RESOURCES);
+
+ }
+ return "(unknown CL error)";
+}
+
void hc_clEnqueueNDRangeKernel (cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
{
cl_int CL_err = clEnqueueNDRangeKernel (command_queue, kernel, work_dim, global_work_offset, global_work_size, local_work_size, num_events_in_wait_list, event_wait_list, event);
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clEnqueueNDRangeKernel()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clEnqueueNDRangeKernel()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clGetEventInfo()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clGetEventInfo()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clFlush()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clFlush()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clFinish()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clFinish()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clSetKernelArg()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clSetKernelArg()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clEnqueueWriteBuffer()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clEnqueueWriteBuffer()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clEnqueueCopyBuffer()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clEnqueueCopyBuffer()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clEnqueueReadBuffer()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clEnqueueReadBuffer()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clGetPlatformIDs()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clGetPlatformIDs()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clGetPlatformInfo()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clGetPlatformInfo()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clGetDeviceIDs()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clGetDeviceIDs()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clGetDeviceInfo()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clGetDeviceInfo()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clCreateContext()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clCreateContext()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clCreateCommandQueue()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clCreateCommandQueue()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clCreateCommandQueueWithProperties()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clCreateCommandQueueWithProperties()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clCreateBuffer()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clCreateBuffer()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clCreateProgramWithSource()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clCreateProgramWithSource()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clCreateProgramWithBinary()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clCreateProgramWithBinary()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clBuildProgram()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clBuildProgram()", CL_err, val2cstr_cl(CL_err));
// If we exit here we can't see the error message
// exit (-1);
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clReleaseMemObject()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clReleaseMemObject()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clReleaseProgram()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clReleaseProgram()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clReleaseProgram()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clReleaseProgram()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clReleaseCommandQueue()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clReleaseCommandQueue()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clReleaseContext()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clReleaseContext()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clEnqueueMapBuffer()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clEnqueueMapBuffer()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clEnqueueUnmapMemObject()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clEnqueueUnmapMemObject()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clEnqueueFillBuffer()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clEnqueueFillBuffer()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}
if (CL_err != CL_SUCCESS)
{
- log_error ("ERROR: %s %d\n", "clGetKernelWorkGroupInfo()", CL_err);
+ log_error ("ERROR: %s (%d)%s\n", "clGetKernelWorkGroupInfo()", CL_err, val2cstr_cl(CL_err));
exit (-1);
}