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