Commit 608bd4e2 authored by Victor Oliveira's avatar Victor Oliveira

creating an opencl log to keep messages, instead of using g_warning and g_printf

parent a7fbfec9
#include <glib.h> #include <glib.h>
#include "gegl.h" #include "gegl.h"
#include "gegl/gegl-debug.h"
#include "gegl-utils.h" #include "gegl-utils.h"
#include "gegl-types-internal.h" #include "gegl-types-internal.h"
#include "gegl-buffer-types.h" #include "gegl-buffer-types.h"
...@@ -70,7 +71,7 @@ gegl_buffer_cl_cache_new (GeglBuffer *buffer, ...@@ -70,7 +71,7 @@ gegl_buffer_cl_cache_new (GeglBuffer *buffer,
g_static_mutex_unlock (&cache_mutex); g_static_mutex_unlock (&cache_mutex);
} }
#define CL_ERROR {g_printf("[OpenCL] Error in %s:%d@%s - %s\n", __FILE__, __LINE__, __func__, gegl_cl_errstring(cl_err)); goto error;} #define CL_ERROR {GEGL_NOTE (GEGL_DEBUG_OPENCL, "Error in %s:%d@%s - %s\n", __FILE__, __LINE__, __func__, gegl_cl_errstring(cl_err)); goto error;}
gboolean gboolean
gegl_buffer_cl_cache_merge (GeglBuffer *buffer, gegl_buffer_cl_cache_merge (GeglBuffer *buffer,
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <glib/gprintf.h> #include <glib/gprintf.h>
#include "gegl.h" #include "gegl.h"
#include "gegl/gegl-debug.h"
#include "gegl-buffer-types.h" #include "gegl-buffer-types.h"
#include "gegl-buffer-cl-iterator.h" #include "gegl-buffer-cl-iterator.h"
...@@ -15,7 +16,7 @@ ...@@ -15,7 +16,7 @@
#include "gegl-tile-storage.h" #include "gegl-tile-storage.h"
#include "gegl-utils.h" #include "gegl-utils.h"
#define CL_ERROR {g_printf("[OpenCL] Error in %s:%d@%s - %s\n", __FILE__, __LINE__, __func__, gegl_cl_errstring(cl_err)); goto error;} #define CL_ERROR {GEGL_NOTE (GEGL_DEBUG_OPENCL, "Error in %s:%d@%s - %s\n", __FILE__, __LINE__, __func__, gegl_cl_errstring(cl_err)); goto error;}
typedef struct GeglBufferClIterators typedef struct GeglBufferClIterators
{ {
......
...@@ -14,7 +14,8 @@ typedef enum { ...@@ -14,7 +14,8 @@ typedef enum {
GEGL_DEBUG_PROCESSOR = 1 << 4, GEGL_DEBUG_PROCESSOR = 1 << 4,
GEGL_DEBUG_CACHE = 1 << 5, GEGL_DEBUG_CACHE = 1 << 5,
GEGL_DEBUG_MISC = 1 << 6, GEGL_DEBUG_MISC = 1 << 6,
GEGL_DEBUG_INVALIDATION = 1 << 7 GEGL_DEBUG_INVALIDATION = 1 << 7,
GEGL_DEBUG_OPENCL = 1 << 8
} GeglDebugFlag; } GeglDebugFlag;
/* only compiled in from gegl-init.c but kept here to /* only compiled in from gegl-init.c but kept here to
......
...@@ -598,7 +598,7 @@ gegl_post_parse_hook (GOptionContext *context, ...@@ -598,7 +598,7 @@ gegl_post_parse_hook (GOptionContext *context,
if (gegl_config()->use_opencl) if (gegl_config()->use_opencl)
gegl_cl_init (NULL); gegl_cl_init (NULL);
g_printf("[OpenCL] Using OpenCL: %d\n", gegl_config()->use_opencl && gegl_cl_is_accelerated ()); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Using OpenCL: %d\n", gegl_config()->use_opencl && gegl_cl_is_accelerated ());
return TRUE; return TRUE;
} }
......
#include "gegl.h" #include "gegl.h"
#include <glib/gprintf.h> #include "gegl/gegl-debug.h"
#include "gegl-cl-color.h" #include "gegl-cl-color.h"
#include "gegl-cl-init.h" #include "gegl-cl-init.h"
...@@ -189,7 +189,7 @@ gegl_cl_color_supported (const Babl *in_format, const Babl *out_format) ...@@ -189,7 +189,7 @@ gegl_cl_color_supported (const Babl *in_format, const Babl *out_format)
return GEGL_CL_COLOR_NOT_SUPPORTED; return GEGL_CL_COLOR_NOT_SUPPORTED;
} }
#define CL_ERROR {g_printf("[OpenCL] Error in %s:%d@%s - %s\n", __FILE__, __LINE__, __func__, gegl_cl_errstring(errcode)); return FALSE;} #define CL_ERROR {GEGL_NOTE (GEGL_DEBUG_OPENCL, "Error in %s:%d@%s - %s\n", __FILE__, __LINE__, __func__, gegl_cl_errstring(errcode)); return FALSE;}
gboolean gboolean
gegl_cl_color_conv (cl_mem in_tex, cl_mem out_tex, const size_t size, gegl_cl_color_conv (cl_mem in_tex, cl_mem out_tex, const size_t size,
......
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
#include <gmodule.h> #include <gmodule.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <glib/gprintf.h>
#include "gegl-cl-color.h" #include "gegl-cl-color.h"
#include "gegl/gegl-debug.h"
const char *gegl_cl_errstring(cl_int err) { const char *gegl_cl_errstring(cl_int err) {
static const char* strings[] = static const char* strings[] =
{ {
...@@ -235,7 +236,7 @@ gegl_cl_init (GError **error) ...@@ -235,7 +236,7 @@ gegl_cl_init (GError **error)
err = gegl_clGetPlatformIDs (1, &cl_state.platform, NULL); err = gegl_clGetPlatformIDs (1, &cl_state.platform, NULL);
if(err != CL_SUCCESS) if(err != CL_SUCCESS)
{ {
g_printf("[OpenCL] Could not create platform\n"); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Could not create platform");
return FALSE; return FALSE;
} }
...@@ -246,7 +247,7 @@ gegl_cl_init (GError **error) ...@@ -246,7 +247,7 @@ gegl_cl_init (GError **error)
err = gegl_clGetDeviceIDs (cl_state.platform, CL_DEVICE_TYPE_DEFAULT, 1, &cl_state.device, NULL); err = gegl_clGetDeviceIDs (cl_state.platform, CL_DEVICE_TYPE_DEFAULT, 1, &cl_state.device, NULL);
if(err != CL_SUCCESS) if(err != CL_SUCCESS)
{ {
g_printf("[OpenCL] Could not create device\n"); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Could not create device");
return FALSE; return FALSE;
} }
...@@ -259,12 +260,12 @@ gegl_cl_init (GError **error) ...@@ -259,12 +260,12 @@ gegl_cl_init (GError **error)
cl_state.iter_width = 4096; cl_state.iter_width = 4096;
cl_state.iter_height = 4096; cl_state.iter_height = 4096;
g_printf("[OpenCL] Platform Name:%s\n", cl_state.platform_name); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Platform Name:%s", cl_state.platform_name);
g_printf("[OpenCL] Version:%s\n", cl_state.platform_version); GEGL_NOTE (GEGL_DEBUG_OPENCL, " Version:%s", cl_state.platform_version);
g_printf("[OpenCL] Extensions:%s\n", cl_state.platform_ext); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Extensions:%s", cl_state.platform_ext);
g_printf("[OpenCL] Default Device Name:%s\n", cl_state.device_name); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Default Device Name:%s", cl_state.device_name);
g_printf("[OpenCL] Max Alloc: %lu bytes\n", (unsigned long)cl_state.max_mem_alloc); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Max Alloc: %lu bytes", (unsigned long)cl_state.max_mem_alloc);
g_printf("[OpenCL] Local Mem: %lu bytes\n", (unsigned long)cl_state.local_mem_size); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Local Mem: %lu bytes", (unsigned long)cl_state.local_mem_size);
while (cl_state.iter_width * cl_state.iter_height * 16 > cl_state.max_mem_alloc) while (cl_state.iter_width * cl_state.iter_height * 16 > cl_state.max_mem_alloc)
{ {
...@@ -275,22 +276,22 @@ gegl_cl_init (GError **error) ...@@ -275,22 +276,22 @@ gegl_cl_init (GError **error)
} }
cl_state.iter_width /= 2; cl_state.iter_width /= 2;
g_printf("[OpenCL] Iteration size: (%d, %d)\n", cl_state.iter_width, cl_state.iter_height); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Iteration size: (%d, %d)", cl_state.iter_width, cl_state.iter_height);
if (cl_state.image_support) if (cl_state.image_support)
{ {
g_printf("[OpenCL] Image Support OK\n"); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Image Support OK");
} }
else else
{ {
g_printf("[OpenCL] Image Support Error\n"); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Image Support Error");
return FALSE; return FALSE;
} }
cl_state.ctx = gegl_clCreateContext(0, 1, &cl_state.device, NULL, NULL, &err); cl_state.ctx = gegl_clCreateContext(0, 1, &cl_state.device, NULL, NULL, &err);
if(err != CL_SUCCESS) if(err != CL_SUCCESS)
{ {
g_printf("[OpenCL] Could not create context\n"); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Could not create context");
return FALSE; return FALSE;
} }
...@@ -298,7 +299,7 @@ gegl_cl_init (GError **error) ...@@ -298,7 +299,7 @@ gegl_cl_init (GError **error)
if(err != CL_SUCCESS) if(err != CL_SUCCESS)
{ {
g_printf("[OpenCL] Could not create command queue\n"); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Could not create command queue");
return FALSE; return FALSE;
} }
...@@ -312,7 +313,7 @@ gegl_cl_init (GError **error) ...@@ -312,7 +313,7 @@ gegl_cl_init (GError **error)
if (cl_state.is_accelerated) if (cl_state.is_accelerated)
gegl_cl_color_compile_kernels(); gegl_cl_color_compile_kernels();
g_printf("[OpenCL] OK\n"); GEGL_NOTE (GEGL_DEBUG_OPENCL, "OK");
return TRUE; return TRUE;
} }
...@@ -358,14 +359,14 @@ gegl_cl_compile_and_build (const char *program_source, const char *kernel_name[] ...@@ -358,14 +359,14 @@ gegl_cl_compile_and_build (const char *program_source, const char *kernel_name[]
gegl_cl_get_device(), gegl_cl_get_device(),
CL_PROGRAM_BUILD_LOG, CL_PROGRAM_BUILD_LOG,
s, msg, NULL) ); s, msg, NULL) );
g_printf("[OpenCL] Build Error:%s\n%s", gegl_cl_errstring(build_errcode), msg); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Build Error:%s\n%s", gegl_cl_errstring(build_errcode), msg);
g_free (msg); g_free (msg);
return NULL; return NULL;
} }
else else
{ {
g_printf("[OpenCL] Compiling successful\n"); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Compiling successful\n");
} }
for (i=0; i<kernel_n; i++) for (i=0; i<kernel_n; i++)
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <glib-object.h> #include <glib-object.h>
#include "gegl.h" #include "gegl.h"
#include "gegl/gegl-debug.h"
#include "gegl-types-internal.h" #include "gegl-types-internal.h"
#include "gegl-operation-point-composer.h" #include "gegl-operation-point-composer.h"
#include "gegl-utils.h" #include "gegl-utils.h"
...@@ -156,7 +157,7 @@ gegl_operation_point_composer_cl_process (GeglOperation *operation, ...@@ -156,7 +157,7 @@ gegl_operation_point_composer_cl_process (GeglOperation *operation,
!gegl_cl_color_babl (aux_format, NULL) || !gegl_cl_color_babl (aux_format, NULL) ||
!gegl_cl_color_babl (out_format, NULL)) !gegl_cl_color_babl (out_format, NULL))
{ {
g_warning ("[OpenCL] Non-texturizable format!"); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Non-texturizable format!");
return FALSE; return FALSE;
} }
...@@ -177,8 +178,8 @@ gegl_operation_point_composer_cl_process (GeglOperation *operation, ...@@ -177,8 +178,8 @@ gegl_operation_point_composer_cl_process (GeglOperation *operation,
i->size[0][j], &i->roi[0][j]); i->size[0][j], &i->roi[0][j]);
if (cl_err != CL_SUCCESS) if (cl_err != CL_SUCCESS)
{ {
g_warning("[OpenCL] Error in %s [GeglOperationPointComposer] Kernel\n", GEGL_NOTE (GEGL_DEBUG_OPENCL, "Error in %s [GeglOperationPointComposer] Kernel",
GEGL_OPERATION_CLASS (operation)->name); GEGL_OPERATION_CLASS (operation)->name);
return FALSE; return FALSE;
} }
} }
...@@ -195,8 +196,8 @@ gegl_operation_point_composer_cl_process (GeglOperation *operation, ...@@ -195,8 +196,8 @@ gegl_operation_point_composer_cl_process (GeglOperation *operation,
i->size[0][j], &i->roi[0][j]); i->size[0][j], &i->roi[0][j]);
if (cl_err != CL_SUCCESS) if (cl_err != CL_SUCCESS)
{ {
g_warning("[OpenCL] Error in %s [GeglOperationPointComposer] Kernel\n", GEGL_NOTE (GEGL_DEBUG_OPENCL, "Error in %s [GeglOperationPointComposer] Kernel",
GEGL_OPERATION_CLASS (operation)->name); GEGL_OPERATION_CLASS (operation)->name);
return FALSE; return FALSE;
} }
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <glib-object.h> #include <glib-object.h>
#include "gegl.h" #include "gegl.h"
#include "gegl/gegl-debug.h"
#include "gegl-types-internal.h" #include "gegl-types-internal.h"
#include "gegl-operation-point-filter.h" #include "gegl-operation-point-filter.h"
#include "graph/gegl-pad.h" #include "graph/gegl-pad.h"
...@@ -91,17 +92,17 @@ gegl_operation_point_filter_cl_process (GeglOperation *operation, ...@@ -91,17 +92,17 @@ gegl_operation_point_filter_cl_process (GeglOperation *operation,
if (!gegl_cl_color_babl (in_format, NULL) || if (!gegl_cl_color_babl (in_format, NULL) ||
!gegl_cl_color_babl (out_format, NULL)) !gegl_cl_color_babl (out_format, NULL))
{ {
g_warning ("[OpenCL] Non-texturizable format!"); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Non-texturizable format!");
return FALSE; return FALSE;
} }
g_printf("[OpenCL] BABL formats: (%s,%s) (%s,%s)\n \t Tile Size:(%d, %d)\n", GEGL_NOTE (GEGL_DEBUG_OPENCL, "BABL formats: (%s,%s) (%s,%s)\n \t Tile Size:(%d, %d)\n",
babl_get_name(input->format), babl_get_name(input->format),
babl_get_name(in_format), babl_get_name(in_format),
babl_get_name(out_format), babl_get_name(out_format),
babl_get_name(output->format), babl_get_name(output->format),
input->tile_storage->tile_width, input->tile_storage->tile_width,
input->tile_storage->tile_height); input->tile_storage->tile_height);
/* Process */ /* Process */
{ {
...@@ -116,8 +117,8 @@ gegl_operation_point_filter_cl_process (GeglOperation *operation, ...@@ -116,8 +117,8 @@ gegl_operation_point_filter_cl_process (GeglOperation *operation,
i->size[0][j], &i->roi[0][j]); i->size[0][j], &i->roi[0][j]);
if (cl_err != CL_SUCCESS) if (cl_err != CL_SUCCESS)
{ {
g_warning("[OpenCL] Error in %s [GeglOperationPointFilter] Kernel\n", GEGL_NOTE (GEGL_DEBUG_OPENCL, "Error in %s [GeglOperationPointFilter] Kernel",
GEGL_OPERATION_CLASS (operation)->name); GEGL_OPERATION_CLASS (operation)->name);
return FALSE; return FALSE;
} }
} }
......
...@@ -30,6 +30,7 @@ gegl_chant_double (radius, _("Radius"), 0.0, 200.0, 4.0, ...@@ -30,6 +30,7 @@ gegl_chant_double (radius, _("Radius"), 0.0, 200.0, 4.0,
#define GEGL_CHANT_C_FILE "box-blur.c" #define GEGL_CHANT_C_FILE "box-blur.c"
#include "gegl-chant.h" #include "gegl-chant.h"
#include "gegl/gegl-debug.h"
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
...@@ -349,7 +350,7 @@ cl_process (GeglOperation *operation, ...@@ -349,7 +350,7 @@ cl_process (GeglOperation *operation,
cl_err = cl_box_blur(i->tex[read][j], i->tex[aux][j], i->tex[0][j], i->size[0][j], &i->roi[0][j], ceil (o->radius)); cl_err = cl_box_blur(i->tex[read][j], i->tex[aux][j], i->tex[0][j], i->size[0][j], &i->roi[0][j], ceil (o->radius));
if (cl_err != CL_SUCCESS) if (cl_err != CL_SUCCESS)
{ {
g_warning("[OpenCL] Error in box-blur: %s\n", gegl_cl_errstring(cl_err)); GEGL_NOTE (GEGL_DEBUG_OPENCL, "Error in gegl:box-blur: %s", gegl_cl_errstring(cl_err));
return FALSE; return FALSE;
} }
} }
......
...@@ -4,5 +4,4 @@ SUBDIRS = \ ...@@ -4,5 +4,4 @@ SUBDIRS = \
compositions \ compositions \
simple \ simple \
xml \ xml \
python \ python
opencl
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment