[gegl] gegl: remove big overallocation in auto-threading code



commit c9a1bc977496bd5a8828259fbb057a34cbe5ca49
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Sep 27 21:47:13 2017 +0200

    gegl: remove big overallocation in auto-threading code
    
    The temp-buffers are used for copies of results from
    gegl_buffer_iterator in the correct format for the ops processing.
    For now I have moved the allocation to be within the driving loop.
    
    It might however be better to create an iterator per thread and cut down
    on the code needed.
    
    Fixing bug #788252.

 gegl/operation/gegl-operation-point-composer.c  |   13 +++++++++----
 gegl/operation/gegl-operation-point-composer3.c |   16 ++++++++++------
 gegl/operation/gegl-operation-point-filter.c    |   12 +++++++++---
 3 files changed, 28 insertions(+), 13 deletions(-)
---
diff --git a/gegl/operation/gegl-operation-point-composer.c b/gegl/operation/gegl-operation-point-composer.c
index e68f28c..844a142 100644
--- a/gegl/operation/gegl-operation-point-composer.c
+++ b/gegl/operation/gegl-operation-point-composer.c
@@ -337,7 +337,6 @@ gegl_operation_point_composer_process (GeglOperation       *operation,
         gint in_buf_bpp = input?babl_format_get_bytes_per_pixel (in_buf_format):0;
         gint aux_buf_bpp = aux?babl_format_get_bytes_per_pixel (aux_buf_format):0;
         gint out_buf_bpp = babl_format_get_bytes_per_pixel (output_buf_format);
-        gint temp_id = 0;
 
         if (input)
         {
@@ -348,7 +347,6 @@ gegl_operation_point_composer_process (GeglOperation       *operation,
             if (in_buf_format != in_format)
             {
               thread_data[j].input_fish = babl_fish (in_buf_format, in_format);
-              thread_data[j].in_tmp = gegl_temp_buffer (temp_id++, in_bpp * result->width * result->height);
             }
             else
             {
@@ -368,7 +366,6 @@ gegl_operation_point_composer_process (GeglOperation       *operation,
             if (aux_buf_format != aux_format)
             {
               thread_data[j].aux_fish = babl_fish (aux_buf_format, aux_format);
-              thread_data[j].aux_tmp = gegl_temp_buffer (temp_id++, aux_bpp * result->width * 
result->height);
             }
             else
             {
@@ -387,7 +384,6 @@ gegl_operation_point_composer_process (GeglOperation       *operation,
           if (output_buf_format != gegl_buffer_get_format (output))
           {
             thread_data[j].output_fish = babl_fish (out_format, output_buf_format);
-            thread_data[j].output_tmp = gegl_temp_buffer (temp_id++, out_bpp * result->width * 
result->height);
           }
           else
           {
@@ -400,6 +396,7 @@ gegl_operation_point_composer_process (GeglOperation       *operation,
             gint threads = gegl_config_threads ();
             gint pending;
             gint bit;
+            gint temp_id = 0;
 
             if (i->roi[0].height < threads)
             {
@@ -429,6 +426,14 @@ gegl_operation_point_composer_process (GeglOperation       *operation,
               thread_data[j].level = level;
               thread_data[j].success = TRUE;
             }
+
+           for (gint j = 0; j < threads; j++)
+           {
+               thread_data[j].in_tmp = input?gegl_temp_buffer (temp_id++, in_bpp * i->roi[j].width * 
i->roi[j].height):NULL;
+               thread_data[j].aux_tmp = aux?gegl_temp_buffer (temp_id++, aux_bpp * i->roi[j].width * 
i->roi[j].height):NULL;
+               thread_data[j].output_tmp = gegl_temp_buffer (temp_id++, out_bpp * i->roi[j].width * 
i->roi[j].height);
+           }
+
             pending = threads;
 
             for (gint j = 1; j < threads; j++)
diff --git a/gegl/operation/gegl-operation-point-composer3.c b/gegl/operation/gegl-operation-point-composer3.c
index 705fa9b..70c65ad 100644
--- a/gegl/operation/gegl-operation-point-composer3.c
+++ b/gegl/operation/gegl-operation-point-composer3.c
@@ -255,8 +255,6 @@ gegl_operation_point_composer3_process (GeglOperation       *operation,
         gint aux2_buf_bpp = aux2?babl_format_get_bytes_per_pixel (aux2_buf_format):0;
         gint out_buf_bpp = babl_format_get_bytes_per_pixel (output_buf_format);
 
-        gint temp_id = 0;
-
         if (input)
         {
           if (! babl_format_has_alpha (in_buf_format))
@@ -271,7 +269,6 @@ gegl_operation_point_composer3_process (GeglOperation       *operation,
             if (in_buf_format != in_format)
             {
               thread_data[j].input_fish = babl_fish (in_buf_format, in_format);
-              thread_data[j].in_tmp = gegl_temp_buffer (temp_id++, in_bpp * result->width * result->height);
             }
             else
             {
@@ -297,7 +294,6 @@ gegl_operation_point_composer3_process (GeglOperation       *operation,
             if (aux_buf_format != aux_format)
             {
               thread_data[j].aux_fish = babl_fish (aux_buf_format, aux_format);
-              thread_data[j].aux_tmp = gegl_temp_buffer (temp_id++, aux_bpp * result->width * 
result->height);
             }
             else
             {
@@ -325,7 +321,6 @@ gegl_operation_point_composer3_process (GeglOperation       *operation,
             if (aux2_buf_format != aux2_format)
             {
               thread_data[j].aux2_fish = babl_fish (aux2_buf_format, aux2_format);
-              thread_data[j].aux2_tmp = gegl_temp_buffer (temp_id++, aux2_bpp * result->width * 
result->height);
             }
             else
             {
@@ -344,7 +339,6 @@ gegl_operation_point_composer3_process (GeglOperation       *operation,
           if (output_buf_format != gegl_buffer_get_format (output))
           {
             thread_data[j].output_fish = babl_fish (out_format, output_buf_format);
-            thread_data[j].output_tmp = gegl_temp_buffer (temp_id++, out_bpp * result->width * 
result->height);
           }
           else
           {
@@ -357,6 +351,7 @@ gegl_operation_point_composer3_process (GeglOperation       *operation,
             gint threads = gegl_config_threads ();
             gint pending;
             gint bit;
+           gint temp_id = 0;
 
             if (i->roi[0].height < threads)
             {
@@ -387,6 +382,15 @@ gegl_operation_point_composer3_process (GeglOperation       *operation,
               thread_data[j].level = level;
               thread_data[j].success = TRUE;
             }
+
+           for (gint j = 0; j < threads; j++)
+           {
+               thread_data[j].in_tmp = input?gegl_temp_buffer (temp_id++, in_bpp * i->roi[j].width * 
i->roi[j].height):NULL;
+               thread_data[j].aux_tmp = aux?gegl_temp_buffer (temp_id++, aux_bpp * i->roi[j].width * 
i->roi[j].height):NULL;
+               thread_data[j].aux2_tmp = aux2?gegl_temp_buffer (temp_id++, aux2_bpp * i->roi[j].width * 
i->roi[j].height):NULL;
+               thread_data[j].output_tmp = gegl_temp_buffer (temp_id++, out_bpp * i->roi[j].width * 
i->roi[j].height);
+           }
+
             pending = threads;
 
             for (gint j = 1; j < threads; j++)
diff --git a/gegl/operation/gegl-operation-point-filter.c b/gegl/operation/gegl-operation-point-filter.c
index 18118bc..1e85836 100644
--- a/gegl/operation/gegl-operation-point-filter.c
+++ b/gegl/operation/gegl-operation-point-filter.c
@@ -302,7 +302,6 @@ gegl_operation_point_filter_process (GeglOperation       *operation,
         gint out_bpp = babl_format_get_bytes_per_pixel (out_format);
         gint in_buf_bpp = input?babl_format_get_bytes_per_pixel (in_buf_format):0;
         gint out_buf_bpp = babl_format_get_bytes_per_pixel (output_buf_format);
-        gint temp_id = 0;
 
         if (input)
         {
@@ -312,7 +311,6 @@ gegl_operation_point_filter_process (GeglOperation       *operation,
             if (in_buf_format != in_format)
             {
               thread_data[j].input_fish = babl_fish (in_buf_format, in_format);
-              thread_data[j].in_tmp = gegl_temp_buffer (temp_id++, in_bpp * result->width * result->height);
             }
             else
             {
@@ -329,7 +327,6 @@ gegl_operation_point_filter_process (GeglOperation       *operation,
           if (output_buf_format != gegl_buffer_get_format (output))
           {
             thread_data[j].output_fish = babl_fish (out_format, output_buf_format);
-            thread_data[j].output_tmp = gegl_temp_buffer (temp_id++, out_bpp * result->width * 
result->height);
           }
           else
           {
@@ -342,6 +339,7 @@ gegl_operation_point_filter_process (GeglOperation       *operation,
             gint threads = gegl_config_threads ();
             gint pending;
             gint bit;
+           gint temp_id = 0;
 
             if (i->roi[0].height < threads)
             {
@@ -370,6 +368,14 @@ gegl_operation_point_filter_process (GeglOperation       *operation,
               thread_data[j].level = level;
               thread_data[j].success = TRUE;
             }
+
+
+           for (gint j = 0; j < threads; j++)
+           {
+               thread_data[j].in_tmp = input?gegl_temp_buffer (temp_id++, in_bpp * i->roi[j].width * 
i->roi[j].height):NULL;
+               thread_data[j].output_tmp = gegl_temp_buffer (temp_id++, out_bpp * i->roi[j].width * 
i->roi[j].height);
+           }
+
             pending = threads;
 
             for (gint j = 1; j < threads; j++)


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