[gegl] gegl/operation, operations: adapt to previous commit



commit 1fbd84ccfcb24ef303543568e8decabc59d88a46
Author: Ell <ell_se yahoo com>
Date:   Tue Nov 13 10:31:50 2018 -0500

    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.

 gegl/operation/gegl-operation-composer.c        |  2 +-
 gegl/operation/gegl-operation-composer3.c       |  2 +-
 gegl/operation/gegl-operation-filter.c          |  2 +-
 gegl/operation/gegl-operation-point-composer.c  |  2 +-
 gegl/operation/gegl-operation-point-composer3.c |  2 +-
 gegl/operation/gegl-operation-point-filter.c    |  2 +-
 gegl/operation/gegl-operation-source.c          |  2 +-
 gegl/operation/gegl-operation.c                 |  8 ++++----
 gegl/operation/gegl-operation.h                 |  8 +++-----
 operations/common-cxx/distance-transform.cc     | 12 ++++++------
 operations/common-cxx/warp.cc                   | 25 ++++++++++++++-----------
 operations/transform/transform-core.c           |  2 +-
 12 files changed, 35 insertions(+), 34 deletions(-)
---
diff --git a/gegl/operation/gegl-operation-composer.c b/gegl/operation/gegl-operation-composer.c
index a9ff76047..526d40b23 100644
--- a/gegl/operation/gegl-operation-composer.c
+++ b/gegl/operation/gegl-operation-composer.c
@@ -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);
diff --git a/gegl/operation/gegl-operation-composer3.c b/gegl/operation/gegl-operation-composer3.c
index 25269e8de..91691ee47 100644
--- a/gegl/operation/gegl-operation-composer3.c
+++ b/gegl/operation/gegl-operation-composer3.c
@@ -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);
diff --git a/gegl/operation/gegl-operation-filter.c b/gegl/operation/gegl-operation-filter.c
index a5c7af3ec..5a43f9e1b 100644
--- a/gegl/operation/gegl-operation-filter.c
+++ b/gegl/operation/gegl-operation-filter.c
@@ -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);
diff --git a/gegl/operation/gegl-operation-point-composer.c b/gegl/operation/gegl-operation-point-composer.c
index eb75e151c..ce1e268b9 100644
--- a/gegl/operation/gegl-operation-point-composer.c
+++ b/gegl/operation/gegl-operation-point-composer.c
@@ -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);
diff --git a/gegl/operation/gegl-operation-point-composer3.c b/gegl/operation/gegl-operation-point-composer3.c
index 56279396f..5aaa75d07 100644
--- a/gegl/operation/gegl-operation-point-composer3.c
+++ b/gegl/operation/gegl-operation-point-composer3.c
@@ -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);
diff --git a/gegl/operation/gegl-operation-point-filter.c b/gegl/operation/gegl-operation-point-filter.c
index 365cb8c01..9e2bd2a0a 100644
--- a/gegl/operation/gegl-operation-point-filter.c
+++ b/gegl/operation/gegl-operation-point-filter.c
@@ -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);
diff --git a/gegl/operation/gegl-operation-source.c b/gegl/operation/gegl-operation-source.c
index a64881e94..35fc471a9 100644
--- a/gegl/operation/gegl-operation-source.c
+++ b/gegl/operation/gegl-operation-source.c
@@ -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);
diff --git a/gegl/operation/gegl-operation.c b/gegl/operation/gegl-operation.c
index f60922ce7..c3e55dd4f 100644
--- a/gegl/operation/gegl-operation.c
+++ b/gegl/operation/gegl-operation.c
@@ -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;
diff --git a/gegl/operation/gegl-operation.h b/gegl/operation/gegl-operation.h
index b4d473fb4..39dbf9152 100644
--- a/gegl/operation/gegl-operation.h
+++ b/gegl/operation/gegl-operation.h
@@ -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,
-                              const GeglRectangle *roi);
-gsize
-gegl_operation_get_min_threaded_sub_area (GeglOperation *operation);
+gboolean      gegl_operation_use_threading         (GeglOperation       *operation,
+                                                    const GeglRectangle *roi);
+gdouble       gegl_operation_get_pixels_per_thread (GeglOperation       *operation);
 
 /* Invalidate a specific rectangle, indicating the any computation depending
  * on this roi is now invalid.
diff --git a/operations/common-cxx/distance-transform.cc b/operations/common-cxx/distance-transform.cc
index bb5d46699..396c224b8 100644
--- a/operations/common-cxx/distance-transform.cc
+++ b/operations/common-cxx/distance-transform.cc
@@ -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,8 +173,9 @@ 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,
-                                  [&] (gint y0, gint size)
+  gegl_parallel_distribute_range (
+    height, gegl_operation_get_pixels_per_thread (operation) / width,
+    [&] (gint y0, gint size)
     {
       gfloat *g, *row_copy;
       gint q, w, *t, *s;
@@ -261,8 +260,9 @@ 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,
-                                  [&] (gint x0, gint size)
+  gegl_parallel_distribute_range (
+    width, gegl_operation_get_pixels_per_thread (operation) / height,
+    [&] (gint x0, gint size)
     {
       gint x;
       gint y;
diff --git a/operations/common-cxx/warp.cc b/operations/common-cxx/warp.cc
index d36776e53..9373e37f9 100644
--- a/operations/common-cxx/warp.cc
+++ b/operations/common-cxx/warp.cc
@@ -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,8 +457,10 @@ stamp (GeglProperties      *o,
     {
       gfloat total_weight = 0.0f;
 
-      gegl_parallel_distribute_range (area.height, MIN_PARALLEL_SUB_SIZE,
-                                      [&] (gint y0, gint height)
+      gegl_parallel_distribute_range (
+        area.height, gegl_operation_get_pixels_per_thread (operation) /
+                     area.width,
+        [&] (gint y0, gint height)
         {
           static GMutex mutex;
           gfloat        local_x_mean       = 0.0f;
@@ -553,8 +554,9 @@ stamp (GeglProperties      *o,
    */
   stampbuf = g_new (gfloat, 2 * area.height * area.width);
 
-  gegl_parallel_distribute_range (area.height, MIN_PARALLEL_SUB_SIZE,
-                                  [=] (gint y0, gint height)
+  gegl_parallel_distribute_range (
+    area.height, gegl_operation_get_pixels_per_thread (operation) / area.width,
+    [=] (gint y0, gint height)
     {
       gfloat yi;
       gint   y_iter;
@@ -707,8 +709,9 @@ stamp (GeglProperties      *o,
     });
 
   /* Paste the stamp into the source buffer. */
-  gegl_parallel_distribute_range (area.height, MIN_PARALLEL_SUB_SIZE,
-                                  [=] (gint y0, gint height)
+  gegl_parallel_distribute_range (
+    area.height, gegl_operation_get_pixels_per_thread (operation) / area.width,
+    [=] (gint y0, gint height)
     {
       gfloat yi;
       gint   y_iter;
@@ -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);
                 }
diff --git a/operations/transform/transform-core.c b/operations/transform/transform-core.c
index 7a7e41753..4edd4cf00 100644
--- a/operations/transform/transform-core.c
+++ b/operations/transform/transform-core.c
@@ -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);


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