[gegl] opencl: make gegl_cl_is_accelerated() a macro



commit f1ede099814b8bdbb7dded106fc7a4aa5d656975
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Jun 18 07:57:09 2014 +0200

    opencl: make gegl_cl_is_accelerated() a macro
    
    This avoid the function call overhead in code checking whether CL is enabled
    or not; the overhead is noticable when profiling buffer access functions.

 gegl/opencl/gegl-cl-init.c |   16 ++++++----------
 gegl/opencl/gegl-cl-init.h |    4 ++++
 2 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/gegl/opencl/gegl-cl-init.c b/gegl/opencl/gegl-cl-init.c
index 3cc26ab..8ae1ef1 100644
--- a/gegl/opencl/gegl-cl-init.c
+++ b/gegl/opencl/gegl-cl-init.c
@@ -127,9 +127,10 @@ const char *gegl_cl_errstring(cl_int err) {
   return strings[-err];
 }
 
+gboolean _gegl_cl_is_accelerated;
+
 typedef struct
 {
-  gboolean         is_accelerated;
   gboolean         is_loaded;
   gboolean         have_opengl;
   gboolean         hard_disable;
@@ -155,11 +156,6 @@ static cl_device_type gegl_cl_default_device_type = CL_DEVICE_TYPE_DEFAULT;
 static GeglClState cl_state = { 0, };
 static GHashTable *cl_program_hash = NULL;
 
-gboolean
-gegl_cl_is_accelerated (void)
-{
-  return cl_state.is_accelerated;
-}
 
 gboolean
 gegl_cl_has_gl_sharing (void)
@@ -170,14 +166,14 @@ gegl_cl_has_gl_sharing (void)
 void
 gegl_cl_disable (void)
 {
-  cl_state.is_accelerated = FALSE;
+  _gegl_cl_is_accelerated = FALSE;
 }
 
 void
 gegl_cl_hard_disable (void)
 {
   cl_state.hard_disable = TRUE;
-  cl_state.is_accelerated = FALSE;
+  _gegl_cl_is_accelerated = FALSE;
 }
 
 cl_platform_id
@@ -744,7 +740,7 @@ gegl_cl_init_common (cl_device_type          requested_device_type,
 
       if (gl_sharing)
         cl_state.have_opengl = TRUE;
-      cl_state.is_accelerated = TRUE;
+      _gegl_cl_is_accelerated = TRUE;
       cl_state.is_loaded = TRUE;
 
       /* XXX: this dict is being leaked */
@@ -756,7 +752,7 @@ gegl_cl_init_common (cl_device_type          requested_device_type,
     }
 
   if (cl_state.is_loaded)
-    cl_state.is_accelerated = TRUE;
+    _gegl_cl_is_accelerated = TRUE;
 
   return TRUE;
 }
diff --git a/gegl/opencl/gegl-cl-init.h b/gegl/opencl/gegl-cl-init.h
index fd0dfd5..92ddd3b 100644
--- a/gegl/opencl/gegl-cl-init.h
+++ b/gegl/opencl/gegl-cl-init.h
@@ -67,6 +67,10 @@ typedef struct
 GeglClRunData *   gegl_cl_compile_and_build (const char *program_source,
                                              const char *kernel_name[]);
 
+extern gboolean _gegl_cl_is_accelerated;
+
+#define gegl_cl_is_accelerated()   _gegl_cl_is_accelerated
+
 #define GEGL_CL_CHUNK_SIZE 1024 * 1024
 
 #ifdef __GEGL_CL_INIT_MAIN__


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