[gegl] gegl, opencl: share informations in a private header with opencl



commit 814fcddcda5abf6bc9817f58dc79e910858c81b5
Author: Carlos Zubieta <czubieta dev gmail com>
Date:   Tue Oct 22 11:58:59 2013 +0200

    gegl,opencl: share informations in a private header with opencl

 gegl/Makefile.am             |    1 +
 gegl/gegl-random-priv.h      |   28 ++++++++++++++++++++++++++++
 gegl/gegl-random.c           |    5 ++---
 gegl/opencl/gegl-cl-random.c |   36 ++++++++++++++++++------------------
 gegl/opencl/gegl-cl-random.h |   14 ++------------
 5 files changed, 51 insertions(+), 33 deletions(-)
---
diff --git a/gegl/Makefile.am b/gegl/Makefile.am
index f7d239a..847ce7d 100644
--- a/gegl/Makefile.am
+++ b/gegl/Makefile.am
@@ -97,6 +97,7 @@ GEGL_sources = \
        gegl-matrix.h                   \
        gegl-module.h                   \
        gegl-plugin.h                   \
+       gegl-random-priv.h              \
        gegl-types-internal.h           \
        gegl-xml.h
 
diff --git a/gegl/gegl-random-priv.h b/gegl/gegl-random-priv.h
new file mode 100644
index 0000000..c5e2391
--- /dev/null
+++ b/gegl/gegl-random-priv.h
@@ -0,0 +1,28 @@
+/* This file is part of GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2012, 2013 Øyvind Kolås
+ */
+
+#ifndef __GEGL_RANDOM_PRIV_H__
+#define __GEGL_RANDOM_PRIV_H__
+
+#define PRIMES_SIZE       533
+#define RANDOM_DATA_SIZE (15083+15091+15101)
+
+void
+gegl_random_init (void);
+
+#endif /* __GEGL_RANDOM_PRIV_H__ */
diff --git a/gegl/gegl-random.c b/gegl/gegl-random.c
index 496417d..8328131 100644
--- a/gegl/gegl-random.c
+++ b/gegl/gegl-random.c
@@ -38,10 +38,11 @@
 
 #include <glib.h>
 #include <gegl.h>
+#include "gegl-random-priv.h"
 
 /* a set of reasonably large primes to choose from for array sizes
  */
-long gegl_random_primes[]={
+long gegl_random_primes[PRIMES_SIZE]={
 10007,10009,10037,10039,10061,10067,10069,10079,10091,10093,10099,10103,10111,
 10133,10139,10141,10151,10159,10163,10169,10177,10181,10193,10211,10223,10243,
 10247,10253,10259,10267,10271,10273,10289,10301,10303,10313,10321,10331,10333,
@@ -91,8 +92,6 @@ long gegl_random_primes[]={
 #define NPRIME     101111
 #define MAX_TABLES 3
 
-#define RANDOM_DATA_SIZE (15083+15091+15101)
-
 gint32          gegl_random_data[RANDOM_DATA_SIZE];
 static gboolean random_data_inited = FALSE;
 
diff --git a/gegl/opencl/gegl-cl-random.c b/gegl/opencl/gegl-cl-random.c
index efd7c97..4724cd5 100644
--- a/gegl/opencl/gegl-cl-random.c
+++ b/gegl/opencl/gegl-cl-random.c
@@ -19,35 +19,35 @@
 #include <glib.h>
 #include "gegl-cl-random.h"
 #include "opencl/gegl-cl.h"
+#include "gegl-random-priv.h"
 
 /*XXX: defined in gegl-random.c*/
-#define RANDOM_DATA_SIZE (15083+15091+15101)
-#define PRIMES_SIZE 533
 
-extern gint32      *gegl_random_data;
-extern long        *gegl_random_primes;
-extern inline void gegl_random_init (void);
+extern gint32 *gegl_random_data;
+extern long   *gegl_random_primes;
 
-cl_mem gegl_cl_load_random_data(int *cl_err)
+cl_mem
+gegl_cl_load_random_data (gint *cl_err)
 {
-  gegl_random_init();
   cl_mem cl_random_data;
-  cl_random_data = gegl_clCreateBuffer(gegl_cl_get_context(),
-                                       CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY,
-                                       RANDOM_DATA_SIZE*sizeof(gint32),
-                                       (void*) &gegl_random_data,
-                                       cl_err);
+  gegl_random_init ();
+  cl_random_data = gegl_clCreateBuffer (gegl_cl_get_context (),
+                                        CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY,
+                                        RANDOM_DATA_SIZE * sizeof (gint32),
+                                        (void*) &gegl_random_data,
+                                        cl_err);
   return cl_random_data;
 }
 
-cl_mem gegl_cl_load_random_primes(int *cl_err)
+cl_mem
+gegl_cl_load_random_primes (gint *cl_err)
 {
   cl_mem cl_random_primes;
-  cl_random_primes = gegl_clCreateBuffer(gegl_cl_get_context(),
-                                         CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY,
-                                         PRIMES_SIZE*sizeof(long),
-                                         (void*) &gegl_random_primes,
-                                         cl_err);
+  cl_random_primes = gegl_clCreateBuffer (gegl_cl_get_context (),
+                                          CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY,
+                                          PRIMES_SIZE * sizeof (long),
+                                          (void*) &gegl_random_primes,
+                                          cl_err);
   return cl_random_primes;
 }
 
diff --git a/gegl/opencl/gegl-cl-random.h b/gegl/opencl/gegl-cl-random.h
index b2280ab..186827d 100644
--- a/gegl/opencl/gegl-cl-random.h
+++ b/gegl/opencl/gegl-cl-random.h
@@ -21,19 +21,9 @@
 
 #include "gegl-cl-types.h"
 /** Load the random data needed to generate random numbers in the GPU*/
-cl_mem gegl_cl_load_random_data(int *cl_err);
+cl_mem gegl_cl_load_random_data (int *cl_err);
 
 /** Load the primes needed to generate random numbers in the GPU*/
-cl_mem gegl_cl_load_random_primes(int *cl_err);
-
-/*
-#define GEGL_CL_LOAD_RANDOM(obj)           \
-   { obj = gegl_cl_load_random(&cl_err);   \
-    CL_CHECK;}
-
-#define GEGL_CL_RELEASE_RANDOM(obj)        \
-  { cl_err = gegl_clReleaseMemObject(obj); \
-    CL_CHECK; }
-*/
+cl_mem gegl_cl_load_random_primes (int *cl_err);
 
 #endif


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