[gegl] Add gegl_cl_set_profiling()



commit a2bd108c4c68680461e436207d548c1642392a0b
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Fri Nov 1 13:45:02 2013 -0700

    Add gegl_cl_set_profiling()
    
    Must be called before cl_init() is, so before "use-opencl" is set
    to TRUE.

 gegl/opencl/gegl-cl-init.c  |   18 +++++++++++++++++-
 gegl/opencl/gegl-cl-init.h  |    6 ++++++
 gegl/opencl/gegl-cl-types.h |    1 +
 3 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/gegl/opencl/gegl-cl-init.c b/gegl/opencl/gegl-cl-init.c
index 9ac6fc5..c6e85d4 100644
--- a/gegl/opencl/gegl-cl-init.c
+++ b/gegl/opencl/gegl-cl-init.c
@@ -131,6 +131,7 @@ typedef struct
   gboolean         is_accelerated;
   gboolean         is_loaded;
   gboolean         hard_disable;
+  gboolean         enable_profiling;
   cl_context       ctx;
   cl_platform_id   platform;
   cl_device_id     device;
@@ -212,6 +213,14 @@ gegl_cl_get_iter_height (void)
   return cl_state.iter_height;
 }
 
+void
+gegl_cl_set_profiling (gboolean enable)
+{
+  g_return_if_fail (!cl_state.is_loaded);
+
+  cl_state.enable_profiling = enable;
+}
+
 #ifdef G_OS_WIN32
 
 #include <windows.h>
@@ -323,6 +332,8 @@ gegl_cl_init (GError **error)
       CL_LOAD_FUNCTION (clEnqueueBarrier)
       CL_LOAD_FUNCTION (clFinish)
 
+      CL_LOAD_FUNCTION (clGetEventProfilingInfo)
+
       CL_LOAD_FUNCTION (clReleaseKernel)
       CL_LOAD_FUNCTION (clReleaseProgram)
       CL_LOAD_FUNCTION (clReleaseCommandQueue)
@@ -397,7 +408,12 @@ gegl_cl_init (GError **error)
           return FALSE;
         }
 
-      cl_state.cq  = gegl_clCreateCommandQueue(cl_state.ctx, cl_state.device, 0, &err);
+      {
+        cl_command_queue_properties command_queue_flags = 0;
+        if (cl_state.enable_profiling)
+          command_queue_flags |= CL_QUEUE_PROFILING_ENABLE;
+        cl_state.cq = gegl_clCreateCommandQueue(cl_state.ctx, cl_state.device, command_queue_flags, &err);
+      }
 
       if(err != CL_SUCCESS)
         {
diff --git a/gegl/opencl/gegl-cl-init.h b/gegl/opencl/gegl-cl-init.h
index ac527be..4e241f1 100644
--- a/gegl/opencl/gegl-cl-init.h
+++ b/gegl/opencl/gegl-cl-init.h
@@ -45,6 +45,8 @@ size_t            gegl_cl_get_iter_width (void);
 
 size_t            gegl_cl_get_iter_height (void);
 
+void              gegl_cl_set_profiling (gboolean enable);
+
 typedef struct
 {
   cl_program  program;
@@ -91,6 +93,8 @@ t_clEnqueueNDRangeKernel    gegl_clEnqueueNDRangeKernel    = NULL;
 t_clEnqueueBarrier          gegl_clEnqueueBarrier          = NULL;
 t_clFinish                  gegl_clFinish                  = NULL;
 
+t_clGetEventProfilingInfo   gegl_clGetEventProfilingInfo   = NULL;
+
 t_clEnqueueMapBuffer        gegl_clEnqueueMapBuffer        = NULL;
 t_clEnqueueMapImage         gegl_clEnqueueMapImage         = NULL;
 t_clEnqueueUnmapMemObject   gegl_clEnqueueUnmapMemObject   = NULL;
@@ -135,6 +139,8 @@ extern t_clEnqueueNDRangeKernel    gegl_clEnqueueNDRangeKernel;
 extern t_clEnqueueBarrier          gegl_clEnqueueBarrier;
 extern t_clFinish                  gegl_clFinish;
 
+extern t_clGetEventProfilingInfo   gegl_clGetEventProfilingInfo;
+
 extern t_clEnqueueMapBuffer        gegl_clEnqueueMapBuffer;
 extern t_clEnqueueMapImage         gegl_clEnqueueMapImage;
 extern t_clEnqueueUnmapMemObject   gegl_clEnqueueUnmapMemObject;
diff --git a/gegl/opencl/gegl-cl-types.h b/gegl/opencl/gegl-cl-types.h
index ae83aa1..69a9a3e 100644
--- a/gegl/opencl/gegl-cl-types.h
+++ b/gegl/opencl/gegl-cl-types.h
@@ -77,6 +77,7 @@ typedef CL_API_ENTRY void *            (CL_API_CALL *t_clEnqueueMapBuffer
 typedef CL_API_ENTRY void *            (CL_API_CALL *t_clEnqueueMapImage        ) (cl_command_queue, cl_mem, 
cl_bool, cl_map_flags, const size_t [3], const size_t [3], size_t *, size_t *, cl_uint, const cl_event *, 
cl_event *, cl_int *);
 typedef CL_API_ENTRY cl_int            (CL_API_CALL *t_clEnqueueUnmapMemObject  ) (cl_command_queue, cl_mem, 
void *, cl_uint, const cl_event *, cl_event *);
 
+typedef CL_API_ENTRY cl_int            (CL_API_CALL *t_clGetEventProfilingInfo  ) (cl_event, 
cl_profiling_info, size_t, void *, size_t *);
 
 typedef CL_API_ENTRY cl_int            (CL_API_CALL *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_API_ENTRY cl_int            (CL_API_CALL *t_clEnqueueBarrier         ) (cl_command_queue);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]