[gegl/gsoc2011-opencl: 4/12] More OpenCL functions stubs
- From: Victor Matheus de Araujo Oliveira <vmaolive src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/gsoc2011-opencl: 4/12] More OpenCL functions stubs
- Date: Fri, 29 Jul 2011 19:31:03 +0000 (UTC)
commit 77013fe3af13f8bb86a1e54fe373f70dbe5d172d
Author: Victor Oliveira <victormatheus gmail com>
Date: Sat Jul 2 01:31:30 2011 -0300
More OpenCL functions stubs
gegl/opencl/gegl-cl-init.c | 87 ++++++++++++++++++++++++++++++++++++++++++-
gegl/opencl/gegl-cl-init.h | 61 ++++++++++++++++++++++++++++++
gegl/opencl/gegl-cl-types.h | 41 ++++++++++++++++----
3 files changed, 178 insertions(+), 11 deletions(-)
---
diff --git a/gegl/opencl/gegl-cl-init.c b/gegl/opencl/gegl-cl-init.c
index 6a14463..59563a9 100644
--- a/gegl/opencl/gegl-cl-init.c
+++ b/gegl/opencl/gegl-cl-init.c
@@ -3,8 +3,62 @@
#undef __GEGL_CL_INIT_MAIN__
#include <gmodule.h>
+#include <string.h>
#include <stdio.h>
+/* http://forums.amd.com/forum/messageview.cfm?catid=390&threadid=128536 */
+char *gegl_cl_errstring(cl_int err) {
+ switch (err) {
+ case CL_SUCCESS: return strdup("Success!");
+ case CL_DEVICE_NOT_FOUND: return strdup("Device not found.");
+ case CL_DEVICE_NOT_AVAILABLE: return strdup("Device not available");
+ case CL_COMPILER_NOT_AVAILABLE: return strdup("Compiler not available");
+ case CL_MEM_OBJECT_ALLOCATION_FAILURE: return strdup("Memory object allocation failure");
+ case CL_OUT_OF_RESOURCES: return strdup("Out of resources");
+ case CL_OUT_OF_HOST_MEMORY: return strdup("Out of host memory");
+ case CL_PROFILING_INFO_NOT_AVAILABLE: return strdup("Profiling information not available");
+ case CL_MEM_COPY_OVERLAP: return strdup("Memory copy overlap");
+ case CL_IMAGE_FORMAT_MISMATCH: return strdup("Image format mismatch");
+ case CL_IMAGE_FORMAT_NOT_SUPPORTED: return strdup("Image format not supported");
+ case CL_BUILD_PROGRAM_FAILURE: return strdup("Program build failure");
+ case CL_MAP_FAILURE: return strdup("Map failure");
+ case CL_INVALID_VALUE: return strdup("Invalid value");
+ case CL_INVALID_DEVICE_TYPE: return strdup("Invalid device type");
+ case CL_INVALID_PLATFORM: return strdup("Invalid platform");
+ case CL_INVALID_DEVICE: return strdup("Invalid device");
+ case CL_INVALID_CONTEXT: return strdup("Invalid context");
+ case CL_INVALID_QUEUE_PROPERTIES: return strdup("Invalid queue properties");
+ case CL_INVALID_COMMAND_QUEUE: return strdup("Invalid command queue");
+ case CL_INVALID_HOST_PTR: return strdup("Invalid host pointer");
+ case CL_INVALID_MEM_OBJECT: return strdup("Invalid memory object");
+ case CL_INVALID_IMAGE_FORMAT_DESCRIPTOR: return strdup("Invalid image format descriptor");
+ case CL_INVALID_IMAGE_SIZE: return strdup("Invalid image size");
+ case CL_INVALID_SAMPLER: return strdup("Invalid sampler");
+ case CL_INVALID_BINARY: return strdup("Invalid binary");
+ case CL_INVALID_BUILD_OPTIONS: return strdup("Invalid build options");
+ case CL_INVALID_PROGRAM: return strdup("Invalid program");
+ case CL_INVALID_PROGRAM_EXECUTABLE: return strdup("Invalid program executable");
+ case CL_INVALID_KERNEL_NAME: return strdup("Invalid kernel name");
+ case CL_INVALID_KERNEL_DEFINITION: return strdup("Invalid kernel definition");
+ case CL_INVALID_KERNEL: return strdup("Invalid kernel");
+ case CL_INVALID_ARG_INDEX: return strdup("Invalid argument index");
+ case CL_INVALID_ARG_VALUE: return strdup("Invalid argument value");
+ case CL_INVALID_ARG_SIZE: return strdup("Invalid argument size");
+ case CL_INVALID_KERNEL_ARGS: return strdup("Invalid kernel arguments");
+ case CL_INVALID_WORK_DIMENSION: return strdup("Invalid work dimension");
+ case CL_INVALID_WORK_GROUP_SIZE: return strdup("Invalid work group size");
+ case CL_INVALID_WORK_ITEM_SIZE: return strdup("Invalid work item size");
+ case CL_INVALID_GLOBAL_OFFSET: return strdup("Invalid global offset");
+ case CL_INVALID_EVENT_WAIT_LIST: return strdup("Invalid event wait list");
+ case CL_INVALID_EVENT: return strdup("Invalid event");
+ case CL_INVALID_OPERATION: return strdup("Invalid operation");
+ case CL_INVALID_GL_OBJECT: return strdup("Invalid OpenGL object");
+ case CL_INVALID_BUFFER_SIZE: return strdup("Invalid buffer size");
+ case CL_INVALID_MIP_LEVEL: return strdup("Invalid mip-map level");
+ default: return strdup("Unknown");
+ }
+}
+
static gboolean cl_is_accelerated = FALSE;
gboolean
@@ -16,7 +70,7 @@ gegl_cl_is_accelerated (void)
#define CL_LOAD_FUNCTION(func) \
if (!g_module_symbol (module, #func, (gpointer *)& gegl_##func)) \
{ \
- g_set_error (error, 0, 0, \
+ g_set_error (error, 0, 0, \
"%s: %s", "libOpenCL.so", g_module_error ()); \
if (!g_module_close (module)) \
g_warning ("%s: %s", "libOpenCL.so", g_module_error ()); \
@@ -24,7 +78,7 @@ if (!g_module_symbol (module, #func, (gpointer *)& gegl_##func))
} \
if (gegl_##func == NULL) \
{ \
- g_set_error (error, 0, 0, "symbol gegl_##func is NULL"); \
+ g_set_error (error, 0, 0, "symbol gegl_##func is NULL"); \
if (!g_module_close (module)) \
g_warning ("%s: %s", "libOpenCL.so", g_module_error ()); \
return FALSE; \
@@ -50,6 +104,35 @@ gegl_cl_init (GError **error)
CL_LOAD_FUNCTION (clGetPlatformIDs)
CL_LOAD_FUNCTION (clGetPlatformInfo)
+ CL_LOAD_FUNCTION (clGetDeviceIDs)
+ CL_LOAD_FUNCTION (clGetDeviceInfo)
+
+ CL_LOAD_FUNCTION (clCreateContext)
+ CL_LOAD_FUNCTION (clCreateContextFromType)
+ CL_LOAD_FUNCTION (clCreateCommandQueue)
+ CL_LOAD_FUNCTION (clCreateProgramWithSource)
+ CL_LOAD_FUNCTION (clBuildProgram)
+ CL_LOAD_FUNCTION (clGetProgramBuildInfo)
+
+ CL_LOAD_FUNCTION (clCreateKernel)
+ CL_LOAD_FUNCTION (clSetKernelArg)
+ CL_LOAD_FUNCTION (clGetKernelWorkGroupInfo)
+ CL_LOAD_FUNCTION (clCreateBuffer)
+ CL_LOAD_FUNCTION (clEnqueueWriteBuffer)
+ CL_LOAD_FUNCTION (clEnqueueReadBuffer)
+ CL_LOAD_FUNCTION (clEnqueueCopyBuffer)
+ CL_LOAD_FUNCTION (clCreateImage2D)
+ CL_LOAD_FUNCTION (clEnqueueWriteImage)
+ CL_LOAD_FUNCTION (clEnqueueReadImage)
+ CL_LOAD_FUNCTION (clEnqueueCopyImage)
+ CL_LOAD_FUNCTION (clEnqueueNDRangeKernel)
+ CL_LOAD_FUNCTION (clFinish)
+
+ CL_LOAD_FUNCTION (clReleaseKernel)
+ CL_LOAD_FUNCTION (clReleaseProgram)
+ CL_LOAD_FUNCTION (clReleaseCommandQueue)
+ CL_LOAD_FUNCTION (clReleaseContext)
+ CL_LOAD_FUNCTION (clReleaseMemObject)
cl_is_accelerated = TRUE;
}
diff --git a/gegl/opencl/gegl-cl-init.h b/gegl/opencl/gegl-cl-init.h
index 9dc0aba..2016a6e 100644
--- a/gegl/opencl/gegl-cl-init.h
+++ b/gegl/opencl/gegl-cl-init.h
@@ -4,6 +4,8 @@
#include "gegl-cl-types.h"
#include <gmodule.h>
+char *gegl_cl_errstring(cl_int err);
+
gboolean gegl_cl_init (GError **error);
gboolean gegl_cl_is_accelerated (void);
@@ -11,9 +13,68 @@ gboolean gegl_cl_is_accelerated (void);
#ifdef __GEGL_CL_INIT_MAIN__
t_clGetPlatformIDs gegl_clGetPlatformIDs = NULL;
t_clGetPlatformInfo gegl_clGetPlatformInfo = NULL;
+t_clGetDeviceIDs gegl_clGetDeviceIDs = NULL;
+t_clGetDeviceInfo gegl_clGetDeviceInfo = NULL;
+
+t_clCreateContext gegl_clCreateContext = NULL;
+t_clCreateContextFromType gegl_clCreateContextFromType = NULL;
+t_clCreateCommandQueue gegl_clCreateCommandQueue = NULL;
+t_clCreateProgramWithSource gegl_clCreateProgramWithSource = NULL;
+t_clBuildProgram gegl_clBuildProgram = NULL;
+t_clGetProgramBuildInfo gegl_clGetProgramBuildInfo = NULL;
+t_clCreateKernel gegl_clCreateKernel = NULL;
+t_clSetKernelArg gegl_clSetKernelArg = NULL;
+t_clGetKernelWorkGroupInfo gegl_clGetKernelWorkGroupInfo = NULL;
+t_clCreateBuffer gegl_clCreateBuffer = NULL;
+t_clEnqueueWriteBuffer gegl_clEnqueueWriteBuffer = NULL;
+t_clEnqueueReadBuffer gegl_clEnqueueReadBuffer = NULL;
+t_clEnqueueCopyBuffer gegl_clEnqueueCopyBuffer = NULL;
+t_clCreateImage2D gegl_clCreateImage2D = NULL;
+t_clEnqueueWriteImage gegl_clEnqueueWriteImage = NULL;
+t_clEnqueueReadImage gegl_clEnqueueReadImage = NULL;
+t_clEnqueueCopyImage gegl_clEnqueueCopyImage = NULL;
+t_clEnqueueNDRangeKernel gegl_clEnqueueNDRangeKernel = NULL;
+t_clFinish gegl_clFinish = NULL;
+
+t_clReleaseKernel gegl_clReleaseKernel = NULL;
+t_clReleaseProgram gegl_clReleaseProgram = NULL;
+t_clReleaseCommandQueue gegl_clReleaseCommandQueue = NULL;
+t_clReleaseContext gegl_clReleaseContext = NULL;
+t_clReleaseMemObject gegl_clReleaseMemObject = NULL;
+
#else
+
extern t_clGetPlatformIDs gegl_clGetPlatformIDs;
extern t_clGetPlatformInfo gegl_clGetPlatformInfo;
+extern t_clGetDeviceIDs gegl_clGetDeviceIDs;
+extern t_clGetDeviceInfo gegl_clGetDeviceInfo;
+
+extern t_clCreateContext gegl_clCreateContext;
+extern t_clCreateContextFromType gegl_clCreateContextFromType;
+extern t_clCreateCommandQueue gegl_clCreateCommandQueue;
+extern t_clCreateProgramWithSource gegl_clCreateProgramWithSource;
+extern t_clBuildProgram gegl_clBuildProgram;
+extern t_clGetProgramBuildInfo gegl_clGetProgramBuildInfo;
+extern t_clCreateKernel gegl_clCreateKernel;
+extern t_clSetKernelArg gegl_clSetKernelArg;
+extern t_clGetKernelWorkGroupInfo gegl_clGetKernelWorkGroupInfo;
+extern t_clCreateBuffer gegl_clCreateBuffer;
+extern t_clEnqueueWriteBuffer gegl_clEnqueueWriteBuffer;
+extern t_clEnqueueReadBuffer gegl_clEnqueueReadBuffer;
+extern t_clCreateImage2D gegl_clCreateImage2D;
+extern t_clEnqueueWriteImage gegl_clEnqueueWriteImage;
+extern t_clEnqueueReadImage gegl_clEnqueueReadImage;
+extern t_clEnqueueCopyImage gegl_clEnqueueCopyImage;
+extern t_clEnqueueCopyBuffer gegl_clEnqueueCopyBuffer;
+extern t_clEnqueueNDRangeKernel gegl_clEnqueueNDRangeKernel;
+extern t_clFinish gegl_clFinish;
+
+extern t_clReleaseKernel gegl_clReleaseKernel;
+extern t_clReleaseProgram gegl_clReleaseProgram;
+extern t_clReleaseCommandQueue gegl_clReleaseCommandQueue;
+extern t_clReleaseContext gegl_clReleaseContext;
+extern t_clReleaseMemObject gegl_clReleaseMemObject;
+
#endif
#endif /* __GEGL_CL_INIT_H__ */
diff --git a/gegl/opencl/gegl-cl-types.h b/gegl/opencl/gegl-cl-types.h
index 1182c4c..529171c 100644
--- a/gegl/opencl/gegl-cl-types.h
+++ b/gegl/opencl/gegl-cl-types.h
@@ -8,14 +8,37 @@
#include <CL/cl_gl_ext.h>
#include <CL/cl_ext.h>
-typedef cl_int (*t_clGetPlatformIDs)(cl_uint,
- cl_platform_id *,
- cl_uint *);
-
-typedef cl_int (*t_clGetPlatformInfo)(cl_platform_id,
- cl_platform_info,
- size_t,
- void *,
- size_t *);
+typedef cl_int (*t_clGetPlatformIDs) (cl_uint, cl_platform_id *, cl_uint *);
+typedef cl_int (*t_clGetPlatformInfo) (cl_platform_id, cl_platform_info, size_t, void *, size_t *);
+typedef cl_int (*t_clGetDeviceIDs) (cl_platform_id, cl_device_type, cl_uint, cl_device_id *, cl_uint *);
+typedef cl_int (*t_clGetDeviceInfo) (cl_device_id, cl_device_info, size_t, void *, size_t *);
+
+typedef cl_context (*t_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_context (*t_clCreateContextFromType ) (cl_context_properties *, cl_device_type, void (*pfn_notify) (const char *, const void *, size_t, void *), void *, cl_int *);
+typedef cl_command_queue (*t_clCreateCommandQueue ) (cl_context context, cl_device_id device, cl_command_queue_properties, cl_int *);
+typedef cl_program (*t_clCreateProgramWithSource) (cl_context, cl_uint, const char **, const size_t *, cl_int *);
+typedef cl_int (*t_clBuildProgram ) (cl_program, cl_uint, const cl_device_id *, const char *, void (CL_CALLBACK *)(cl_program, void *), void *);
+typedef cl_int (*t_clGetProgramBuildInfo ) (cl_program, cl_device_id, cl_program_build_info, size_t, void *, size_t *);
+typedef cl_kernel (*t_clCreateKernel ) (cl_program, const char *, cl_int *);
+typedef cl_int (*t_clSetKernelArg ) (cl_kernel, cl_uint, size_t, const void *);
+typedef cl_int (*t_clGetKernelWorkGroupInfo ) (cl_kernel, cl_device_id, cl_kernel_work_group_info, size_t, void *, size_t *);
+typedef cl_mem (*t_clCreateBuffer ) (cl_context, cl_mem_flags, size_t, void *, cl_int *);
+typedef cl_int (*t_clEnqueueWriteBuffer ) (cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *);
+typedef cl_int (*t_clEnqueueReadBuffer ) (cl_command_queue, cl_mem, cl_bool, size_t, size_t, void *, cl_uint, const cl_event *, cl_event *);
+typedef cl_int (*t_clEnqueueCopyBuffer ) (cl_command_queue, cl_mem, cl_mem, size_t, size_t, size_t, cl_uint, const cl_event *, cl_event *);
+
+typedef cl_mem (*t_clCreateImage2D ) (cl_context, cl_mem_flags, const cl_image_format *, size_t, size_t, size_t, void *, cl_int *);
+typedef cl_int (*t_clEnqueueReadImage ) (cl_command_queue, cl_mem, cl_bool, const size_t [3], const size_t [3], size_t, size_t, void *, cl_uint, const cl_event *, cl_event *);
+typedef cl_int (*t_clEnqueueWriteImage ) (cl_command_queue, cl_mem, cl_bool, const size_t [3], const size_t [3], size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *);
+typedef cl_int (*t_clEnqueueCopyImage ) (cl_command_queue, cl_mem, cl_mem, const size_t [3], const size_t [3], const size_t [3], cl_uint, const cl_event *, cl_event *);
+
+typedef cl_int (*t_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 (*t_clFinish ) (cl_command_queue);
+
+typedef cl_int (*t_clReleaseKernel ) (cl_kernel);
+typedef cl_int (*t_clReleaseProgram ) (cl_program);
+typedef cl_int (*t_clReleaseCommandQueue) (cl_command_queue);
+typedef cl_int (*t_clReleaseContext ) (cl_context);
+typedef cl_int (*t_clReleaseMemObject ) (cl_mem);
#endif /* __GEGL_CL_TYPES_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]