mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-22 14:48:12 +00:00
Get rid of exit() calls in OpenCL wrapper library with the goal to have a better control which error can be ignored under special circumstances
Note, not all return codes from some of the subfunctions are uset yet, it would be too much changes at once This is a preparation for https://github.com/hashcat/hashcat/issues/416
This commit is contained in:
parent
3fa2d10914
commit
6ba0eb8b39
@ -13,6 +13,7 @@
|
||||
- Replace DARWIN macro with compiler predefined macro __APPLE__
|
||||
- Replace LINUX macro with compiler predefined macro __linux__
|
||||
- Allow the use of enc_id == 0 in hash-mode 10600 and 10700 as it takes no part in the actual computation
|
||||
- Get rid of exit() calls in OpenCL wrapper library with the goal to have a better control which error can be ignored under special circumstances
|
||||
|
||||
##
|
||||
## Bugs
|
||||
|
@ -19,12 +19,10 @@
|
||||
|
||||
#ifdef WIN
|
||||
#include <CL/cl.h>
|
||||
// #include <CL/cl_ext.h> // used for CL_DEVICE_TOPOLOGY_AMD but broken for dual GPU
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <CL/cl.h>
|
||||
// #include <CL/cl_ext.h> // used for CL_DEVICE_TOPOLOGY_AMD but broken for dual GPU
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
@ -33,118 +31,116 @@
|
||||
|
||||
#include <shared.h>
|
||||
|
||||
typedef cl_mem (CL_API_CALL *OCL_CLCREATEBUFFER) (cl_context, cl_mem_flags, size_t, void *, cl_int *);
|
||||
typedef cl_command_queue (CL_API_CALL *OCL_CLCREATECOMMANDQUEUE) (cl_context, cl_device_id, cl_command_queue_properties, cl_int *);
|
||||
typedef cl_context (CL_API_CALL *OCL_CLCREATECONTEXT) (const cl_context_properties *, cl_uint, const cl_device_id *, void (CL_CALLBACK *)(const char *, const void *, size_t, void *), void *, cl_int *);
|
||||
typedef cl_kernel (CL_API_CALL *OCL_CLCREATEKERNEL) (cl_program, const char *, cl_int *);
|
||||
typedef cl_program (CL_API_CALL *OCL_CLCREATEPROGRAMWITHSOURCE) (cl_context, cl_uint, const char **, const size_t *, cl_int *);
|
||||
typedef cl_program (CL_API_CALL *OCL_CLCREATEPROGRAMWITHBINARY) (cl_context, cl_uint, const cl_device_id *, const size_t *, const unsigned char **, cl_int *, cl_int *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLBUILDPROGRAM) (cl_program, cl_uint, const cl_device_id *, const char *, void (CL_CALLBACK *)(cl_program, void *), void *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLENQUEUENDRANGEKERNEL) (cl_command_queue, cl_kernel, cl_uint, const size_t *, const size_t *, const size_t *, cl_uint, const cl_event *, cl_event *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLENQUEUEREADBUFFER) (cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLENQUEUEWRITEBUFFER) (cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLENQUEUECOPYBUFFER) (cl_command_queue, cl_mem, cl_mem, size_t, size_t, size_t, cl_uint, const cl_event *, cl_event *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLFLUSH) (cl_command_queue);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLFINISH) (cl_command_queue);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETDEVICEIDS) (cl_platform_id, cl_device_type, cl_uint, cl_device_id *, cl_uint *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETDEVICEINFO) (cl_device_id, cl_device_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETPLATFORMIDS) (cl_uint, cl_platform_id *, cl_uint *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETPLATFORMINFO) (cl_platform_id, cl_platform_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLRELEASECOMMANDQUEUE) (cl_command_queue);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLRELEASECONTEXT) (cl_context);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLRELEASEKERNEL) (cl_kernel);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLRELEASEMEMOBJECT) (cl_mem);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLRELEASEPROGRAM) (cl_program);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLSETKERNELARG) (cl_kernel, cl_uint, size_t, const void *);
|
||||
typedef void * (CL_API_CALL *OCL_CLENQUEUEMAPBUFFER) (cl_command_queue, cl_mem, cl_bool, cl_map_flags, size_t, size_t, cl_uint, const cl_event *, cl_event *, cl_int *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLENQUEUEUNMAPMEMOBJECT) (cl_command_queue, cl_mem, void *, cl_uint, const cl_event *, cl_event *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLENQUEUEFILLBUFFER) (cl_command_queue, cl_mem, const void *, size_t, size_t, size_t, cl_uint, const cl_event *, cl_event *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETKERNELWORKGROUPINFO) (cl_kernel, cl_device_id, cl_kernel_work_group_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETPROGRAMBUILDINFO) (cl_program, cl_device_id, cl_program_build_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETPROGRAMINFO) (cl_program, cl_program_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETEVENTINFO) (cl_event, cl_event_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLWAITFOREVENTS) (cl_uint, const cl_event *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETEVENTPROFILINGINFO) (cl_event, cl_profiling_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLRELEASEEVENT) (cl_event);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLBUILDPROGRAM) (cl_program, cl_uint, const cl_device_id *, const char *, void (CL_CALLBACK *)(cl_program, void *), void *);
|
||||
typedef cl_mem (CL_API_CALL *OCL_CLCREATEBUFFER) (cl_context, cl_mem_flags, size_t, void *, cl_int *);
|
||||
typedef cl_command_queue (CL_API_CALL *OCL_CLCREATECOMMANDQUEUE) (cl_context, cl_device_id, cl_command_queue_properties, cl_int *);
|
||||
typedef cl_context (CL_API_CALL *OCL_CLCREATECONTEXT) (const cl_context_properties *, cl_uint, const cl_device_id *, void (CL_CALLBACK *)(const char *, const void *, size_t, void *), void *, cl_int *);
|
||||
typedef cl_kernel (CL_API_CALL *OCL_CLCREATEKERNEL) (cl_program, const char *, cl_int *);
|
||||
typedef cl_program (CL_API_CALL *OCL_CLCREATEPROGRAMWITHBINARY) (cl_context, cl_uint, const cl_device_id *, const size_t *, const unsigned char **, cl_int *, cl_int *);
|
||||
typedef cl_program (CL_API_CALL *OCL_CLCREATEPROGRAMWITHSOURCE) (cl_context, cl_uint, const char **, const size_t *, cl_int *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLENQUEUECOPYBUFFER) (cl_command_queue, cl_mem, cl_mem, size_t, size_t, size_t, cl_uint, const cl_event *, cl_event *);
|
||||
typedef void * (CL_API_CALL *OCL_CLENQUEUEMAPBUFFER) (cl_command_queue, cl_mem, cl_bool, cl_map_flags, size_t, size_t, cl_uint, const cl_event *, cl_event *, cl_int *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLENQUEUENDRANGEKERNEL) (cl_command_queue, cl_kernel, cl_uint, const size_t *, const size_t *, const size_t *, cl_uint, const cl_event *, cl_event *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLENQUEUEREADBUFFER) (cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLENQUEUEUNMAPMEMOBJECT) (cl_command_queue, cl_mem, void *, cl_uint, const cl_event *, cl_event *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLENQUEUEWRITEBUFFER) (cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLFINISH) (cl_command_queue);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLFLUSH) (cl_command_queue);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETDEVICEIDS) (cl_platform_id, cl_device_type, cl_uint, cl_device_id *, cl_uint *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETDEVICEINFO) (cl_device_id, cl_device_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETEVENTINFO) (cl_event, cl_event_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETEVENTPROFILINGINFO) (cl_event, cl_profiling_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETKERNELWORKGROUPINFO) (cl_kernel, cl_device_id, cl_kernel_work_group_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETPLATFORMIDS) (cl_uint, cl_platform_id *, cl_uint *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETPLATFORMINFO) (cl_platform_id, cl_platform_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETPROGRAMBUILDINFO) (cl_program, cl_device_id, cl_program_build_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLGETPROGRAMINFO) (cl_program, cl_program_info, size_t, void *, size_t *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLRELEASECOMMANDQUEUE) (cl_command_queue);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLRELEASECONTEXT) (cl_context);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLRELEASEEVENT) (cl_event);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLRELEASEKERNEL) (cl_kernel);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLRELEASEMEMOBJECT) (cl_mem);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLRELEASEPROGRAM) (cl_program);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLSETKERNELARG) (cl_kernel, cl_uint, size_t, const void *);
|
||||
typedef cl_int (CL_API_CALL *OCL_CLWAITFOREVENTS) (cl_uint, const cl_event *);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
OCL_LIB lib;
|
||||
|
||||
OCL_CLBUILDPROGRAM clBuildProgram;
|
||||
OCL_CLCREATEBUFFER clCreateBuffer;
|
||||
OCL_CLCREATECOMMANDQUEUE clCreateCommandQueue;
|
||||
OCL_CLCREATECONTEXT clCreateContext;
|
||||
OCL_CLCREATEKERNEL clCreateKernel;
|
||||
OCL_CLBUILDPROGRAM clBuildProgram;
|
||||
OCL_CLCREATEBUFFER clCreateBuffer;
|
||||
OCL_CLCREATECOMMANDQUEUE clCreateCommandQueue;
|
||||
OCL_CLCREATECONTEXT clCreateContext;
|
||||
OCL_CLCREATEKERNEL clCreateKernel;
|
||||
OCL_CLCREATEPROGRAMWITHBINARY clCreateProgramWithBinary;
|
||||
OCL_CLCREATEPROGRAMWITHSOURCE clCreateProgramWithSource;
|
||||
OCL_CLENQUEUECOPYBUFFER clEnqueueCopyBuffer;
|
||||
OCL_CLENQUEUEFILLBUFFER clEnqueueFillBuffer;
|
||||
OCL_CLENQUEUEMAPBUFFER clEnqueueMapBuffer;
|
||||
OCL_CLENQUEUENDRANGEKERNEL clEnqueueNDRangeKernel;
|
||||
OCL_CLENQUEUEREADBUFFER clEnqueueReadBuffer;
|
||||
OCL_CLENQUEUEUNMAPMEMOBJECT clEnqueueUnmapMemObject;
|
||||
OCL_CLENQUEUEWRITEBUFFER clEnqueueWriteBuffer;
|
||||
OCL_CLFINISH clFinish;
|
||||
OCL_CLFLUSH clFlush;
|
||||
OCL_CLGETDEVICEIDS clGetDeviceIDs;
|
||||
OCL_CLGETDEVICEINFO clGetDeviceInfo;
|
||||
OCL_CLGETEVENTINFO clGetEventInfo;
|
||||
OCL_CLGETKERNELWORKGROUPINFO clGetKernelWorkGroupInfo;
|
||||
OCL_CLGETPLATFORMIDS clGetPlatformIDs;
|
||||
OCL_CLGETPLATFORMINFO clGetPlatformInfo;
|
||||
OCL_CLGETPROGRAMBUILDINFO clGetProgramBuildInfo;
|
||||
OCL_CLGETPROGRAMINFO clGetProgramInfo;
|
||||
OCL_CLRELEASECOMMANDQUEUE clReleaseCommandQueue;
|
||||
OCL_CLRELEASECONTEXT clReleaseContext;
|
||||
OCL_CLRELEASEKERNEL clReleaseKernel;
|
||||
OCL_CLRELEASEMEMOBJECT clReleaseMemObject;
|
||||
OCL_CLRELEASEPROGRAM clReleaseProgram;
|
||||
OCL_CLSETKERNELARG clSetKernelArg;
|
||||
OCL_CLWAITFOREVENTS clWaitForEvents;
|
||||
OCL_CLGETEVENTPROFILINGINFO clGetEventProfilingInfo;
|
||||
OCL_CLRELEASEEVENT clReleaseEvent;
|
||||
OCL_CLENQUEUECOPYBUFFER clEnqueueCopyBuffer;
|
||||
OCL_CLENQUEUEMAPBUFFER clEnqueueMapBuffer;
|
||||
OCL_CLENQUEUENDRANGEKERNEL clEnqueueNDRangeKernel;
|
||||
OCL_CLENQUEUEREADBUFFER clEnqueueReadBuffer;
|
||||
OCL_CLENQUEUEUNMAPMEMOBJECT clEnqueueUnmapMemObject;
|
||||
OCL_CLENQUEUEWRITEBUFFER clEnqueueWriteBuffer;
|
||||
OCL_CLFINISH clFinish;
|
||||
OCL_CLFLUSH clFlush;
|
||||
OCL_CLGETDEVICEIDS clGetDeviceIDs;
|
||||
OCL_CLGETDEVICEINFO clGetDeviceInfo;
|
||||
OCL_CLGETEVENTINFO clGetEventInfo;
|
||||
OCL_CLGETEVENTPROFILINGINFO clGetEventProfilingInfo;
|
||||
OCL_CLGETKERNELWORKGROUPINFO clGetKernelWorkGroupInfo;
|
||||
OCL_CLGETPLATFORMIDS clGetPlatformIDs;
|
||||
OCL_CLGETPLATFORMINFO clGetPlatformInfo;
|
||||
OCL_CLGETPROGRAMBUILDINFO clGetProgramBuildInfo;
|
||||
OCL_CLGETPROGRAMINFO clGetProgramInfo;
|
||||
OCL_CLRELEASECOMMANDQUEUE clReleaseCommandQueue;
|
||||
OCL_CLRELEASECONTEXT clReleaseContext;
|
||||
OCL_CLRELEASEEVENT clReleaseEvent;
|
||||
OCL_CLRELEASEKERNEL clReleaseKernel;
|
||||
OCL_CLRELEASEMEMOBJECT clReleaseMemObject;
|
||||
OCL_CLRELEASEPROGRAM clReleaseProgram;
|
||||
OCL_CLSETKERNELARG clSetKernelArg;
|
||||
OCL_CLWAITFOREVENTS clWaitForEvents;
|
||||
|
||||
} hc_opencl_lib_t;
|
||||
|
||||
#define OCL_PTR hc_opencl_lib_t
|
||||
|
||||
int ocl_init (OCL_PTR *ocl);
|
||||
const char *val2cstr_cl (cl_int CL_err);
|
||||
|
||||
int ocl_init (OCL_PTR *ocl);
|
||||
void ocl_close (OCL_PTR *ocl);
|
||||
|
||||
cl_mem hc_clCreateBuffer (OCL_PTR *ocl, cl_context context, cl_mem_flags flags, size_t size, void *host_ptr);
|
||||
cl_command_queue hc_clCreateCommandQueue (OCL_PTR *ocl, cl_context context, cl_device_id device, cl_command_queue_properties properties);
|
||||
//cl_command_queue hc_clCreateCommandQueueWithProperties (cl_context context, cl_device_id device, const cl_queue_properties *properties);
|
||||
cl_context hc_clCreateContext (OCL_PTR *ocl, cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify) (const char *, const void *, size_t, void *), void *user_data);
|
||||
cl_kernel hc_clCreateKernel (OCL_PTR *ocl, cl_program program, const char *kernel_name);
|
||||
cl_program hc_clCreateProgramWithSource (OCL_PTR *ocl, cl_context context, cl_uint count, const char **strings, const size_t *lengths);
|
||||
cl_program hc_clCreateProgramWithBinary (OCL_PTR *ocl, cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status);
|
||||
cl_int hc_clBuildProgram (OCL_PTR *ocl, cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify) (cl_program program, void *user_data), void *user_data, bool exitOnFail);
|
||||
void hc_clEnqueueNDRangeKernel (OCL_PTR *ocl, 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);
|
||||
void hc_clEnqueueReadBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
||||
void hc_clEnqueueWriteBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
||||
void hc_clEnqueueCopyBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
||||
void hc_clFlush (OCL_PTR *ocl, cl_command_queue command_queue);
|
||||
void hc_clFinish (OCL_PTR *ocl, cl_command_queue command_queue);
|
||||
void hc_clGetDeviceIDs (OCL_PTR *ocl, cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices);
|
||||
void hc_clGetDeviceInfo (OCL_PTR *ocl, cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
||||
void hc_clGetPlatformIDs (OCL_PTR *ocl, cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms);
|
||||
void hc_clGetPlatformInfo (OCL_PTR *ocl, cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
||||
void hc_clReleaseCommandQueue (OCL_PTR *ocl, cl_command_queue command_queue);
|
||||
void hc_clReleaseContext (OCL_PTR *ocl, cl_context context);
|
||||
void hc_clReleaseKernel (OCL_PTR *ocl, cl_kernel kernel);
|
||||
void hc_clReleaseMemObject (OCL_PTR *ocl, cl_mem mem);
|
||||
void hc_clReleaseProgram (OCL_PTR *ocl, cl_program program);
|
||||
void hc_clSetKernelArg (OCL_PTR *ocl, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value);
|
||||
void *hc_clEnqueueMapBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
||||
void hc_clEnqueueUnmapMemObject (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
||||
cl_int hc_clEnqueueFillBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, const void *pattern, size_t pattern_size, size_t offset, size_t size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
||||
void hc_clGetKernelWorkGroupInfo (OCL_PTR *ocl, cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
||||
cl_int hc_clGetProgramBuildInfo (OCL_PTR *ocl, cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
||||
void hc_clGetProgramInfo (OCL_PTR *ocl, cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t * param_value_size_ret);
|
||||
void hc_clGetEventInfo (OCL_PTR *ocl, cl_event event, cl_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
||||
void hc_clWaitForEvents (OCL_PTR *ocl, cl_uint num_events, const cl_event *event_list);
|
||||
void hc_clGetEventProfilingInfo (OCL_PTR *ocl, cl_event event, cl_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
||||
void hc_clReleaseEvent (OCL_PTR *ocl, cl_event event);
|
||||
cl_int hc_clBuildProgram (OCL_PTR *ocl, cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify) (cl_program program, void *user_data), void *user_data);
|
||||
cl_int hc_clCreateBuffer (OCL_PTR *ocl, cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_mem *mem);
|
||||
cl_int hc_clCreateCommandQueue (OCL_PTR *ocl, cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_command_queue *command_queue);
|
||||
cl_int hc_clCreateContext (OCL_PTR *ocl, cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify) (const char *, const void *, size_t, void *), void *user_data, cl_context *context);
|
||||
cl_int hc_clCreateKernel (OCL_PTR *ocl, cl_program program, const char *kernel_name, cl_kernel *kernel);
|
||||
cl_int hc_clCreateProgramWithBinary (OCL_PTR *ocl, cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_program *program);
|
||||
cl_int hc_clCreateProgramWithSource (OCL_PTR *ocl, cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_program *program);
|
||||
cl_int hc_clEnqueueCopyBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
||||
cl_int hc_clEnqueueMapBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event, void **buf);
|
||||
cl_int hc_clEnqueueNDRangeKernel (OCL_PTR *ocl, 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 hc_clEnqueueReadBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
||||
cl_int hc_clEnqueueUnmapMemObject (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
||||
cl_int hc_clEnqueueWriteBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
||||
cl_int hc_clFinish (OCL_PTR *ocl, cl_command_queue command_queue);
|
||||
cl_int hc_clFlush (OCL_PTR *ocl, cl_command_queue command_queue);
|
||||
cl_int hc_clGetDeviceIDs (OCL_PTR *ocl, cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices);
|
||||
cl_int hc_clGetDeviceInfo (OCL_PTR *ocl, cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
||||
cl_int hc_clGetEventInfo (OCL_PTR *ocl, cl_event event, cl_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
||||
cl_int hc_clGetEventProfilingInfo (OCL_PTR *ocl, cl_event event, cl_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
||||
cl_int hc_clGetKernelWorkGroupInfo (OCL_PTR *ocl, cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
||||
cl_int hc_clGetPlatformIDs (OCL_PTR *ocl, cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms);
|
||||
cl_int hc_clGetPlatformInfo (OCL_PTR *ocl, cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
||||
cl_int hc_clGetProgramBuildInfo (OCL_PTR *ocl, cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
||||
cl_int hc_clGetProgramInfo (OCL_PTR *ocl, cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t * param_value_size_ret);
|
||||
cl_int hc_clReleaseCommandQueue (OCL_PTR *ocl, cl_command_queue command_queue);
|
||||
cl_int hc_clReleaseContext (OCL_PTR *ocl, cl_context context);
|
||||
cl_int hc_clReleaseEvent (OCL_PTR *ocl, cl_event event);
|
||||
cl_int hc_clReleaseKernel (OCL_PTR *ocl, cl_kernel kernel);
|
||||
cl_int hc_clReleaseMemObject (OCL_PTR *ocl, cl_mem mem);
|
||||
cl_int hc_clReleaseProgram (OCL_PTR *ocl, cl_program program);
|
||||
cl_int hc_clSetKernelArg (OCL_PTR *ocl, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value);
|
||||
cl_int hc_clWaitForEvents (OCL_PTR *ocl, cl_uint num_events, const cl_event *event_list);
|
||||
|
||||
#endif
|
||||
|
547
src/ext_OpenCL.c
547
src/ext_OpenCL.c
@ -105,7 +105,6 @@ int ocl_init (OCL_PTR *ocl)
|
||||
HC_LOAD_FUNC(ocl, clCreateProgramWithBinary, OCL_CLCREATEPROGRAMWITHBINARY, OpenCL, 1)
|
||||
HC_LOAD_FUNC(ocl, clCreateProgramWithSource, OCL_CLCREATEPROGRAMWITHSOURCE, OpenCL, 1)
|
||||
HC_LOAD_FUNC(ocl, clEnqueueCopyBuffer, OCL_CLENQUEUECOPYBUFFER, OpenCL, 1)
|
||||
HC_LOAD_FUNC(ocl, clEnqueueFillBuffer, OCL_CLENQUEUEFILLBUFFER, OpenCL, -1)
|
||||
HC_LOAD_FUNC(ocl, clEnqueueMapBuffer, OCL_CLENQUEUEMAPBUFFER, OpenCL, 1)
|
||||
HC_LOAD_FUNC(ocl, clEnqueueNDRangeKernel, OCL_CLENQUEUENDRANGEKERNEL, OpenCL, 1)
|
||||
HC_LOAD_FUNC(ocl, clEnqueueReadBuffer, OCL_CLENQUEUEREADBUFFER, OpenCL, 1)
|
||||
@ -141,490 +140,194 @@ void ocl_close (OCL_PTR *ocl)
|
||||
if (ocl->lib)
|
||||
hc_dlclose (ocl->lib);
|
||||
|
||||
free (ocl);
|
||||
myfree (ocl);
|
||||
}
|
||||
}
|
||||
|
||||
void hc_clEnqueueNDRangeKernel (OCL_PTR *ocl, 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 hc_clEnqueueNDRangeKernel (OCL_PTR *ocl, 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 = ocl->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 : %s\n", "clEnqueueNDRangeKernel()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clEnqueueNDRangeKernel (command_queue, kernel, work_dim, global_work_offset, global_work_size, local_work_size, num_events_in_wait_list, event_wait_list, event);
|
||||
}
|
||||
|
||||
void hc_clGetEventInfo (OCL_PTR *ocl, cl_event event, cl_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
cl_int hc_clGetEventInfo (OCL_PTR *ocl, cl_event event, cl_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
{
|
||||
cl_int CL_err = ocl->clGetEventInfo (event, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clGetEventInfo()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clGetEventInfo (event, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
}
|
||||
|
||||
void hc_clFlush (OCL_PTR *ocl, cl_command_queue command_queue)
|
||||
cl_int hc_clFlush (OCL_PTR *ocl, cl_command_queue command_queue)
|
||||
{
|
||||
cl_int CL_err = ocl->clFlush (command_queue);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clFlush()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clFlush (command_queue);
|
||||
}
|
||||
|
||||
void hc_clFinish (OCL_PTR *ocl, cl_command_queue command_queue)
|
||||
cl_int hc_clFinish (OCL_PTR *ocl, cl_command_queue command_queue)
|
||||
{
|
||||
cl_int CL_err = ocl->clFinish (command_queue);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clFinish()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clFinish (command_queue);
|
||||
}
|
||||
|
||||
void hc_clSetKernelArg (OCL_PTR *ocl, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value)
|
||||
cl_int hc_clSetKernelArg (OCL_PTR *ocl, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value)
|
||||
{
|
||||
cl_int CL_err = ocl->clSetKernelArg (kernel, arg_index, arg_size, arg_value);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clSetKernelArg()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clSetKernelArg (kernel, arg_index, arg_size, arg_value);
|
||||
}
|
||||
|
||||
void hc_clEnqueueWriteBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
||||
cl_int hc_clEnqueueWriteBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
||||
{
|
||||
cl_int CL_err = ocl->clEnqueueWriteBuffer (command_queue, buffer, blocking_write, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clEnqueueWriteBuffer()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clEnqueueWriteBuffer (command_queue, buffer, blocking_write, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event);
|
||||
}
|
||||
|
||||
void hc_clEnqueueCopyBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
||||
cl_int hc_clEnqueueCopyBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
||||
{
|
||||
cl_int CL_err = ocl->clEnqueueCopyBuffer (command_queue, src_buffer, dst_buffer, src_offset, dst_offset, cb, num_events_in_wait_list, event_wait_list, event);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clEnqueueCopyBuffer()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clEnqueueCopyBuffer (command_queue, src_buffer, dst_buffer, src_offset, dst_offset, cb, num_events_in_wait_list, event_wait_list, event);
|
||||
}
|
||||
|
||||
void hc_clEnqueueReadBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
||||
cl_int hc_clEnqueueReadBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
||||
{
|
||||
cl_int CL_err = ocl->clEnqueueReadBuffer (command_queue, buffer, blocking_read, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clEnqueueReadBuffer()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clEnqueueReadBuffer (command_queue, buffer, blocking_read, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event);
|
||||
}
|
||||
|
||||
void hc_clGetPlatformIDs (OCL_PTR *ocl, cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms)
|
||||
cl_int hc_clGetPlatformIDs (OCL_PTR *ocl, cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms)
|
||||
{
|
||||
cl_int CL_err = ocl->clGetPlatformIDs (num_entries, platforms, num_platforms);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clGetPlatformIDs()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clGetPlatformIDs (num_entries, platforms, num_platforms);
|
||||
}
|
||||
|
||||
void hc_clGetPlatformInfo (OCL_PTR *ocl, cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
cl_int hc_clGetPlatformInfo (OCL_PTR *ocl, cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
{
|
||||
cl_int CL_err = ocl->clGetPlatformInfo (platform, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clGetPlatformInfo()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clGetPlatformInfo (platform, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
}
|
||||
|
||||
void hc_clGetDeviceIDs (OCL_PTR *ocl, cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices)
|
||||
cl_int hc_clGetDeviceIDs (OCL_PTR *ocl, cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices)
|
||||
{
|
||||
cl_int CL_err = ocl->clGetDeviceIDs (platform, device_type, num_entries, devices, num_devices);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clGetDeviceIDs()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clGetDeviceIDs (platform, device_type, num_entries, devices, num_devices);
|
||||
}
|
||||
|
||||
void hc_clGetDeviceInfo (OCL_PTR *ocl, cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
cl_int hc_clGetDeviceInfo (OCL_PTR *ocl, cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
{
|
||||
cl_int CL_err = ocl->clGetDeviceInfo (device, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clGetDeviceInfo()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clGetDeviceInfo (device, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
}
|
||||
|
||||
cl_context hc_clCreateContext (OCL_PTR *ocl, cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify) (const char *, const void *, size_t, void *), void *user_data)
|
||||
cl_int hc_clCreateContext (OCL_PTR *ocl, cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify) (const char *, const void *, size_t, void *), void *user_data, cl_context *context)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
cl_context context = ocl->clCreateContext (properties, num_devices, devices, pfn_notify, user_data, &CL_err);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clCreateContext()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
return (context);
|
||||
}
|
||||
|
||||
cl_command_queue hc_clCreateCommandQueue (OCL_PTR *ocl, cl_context context, cl_device_id device, cl_command_queue_properties properties)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
cl_command_queue command_queue = ocl->clCreateCommandQueue (context, device, properties, &CL_err);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clCreateCommandQueue()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
return (command_queue);
|
||||
}
|
||||
|
||||
/*
|
||||
cl_command_queue hc_clCreateCommandQueueWithProperties (cl_context context, cl_device_id device, const cl_queue_properties *properties)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
cl_command_queue command_queue = clCreateCommandQueueWithProperties (context, device, properties, &CL_err);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clCreateCommandQueueWithProperties()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
return (command_queue);
|
||||
}
|
||||
*/
|
||||
|
||||
cl_mem hc_clCreateBuffer (OCL_PTR *ocl, cl_context context, cl_mem_flags flags, size_t size, void *host_ptr)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
cl_mem mem = ocl->clCreateBuffer (context, flags, size, host_ptr, &CL_err);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clCreateBuffer()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
return (mem);
|
||||
}
|
||||
|
||||
cl_program hc_clCreateProgramWithSource (OCL_PTR *ocl, cl_context context, cl_uint count, const char **strings, const size_t *lengths)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
cl_program program = ocl->clCreateProgramWithSource (context, count, strings, lengths, &CL_err);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clCreateProgramWithSource()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
return (program);
|
||||
}
|
||||
|
||||
cl_program hc_clCreateProgramWithBinary (OCL_PTR *ocl, cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
cl_program program = ocl->clCreateProgramWithBinary (context, num_devices, device_list, lengths, binaries, binary_status, &CL_err);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clCreateProgramWithBinary()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
return (program);
|
||||
}
|
||||
|
||||
cl_int hc_clBuildProgram (OCL_PTR *ocl, cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify) (cl_program program, void *user_data), void *user_data, bool exitOnFail)
|
||||
{
|
||||
cl_int CL_err = ocl->clBuildProgram (program, num_devices, device_list, options, pfn_notify, user_data);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
size_t len = strlen (options) + 256;
|
||||
|
||||
char *options_update = (char *) mymalloc (len + 1);
|
||||
|
||||
snprintf (options_update, len, "%s -cl-opt-disable", options);
|
||||
|
||||
if (data.quiet == 0) log_error ("\n=== Build failed, retry with optimization disabled ===\n");
|
||||
|
||||
CL_err = ocl->clBuildProgram (program, num_devices, device_list, options_update, pfn_notify, user_data);
|
||||
|
||||
myfree (options_update);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clBuildProgram()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
log_error ("\n=== Build Options : %s ===\n", options);
|
||||
|
||||
size_t len = 0;
|
||||
|
||||
cl_int err = hc_clGetProgramBuildInfo (ocl, program, *device_list, CL_PROGRAM_BUILD_LOG, 0, NULL, &len);
|
||||
|
||||
if (err == CL_SUCCESS && len > 0)
|
||||
{
|
||||
char *buf = (char *) mymalloc (len + 1);
|
||||
|
||||
if (hc_clGetProgramBuildInfo (ocl, program, *device_list, CL_PROGRAM_BUILD_LOG, len, buf, NULL) == CL_SUCCESS)
|
||||
{
|
||||
fprintf (stderr, "\n=== Build Log (start) ===\n%s\n=== Build Log (end) ===\n", buf);
|
||||
}
|
||||
|
||||
myfree (buf);
|
||||
}
|
||||
|
||||
if (exitOnFail) exit (-1);
|
||||
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
cl_kernel hc_clCreateKernel (OCL_PTR *ocl, cl_program program, const char *kernel_name)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
cl_kernel kernel = ocl->clCreateKernel (program, kernel_name, &CL_err);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s %d - %s\n", "clCreateKernel()", CL_err, kernel_name);
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
return (kernel);
|
||||
}
|
||||
|
||||
void hc_clReleaseMemObject (OCL_PTR *ocl, cl_mem mem)
|
||||
{
|
||||
cl_int CL_err = ocl->clReleaseMemObject (mem);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clReleaseMemObject()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
}
|
||||
|
||||
void hc_clReleaseKernel (OCL_PTR *ocl, cl_kernel kernel)
|
||||
{
|
||||
cl_int CL_err = ocl->clReleaseKernel (kernel);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clReleaseProgram()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
}
|
||||
|
||||
void hc_clReleaseProgram (OCL_PTR *ocl, cl_program program)
|
||||
{
|
||||
cl_int CL_err = ocl->clReleaseProgram (program);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clReleaseProgram()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
}
|
||||
|
||||
void hc_clReleaseCommandQueue (OCL_PTR *ocl, cl_command_queue command_queue)
|
||||
{
|
||||
cl_int CL_err = ocl->clReleaseCommandQueue (command_queue);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clReleaseCommandQueue()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
}
|
||||
|
||||
void hc_clReleaseContext (OCL_PTR *ocl, cl_context context)
|
||||
{
|
||||
cl_int CL_err = ocl->clReleaseContext (context);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clReleaseContext()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
}
|
||||
|
||||
void *hc_clEnqueueMapBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
void *buf = ocl->clEnqueueMapBuffer (command_queue, buffer, blocking_read, map_flags, offset, cb, num_events_in_wait_list, event_wait_list, event, &CL_err);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clEnqueueMapBuffer()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void hc_clEnqueueUnmapMemObject (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
||||
{
|
||||
cl_int CL_err = ocl->clEnqueueUnmapMemObject (command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clEnqueueUnmapMemObject()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
}
|
||||
|
||||
cl_int hc_clEnqueueFillBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, const void *pattern, size_t pattern_size, size_t offset, size_t size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
||||
{
|
||||
cl_int CL_err = -1;
|
||||
|
||||
if (ocl->clEnqueueFillBuffer)
|
||||
{
|
||||
CL_err = ocl->clEnqueueFillBuffer (command_queue, buffer, pattern, pattern_size, offset, size, num_events_in_wait_list, event_wait_list, event);
|
||||
|
||||
if (CL_err != CL_SUCCESS && data.quiet == 0)
|
||||
log_error ("WARNING: %s : %d : %s\n", "clEnqueueFillBuffer()", CL_err, val2cstr_cl (CL_err));
|
||||
}
|
||||
*context = ocl->clCreateContext (properties, num_devices, devices, pfn_notify, user_data, &CL_err);
|
||||
|
||||
return CL_err;
|
||||
}
|
||||
|
||||
void hc_clGetKernelWorkGroupInfo (OCL_PTR *ocl, cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
cl_int hc_clCreateCommandQueue (OCL_PTR *ocl, cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_command_queue *command_queue)
|
||||
{
|
||||
cl_int CL_err = ocl->clGetKernelWorkGroupInfo (kernel, device, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
cl_int CL_err;
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clGetKernelWorkGroupInfo()", CL_err, val2cstr_cl (CL_err));
|
||||
*command_queue = ocl->clCreateCommandQueue (context, device, properties, &CL_err);
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return CL_err;
|
||||
}
|
||||
|
||||
cl_int hc_clCreateBuffer (OCL_PTR *ocl, cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_mem *mem)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
*mem = ocl->clCreateBuffer (context, flags, size, host_ptr, &CL_err);
|
||||
|
||||
return CL_err;
|
||||
}
|
||||
|
||||
cl_int hc_clCreateProgramWithSource (OCL_PTR *ocl, cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_program *program)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
*program = ocl->clCreateProgramWithSource (context, count, strings, lengths, &CL_err);
|
||||
|
||||
return CL_err;
|
||||
}
|
||||
|
||||
cl_int hc_clCreateProgramWithBinary (OCL_PTR *ocl, cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_program *program)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
*program = ocl->clCreateProgramWithBinary (context, num_devices, device_list, lengths, binaries, binary_status, &CL_err);
|
||||
|
||||
return CL_err;
|
||||
}
|
||||
|
||||
cl_int hc_clBuildProgram (OCL_PTR *ocl, cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify) (cl_program program, void *user_data), void *user_data)
|
||||
{
|
||||
return ocl->clBuildProgram (program, num_devices, device_list, options, pfn_notify, user_data);
|
||||
}
|
||||
|
||||
cl_int hc_clCreateKernel (OCL_PTR *ocl, cl_program program, const char *kernel_name, cl_kernel *kernel)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
*kernel = ocl->clCreateKernel (program, kernel_name, &CL_err);
|
||||
|
||||
return CL_err;
|
||||
}
|
||||
|
||||
cl_int hc_clReleaseMemObject (OCL_PTR *ocl, cl_mem mem)
|
||||
{
|
||||
return ocl->clReleaseMemObject (mem);
|
||||
}
|
||||
|
||||
cl_int hc_clReleaseKernel (OCL_PTR *ocl, cl_kernel kernel)
|
||||
{
|
||||
return ocl->clReleaseKernel (kernel);
|
||||
}
|
||||
|
||||
cl_int hc_clReleaseProgram (OCL_PTR *ocl, cl_program program)
|
||||
{
|
||||
return ocl->clReleaseProgram (program);
|
||||
}
|
||||
|
||||
cl_int hc_clReleaseCommandQueue (OCL_PTR *ocl, cl_command_queue command_queue)
|
||||
{
|
||||
return ocl->clReleaseCommandQueue (command_queue);
|
||||
}
|
||||
|
||||
cl_int hc_clReleaseContext (OCL_PTR *ocl, cl_context context)
|
||||
{
|
||||
return ocl->clReleaseContext (context);
|
||||
}
|
||||
|
||||
cl_int hc_clEnqueueMapBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event, void **buf)
|
||||
{
|
||||
cl_int CL_err;
|
||||
|
||||
*buf = ocl->clEnqueueMapBuffer (command_queue, buffer, blocking_read, map_flags, offset, cb, num_events_in_wait_list, event_wait_list, event, &CL_err);
|
||||
|
||||
return CL_err;
|
||||
}
|
||||
|
||||
cl_int hc_clEnqueueUnmapMemObject (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
||||
{
|
||||
return ocl->clEnqueueUnmapMemObject (command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event);
|
||||
}
|
||||
|
||||
cl_int hc_clGetKernelWorkGroupInfo (OCL_PTR *ocl, cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
{
|
||||
return ocl->clGetKernelWorkGroupInfo (kernel, device, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
}
|
||||
|
||||
cl_int hc_clGetProgramBuildInfo (OCL_PTR *ocl, cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
{
|
||||
cl_int CL_err = ocl->clGetProgramBuildInfo (program, device, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clGetProgramBuildInfo()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return CL_err;
|
||||
return ocl->clGetProgramBuildInfo (program, device, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
}
|
||||
|
||||
void hc_clGetProgramInfo (OCL_PTR *ocl, cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
cl_int hc_clGetProgramInfo (OCL_PTR *ocl, cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
{
|
||||
cl_int CL_err = ocl->clGetProgramInfo (program, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clGetProgramInfo()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clGetProgramInfo (program, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
}
|
||||
|
||||
void hc_clWaitForEvents (OCL_PTR *ocl, cl_uint num_events, const cl_event *event_list)
|
||||
cl_int hc_clWaitForEvents (OCL_PTR *ocl, cl_uint num_events, const cl_event *event_list)
|
||||
{
|
||||
cl_int CL_err = ocl->clWaitForEvents (num_events, event_list);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clWaitForEvents()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clWaitForEvents (num_events, event_list);
|
||||
}
|
||||
|
||||
void hc_clGetEventProfilingInfo (OCL_PTR *ocl, cl_event event, cl_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
cl_int hc_clGetEventProfilingInfo (OCL_PTR *ocl, cl_event event, cl_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
||||
{
|
||||
cl_int CL_err = ocl->clGetEventProfilingInfo (event, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clGetEventProfilingInfo()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clGetEventProfilingInfo (event, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
}
|
||||
|
||||
void hc_clReleaseEvent (OCL_PTR *ocl, cl_event event)
|
||||
cl_int hc_clReleaseEvent (OCL_PTR *ocl, cl_event event)
|
||||
{
|
||||
cl_int CL_err = ocl->clReleaseEvent (event);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: %s : %d : %s\n", "clReleaseEvent()", CL_err, val2cstr_cl (CL_err));
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
return ocl->clReleaseEvent (event);
|
||||
}
|
||||
|
2048
src/hashcat.c
2048
src/hashcat.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user