[gegl/openmp: 4/4] buffer: wrap gegl_buffer_get babl conversions in openmp
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/openmp: 4/4] buffer: wrap gegl_buffer_get babl conversions in openmp
- Date: Tue, 3 Jun 2014 20:51:40 +0000 (UTC)
commit 9ad024c8e595eeada734641a035db27b6fe82d76
Author: Øyvind Kolås <pippin gimp org>
Date: Tue Jun 3 22:48:25 2014 +0200
buffer: wrap gegl_buffer_get babl conversions in openmp
gegl/buffer/gegl-buffer-access.c | 55 +++++++++++++++++++++++++------------
1 files changed, 37 insertions(+), 18 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index fae90c2..c4bb19a 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -27,6 +27,7 @@
#include "gegl.h"
#include "gegl-debug.h"
+#include "gegl-config.h"
#include "gegl-types-internal.h"
#include "gegl-algorithms.h"
#include "gegl-buffer-types.h"
@@ -310,10 +311,8 @@ gegl_buffer_iterate_write (GeglBuffer *buffer,
if (buffer_y + y >= buffer_abyss_y &&
buffer_y + y < abyss_y_total)
- {
- babl_process (fish, bp + lskip * bpx_size, tp + lskip * px_size,
- pixels - lskip - rskip);
- }
+ babl_process (fish, bp + lskip * bpx_size, tp + lskip * px_size,
+ pixels - lskip - rskip);
tp += tile_stride;
bp += buf_stride;
@@ -328,11 +327,8 @@ gegl_buffer_iterate_write (GeglBuffer *buffer,
if (buffer_y + y >= buffer_abyss_y &&
buffer_y + y < abyss_y_total)
- {
-
- memcpy (tp + lskip * px_size, bp + lskip * px_size,
- (pixels - lskip - rskip) * px_size);
- }
+ memcpy (tp + lskip * px_size, bp + lskip * px_size,
+ (pixels - lskip - rskip) * px_size);
tp += tile_stride;
bp += buf_stride;
@@ -386,7 +382,8 @@ gegl_buffer_iterate_read_simple (GeglBuffer *buffer,
gint tiledx = buffer_x + bufx;
gint offsetx = gegl_tile_offset (tiledx, tile_width);
guchar *bp, *tile_base, *tp;
- gint pixels, row, y;
+ gint pixels, y;
+ gint y2, yd;
GeglTile *tile;
bp = buf + bufy * buf_stride + bufx * bpx_size;
@@ -412,18 +409,40 @@ gegl_buffer_iterate_read_simple (GeglBuffer *buffer,
tp = ((guchar *) tile_base) + (offsety * tile_width + offsetx) * px_size;
y = bufy;
- for (row = offsety;
- row < tile_height && y < height;
- row++, y++)
+ y2 = 0;
+ yd = tile_height - offsety;
+ if (height - y < yd)
+ yd = height - y;
+
+#ifdef HAVE_OPENMP
+ if (gegl_config()->use_openmp)
{
if (fish)
- babl_process (fish, tp, bp, pixels);
+#pragma omp parallel for
+ for (y2 = 0; y2 < yd; y2 ++)
+ babl_process (fish, tp + y2 * tile_stride,
+ bp + y2 * buf_stride, pixels);
else
- memcpy (bp, tp, pixels * px_size);
-
- tp += tile_stride;
- bp += buf_stride;
+#pragma omp parallel for
+ for (y2 = 0; y2 < yd; y2 ++)
+ memcpy (bp + y2 * buf_stride,
+ tp + y2 * tile_stride, pixels * px_size);
}
+ else
+#endif
+ {
+ if (fish)
+ for (y2 = 0; y2 < yd; y2 ++)
+ babl_process (fish, tp + y2 * tile_stride,
+ bp + y2 * buf_stride, pixels);
+ else
+ for (y2 = 0; y2 < yd; y2 ++)
+ memcpy (bp + y2 * buf_stride,
+ tp + y2 * tile_stride, pixels * px_size);
+ }
+
+ tp += tile_stride * y2;
+ bp += buf_stride * y2;
gegl_tile_unref (tile);
bufx += (tile_width - offsetx);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]