Commit 1fbd84cc authored by Ell's avatar Ell

gegl/operation, operations: adapt to previous commit

Rename gegl_operation_get_min_threaded_sub_size() to
gegl_operation_get_pixels_per_thread().  This function returns the
(very hypothetical, ATM) cost of using each additional thread for
processing the operation, realtive to the cost of processing a
single pixel.  As before, it simply returns 64 * 64 for now.  This
function is meant to be used for the thread_cost parameter of
gegl_parallel_distribute_area().

Use the new function in the auto-threaded operation classes, and in
manually-threaded operations using gegl_parallel_distribute_area().
Additionally, use the function in manually-threaded operations
using gegl_parallel_distribute_range(), by dividing its result by
the relevant dimension of the processed area.
parent e1d01be8
...@@ -182,7 +182,7 @@ gegl_operation_composer_process (GeglOperation *operation, ...@@ -182,7 +182,7 @@ gegl_operation_composer_process (GeglOperation *operation,
gegl_parallel_distribute_area ( gegl_parallel_distribute_area (
result, result,
gegl_operation_get_min_threaded_sub_area (operation), gegl_operation_get_pixels_per_thread (operation),
GEGL_SPLIT_STRATEGY_AUTO, GEGL_SPLIT_STRATEGY_AUTO,
(GeglParallelDistributeAreaFunc) thread_process, (GeglParallelDistributeAreaFunc) thread_process,
&data); &data);
......
...@@ -204,7 +204,7 @@ gegl_operation_composer3_process (GeglOperation *operation, ...@@ -204,7 +204,7 @@ gegl_operation_composer3_process (GeglOperation *operation,
gegl_parallel_distribute_area ( gegl_parallel_distribute_area (
result, result,
gegl_operation_get_min_threaded_sub_area (operation), gegl_operation_get_pixels_per_thread (operation),
GEGL_SPLIT_STRATEGY_AUTO, GEGL_SPLIT_STRATEGY_AUTO,
(GeglParallelDistributeAreaFunc) thread_process, (GeglParallelDistributeAreaFunc) thread_process,
&data); &data);
......
...@@ -200,7 +200,7 @@ gegl_operation_filter_process (GeglOperation *operation, ...@@ -200,7 +200,7 @@ gegl_operation_filter_process (GeglOperation *operation,
gegl_parallel_distribute_area ( gegl_parallel_distribute_area (
result, result,
gegl_operation_get_min_threaded_sub_area (operation), gegl_operation_get_pixels_per_thread (operation),
split_strategy, split_strategy,
(GeglParallelDistributeAreaFunc) thread_process, (GeglParallelDistributeAreaFunc) thread_process,
&data); &data);
......
...@@ -331,7 +331,7 @@ gegl_operation_point_composer_process (GeglOperation *operation, ...@@ -331,7 +331,7 @@ gegl_operation_point_composer_process (GeglOperation *operation,
gegl_parallel_distribute_area ( gegl_parallel_distribute_area (
result, result,
gegl_operation_get_min_threaded_sub_area (operation), gegl_operation_get_pixels_per_thread (operation),
GEGL_SPLIT_STRATEGY_AUTO, GEGL_SPLIT_STRATEGY_AUTO,
(GeglParallelDistributeAreaFunc) thread_process, (GeglParallelDistributeAreaFunc) thread_process,
&data); &data);
......
...@@ -249,7 +249,7 @@ gegl_operation_point_composer3_process (GeglOperation *operation, ...@@ -249,7 +249,7 @@ gegl_operation_point_composer3_process (GeglOperation *operation,
gegl_parallel_distribute_area ( gegl_parallel_distribute_area (
result, result,
gegl_operation_get_min_threaded_sub_area (operation), gegl_operation_get_pixels_per_thread (operation),
GEGL_SPLIT_STRATEGY_AUTO, GEGL_SPLIT_STRATEGY_AUTO,
(GeglParallelDistributeAreaFunc) thread_process, (GeglParallelDistributeAreaFunc) thread_process,
&data); &data);
......
...@@ -289,7 +289,7 @@ gegl_operation_point_filter_process (GeglOperation *operation, ...@@ -289,7 +289,7 @@ gegl_operation_point_filter_process (GeglOperation *operation,
gegl_parallel_distribute_area ( gegl_parallel_distribute_area (
result, result,
gegl_operation_get_min_threaded_sub_area (operation), gegl_operation_get_pixels_per_thread (operation),
GEGL_SPLIT_STRATEGY_AUTO, GEGL_SPLIT_STRATEGY_AUTO,
(GeglParallelDistributeAreaFunc) thread_process, (GeglParallelDistributeAreaFunc) thread_process,
&data); &data);
......
...@@ -127,7 +127,7 @@ gegl_operation_source_process (GeglOperation *operation, ...@@ -127,7 +127,7 @@ gegl_operation_source_process (GeglOperation *operation,
gegl_parallel_distribute_area ( gegl_parallel_distribute_area (
result, result,
gegl_operation_get_min_threaded_sub_area (operation), gegl_operation_get_pixels_per_thread (operation),
GEGL_SPLIT_STRATEGY_AUTO, GEGL_SPLIT_STRATEGY_AUTO,
(GeglParallelDistributeAreaFunc) thread_process, (GeglParallelDistributeAreaFunc) thread_process,
&data); &data);
......
...@@ -816,15 +816,15 @@ gegl_operation_use_threading (GeglOperation *operation, ...@@ -816,15 +816,15 @@ gegl_operation_use_threading (GeglOperation *operation,
return FALSE; return FALSE;
if (op_class->threaded && if (op_class->threaded &&
roi->width * roi->height > (gdouble) roi->width * (gdouble) roi->height >=
gegl_operation_get_min_threaded_sub_area (operation)) 2 * gegl_operation_get_pixels_per_thread (operation))
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
gsize gdouble
gegl_operation_get_min_threaded_sub_area (GeglOperation *operation) gegl_operation_get_pixels_per_thread (GeglOperation *operation)
{ {
/* FIXME: too arbitrary? */ /* FIXME: too arbitrary? */
return 64 * 64; return 64 * 64;
......
...@@ -245,11 +245,9 @@ void gegl_operation_set_key (const gchar *operation_type, ...@@ -245,11 +245,9 @@ void gegl_operation_set_key (const gchar *operation_type,
gboolean gegl_operation_use_opencl (const GeglOperation *operation); gboolean gegl_operation_use_opencl (const GeglOperation *operation);
gboolean gboolean gegl_operation_use_threading (GeglOperation *operation,
gegl_operation_use_threading (GeglOperation *operation, const GeglRectangle *roi);
const GeglRectangle *roi); gdouble gegl_operation_get_pixels_per_thread (GeglOperation *operation);
gsize
gegl_operation_get_min_threaded_sub_area (GeglOperation *operation);
/* Invalidate a specific rectangle, indicating the any computation depending /* Invalidate a specific rectangle, indicating the any computation depending
* on this roi is now invalid. * on this roi is now invalid.
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#include "config.h" #include "config.h"
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#define MIN_PARALLEL_SUB_SIZE 64
#ifdef GEGL_PROPERTIES #ifdef GEGL_PROPERTIES
property_enum (metric, _("Metric"), property_enum (metric, _("Metric"),
...@@ -175,8 +173,9 @@ binary_dt_2nd_pass (GeglOperation *operation, ...@@ -175,8 +173,9 @@ binary_dt_2nd_pass (GeglOperation *operation,
* lines (i.e. each thread will work on a given range of lines without * lines (i.e. each thread will work on a given range of lines without
* needing to read data updated by other threads). * needing to read data updated by other threads).
*/ */
gegl_parallel_distribute_range (height, MIN_PARALLEL_SUB_SIZE, gegl_parallel_distribute_range (
[&] (gint y0, gint size) height, gegl_operation_get_pixels_per_thread (operation) / width,
[&] (gint y0, gint size)
{ {
gfloat *g, *row_copy; gfloat *g, *row_copy;
gint q, w, *t, *s; gint q, w, *t, *s;
...@@ -261,8 +260,9 @@ binary_dt_1st_pass (GeglOperation *operation, ...@@ -261,8 +260,9 @@ binary_dt_1st_pass (GeglOperation *operation,
* columns (i.e. each thread will work on a given range of columns without * columns (i.e. each thread will work on a given range of columns without
* needing to read data updated by other threads). * needing to read data updated by other threads).
*/ */
gegl_parallel_distribute_range (width, MIN_PARALLEL_SUB_SIZE, gegl_parallel_distribute_range (
[&] (gint x0, gint size) width, gegl_operation_get_pixels_per_thread (operation) / height,
[&] (gint x0, gint size)
{ {
gint x; gint x;
gint y; gint y;
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include <math.h> #include <math.h>
#define MIN_PARALLEL_SUB_SIZE 64
#ifdef GEGL_PROPERTIES #ifdef GEGL_PROPERTIES
enum_start (gegl_warp_behavior) enum_start (gegl_warp_behavior)
...@@ -391,7 +389,8 @@ get_stamp_force (gfloat x, ...@@ -391,7 +389,8 @@ get_stamp_force (gfloat x,
} }
static void static void
stamp (GeglProperties *o, stamp (GeglOperation *operation,
GeglProperties *o,
gfloat *srcbuf, gfloat *srcbuf,
gint srcbuf_stride, gint srcbuf_stride,
const GeglRectangle *srcbuf_extent, const GeglRectangle *srcbuf_extent,
...@@ -458,8 +457,10 @@ stamp (GeglProperties *o, ...@@ -458,8 +457,10 @@ stamp (GeglProperties *o,
{ {
gfloat total_weight = 0.0f; gfloat total_weight = 0.0f;
gegl_parallel_distribute_range (area.height, MIN_PARALLEL_SUB_SIZE, gegl_parallel_distribute_range (
[&] (gint y0, gint height) area.height, gegl_operation_get_pixels_per_thread (operation) /
area.width,
[&] (gint y0, gint height)
{ {
static GMutex mutex; static GMutex mutex;
gfloat local_x_mean = 0.0f; gfloat local_x_mean = 0.0f;
...@@ -553,8 +554,9 @@ stamp (GeglProperties *o, ...@@ -553,8 +554,9 @@ stamp (GeglProperties *o,
*/ */
stampbuf = g_new (gfloat, 2 * area.height * area.width); stampbuf = g_new (gfloat, 2 * area.height * area.width);
gegl_parallel_distribute_range (area.height, MIN_PARALLEL_SUB_SIZE, gegl_parallel_distribute_range (
[=] (gint y0, gint height) area.height, gegl_operation_get_pixels_per_thread (operation) / area.width,
[=] (gint y0, gint height)
{ {
gfloat yi; gfloat yi;
gint y_iter; gint y_iter;
...@@ -707,8 +709,9 @@ stamp (GeglProperties *o, ...@@ -707,8 +709,9 @@ stamp (GeglProperties *o,
}); });
/* Paste the stamp into the source buffer. */ /* Paste the stamp into the source buffer. */
gegl_parallel_distribute_range (area.height, MIN_PARALLEL_SUB_SIZE, gegl_parallel_distribute_range (
[=] (gint y0, gint height) area.height, gegl_operation_get_pixels_per_thread (operation) / area.width,
[=] (gint y0, gint height)
{ {
gfloat yi; gfloat yi;
gint y_iter; gint y_iter;
...@@ -898,7 +901,7 @@ process (GeglOperation *operation, ...@@ -898,7 +901,7 @@ process (GeglOperation *operation,
if (stamps == 1) if (stamps == 1)
{ {
stamp (o, stamp (operation, o,
srcbuf, srcbuf_stride, &srcbuf_extent, srcbuf, srcbuf_stride, &srcbuf_extent,
next.x, next.y); next.x, next.y);
} }
...@@ -909,7 +912,7 @@ process (GeglOperation *operation, ...@@ -909,7 +912,7 @@ process (GeglOperation *operation,
t = 1.0 - ((stamps - i - 1) * spacing) / dist; t = 1.0 - ((stamps - i - 1) * spacing) / dist;
gegl_path_point_lerp (&lerp, &prev, &next, t); gegl_path_point_lerp (&lerp, &prev, &next, t);
stamp (o, stamp (operation, o,
srcbuf, srcbuf_stride, &srcbuf_extent, srcbuf, srcbuf_stride, &srcbuf_extent,
lerp.x, lerp.y); lerp.x, lerp.y);
} }
......
...@@ -1683,7 +1683,7 @@ gegl_transform_process (GeglOperation *operation, ...@@ -1683,7 +1683,7 @@ gegl_transform_process (GeglOperation *operation,
gegl_parallel_distribute_area ( gegl_parallel_distribute_area (
result, result,
gegl_operation_get_min_threaded_sub_area (operation), gegl_operation_get_pixels_per_thread (operation),
GEGL_SPLIT_STRATEGY_AUTO, GEGL_SPLIT_STRATEGY_AUTO,
(GeglParallelDistributeAreaFunc) thread_process, (GeglParallelDistributeAreaFunc) thread_process,
&data); &data);
......
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