Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2020-05-05 00:59:58 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-05-05 15:06:08 +0300
commit4e5a328e556109162b81ec3a388988375a91b0d9 (patch)
treeacf1e4b9ffee67b079714f5ddf5e1dfc9bcb2321 /source/blender/blenlib
parentc54ced9f5529e2111144f29eadbada215f627fa0 (diff)
Tasks: support build with TBB version 2017
Make the task pool implementation compatible with older versions that are used by install_deps.sh.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/task_pool.cc31
-rw-r--r--source/blender/blenlib/intern/task_scheduler.cc11
2 files changed, 33 insertions, 9 deletions
diff --git a/source/blender/blenlib/intern/task_pool.cc b/source/blender/blenlib/intern/task_pool.cc
index b0d7df92343..b97db30d64f 100644
--- a/source/blender/blenlib/intern/task_pool.cc
+++ b/source/blender/blenlib/intern/task_pool.cc
@@ -72,7 +72,10 @@ class Task {
}
}
- /* Move constructor. */
+ /* Move constructor.
+ * For performance, ensure we never copy the task and only move it.
+ * For TBB version 2017 and earlier we apply a workaround to make up for
+ * the lack of move constructor support. */
Task(Task &&other)
: pool(other.pool),
run(other.run),
@@ -87,16 +90,32 @@ class Task {
other.freedata = NULL;
}
- /* Execute task. */
- void operator()() const
+#if defined(WITH_TBB) && TBB_INTERFACE_VERSION_MAJOR < 10
+ Task(const Task &other)
+ : pool(other.pool),
+ run(other.run),
+ taskdata(other.taskdata),
+ free_taskdata(other.free_taskdata),
+ freedata(other.freedata)
{
- run(pool, taskdata);
+ ((Task &)other).pool = NULL;
+ ((Task &)other).run = NULL;
+ ((Task &)other).taskdata = NULL;
+ ((Task &)other).free_taskdata = false;
+ ((Task &)other).freedata = NULL;
}
-
- /* For performance, ensure we never copy the task and only move it. */
+#else
Task(const Task &other) = delete;
+#endif
+
Task &operator=(const Task &other) = delete;
Task &operator=(Task &&other) = delete;
+
+ /* Execute task. */
+ void operator()() const
+ {
+ run(pool, taskdata);
+ }
};
/* TBB Task Group.
diff --git a/source/blender/blenlib/intern/task_scheduler.cc b/source/blender/blenlib/intern/task_scheduler.cc
index 682fee5c46d..325056d41ee 100644
--- a/source/blender/blenlib/intern/task_scheduler.cc
+++ b/source/blender/blenlib/intern/task_scheduler.cc
@@ -29,18 +29,21 @@
/* Quiet top level deprecation message, unrelated to API usage here. */
# define TBB_SUPPRESS_DEPRECATED_MESSAGES 1
# include <tbb/tbb.h>
+# if TBB_INTERFACE_VERSION_MAJOR >= 10
+# define WITH_TBB_GLOBAL_CONTROL
+# endif
#endif
/* Task Scheduler */
static int task_scheduler_num_threads = 1;
-#ifdef WITH_TBB
+#ifdef WITH_TBB_GLOBAL_CONTROL
static tbb::global_control *task_scheduler_global_control = nullptr;
#endif
void BLI_task_scheduler_init()
{
-#ifdef WITH_TBB
+#ifdef WITH_TBB_GLOBAL_CONTROL
const int num_threads_override = BLI_system_num_threads_override_get();
if (num_threads_override > 0) {
@@ -57,12 +60,14 @@ void BLI_task_scheduler_init()
* at all. */
task_scheduler_num_threads = BLI_system_thread_count();
}
+#else
+ task_scheduler_num_threads = BLI_system_thread_count();
#endif
}
void BLI_task_scheduler_exit()
{
-#ifdef WITH_TBB
+#ifdef WITH_TBB_GLOBAL_CONTROL
OBJECT_GUARDED_DELETE(task_scheduler_global_control, tbb::global_control);
#endif
}