1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-26 09:58:16 +00:00

Merge pull request #167 from gm4tr1x/issue84

Issue84
This commit is contained in:
Jens Steube 2016-01-27 18:43:18 +01:00
commit cae457df0c
7 changed files with 568 additions and 351 deletions

View File

@ -46,6 +46,8 @@
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
#endif #endif
typedef void *OCL_LIB;
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
typedef void *HM_LIB; typedef void *HM_LIB;
#endif #endif
@ -78,6 +80,8 @@ typedef UINT64 uint64_t;
typedef HINSTANCE HM_LIB; typedef HINSTANCE HM_LIB;
#endif #endif
typedef HINSTANCE OCL_LIB;
#define mkdir(name,mode) mkdir (name) #define mkdir(name,mode) mkdir (name)
#endif // _WIN #endif // _WIN

View File

@ -1,5 +1,7 @@
/** /**
* Author......: Jens Steube <jens.steube@gmail.com> * Authors.....: Jens Steube <jens.steube@gmail.com>
* Gabriele Gristina <matrix@hashcat.net>
*
* License.....: MIT * License.....: MIT
*/ */
@ -25,33 +27,110 @@
// #include <CL/cl_ext.h> // used for CL_DEVICE_TOPOLOGY_AMD but broken for dual GPU // #include <CL/cl_ext.h> // used for CL_DEVICE_TOPOLOGY_AMD but broken for dual GPU
#endif #endif
void hc_clBuildProgram (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); #include <shared.h>
cl_mem hc_clCreateBuffer (cl_context context, cl_mem_flags flags, size_t size, void *host_ptr);
cl_command_queue hc_clCreateCommandQueue (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 (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 (cl_program program, const char *kernel_name);
cl_program hc_clCreateProgramWithSource (cl_context context, cl_uint count, const char **strings, const size_t *lengths);
cl_program hc_clCreateProgramWithBinary (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);
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);
void hc_clEnqueueReadBuffer (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 (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 (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 (cl_command_queue command_queue);
void hc_clFinish (cl_command_queue command_queue);
void hc_clGetDeviceIDs (cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices);
void hc_clGetDeviceInfo (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 (cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms);
void hc_clGetPlatformInfo (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 (cl_command_queue command_queue);
void hc_clReleaseContext (cl_context context);
void hc_clReleaseKernel (cl_kernel kernel);
void hc_clReleaseMemObject (cl_mem mem);
void hc_clReleaseProgram (cl_program program);
void hc_clSetKernelArg (cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value);
void *hc_clEnqueueMapBuffer (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 (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);
void hc_clEnqueueFillBuffer (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 (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);
typedef cl_mem (*OCL_CLCREATEBUFFER) (cl_context, cl_mem_flags, size_t, void *, cl_int *);
typedef cl_command_queue (*OCL_CLCREATECOMMANDQUEUE) (cl_context, cl_device_id, cl_command_queue_properties, cl_int *);
typedef cl_context (*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 (*OCL_CLCREATEKERNEL) (cl_program, const char *, cl_int *);
typedef cl_program (*OCL_CLCREATEPROGRAMWITHSOURCE) (cl_context, cl_uint, const char **, const size_t *, cl_int *);
typedef cl_program (*OCL_CLCREATEPROGRAMWITHBINARY) (cl_context, cl_uint, const cl_device_id *, const size_t *, const unsigned char **, cl_int *, cl_int *);
typedef cl_int (*OCL_CLBUILDPROGRAM) (cl_program, cl_uint, const cl_device_id *, const char *, void (CL_CALLBACK *)(cl_program, void *), void *);
typedef cl_int (*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 (*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 (*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 (*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 (*OCL_CLFLUSH) (cl_command_queue);
typedef cl_int (*OCL_CLFINISH) (cl_command_queue);
typedef cl_int (*OCL_CLGETDEVICEIDS) (cl_platform_id, cl_device_type, cl_uint, cl_device_id *, cl_uint *);
typedef cl_int (*OCL_CLGETDEVICEINFO) (cl_device_id, cl_device_info, size_t, void *, size_t *);
typedef cl_int (*OCL_CLGETPLATFORMIDS) (cl_uint, cl_platform_id *, cl_uint *);
typedef cl_int (*OCL_CLGETPLATFORMINFO) (cl_platform_id, cl_platform_info, size_t, void *, size_t *);
typedef cl_int (*OCL_CLRELEASECOMMANDQUEUE) (cl_command_queue);
typedef cl_int (*OCL_CLRELEASECONTEXT) (cl_context);
typedef cl_int (*OCL_CLRELEASEKERNEL) (cl_kernel);
typedef cl_int (*OCL_CLRELEASEMEMOBJECT) (cl_mem);
typedef cl_int (*OCL_CLRELEASEPROGRAM) (cl_program);
typedef cl_int (*OCL_CLSETKERNELARG) (cl_kernel, cl_uint, size_t, const void *);
typedef void * (*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 (*OCL_CLENQUEUEUNMAPMEMOBJECT) (cl_command_queue, cl_mem, void *, cl_uint, const cl_event *, cl_event *);
typedef cl_int (*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 (*OCL_CLGETKERNELWORKGROUPINFO) (cl_kernel, cl_device_id, cl_kernel_work_group_info, size_t, void *, size_t *);
typedef cl_int (*OCL_CLGETPROGRAMBUILDINFO) (cl_program, cl_device_id, cl_program_build_info, size_t, void *, size_t *);
typedef cl_int (*OCL_CLGETPROGRAMINFO) (cl_program, cl_program_info, size_t, void *, size_t *);
typedef cl_int (*OCL_CLGETEVENTINFO) (cl_event, cl_event_info, size_t, void *, size_t *);
typedef struct
{
OCL_LIB lib;
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;
} hc_opencl_lib_t;
#define OCL_PTR hc_opencl_lib_t
void 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);
void 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);
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);
void 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);
void 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);
#endif #endif

View File

@ -46,6 +46,20 @@
#endif #endif
/**
* libraries stuff
*/
#ifdef _WIN
#define hc_dlopen LoadLibrary
#define hc_dlclose FreeLibrary
#define hc_dlsym GetProcAddress
#else
#define hc_dlopen dlopen
#define hc_dlclose dlclose
#define hc_dlsym dlsym
#endif
/** /**
* system stuff * system stuff
*/ */

View File

@ -1057,6 +1057,12 @@ typedef struct
int rule_len_l; int rule_len_l;
int rule_len_r; int rule_len_r;
/**
* opencl
*/
void *ocl;
/** /**
* hardware watchdog * hardware watchdog
*/ */

View File

@ -142,7 +142,7 @@ BINARY_NATIVE := $(PROG_NAME).app
CFLAGS_NATIVE := -D_POSIX -DOSX CFLAGS_NATIVE := -D_POSIX -DOSX
CFLAGS_NATIVE += $(CFLAGS) CFLAGS_NATIVE += $(CFLAGS)
LFLAGS_NATIVE := -framework OpenCL -lpthread LFLAGS_NATIVE := -lpthread
FOUND_ADL := 0 FOUND_ADL := 0
FOUND_NVML := 0 FOUND_NVML := 0
@ -152,10 +152,9 @@ ifeq ($(UNAME),Linux)
CFLAGS_NATIVE := -D_POSIX -DLINUX CFLAGS_NATIVE := -D_POSIX -DLINUX
CFLAGS_NATIVE += -s $(CFLAGS) CFLAGS_NATIVE += -s $(CFLAGS)
LFLAGS_NATIVE := -lOpenCL -lpthread LFLAGS_NATIVE := -lpthread -ldl
ifneq (,$(filter 1,$(FOUND_ADL) $(FOUND_NVML))) ifneq (,$(filter 1,$(FOUND_ADL) $(FOUND_NVML)))
LFLAGS_NATIVE += -ldl
CFLAGS_NATIVE += -DHAVE_HWMON CFLAGS_NATIVE += -DHAVE_HWMON
ifeq ($(FOUND_ADL),1) ifeq ($(FOUND_ADL),1)
CFLAGS_NATIVE += -DHAVE_ADL -I$(ADL)/include/ CFLAGS_NATIVE += -DHAVE_ADL -I$(ADL)/include/
@ -206,7 +205,7 @@ endif
CFLAGS_CROSS_32 := -m32 CFLAGS_CROSS_32 := -m32
CFLAGS_CROSS_64 := -m64 CFLAGS_CROSS_64 := -m64
LFLAGS_CROSS_LINUX := -lpthread -lOpenCL -ldl LFLAGS_CROSS_LINUX := -lpthread -ldl
LFLAGS_CROSS_WIN := -lpsapi LFLAGS_CROSS_WIN := -lpsapi
## ##
@ -347,8 +346,8 @@ oclHashcat32.bin: src/oclHashcat.c $(LINUX_32_OBJS)
oclHashcat64.bin: src/oclHashcat.c $(LINUX_64_OBJS) oclHashcat64.bin: src/oclHashcat.c $(LINUX_64_OBJS)
$(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DVERSION_SUM=\"$(VERSION_SUM)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" $(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DVERSION_SUM=\"$(VERSION_SUM)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
oclHashcat32.exe: src/oclHashcat.c $(WIN_32_OBJS) lib/libOpenCL.a oclHashcat32.exe: src/oclHashcat.c $(WIN_32_OBJS)
$(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DVERSION_SUM=\"$(VERSION_SUM)\" -static-libgcc $(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DVERSION_SUM=\"$(VERSION_SUM)\" -static-libgcc
oclHashcat64.exe: src/oclHashcat.c $(WIN_64_OBJS) lib/libOpenCL64.a oclHashcat64.exe: src/oclHashcat.c $(WIN_64_OBJS)
$(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DVERSION_SUM=\"$(VERSION_SUM)\" -static-libgcc $(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DVERSION_SUM=\"$(VERSION_SUM)\" -static-libgcc

View File

@ -1,5 +1,7 @@
/** /**
* Author......: Jens Steube <jens.steube@gmail.com> * Authors.....: Jens Steube <jens.steube@gmail.com>
* Gabriele Gristina <matrix@hashcat.net>
*
* License.....: MIT * License.....: MIT
*/ */
@ -54,9 +56,78 @@ const char *val2cstr_cl (cl_int CL_err)
return "CL_UNKNOWN_ERROR"; 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) #define LOAD_FUNC(ptr,name,type) \
ptr->name = (type) hc_dlsym (ptr->lib, #name); \
if (!ptr->name) { \
log_error ("ERROR: #name is missing from opencl shared library"); \
exit (-1); \
}
void ocl_init (OCL_PTR *ocl)
{ {
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); memset (ocl, 0, sizeof (hc_opencl_lib_t));
#ifdef _WIN
ocl->lib = hc_dlopen ("OpenCL");
#elif OSX
ocl->lib = hc_dlopen ("/System/Library/Frameworks/OpenCL.framework/OpenCL", RTLD_NOW);
#else
ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
#endif
if (!ocl->lib)
{
log_error ("ERROR: cannot load opencl library");
exit (-1);
}
LOAD_FUNC(ocl, clBuildProgram, OCL_CLBUILDPROGRAM)
LOAD_FUNC(ocl, clCreateBuffer, OCL_CLCREATEBUFFER)
LOAD_FUNC(ocl, clCreateCommandQueue, OCL_CLCREATECOMMANDQUEUE)
LOAD_FUNC(ocl, clCreateContext, OCL_CLCREATECONTEXT)
LOAD_FUNC(ocl, clCreateKernel, OCL_CLCREATEKERNEL)
LOAD_FUNC(ocl, clCreateProgramWithBinary, OCL_CLCREATEPROGRAMWITHBINARY)
LOAD_FUNC(ocl, clCreateProgramWithSource, OCL_CLCREATEPROGRAMWITHSOURCE)
LOAD_FUNC(ocl, clEnqueueCopyBuffer, OCL_CLENQUEUECOPYBUFFER)
LOAD_FUNC(ocl, clEnqueueFillBuffer, OCL_CLENQUEUEFILLBUFFER)
LOAD_FUNC(ocl, clEnqueueMapBuffer, OCL_CLENQUEUEMAPBUFFER)
LOAD_FUNC(ocl, clEnqueueNDRangeKernel, OCL_CLENQUEUENDRANGEKERNEL)
LOAD_FUNC(ocl, clEnqueueReadBuffer, OCL_CLENQUEUEREADBUFFER)
LOAD_FUNC(ocl, clEnqueueUnmapMemObject, OCL_CLENQUEUEUNMAPMEMOBJECT)
LOAD_FUNC(ocl, clEnqueueWriteBuffer, OCL_CLENQUEUEWRITEBUFFER)
LOAD_FUNC(ocl, clFinish, OCL_CLFINISH)
LOAD_FUNC(ocl, clFlush, OCL_CLFLUSH)
LOAD_FUNC(ocl, clGetDeviceIDs, OCL_CLGETDEVICEIDS)
LOAD_FUNC(ocl, clGetDeviceInfo, OCL_CLGETDEVICEINFO)
LOAD_FUNC(ocl, clGetEventInfo, OCL_CLGETEVENTINFO)
LOAD_FUNC(ocl, clGetKernelWorkGroupInfo, OCL_CLGETKERNELWORKGROUPINFO)
LOAD_FUNC(ocl, clGetPlatformIDs, OCL_CLGETPLATFORMIDS)
LOAD_FUNC(ocl, clGetPlatformInfo, OCL_CLGETPLATFORMINFO)
LOAD_FUNC(ocl, clGetProgramBuildInfo, OCL_CLGETPROGRAMBUILDINFO)
LOAD_FUNC(ocl, clGetProgramInfo, OCL_CLGETPROGRAMINFO)
LOAD_FUNC(ocl, clReleaseCommandQueue, OCL_CLRELEASECOMMANDQUEUE)
LOAD_FUNC(ocl, clReleaseContext, OCL_CLRELEASECONTEXT)
LOAD_FUNC(ocl, clReleaseKernel, OCL_CLRELEASEKERNEL)
LOAD_FUNC(ocl, clReleaseMemObject, OCL_CLRELEASEMEMOBJECT)
LOAD_FUNC(ocl, clReleaseProgram, OCL_CLRELEASEPROGRAM)
LOAD_FUNC(ocl, clSetKernelArg, OCL_CLSETKERNELARG)
}
void ocl_close (OCL_PTR *ocl)
{
if (ocl)
{
if (ocl->lib)
hc_dlclose (ocl->lib);
free (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 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) if (CL_err != CL_SUCCESS)
{ {
@ -66,9 +137,9 @@ void hc_clEnqueueNDRangeKernel (cl_command_queue command_queue, cl_kernel kernel
} }
} }
void hc_clGetEventInfo (cl_event event, cl_event_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)
{ {
cl_int CL_err = clGetEventInfo (event, param_name, param_value_size, param_value, 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) if (CL_err != CL_SUCCESS)
{ {
@ -78,9 +149,9 @@ void hc_clGetEventInfo (cl_event event, cl_event_info param_name, size_t param_v
} }
} }
void hc_clFlush (cl_command_queue command_queue) void hc_clFlush (OCL_PTR *ocl, cl_command_queue command_queue)
{ {
cl_int CL_err = clFlush (command_queue); cl_int CL_err = ocl->clFlush (command_queue);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -90,9 +161,9 @@ void hc_clFlush (cl_command_queue command_queue)
} }
} }
void hc_clFinish (cl_command_queue command_queue) void hc_clFinish (OCL_PTR *ocl, cl_command_queue command_queue)
{ {
cl_int CL_err = clFinish (command_queue); cl_int CL_err = ocl->clFinish (command_queue);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -102,9 +173,9 @@ void hc_clFinish (cl_command_queue command_queue)
} }
} }
void hc_clSetKernelArg (cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value) void hc_clSetKernelArg (OCL_PTR *ocl, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value)
{ {
cl_int CL_err = clSetKernelArg (kernel, arg_index, arg_size, arg_value); cl_int CL_err = ocl->clSetKernelArg (kernel, arg_index, arg_size, arg_value);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -114,9 +185,9 @@ void hc_clSetKernelArg (cl_kernel kernel, cl_uint arg_index, size_t arg_size, co
} }
} }
void hc_clEnqueueWriteBuffer (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_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 = clEnqueueWriteBuffer (command_queue, buffer, blocking_write, offset, cb, ptr, num_events_in_wait_list, event_wait_list, 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) if (CL_err != CL_SUCCESS)
{ {
@ -126,9 +197,9 @@ void hc_clEnqueueWriteBuffer (cl_command_queue command_queue, cl_mem buffer, cl_
} }
} }
void hc_clEnqueueCopyBuffer (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_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 = clEnqueueCopyBuffer (command_queue, src_buffer, dst_buffer, src_offset, dst_offset, cb, num_events_in_wait_list, event_wait_list, 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) if (CL_err != CL_SUCCESS)
{ {
@ -138,9 +209,9 @@ void hc_clEnqueueCopyBuffer (cl_command_queue command_queue, cl_mem src_buffer,
} }
} }
void hc_clEnqueueReadBuffer (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_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 = clEnqueueReadBuffer (command_queue, buffer, blocking_read, offset, cb, ptr, num_events_in_wait_list, event_wait_list, 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) if (CL_err != CL_SUCCESS)
{ {
@ -150,9 +221,9 @@ void hc_clEnqueueReadBuffer (cl_command_queue command_queue, cl_mem buffer, cl_b
} }
} }
void hc_clGetPlatformIDs (cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms) void hc_clGetPlatformIDs (OCL_PTR *ocl, cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms)
{ {
cl_int CL_err = clGetPlatformIDs (num_entries, platforms, num_platforms); cl_int CL_err = ocl->clGetPlatformIDs (num_entries, platforms, num_platforms);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -162,9 +233,9 @@ void hc_clGetPlatformIDs (cl_uint num_entries, cl_platform_id *platforms, cl_uin
} }
} }
void hc_clGetPlatformInfo (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_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 = clGetPlatformInfo (platform, param_name, param_value_size, param_value, 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) if (CL_err != CL_SUCCESS)
{ {
@ -174,9 +245,9 @@ void hc_clGetPlatformInfo (cl_platform_id platform, cl_platform_info param_name,
} }
} }
void hc_clGetDeviceIDs (cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices) 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 CL_err = clGetDeviceIDs (platform, device_type, num_entries, devices, num_devices); cl_int CL_err = ocl->clGetDeviceIDs (platform, device_type, num_entries, devices, num_devices);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -186,9 +257,9 @@ void hc_clGetDeviceIDs (cl_platform_id platform, cl_device_type device_type, cl_
} }
} }
void hc_clGetDeviceInfo (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_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 = clGetDeviceInfo (device, param_name, param_value_size, param_value, 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) if (CL_err != CL_SUCCESS)
{ {
@ -198,11 +269,11 @@ void hc_clGetDeviceInfo (cl_device_id device, cl_device_info param_name, size_t
} }
} }
cl_context hc_clCreateContext (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 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 CL_err; cl_int CL_err;
cl_context context = clCreateContext (properties, num_devices, devices, pfn_notify, user_data, &CL_err); cl_context context = ocl->clCreateContext (properties, num_devices, devices, pfn_notify, user_data, &CL_err);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -214,12 +285,11 @@ cl_context hc_clCreateContext (cl_context_properties *properties, cl_uint num_de
return (context); return (context);
} }
cl_command_queue hc_clCreateCommandQueue (OCL_PTR *ocl, cl_context context, cl_device_id device, cl_command_queue_properties properties)
cl_command_queue hc_clCreateCommandQueue (cl_context context, cl_device_id device, cl_command_queue_properties properties)
{ {
cl_int CL_err; cl_int CL_err;
cl_command_queue command_queue = clCreateCommandQueue (context, device, properties, &CL_err); cl_command_queue command_queue = ocl->clCreateCommandQueue (context, device, properties, &CL_err);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -249,11 +319,11 @@ cl_command_queue hc_clCreateCommandQueueWithProperties (cl_context context, cl_d
} }
*/ */
cl_mem hc_clCreateBuffer (cl_context context, cl_mem_flags flags, size_t size, void *host_ptr) 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_int CL_err;
cl_mem mem = clCreateBuffer (context, flags, size, host_ptr, &CL_err); cl_mem mem = ocl->clCreateBuffer (context, flags, size, host_ptr, &CL_err);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -265,11 +335,11 @@ cl_mem hc_clCreateBuffer (cl_context context, cl_mem_flags flags, size_t size, v
return (mem); return (mem);
} }
cl_program hc_clCreateProgramWithSource (cl_context context, cl_uint count, const char **strings, const size_t *lengths) 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_int CL_err;
cl_program program = clCreateProgramWithSource (context, count, strings, lengths, &CL_err); cl_program program = ocl->clCreateProgramWithSource (context, count, strings, lengths, &CL_err);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -281,11 +351,11 @@ cl_program hc_clCreateProgramWithSource (cl_context context, cl_uint count, cons
return (program); return (program);
} }
cl_program hc_clCreateProgramWithBinary (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 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_int CL_err;
cl_program program = clCreateProgramWithBinary (context, num_devices, device_list, lengths, binaries, binary_status, &CL_err); cl_program program = ocl->clCreateProgramWithBinary (context, num_devices, device_list, lengths, binaries, binary_status, &CL_err);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -297,9 +367,9 @@ cl_program hc_clCreateProgramWithBinary (cl_context context, cl_uint num_devices
return (program); return (program);
} }
void hc_clBuildProgram (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) void 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 CL_err = clBuildProgram (program, num_devices, device_list, options, pfn_notify, user_data); cl_int CL_err = ocl->clBuildProgram (program, num_devices, device_list, options, pfn_notify, user_data);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -310,11 +380,11 @@ void hc_clBuildProgram (cl_program program, cl_uint num_devices, const cl_device
} }
} }
cl_kernel hc_clCreateKernel (cl_program program, const char *kernel_name) cl_kernel hc_clCreateKernel (OCL_PTR *ocl, cl_program program, const char *kernel_name)
{ {
cl_int CL_err; cl_int CL_err;
cl_kernel kernel = clCreateKernel (program, kernel_name, &CL_err); cl_kernel kernel = ocl->clCreateKernel (program, kernel_name, &CL_err);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -326,9 +396,9 @@ cl_kernel hc_clCreateKernel (cl_program program, const char *kernel_name)
return (kernel); return (kernel);
} }
void hc_clReleaseMemObject (cl_mem mem) void hc_clReleaseMemObject (OCL_PTR *ocl, cl_mem mem)
{ {
cl_int CL_err = clReleaseMemObject (mem); cl_int CL_err = ocl->clReleaseMemObject (mem);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -338,9 +408,9 @@ void hc_clReleaseMemObject (cl_mem mem)
} }
} }
void hc_clReleaseKernel (cl_kernel kernel) void hc_clReleaseKernel (OCL_PTR *ocl, cl_kernel kernel)
{ {
cl_int CL_err = clReleaseKernel (kernel); cl_int CL_err = ocl->clReleaseKernel (kernel);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -350,9 +420,9 @@ void hc_clReleaseKernel (cl_kernel kernel)
} }
} }
void hc_clReleaseProgram (cl_program program) void hc_clReleaseProgram (OCL_PTR *ocl, cl_program program)
{ {
cl_int CL_err = clReleaseProgram (program); cl_int CL_err = ocl->clReleaseProgram (program);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -362,9 +432,9 @@ void hc_clReleaseProgram (cl_program program)
} }
} }
void hc_clReleaseCommandQueue (cl_command_queue command_queue) void hc_clReleaseCommandQueue (OCL_PTR *ocl, cl_command_queue command_queue)
{ {
cl_int CL_err = clReleaseCommandQueue (command_queue); cl_int CL_err = ocl->clReleaseCommandQueue (command_queue);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -374,9 +444,9 @@ void hc_clReleaseCommandQueue (cl_command_queue command_queue)
} }
} }
void hc_clReleaseContext (cl_context context) void hc_clReleaseContext (OCL_PTR *ocl, cl_context context)
{ {
cl_int CL_err = clReleaseContext (context); cl_int CL_err = ocl->clReleaseContext (context);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -386,11 +456,11 @@ void hc_clReleaseContext (cl_context context)
} }
} }
void *hc_clEnqueueMapBuffer (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 *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; cl_int CL_err;
void *buf = clEnqueueMapBuffer (command_queue, buffer, blocking_read, map_flags, offset, cb, num_events_in_wait_list, event_wait_list, event, &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) if (CL_err != CL_SUCCESS)
{ {
@ -402,9 +472,9 @@ void *hc_clEnqueueMapBuffer (cl_command_queue command_queue, cl_mem buffer, cl_b
return buf; return buf;
} }
void hc_clEnqueueUnmapMemObject (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) 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 = clEnqueueUnmapMemObject (command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, 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) if (CL_err != CL_SUCCESS)
{ {
@ -414,9 +484,9 @@ void hc_clEnqueueUnmapMemObject (cl_command_queue command_queue, cl_mem memobj,
} }
} }
void hc_clEnqueueFillBuffer (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_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 = clEnqueueFillBuffer (command_queue, buffer, pattern, pattern_size, offset, size, num_events_in_wait_list, event_wait_list, event); cl_int 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) if (CL_err != CL_SUCCESS)
{ {
@ -426,9 +496,9 @@ void hc_clEnqueueFillBuffer (cl_command_queue command_queue, cl_mem buffer, cons
} }
} }
void hc_clGetKernelWorkGroupInfo (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) 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 CL_err = clGetKernelWorkGroupInfo (kernel, device, param_name, param_value_size, param_value, param_value_size_ret); cl_int CL_err = ocl->clGetKernelWorkGroupInfo (kernel, device, param_name, param_value_size, param_value, param_value_size_ret);
if (CL_err != CL_SUCCESS) if (CL_err != CL_SUCCESS)
{ {
@ -437,3 +507,27 @@ void hc_clGetKernelWorkGroupInfo (cl_kernel kernel, cl_device_id device, cl_kern
exit (-1); exit (-1);
} }
} }
void 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));
exit (-1);
}
}
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 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);
}
}

File diff suppressed because it is too large Load Diff