[Bf-blender-cvs] [c8e3e6006fa] temp-compositor-scheduling: Tweaked InputToOutput scheduling.

Jeroen Bakker noreply at git.blender.org
Tue Apr 13 10:49:20 CEST 2021


Commit: c8e3e6006fa75a0ead0e29220f238f409565b81d
Author: Jeroen Bakker
Date:   Tue Apr 13 10:48:53 2021 +0200
Branches: temp-compositor-scheduling
https://developer.blender.org/rBc8e3e6006fa75a0ead0e29220f238f409565b81d

Tweaked InputToOutput scheduling.

No real difference in perfomance.

===================================================================

M	source/blender/blenlib/BLI_threads.h
M	source/blender/blenlib/intern/threads.cc
M	source/blender/compositor/intern/COM_ExecutionSystem.cc

===================================================================

diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index eefde1afefb..229728c597d 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -195,6 +195,8 @@ void BLI_thread_queue_nowait(ThreadQueue *queue);
 #  define BLI_thread_local_set(name, value) name = value
 #endif /* defined(__APPLE__) */
 
+void BLI_thread_yield(void);
+
 /* **** Special functions to help performance on crazy NUMA setups. **** */
 
 /* Make sure process/thread is using NUMA node with fast memory access. */
diff --git a/source/blender/blenlib/intern/threads.cc b/source/blender/blenlib/intern/threads.cc
index 35097013439..50741811001 100644
--- a/source/blender/blenlib/intern/threads.cc
+++ b/source/blender/blenlib/intern/threads.cc
@@ -24,6 +24,7 @@
 #include <cerrno>
 #include <cstdlib>
 #include <cstring>
+#include <thread>
 
 #include "MEM_guardedalloc.h"
 
@@ -815,6 +816,11 @@ void BLI_thread_queue_wait_finish(ThreadQueue *queue)
   pthread_mutex_unlock(&queue->mutex);
 }
 
+void BLI_thread_yield(void)
+{
+  std::this_thread::yield();
+}
+
 /* **** Special functions to help performance on crazy NUMA setups. **** */
 
 #if 0  /* UNUSED */
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cc b/source/blender/compositor/intern/COM_ExecutionSystem.cc
index 67264a94c73..3482fe24768 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cc
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cc
@@ -33,8 +33,6 @@
 #include "COM_ReadBufferOperation.h"
 #include "COM_WorkScheduler.h"
 
-#include <thread>
-
 #ifdef WITH_CXX_GUARDEDALLOC
 #  include "MEM_guardedalloc.h"
 #endif
@@ -273,26 +271,41 @@ void ExecutionSystem::execute()
   }
 }
 
-static bool is_completed(Vector<ExecutionGroup *> &groups)
+static bool is_completed(ExecutionGroup *group)
 {
-  for (ExecutionGroup *group : groups) {
-    for (WorkPackage &work_package : group->get_work_packages()) {
-      if (work_package.state != eWorkPackageState::Executed) {
-        return false;
-      }
+  for (const WorkPackage &work_package : group->get_work_packages()) {
+    if (work_package.priority != eCompositorPriority::Unset &&
+        work_package.state != eWorkPackageState::Executed) {
+      return false;
+    }
+  }
+  return true;
+}
+
+/* NOTE: function changes `uncompleted_groups` parameter. */
+static bool is_completed(Vector<ExecutionGroup *> &uncompleted_groups)
+{
+  while (uncompleted_groups.size()) {
+    ExecutionGroup *group = uncompleted_groups.last();
+    if (is_completed(group)) {
+      uncompleted_groups.remove_last();
+    }
+    else {
+      return false;
     }
   }
   return true;
 }
 
-static void wait_for_completion(const bNodeTree *node_tree, Vector<ExecutionGroup *> &groups)
+static void wait_for_completion(const bNodeTree *node_tree, const Vector<ExecutionGroup *> &groups)
 {
-  while (!is_completed(groups)) {
+  Vector<ExecutionGroup *> uncompleted_groups = groups;
+
+  while (!is_completed(uncompleted_groups)) {
     if (node_tree->test_break && node_tree->test_break(node_tree->tbh)) {
       break;
     }
-    /* TODO: Wrap this in a function in BLI. */
-    std::this_thread::yield();
+    BLI_thread_yield();
   }
 }



More information about the Bf-blender-cvs mailing list