[gegl] operation: allow disabling dynamic per-op thread-cost using env var



commit 25c6a617081cb9b285fde45e7e43a5d37eefee4f
Author: Ell <ell_se yahoo com>
Date:   Sun Apr 26 13:11:23 2020 +0300

    operation: allow disabling dynamic per-op thread-cost using env var
    
    In GeglOperation, allow disabling the dynamic per-operation thread-
    cost by setting the GEGL_DYNAMIC_THREAD_COST environment varaible
    to 0, for troubleshooting.  When disabled,
    gegl_operation_get_pixels_per_thread() always returns the default
    thread cost (currently 64x64 pixels per thread).

 gegl/operation/gegl-operation.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/gegl/operation/gegl-operation.c b/gegl/operation/gegl-operation.c
index 39e6ba6e3..e8097eda6 100644
--- a/gegl/operation/gegl-operation.c
+++ b/gegl/operation/gegl-operation.c
@@ -20,6 +20,7 @@
 #include "config.h"
 
 #include <glib-object.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include "gegl.h"
@@ -875,12 +876,33 @@ gegl_operation_use_threading (GeglOperation *operation,
   return FALSE;
 }
 
+static gboolean
+gegl_operation_dynamic_thread_cost (void)
+{
+  static gint dynamic_thread_cost = -1;
+
+  if (dynamic_thread_cost < 0)
+    {
+      if (g_getenv ("GEGL_DYNAMIC_THREAD_COST"))
+        {
+          dynamic_thread_cost = atoi (g_getenv ("GEGL_DYNAMIC_THREAD_COST")) ?
+                                TRUE : FALSE;
+        }
+      else
+        {
+          dynamic_thread_cost = TRUE;
+        }
+    }
+
+  return dynamic_thread_cost;
+}
+
 gdouble
 gegl_operation_get_pixels_per_thread (GeglOperation *operation)
 {
   GeglOperationPrivate *priv = gegl_operation_get_instance_private (operation);
 
-  if (priv->pixel_time < 0.0)
+  if (priv->pixel_time < 0.0 || ! gegl_operation_dynamic_thread_cost ())
     return GEGL_OPERATION_DEFAULT_PIXELS_PER_THREAD;
   else if (priv->pixel_time == 0.0)
     return GEGL_OPERATION_MAX_PIXELS_PER_THREAD;


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