From 954be23a121f15200cd2cf2b4358c7e363436907 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 16 Jan 2016 13:47:43 +0100 Subject: [PATCH] Fix some code formating --- src/ext_OpenCL.c | 147 ++++++++++++++++++++++++----------------------- 1 file changed, 74 insertions(+), 73 deletions(-) diff --git a/src/ext_OpenCL.c b/src/ext_OpenCL.c index 24e4579de..c3c454537 100644 --- a/src/ext_OpenCL.c +++ b/src/ext_OpenCL.c @@ -5,52 +5,53 @@ #include -const char * -val2cstr_cl (cl_int CL_err) +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)"; + #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 "CL_UNKNOWN_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) @@ -59,7 +60,7 @@ void hc_clEnqueueNDRangeKernel (cl_command_queue command_queue, cl_kernel kernel if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clEnqueueNDRangeKernel()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clEnqueueNDRangeKernel()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -71,7 +72,7 @@ void hc_clGetEventInfo (cl_event event, cl_event_info param_name, size_t param_v if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clGetEventInfo()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clGetEventInfo()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -83,7 +84,7 @@ void hc_clFlush (cl_command_queue command_queue) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clFlush()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clFlush()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -95,7 +96,7 @@ void hc_clFinish (cl_command_queue command_queue) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clFinish()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clFinish()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -107,7 +108,7 @@ void hc_clSetKernelArg (cl_kernel kernel, cl_uint arg_index, size_t arg_size, co if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clSetKernelArg()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clSetKernelArg()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -119,7 +120,7 @@ void hc_clEnqueueWriteBuffer (cl_command_queue command_queue, cl_mem buffer, cl_ if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clEnqueueWriteBuffer()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clEnqueueWriteBuffer()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -131,7 +132,7 @@ void hc_clEnqueueCopyBuffer (cl_command_queue command_queue, cl_mem src_buffer, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clEnqueueCopyBuffer()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clEnqueueCopyBuffer()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -143,7 +144,7 @@ void hc_clEnqueueReadBuffer (cl_command_queue command_queue, cl_mem buffer, cl_b if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clEnqueueReadBuffer()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clEnqueueReadBuffer()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -155,7 +156,7 @@ void hc_clGetPlatformIDs (cl_uint num_entries, cl_platform_id *platforms, cl_uin if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clGetPlatformIDs()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clGetPlatformIDs()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -167,7 +168,7 @@ void hc_clGetPlatformInfo (cl_platform_id platform, cl_platform_info param_name, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clGetPlatformInfo()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clGetPlatformInfo()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -179,7 +180,7 @@ void hc_clGetDeviceIDs (cl_platform_id platform, cl_device_type device_type, cl_ if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clGetDeviceIDs()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clGetDeviceIDs()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -191,7 +192,7 @@ void hc_clGetDeviceInfo (cl_device_id device, cl_device_info param_name, size_t if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clGetDeviceInfo()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clGetDeviceInfo()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -205,7 +206,7 @@ cl_context hc_clCreateContext (cl_context_properties *properties, cl_uint num_de if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clCreateContext()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clCreateContext()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -222,7 +223,7 @@ cl_command_queue hc_clCreateCommandQueue (cl_context context, cl_device_id devic if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clCreateCommandQueue()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clCreateCommandQueue()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -239,7 +240,7 @@ cl_command_queue hc_clCreateCommandQueueWithProperties (cl_context context, cl_d if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clCreateCommandQueueWithProperties()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clCreateCommandQueueWithProperties()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -256,7 +257,7 @@ cl_mem hc_clCreateBuffer (cl_context context, cl_mem_flags flags, size_t size, v if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clCreateBuffer()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clCreateBuffer()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -272,7 +273,7 @@ cl_program hc_clCreateProgramWithSource (cl_context context, cl_uint count, cons if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clCreateProgramWithSource()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clCreateProgramWithSource()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -288,7 +289,7 @@ cl_program hc_clCreateProgramWithBinary (cl_context context, cl_uint num_devices if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clCreateProgramWithBinary()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clCreateProgramWithBinary()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -302,7 +303,7 @@ void hc_clBuildProgram (cl_program program, cl_uint num_devices, const cl_device if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clBuildProgram()", CL_err, val2cstr_cl(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); @@ -331,7 +332,7 @@ void hc_clReleaseMemObject (cl_mem mem) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clReleaseMemObject()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clReleaseMemObject()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -343,7 +344,7 @@ void hc_clReleaseKernel (cl_kernel kernel) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clReleaseProgram()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clReleaseProgram()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -355,7 +356,7 @@ void hc_clReleaseProgram (cl_program program) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clReleaseProgram()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clReleaseProgram()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -367,7 +368,7 @@ void hc_clReleaseCommandQueue (cl_command_queue command_queue) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clReleaseCommandQueue()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clReleaseCommandQueue()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -379,7 +380,7 @@ void hc_clReleaseContext (cl_context context) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clReleaseContext()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clReleaseContext()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -393,7 +394,7 @@ void *hc_clEnqueueMapBuffer (cl_command_queue command_queue, cl_mem buffer, cl_b if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clEnqueueMapBuffer()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clEnqueueMapBuffer()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -407,7 +408,7 @@ void hc_clEnqueueUnmapMemObject (cl_command_queue command_queue, cl_mem memobj, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clEnqueueUnmapMemObject()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clEnqueueUnmapMemObject()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -419,7 +420,7 @@ void hc_clEnqueueFillBuffer (cl_command_queue command_queue, cl_mem buffer, cons if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clEnqueueFillBuffer()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clEnqueueFillBuffer()", CL_err, val2cstr_cl (CL_err)); exit (-1); } @@ -431,7 +432,7 @@ void hc_clGetKernelWorkGroupInfo (cl_kernel kernel, cl_device_id device, cl_kern if (CL_err != CL_SUCCESS) { - log_error ("ERROR: %s (%d)%s\n", "clGetKernelWorkGroupInfo()", CL_err, val2cstr_cl(CL_err)); + log_error ("ERROR: %s : %d : %s\n", "clGetKernelWorkGroupInfo()", CL_err, val2cstr_cl (CL_err)); exit (-1); }