View | Details | Raw Unified | Return to bug 252788
Collapse All | Expand All

(-)misc/openvdb/Makefile (-3 / +3 lines)
Lines 1-7 Link Here
1
PORTNAME=	openvdb
1
PORTNAME=	openvdb
2
DISTVERSIONPREFIX=	v
2
DISTVERSIONPREFIX=	v
3
DISTVERSION=	8.1.0
3
DISTVERSION=	8.1.0
4
PORTREVISION=	4
4
PORTREVISION=	5
5
CATEGORIES=	misc
5
CATEGORIES=	misc
6
6
7
MAINTAINER=	yuri@FreeBSD.org
7
MAINTAINER=	yuri@FreeBSD.org
Lines 13-19 LICENSE_FILE= ${WRKSRC}/LICENSE Link Here
13
LIB_DEPENDS=	libblosc.so:archivers/c-blosc \
13
LIB_DEPENDS=	libblosc.so:archivers/c-blosc \
14
		libboost_system.so:devel/boost-libs \
14
		libboost_system.so:devel/boost-libs \
15
		libImath.so:math/Imath \
15
		libImath.so:math/Imath \
16
		libtbb.so:devel/tbb
16
		libtbb.so:devel/onetbb
17
TEST_DEPENDS=	googletest>0:devel/googletest
17
TEST_DEPENDS=	googletest>0:devel/googletest
18
18
19
USES=		cmake:testing compiler:c++11-lang localbase:ldflags pkgconfig
19
USES=		cmake:testing compiler:c++11-lang localbase:ldflags pkgconfig
Lines 22-28 USE_LDCONFIG= yes Link Here
22
USE_GITHUB=	yes
22
USE_GITHUB=	yes
23
GH_ACCOUNT=	AcademySoftwareFoundation
23
GH_ACCOUNT=	AcademySoftwareFoundation
24
24
25
CMAKE_ARGS=		-DCONCURRENT_MALLOC="Tbbmalloc"
25
CMAKE_ARGS=		-DCONCURRENT_MALLOC="Tbbmalloc" -DTbb_INCLUDE_DIR=${LOCALBASE}/include
26
CMAKE_OFF=		OPENVDB_CORE_STATIC
26
CMAKE_OFF=		OPENVDB_CORE_STATIC
27
CMAKE_TESTING_ON=	OPENVDB_BUILD_UNITTESTS # one test fails: https://github.com/AcademySoftwareFoundation/openvdb/issues/1103
27
CMAKE_TESTING_ON=	OPENVDB_BUILD_UNITTESTS # one test fails: https://github.com/AcademySoftwareFoundation/openvdb/issues/1103
28
28
(-)misc/openvdb/files/patch-cmake_FindTBB.cmake (-7 / +42 lines)
Lines 1-10 Link Here
1
--- cmake/FindTBB.cmake.orig	2021-02-05 19:21:38 UTC
1
--- cmake/FindTBB.cmake.orig	2021-08-14 21:20:14 UTC
2
+++ cmake/FindTBB.cmake
2
+++ cmake/FindTBB.cmake
3
@@ -93,7 +93,6 @@ endif()
3
@@ -168,8 +168,22 @@ find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
4
 set(_TBB_COMPONENT_LIST
4
   PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
5
   tbb
6
   tbbmalloc
7
-  tbbmalloc_proxy
8
 )
5
 )
9
 
6
 
10
 if(TBB_FIND_COMPONENTS)
7
-if(EXISTS "${Tbb_INCLUDE_DIR}/tbb/tbb_stddef.h")
8
-  file(STRINGS "${Tbb_INCLUDE_DIR}/tbb/tbb_stddef.h"
9
+set(_tbb_version_file "${Tbb_INCLUDE_DIR}/tbb/tbb_stddef.h")
10
+
11
+if(NOT EXISTS ${_tbb_version_file})
12
+  # From TBB 2021, tbb_stddef is removed and the directory include/tbb is
13
+  # simply an alias for include/oneapi/tbb. Try and find the version header
14
+  # in oneapi/tbb
15
+  find_path(Tbb_INCLUDE_DIR oneapi/tbb/version.h
16
+    ${_FIND_TBB_ADDITIONAL_OPTIONS}
17
+    PATHS ${_TBB_INCLUDE_SEARCH_DIRS}
18
+    PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
19
+  )
20
+  set(_tbb_version_file "${Tbb_INCLUDE_DIR}/oneapi/tbb/version.h")
21
+endif()
22
+
23
+if(EXISTS ${_tbb_version_file})
24
+  file(STRINGS ${_tbb_version_file}
25
     _tbb_version_major_string REGEX "#define TBB_VERSION_MAJOR "
26
   )
27
   string(REGEX REPLACE "#define TBB_VERSION_MAJOR" ""
28
@@ -177,7 +191,7 @@ if(EXISTS "${Tbb_INCLUDE_DIR}/tbb/tbb_stddef.h")
29
   )
30
   string(STRIP "${_tbb_version_major_string}" Tbb_VERSION_MAJOR)
31
 
32
-  file(STRINGS "${Tbb_INCLUDE_DIR}/tbb/tbb_stddef.h"
33
+  file(STRINGS ${_tbb_version_file}
34
      _tbb_version_minor_string REGEX "#define TBB_VERSION_MINOR "
35
   )
36
   string(REGEX REPLACE "#define TBB_VERSION_MINOR" ""
37
@@ -190,6 +204,8 @@ if(EXISTS "${Tbb_INCLUDE_DIR}/tbb/tbb_stddef.h")
38
 
39
   set(Tbb_VERSION ${Tbb_VERSION_MAJOR}.${Tbb_VERSION_MINOR})
40
 endif()
41
+
42
+unset(_tbb_version_file)
43
 
44
 # ------------------------------------------------------------------------
45
 #  Search for TBB lib DIR
(-)misc/openvdb/files/patch-openvdb__houdini_openvdb__houdini_SOP__OpenVDB__Rasterize__Points.cc (+28 lines)
Added Link Here
1
--- openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
3
@@ -20,6 +20,7 @@
4
 #include <openvdb/tools/GridTransformer.h>
5
 #include <openvdb/tools/PointIndexGrid.h>
6
 #include <openvdb/tools/Prune.h>
7
+#include <openvdb/thread/Threading.h>
8
 
9
 #include <CH/CH_Manager.h>
10
 #include <CVEX/CVEX_Context.h>
11
@@ -786,7 +787,7 @@ struct ConstructCandidateVoxelMask
12
         for (size_t n = range.begin(), N = range.end(); n != N; ++n) {
13
 
14
             if (this->wasInterrupted()) {
15
-                tbb::task::self().cancel_group_execution();
16
+                openvdb::thread::cancelGroupExecution();
17
                 break;
18
             }
19
 
20
@@ -2092,7 +2093,7 @@ struct RasterizePoints
21
         for (size_t n = range.begin(), N = range.end(); n != N; ++n) {
22
 
23
             if (this->wasInterrupted()) {
24
-                tbb::task::self().cancel_group_execution();
25
+                openvdb::thread::cancelGroupExecution();
26
                 break;
27
             }
28
 
(-)misc/openvdb/files/patch-openvdb__houdini_openvdb__houdini_SOP__OpenVDB__Sample__Points.cc (+64 lines)
Added Link Here
1
--- openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
3
@@ -16,13 +16,11 @@
4
 #include <openvdb_houdini/SOP_NodeVDB.h>
5
 
6
 #include <openvdb/tools/Interpolation.h>  // for box sampler
7
+#include <openvdb/thread/Threading.h>
8
 #include <openvdb/points/PointCount.h>
9
 #include <openvdb/points/PointSample.h>
10
 #include <openvdb/points/IndexFilter.h>   // for MultiGroupFilter
11
 
12
-#include <tbb/tick_count.h>                 // for timing
13
-#include <tbb/task.h>                       // for cancel
14
-
15
 #include <UT/UT_Interrupt.h>
16
 #include <GA/GA_PageHandle.h>
17
 #include <GA/GA_PageIterator.h>
18
@@ -38,6 +36,7 @@
19
 #include <stdexcept>
20
 #include <string>
21
 #include <vector>
22
+#include <chrono>
23
 
24
 
25
 
26
@@ -327,7 +326,7 @@ class PointSampler (public)
27
     {
28
 
29
         if (mInterrupter->wasInterrupted()) {
30
-            tbb::task::self().cancel_group_execution();
31
+            openvdb::thread::cancelGroupExecution();
32
         }
33
         const GridType& grid = UTvdbGridCast<GridType>(mGrid);
34
         // task local grid accessor
35
@@ -481,7 +480,7 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Contex
36
         int numUnnamedGrids = 0;
37
 
38
         // start time
39
-        tbb::tick_count time_start = tbb::tick_count::now();
40
+        auto time_start = std::chrono::steady_clock::now();
41
         UT_AutoInterrupt progress("Sampling from VDB grids");
42
 
43
         for (hvdb::VdbPrimCIterator it(bGdp, group); it; ++it) {
44
@@ -706,15 +705,16 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Contex
45
             }
46
         }
47
 
48
-        // timing: end time
49
-        tbb::tick_count time_end = tbb::tick_count::now();
50
-
51
         if (verbose) {
52
+            // timing: end time
53
+            auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
54
+                std::chrono::steady_clock::now() - time_start);
55
+            const double seconds = double(duration.count()) / 1000.0;
56
             std::cout << "Sampling " << nPoints + nVDBPoints << " points in "
57
                       << numVectorGrids << " vector grid" << (numVectorGrids == 1 ? "" : "s")
58
                       << " and " << numScalarGrids << " scalar grid"
59
                           << (numScalarGrids == 1 ? "" : "s")
60
-                      << " took " << (time_end - time_start).seconds() << " seconds\n "
61
+                      << " took " << seconds << " seconds\n "
62
                       << (threaded ? "threaded" : "non-threaded") << std::endl;
63
         }
64
 
(-)misc/openvdb/files/patch-openvdb__maya_openvdb__maya_OpenVDBPlugin.cc (+42 lines)
Added Link Here
1
--- openvdb_maya/openvdb_maya/OpenVDBPlugin.cc.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
3
@@ -47,11 +47,8 @@ struct NodeInfo {
4
 
5
 typedef std::vector<NodeInfo> NodeList;
6
 
7
-typedef tbb::mutex Mutex;
8
-typedef Mutex::scoped_lock Lock;
9
-
10
 // Declare this at file scope to ensure thread-safe initialization.
11
-Mutex sRegistryMutex;
12
+std::mutex sRegistryMutex;
13
 
14
 NodeList * gNodes = NULL;
15
 
16
@@ -70,7 +67,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, co
17
     node.type               = type;
18
     node.classification     = classification;
19
 
20
-    Lock lock(sRegistryMutex);
21
+    std::lock_guard<std::mutex> lock(sRegistryMutex);
22
 
23
     if (!gNodes) {
24
         OPENVDB_START_THREADSAFE_STATIC_WRITE
25
@@ -85,7 +82,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, co
26
 void
27
 NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
28
 {
29
-    Lock lock(sRegistryMutex);
30
+    std::lock_guard<std::mutex> lock(sRegistryMutex);
31
 
32
     if (gNodes) {
33
         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
34
@@ -109,7 +106,7 @@ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus
35
 void
36
 NodeRegistry::deregisterNodes(MFnPlugin& plugin, MStatus& status)
37
 {
38
-    Lock lock(sRegistryMutex);
39
+    std::lock_guard<std::mutex> lock(sRegistryMutex);
40
 
41
     if (gNodes) {
42
         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
(-)misc/openvdb/files/patch-openvdb__maya_openvdb__maya_OpenVDBUtil.h (+49 lines)
Added Link Here
1
--- openvdb_maya/openvdb_maya/OpenVDBUtil.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb_maya/openvdb_maya/OpenVDBUtil.h
3
@@ -14,9 +14,8 @@
4
 #include <openvdb/tree/LeafManager.h>
5
 #include <openvdb/tools/VolumeToMesh.h>
6
 #include <openvdb/util/Formats.h> // printBytes
7
+#include <openvdb/thread/Threading.h>
8
 
9
-#include <tbb/tick_count.h>
10
-
11
 #include <maya/M3dView.h>
12
 #include <maya/MString.h>
13
 #include <maya/MDataBlock.h>
14
@@ -40,6 +39,7 @@
15
 #include <string>
16
 #include <type_traits>
17
 #include <vector>
18
+#include <chrono>
19
 
20
 
21
 ////////////////////////////////////////
22
@@ -116,11 +116,15 @@ insertFrameNumber(std::string& str, const MTime& time,
23
 
24
 struct Timer
25
 {
26
-    Timer() : mStamp(tbb::tick_count::now()) { }
27
+    Timer() : mStamp(std::chrono::steady_clock::now()) { }
28
 
29
-    void reset() { mStamp = tbb::tick_count::now(); }
30
+    void reset() { mStamp = std::chrono::steady_clock::now(); }
31
 
32
-    double seconds() const { return (tbb::tick_count::now() - mStamp).seconds(); }
33
+    double seconds() const {
34
+        auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
35
+            std::chrono::steady_clock::now() - mStamp);
36
+        return double(duration.count()) / 1000.0;
37
+    }
38
 
39
     std::string elapsedTime() const {
40
         double sec = seconds();
41
@@ -128,7 +132,7 @@ struct Timer
42
     }
43
 
44
 private:
45
-    tbb::tick_count mStamp;
46
+     std::chrono::time_point<std::chrono::steady_clock> mStamp;
47
 };
48
 
49
 
(-)misc/openvdb/files/patch-openvdb_openvdb_CMakeLists.txt (-18 / +15 lines)
Lines 1-21 Link Here
1
--- openvdb/openvdb/CMakeLists.txt.orig	2021-06-11 21:38:41 UTC
1
--- openvdb/openvdb/CMakeLists.txt.orig	2021-08-14 21:20:14 UTC
2
+++ openvdb/openvdb/CMakeLists.txt
2
+++ openvdb/openvdb/CMakeLists.txt
3
@@ -128,8 +128,8 @@ if(OPENVDB_FUTURE_DEPRECATION AND FUTURE_MINIMUM_TBB_V
3
@@ -437,6 +437,10 @@ set(OPENVDB_LIBRARY_UTIL_INCLUDE_FILES
4
   endif()
4
   util/Util.h
5
 endif()
6
 
7
+find_package(Imath ${MINIMUM_ILMBASE_VERSION} REQUIRED)
8
 if(USE_IMATH_HALF)
9
-  find_package(IlmBase ${MINIMUM_ILMBASE_VERSION} REQUIRED COMPONENTS Half)
10
   if(OPENVDB_FUTURE_DEPRECATION AND FUTURE_MINIMUM_ILMBASE_VERSION)
11
     if(${IlmBase_VERSION} VERSION_LESS FUTURE_MINIMUM_ILMBASE_VERSION)
12
       message(DEPRECATION "Support for IlmBase versions < ${FUTURE_MINIMUM_ILMBASE_VERSION} "
13
@@ -191,7 +191,7 @@ set(OPENVDB_CORE_DEPENDENT_LIBS
14
 )
5
 )
15
 
6
 
16
 if(USE_IMATH_HALF)
7
+set(OPENVDB_LIBRARY_THREAD_INCLUDE_FILES
17
-  list(APPEND OPENVDB_CORE_DEPENDENT_LIBS IlmBase::Half)
8
+  thread/Threading.h
18
+  list(APPEND OPENVDB_CORE_DEPENDENT_LIBS Imath::Half)
9
+)
19
 endif()
10
+
20
 
11
 # @todo CMake >= 3.12, use an object library to consolidate shared/static
21
 if(WIN32)
12
 # builds. There are limitations with earlier versions of CMake when used with
13
 # imported targets.
14
@@ -592,3 +596,4 @@ install(FILES ${OPENVDB_LIBRARY_POINTS_INCLUDE_FILES} 
15
 install(FILES ${OPENVDB_LIBRARY_TOOLS_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/tools)
16
 install(FILES ${OPENVDB_LIBRARY_TREE_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/tree)
17
 install(FILES ${OPENVDB_LIBRARY_UTIL_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/util)
18
+install(FILES ${OPENVDB_LIBRARY_THREAD_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/thread)
(-)misc/openvdb/files/patch-openvdb_openvdb_cmd_openvdb__render.cc (+33 lines)
Added Link Here
1
--- openvdb/openvdb/cmd/openvdb_render.cc.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/cmd/openvdb_render.cc
3
@@ -19,7 +19,14 @@
4
 #include <OpenEXR/ImfHeader.h>
5
 #include <OpenEXR/ImfOutputFile.h>
6
 #include <OpenEXR/ImfPixelType.h>
7
-#include <tbb/task_scheduler_init.h>
8
+
9
+// tbb/task_scheduler_init.h was removed in TBB 2021. The best construct to swap
10
+// to is tbb/global_control (for executables). global_control was only officially
11
+// added in TBB 2019U4 but exists in 2018 as a preview feature. To avoid more
12
+// compile time branching (as we still support 2018), we use it in 2018 too by
13
+// enabling the below define.
14
+#define TBB_PREVIEW_GLOBAL_CONTROL 1
15
+#include <tbb/global_control.h>
16
 #include <tbb/tick_count.h>
17
 
18
 #include <algorithm>
19
@@ -606,8 +613,12 @@ main(int argc, char *argv[])
20
     }
21
 
22
     try {
23
-        tbb::task_scheduler_init schedulerInit(
24
-            (opts.threads == 0) ? tbb::task_scheduler_init::automatic : opts.threads);
25
+        std::unique_ptr<tbb::global_control> control;
26
+        if (opts.threads > 0) {
27
+            // note, opts.threads == 0 means use all threads (default), so don't
28
+            // manually create a tbb::global_control in this case
29
+            control.reset(new tbb::global_control(tbb::global_control::max_allowed_parallelism, opts.threads));
30
+        }
31
 
32
         openvdb::initialize();
33
 
(-)misc/openvdb/files/patch-openvdb_openvdb_io_Queue.cc (+158 lines)
Added Link Here
1
--- openvdb/openvdb/io/Queue.cc.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/io/Queue.cc
3
@@ -5,21 +5,23 @@
4
 /// @author Peter Cucka
5
 
6
 #include "Queue.h"
7
-
8
 #include "File.h"
9
 #include "Stream.h"
10
-#include <openvdb/Exceptions.h>
11
-#include <openvdb/util/logging.h>
12
+#include "openvdb/Exceptions.h"
13
+#include "openvdb/util/logging.h"
14
+
15
 #include <tbb/concurrent_hash_map.h>
16
-#include <tbb/task.h>
17
-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
18
-#include <tbb/tick_count.h>
19
+#include <tbb/task_arena.h>
20
+
21
+#include <thread>
22
 #include <algorithm> // for std::max()
23
 #include <atomic>
24
 #include <iostream>
25
 #include <map>
26
 #include <mutex>
27
+#include <chrono>
28
 
29
+
30
 namespace openvdb {
31
 OPENVDB_USE_VERSION_NAMESPACE
32
 namespace OPENVDB_VERSION_NAME {
33
@@ -28,18 +30,19 @@ namespace io {
34
 namespace {
35
 
36
 // Abstract base class for queuable TBB tasks that adds a task completion callback
37
-class Task: public tbb::task
38
+class Task
39
 {
40
 public:
41
     Task(Queue::Id id): mId(id) {}
42
-    ~Task() override {}
43
+    virtual ~Task() {}
44
 
45
     Queue::Id id() const { return mId; }
46
 
47
     void setNotifier(Queue::Notifier& notifier) { mNotify = notifier; }
48
+    virtual void execute() const = 0;
49
 
50
 protected:
51
-    void notify(Queue::Status status) { if (mNotify) mNotify(this->id(), status); }
52
+    void notify(Queue::Status status) const { if (mNotify) mNotify(this->id(), status); }
53
 
54
 private:
55
     Queue::Id mId;
56
@@ -48,7 +51,7 @@ class Task: public tbb::task (private)
57
 
58
 
59
 // Queuable TBB task that writes one or more grids to a .vdb file or an output stream
60
-class OutputTask: public Task
61
+class OutputTask : public Task
62
 {
63
 public:
64
     OutputTask(Queue::Id id, const GridCPtrVec& grids, const Archive& archive,
65
@@ -56,10 +59,10 @@ class OutputTask: public Task (public)
66
         : Task(id)
67
         , mGrids(grids)
68
         , mArchive(archive.copy())
69
-        , mMetadata(metadata)
70
-    {}
71
+        , mMetadata(metadata) {}
72
+    ~OutputTask() override {}
73
 
74
-    tbb::task* execute() override
75
+    void execute() const override
76
     {
77
         Queue::Status status = Queue::FAILED;
78
         try {
79
@@ -69,10 +72,8 @@ class OutputTask: public Task (public)
80
             if (const char* msg = e.what()) {
81
                 OPENVDB_LOG_ERROR(msg);
82
             }
83
-        } catch (...) {
84
-        }
85
+        } catch (...) {}
86
         this->notify(status);
87
-        return nullptr; // no successor to this task
88
     }
89
 
90
 private:
91
@@ -94,7 +95,6 @@ struct Queue::Impl
92
     /// @todo Provide more information than just "succeeded" or "failed"?
93
     using StatusMap = tbb::concurrent_hash_map<Queue::Id, Queue::Status>;
94
 
95
-
96
     Impl()
97
         : mTimeout(Queue::DEFAULT_TIMEOUT)
98
         , mCapacity(Queue::DEFAULT_CAPACITY)
99
@@ -159,12 +159,15 @@ struct Queue::Impl
100
 
101
     bool canEnqueue() const { return mNumTasks < Int64(mCapacity); }
102
 
103
-    void enqueue(Task& task)
104
+    void enqueue(OutputTask& task)
105
     {
106
-        tbb::tick_count start = tbb::tick_count::now();
107
+        auto start = std::chrono::steady_clock::now();
108
         while (!canEnqueue()) {
109
-            tbb::this_tbb_thread::sleep(tbb::tick_count::interval_t(0.5/*sec*/));
110
-            if ((tbb::tick_count::now() - start).seconds() > double(mTimeout)) {
111
+            std::this_thread::sleep_for(/*0.5s*/std::chrono::milliseconds(500));
112
+            auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
113
+                std::chrono::steady_clock::now() - start);
114
+            const double seconds = double(duration.count()) / 1000.0;
115
+            if (seconds > double(mTimeout)) {
116
                 OPENVDB_THROW(RuntimeError,
117
                     "unable to queue I/O task; " << mTimeout << "-second time limit expired");
118
             }
119
@@ -173,7 +176,10 @@ struct Queue::Impl
120
             std::placeholders::_1, std::placeholders::_2);
121
         task.setNotifier(notify);
122
         this->setStatus(task.id(), Queue::PENDING);
123
-        tbb::task::enqueue(task);
124
+
125
+        // get the global task arena
126
+        tbb::task_arena arena(tbb::task_arena::attach{});
127
+        arena.enqueue([task = std::move(task)] { task.execute(); });
128
         ++mNumTasks;
129
     }
130
 
131
@@ -204,7 +210,7 @@ Queue::~Queue()
132
     /// (e.g., by keeping a static registry of queues that also dispatches
133
     /// or blocks notifications)?
134
     while (mImpl->mNumTasks > 0) {
135
-        tbb::this_tbb_thread::sleep(tbb::tick_count::interval_t(0.5/*sec*/));
136
+        std::this_thread::sleep_for(/*0.5s*/std::chrono::milliseconds(500));
137
     }
138
 }
139
 
140
@@ -290,16 +296,8 @@ Queue::Id
141
 Queue::writeGridVec(const GridCPtrVec& grids, const Archive& archive, const MetaMap& metadata)
142
 {
143
     const Queue::Id taskId = mImpl->mNextId++;
144
-    // From the "GUI Thread" chapter in the TBB Design Patterns guide
145
-    OutputTask* task =
146
-        new(tbb::task::allocate_root()) OutputTask(taskId, grids, archive, metadata);
147
-    try {
148
-        mImpl->enqueue(*task);
149
-    } catch (openvdb::RuntimeError&) {
150
-        // Destroy the task if it could not be enqueued, then rethrow the exception.
151
-        tbb::task::destroy(*task);
152
-        throw;
153
-    }
154
+    OutputTask task(taskId, grids, archive, metadata);
155
+    mImpl->enqueue(task);
156
     return taskId;
157
 }
158
 
(-)misc/openvdb/files/patch-openvdb_openvdb_math_Coord.h (+12 lines)
Added Link Here
1
--- openvdb/openvdb/math/Coord.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/math/Coord.h
3
@@ -13,8 +13,7 @@
4
 #include "Math.h"
5
 #include "Vec3.h"
6
 
7
-namespace tbb { class split; } // forward declaration
8
-
9
+#include <tbb/blocked_range.h> // for tbb::split
10
 
11
 namespace openvdb {
12
 OPENVDB_USE_VERSION_NAMESPACE
(-)misc/openvdb/files/patch-openvdb_openvdb_points_PointSample.h (+31 lines)
Added Link Here
1
--- openvdb/openvdb/points/PointSample.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/points/PointSample.h
3
@@ -10,8 +10,9 @@
4
 #ifndef OPENVDB_POINTS_POINT_SAMPLE_HAS_BEEN_INCLUDED
5
 #define OPENVDB_POINTS_POINT_SAMPLE_HAS_BEEN_INCLUDED
6
 
7
-#include <openvdb/util/NullInterrupter.h>
8
-#include <openvdb/tools/Interpolation.h>
9
+#include "openvdb/util/NullInterrupter.h"
10
+#include "openvdb/thread/Threading.h"
11
+#include "openvdb/tools/Interpolation.h"
12
 
13
 #include "PointDataGrid.h"
14
 #include "PointAttribute.h"
15
@@ -19,7 +20,6 @@
16
 #include <sstream>
17
 #include <type_traits>
18
 
19
-
20
 namespace openvdb {
21
 OPENVDB_USE_VERSION_NAMESPACE
22
 namespace OPENVDB_VERSION_NAME {
23
@@ -299,7 +299,7 @@ class PointDataSampler (private)
24
             using TargetHandleT = AttributeWriteHandle<typename SamplerWrapperT::ValueType>;
25
 
26
             if (util::wasInterrupted(interrupter)) {
27
-                tbb::task::self().cancel_group_execution();
28
+                thread::cancelGroupExecution();
29
                 return;
30
             }
31
 
(-)misc/openvdb/files/patch-openvdb_openvdb_thread_Threading.h (+57 lines)
Added Link Here
1
--- openvdb/openvdb/thread/Threading.h.orig	2021-08-14 21:20:25 UTC
2
+++ openvdb/openvdb/thread/Threading.h
3
@@ -0,0 +1,54 @@
4
+// Copyright Contributors to the OpenVDB Project
5
+// SPDX-License-Identifier: MPL-2.0
6
+//
7
+/// @file Threading.h
8
+
9
+#ifndef OPENVDB_THREAD_THREADING_HAS_BEEN_INCLUDED
10
+#define OPENVDB_THREAD_THREADING_HAS_BEEN_INCLUDED
11
+
12
+#include "openvdb/version.h"
13
+
14
+/// @note tbb/blocked_range.h is the ONLY include that persists from TBB 2020
15
+///   to TBB 2021 that itself includes the TBB specific version header files.
16
+///   In TBB 2020, the version header was called tbb/stddef.h. In 2021, it's
17
+///   called tbb/version.h. We include tbb/blocked_range.h here to indirectly
18
+///   access the version defines in a consistent way so that downstream
19
+///   software doesn't need to provide compile time defines.
20
+#include <tbb/blocked_range.h>
21
+#include <tbb/task.h>
22
+#include <tbb/task_group.h>
23
+
24
+namespace openvdb {
25
+OPENVDB_USE_VERSION_NAMESPACE
26
+namespace OPENVDB_VERSION_NAME {
27
+namespace thread {
28
+
29
+inline bool cancelGroupExecution()
30
+{
31
+    // @note 12000 was the 2021.1-beta05 release. The 2021.1-beta08 release
32
+    //   introduced current_context().
33
+#if TBB_INTERFACE_VERSION >= 12002
34
+    auto ctx = tbb::task::current_context();
35
+    return ctx ? ctx->cancel_group_execution() : false;
36
+#else
37
+    return tbb::task::self().cancel_group_execution();
38
+#endif
39
+}
40
+
41
+inline bool isGroupExecutionCancelled()
42
+{
43
+    // @note 12000 was the 2021.1-beta05 release. The 2021.1-beta08 release
44
+    //   introduced current_context().
45
+#if TBB_INTERFACE_VERSION >= 12002
46
+    auto ctx = tbb::task::current_context();
47
+    return ctx ? ctx->is_group_execution_cancelled() : false;
48
+#else
49
+    return tbb::task::self().is_cancelled();
50
+#endif
51
+}
52
+
53
+} // namespace thread
54
+} // namespace OPENVDB_VERSION_NAME
55
+} // namespace openvdb
56
+
57
+#endif // OPENVDB_THREAD_THREADING_HAS_BEEN_INCLUDED
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_Composite.h (+10 lines)
Added Link Here
1
--- openvdb/openvdb/tools/Composite.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/Composite.h
3
@@ -24,7 +24,6 @@
4
 #include <tbb/parallel_for.h>
5
 #include <tbb/parallel_reduce.h>
6
 #include <tbb/task_group.h>
7
-#include <tbb/task_scheduler_init.h>
8
 
9
 #include <type_traits>
10
 #include <functional>
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_Diagnostics.h (+67 lines)
Added Link Here
1
--- openvdb/openvdb/tools/Diagnostics.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/Diagnostics.h
3
@@ -11,14 +11,17 @@
4
 #ifndef OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
5
 #define OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
6
 
7
-#include <openvdb/Grid.h>
8
-#include <openvdb/math/Math.h>
9
-#include <openvdb/math/Vec3.h>
10
-#include <openvdb/math/Stencils.h>
11
-#include <openvdb/math/Operators.h>
12
-#include <openvdb/tree/LeafManager.h>
13
+#include "openvdb/Grid.h"
14
+#include "openvdb/math/Math.h"
15
+#include "openvdb/math/Vec3.h"
16
+#include "openvdb/math/Stencils.h"
17
+#include "openvdb/math/Operators.h"
18
+#include "openvdb/tree/LeafManager.h"
19
+#include "openvdb/thread/Threading.h"
20
+
21
 #include <tbb/blocked_range.h>
22
 #include <tbb/parallel_reduce.h>
23
+
24
 #include <cmath> // for std::isnan(), std::isfinite()
25
 #include <set>
26
 #include <sstream>
27
@@ -26,7 +29,6 @@
28
 #include <type_traits>
29
 #include <vector>
30
 
31
-
32
 namespace openvdb {
33
 OPENVDB_USE_VERSION_NAMESPACE
34
 namespace OPENVDB_VERSION_NAME {
35
@@ -1160,13 +1162,13 @@ InactiveVoxelValues<TreeType>::operator()(const tbb::b
36
 {
37
     typename TreeType::LeafNodeType::ValueOffCIter iter;
38
 
39
-    for (size_t n = range.begin(); n < range.end() && !tbb::task::self().is_cancelled(); ++n) {
40
+    for (size_t n = range.begin(); n < range.end() && !thread::isGroupExecutionCancelled(); ++n) {
41
         for (iter = mLeafArray.leaf(n).cbeginValueOff(); iter; ++iter) {
42
             mInactiveValues.insert(iter.getValue());
43
         }
44
 
45
         if (mInactiveValues.size() > mNumValues) {
46
-            tbb::task::self().cancel_group_execution();
47
+            thread::cancelGroupExecution();
48
         }
49
     }
50
 }
51
@@ -1250,14 +1252,14 @@ template<typename TreeType>
52
 inline void
53
 InactiveTileValues<TreeType>::operator()(IterRange& range)
54
 {
55
-    for (; range && !tbb::task::self().is_cancelled(); ++range) {
56
+    for (; range && !thread::isGroupExecutionCancelled(); ++range) {
57
         typename TreeType::ValueOffCIter iter = range.iterator();
58
         for (; iter; ++iter) {
59
             mInactiveValues.insert(iter.getValue());
60
         }
61
 
62
         if (mInactiveValues.size() > mNumValues) {
63
-            tbb::task::self().cancel_group_execution();
64
+            thread::cancelGroupExecution();
65
         }
66
     }
67
 }
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_Filter.h (+47 lines)
Added Link Here
1
--- openvdb/openvdb/tools/Filter.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/Filter.h
3
@@ -14,21 +14,24 @@
4
 #ifndef OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
5
 #define OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
6
 
7
-#include <tbb/parallel_for.h>
8
-#include <openvdb/Types.h>
9
-#include <openvdb/math/Math.h>
10
-#include <openvdb/math/Stencils.h>
11
-#include <openvdb/math/Transform.h>
12
-#include <openvdb/tree/NodeManager.h>
13
-#include <openvdb/tree/LeafManager.h>
14
-#include <openvdb/util/NullInterrupter.h>
15
-#include <openvdb/util/Util.h>
16
-#include <openvdb/Grid.h>
17
+#include "openvdb/Types.h"
18
+#include "openvdb/Grid.h"
19
+#include "openvdb/math/Math.h"
20
+#include "openvdb/math/Stencils.h"
21
+#include "openvdb/math/Transform.h"
22
+#include "openvdb/tree/NodeManager.h"
23
+#include "openvdb/tree/LeafManager.h"
24
+#include "openvdb/util/NullInterrupter.h"
25
+#include "openvdb/util/Util.h"
26
+#include "openvdb/thread/Threading.h"
27
 #include "Interpolation.h"
28
+
29
+#include <tbb/parallel_for.h>
30
+#include <tbb/concurrent_vector.h>
31
+
32
 #include <algorithm> // for std::max()
33
 #include <functional>
34
 #include <type_traits>
35
-#include <tbb/concurrent_vector.h>
36
 
37
 namespace openvdb {
38
 OPENVDB_USE_VERSION_NAMESPACE
39
@@ -833,7 +836,7 @@ inline bool
40
 Filter<GridT, MaskT, InterruptT>::wasInterrupted()
41
 {
42
     if (util::wasInterrupted(mInterrupter)) {
43
-        tbb::task::self().cancel_group_execution();
44
+        thread::cancelGroupExecution();
45
         return true;
46
     }
47
     return false;
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_GridOperators.h (+36 lines)
Added Link Here
1
--- openvdb/openvdb/tools/GridOperators.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/GridOperators.h
3
@@ -9,15 +9,16 @@
4
 #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
5
 #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
6
 
7
-#include <openvdb/Grid.h>
8
-#include <openvdb/math/Operators.h>
9
-#include <openvdb/util/NullInterrupter.h>
10
-#include <openvdb/tree/LeafManager.h>
11
-#include <openvdb/tree/ValueAccessor.h>
12
+#include "openvdb/Grid.h"
13
+#include "openvdb/math/Operators.h"
14
+#include "openvdb/util/NullInterrupter.h"
15
+#include "openvdb/thread/Threading.h"
16
+#include "openvdb/tree/LeafManager.h"
17
+#include "openvdb/tree/ValueAccessor.h"
18
 #include "ValueTransformer.h" // for tools::foreach()
19
+
20
 #include <tbb/parallel_for.h>
21
 
22
-
23
 namespace openvdb {
24
 OPENVDB_USE_VERSION_NAMESPACE
25
 namespace OPENVDB_VERSION_NAME {
26
@@ -383,7 +384,9 @@ class GridOperator (public)
27
     /// TBB threads only!
28
     void operator()(const typename LeafManagerT::LeafRange& range) const
29
     {
30
-        if (util::wasInterrupted(mInterrupt)) tbb::task::self().cancel_group_execution();
31
+        if (util::wasInterrupted(mInterrupt)) {
32
+            thread::cancelGroupExecution();
33
+        }
34
 
35
         for (typename LeafManagerT::LeafRange::Iterator leaf=range.begin(); leaf; ++leaf) {
36
             for (typename OutLeafT::ValueOnIter value=leaf->beginValueOn(); value; ++value) {
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_LevelSetMeasure.h (+42 lines)
Added Link Here
1
--- openvdb/openvdb/tools/LevelSetMeasure.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/LevelSetMeasure.h
3
@@ -8,18 +8,21 @@
4
 #ifndef OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
5
 #define OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
6
 
7
-#include <openvdb/math/Math.h>
8
-#include <openvdb/Types.h>
9
-#include <openvdb/Grid.h>
10
-#include <openvdb/tree/LeafManager.h>
11
-#include <openvdb/tree/ValueAccessor.h>
12
-#include <openvdb/math/FiniteDifference.h>
13
-#include <openvdb/math/Operators.h>
14
-#include <openvdb/math/Stencils.h>
15
-#include <openvdb/util/NullInterrupter.h>
16
+#include "openvdb/Types.h"
17
+#include "openvdb/Grid.h"
18
+#include "openvdb/tree/LeafManager.h"
19
+#include "openvdb/tree/ValueAccessor.h"
20
+#include "openvdb/math/Math.h"
21
+#include "openvdb/math/FiniteDifference.h"
22
+#include "openvdb/math/Operators.h"
23
+#include "openvdb/math/Stencils.h"
24
+#include "openvdb/util/NullInterrupter.h"
25
+#include "openvdb/thread/Threading.h"
26
+
27
 #include <tbb/parallel_for.h>
28
 #include <tbb/parallel_sort.h>
29
 #include <tbb/parallel_invoke.h>
30
+
31
 #include <type_traits>
32
 
33
 namespace openvdb {
34
@@ -329,7 +332,7 @@ inline bool
35
 LevelSetMeasure<GridT, InterruptT>::checkInterrupter()
36
 {
37
     if (util::wasInterrupted(mInterrupter)) {
38
-        tbb::task::self().cancel_group_execution();
39
+        thread::cancelGroupExecution();
40
         return false;
41
     }
42
     return true;
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_LevelSetTracker.h (+50 lines)
Added Link Here
1
--- openvdb/openvdb/tools/LevelSetTracker.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/LevelSetTracker.h
3
@@ -12,24 +12,26 @@
4
 #ifndef OPENVDB_TOOLS_LEVEL_SET_TRACKER_HAS_BEEN_INCLUDED
5
 #define OPENVDB_TOOLS_LEVEL_SET_TRACKER_HAS_BEEN_INCLUDED
6
 
7
-#include <tbb/parallel_for.h>
8
-#include <openvdb/Types.h>
9
-#include <openvdb/math/Math.h>
10
-#include <openvdb/math/FiniteDifference.h>
11
-#include <openvdb/math/Operators.h>
12
-#include <openvdb/math/Stencils.h>
13
-#include <openvdb/math/Transform.h>
14
-#include <openvdb/Grid.h>
15
-#include <openvdb/util/NullInterrupter.h>
16
-#include <openvdb/tree/ValueAccessor.h>
17
-#include <openvdb/tree/LeafManager.h>
18
+#include "openvdb/Types.h"
19
+#include "openvdb/Grid.h"
20
+#include "openvdb/math/Math.h"
21
+#include "openvdb/math/FiniteDifference.h"
22
+#include "openvdb/math/Operators.h"
23
+#include "openvdb/math/Stencils.h"
24
+#include "openvdb/math/Transform.h"
25
+#include "openvdb/util/NullInterrupter.h"
26
+#include "openvdb/thread/Threading.h"
27
+#include "openvdb/tree/ValueAccessor.h"
28
+#include "openvdb/tree/LeafManager.h"
29
 #include "ChangeBackground.h"// for changeLevelSetBackground
30
 #include "Morphology.h"//for dilateActiveValues
31
 #include "Prune.h"// for pruneLevelSet
32
+
33
+#include <tbb/parallel_for.h>
34
+
35
 #include <functional>
36
 #include <type_traits>
37
 
38
-
39
 namespace openvdb {
40
 OPENVDB_USE_VERSION_NAMESPACE
41
 namespace OPENVDB_VERSION_NAME {
42
@@ -383,7 +385,7 @@ LevelSetTracker<GridT, InterruptT>::
43
 checkInterrupter()
44
 {
45
     if (util::wasInterrupted(mInterrupter)) {
46
-        tbb::task::self().cancel_group_execution();
47
+        thread::cancelGroupExecution();
48
         return false;
49
     }
50
     return true;
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_MeshToVolume.h (+58 lines)
Added Link Here
1
--- openvdb/openvdb/tools/MeshToVolume.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/MeshToVolume.h
3
@@ -16,12 +16,13 @@
4
 #ifndef OPENVDB_TOOLS_MESH_TO_VOLUME_HAS_BEEN_INCLUDED
5
 #define OPENVDB_TOOLS_MESH_TO_VOLUME_HAS_BEEN_INCLUDED
6
 
7
-#include <openvdb/Platform.h> // for OPENVDB_HAS_CXX11
8
-#include <openvdb/Types.h>
9
-#include <openvdb/math/FiniteDifference.h> // for GodunovsNormSqrd
10
-#include <openvdb/math/Proximity.h> // for closestPointOnTriangleToPoint
11
-#include <openvdb/util/NullInterrupter.h>
12
-#include <openvdb/util/Util.h>
13
+#include "openvdb/Platform.h" // for OPENVDB_HAS_CXX11
14
+#include "openvdb/Types.h"
15
+#include "openvdb/math/FiniteDifference.h" // for GodunovsNormSqrd
16
+#include "openvdb/math/Proximity.h" // for closestPointOnTriangleToPoint
17
+#include "openvdb/util/NullInterrupter.h"
18
+#include "openvdb/util/Util.h"
19
+#include "openvdb/thread/Threading.h"
20
 
21
 #include "ChangeBackground.h"
22
 #include "Prune.h" // for pruneInactive and pruneLevelSet
23
@@ -33,7 +34,7 @@
24
 #include <tbb/parallel_reduce.h>
25
 #include <tbb/partitioner.h>
26
 #include <tbb/task_group.h>
27
-#include <tbb/task_scheduler_init.h>
28
+#include <tbb/task_arena.h>
29
 
30
 #include <algorithm> // for std::sort()
31
 #include <cmath> // for std::isfinite(), std::isnan()
32
@@ -1132,7 +1133,7 @@ inline void
33
 fillArray(ValueType* array, const ValueType val, const size_t length)
34
 {
35
     const auto grainSize = std::max<size_t>(
36
-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
37
+        length / tbb::this_task_arena::max_concurrency(), 1024);
38
     const tbb::blocked_range<size_t> range(0, length, grainSize);
39
     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
40
 }
41
@@ -1989,7 +1990,7 @@ class VoxelizePolygons (public)
42
         for (size_t n = range.begin(), N = range.end(); n < N; ++n) {
43
 
44
             if (this->wasInterrupted()) {
45
-                tbb::task::self().cancel_group_execution();
46
+                thread::cancelGroupExecution();
47
                 break;
48
             }
49
 
50
@@ -2143,7 +2144,7 @@ class VoxelizePolygons (public)
51
 
52
         while (!coordList.empty()) {
53
             if (interrupter && interrupter->wasInterrupted()) {
54
-                tbb::task::self().cancel_group_execution();
55
+                thread::cancelGroupExecution();
56
                 break;
57
             }
58
             for (Int32 pass = 0; pass < 1048576 && !coordList.empty(); ++pass) {
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_Morphology.h (+20 lines)
Added Link Here
1
--- openvdb/openvdb/tools/Morphology.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/Morphology.h
3
@@ -24,7 +24,7 @@
4
 #include "openvdb/tree/ValueAccessor.h"
5
 #include "openvdb/tree/LeafManager.h"
6
 
7
-#include <tbb/task_scheduler_init.h>
8
+#include <tbb/task_arena.h>
9
 #include <tbb/enumerable_thread_specific.h>
10
 #include <tbb/parallel_for.h>
11
 
12
@@ -726,7 +726,7 @@ void Morphology<TreeType>::dilateVoxels(const size_t i
13
         }
14
 
15
         // @note this grain size is used for optimal threading
16
-        const size_t numThreads = size_t(tbb::task_scheduler_init::default_num_threads());
17
+        const size_t numThreads = size_t(tbb::this_task_arena::max_concurrency());
18
         const size_t subTreeSize = math::Max(size_t(1), array.size()/(2*numThreads));
19
 
20
         // perform recursive dilation to sub trees
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_ParticlesToLevelSet.h (+53 lines)
Added Link Here
1
--- openvdb/openvdb/tools/ParticlesToLevelSet.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/ParticlesToLevelSet.h
3
@@ -62,19 +62,23 @@
4
 #ifndef OPENVDB_TOOLS_PARTICLES_TO_LEVELSET_HAS_BEEN_INCLUDED
5
 #define OPENVDB_TOOLS_PARTICLES_TO_LEVELSET_HAS_BEEN_INCLUDED
6
 
7
-#include <tbb/parallel_reduce.h>
8
-#include <tbb/blocked_range.h>
9
-#include <openvdb/Types.h>
10
-#include <openvdb/Grid.h>
11
-#include <openvdb/math/Math.h>
12
-#include <openvdb/math/Transform.h>
13
-#include <openvdb/tree/LeafManager.h>
14
-#include <openvdb/util/logging.h>
15
-#include <openvdb/util/NullInterrupter.h>
16
+#include "openvdb/Types.h"
17
+#include "openvdb/Grid.h"
18
+#include "openvdb/math/Math.h"
19
+#include "openvdb/math/Transform.h"
20
+#include "openvdb/tree/LeafManager.h"
21
+#include "openvdb/util/logging.h"
22
+#include "openvdb/util/NullInterrupter.h"
23
+#include "openvdb/thread/Threading.h"
24
+
25
 #include "Composite.h" // for csgUnion()
26
 #include "PointPartitioner.h"
27
 #include "Prune.h"
28
 #include "SignedFloodFill.h"
29
+
30
+#include <tbb/parallel_reduce.h>
31
+#include <tbb/blocked_range.h>
32
+
33
 #include <functional>
34
 #include <iostream>
35
 #include <type_traits>
36
@@ -738,7 +742,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, Inter
37
         for (Coord c = lo; c.x() <= hi.x(); ++c.x()) {
38
             //only check interrupter every 32'th scan in x
39
             if (!(count++ & ((1<<5)-1)) && util::wasInterrupted(mParent.mInterrupter)) {
40
-                tbb::task::self().cancel_group_execution();
41
+                thread::cancelGroupExecution();
42
                 return false;
43
             }
44
             const Real x2 = math::Pow2(c.x() - P[0]);
45
@@ -804,7 +808,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, Inter
46
         // Densely fill the remaining regions.
47
         for (const auto& bbox: padding) {
48
             if (util::wasInterrupted(mParent.mInterrupter)) {
49
-                tbb::task::self().cancel_group_execution();
50
+                thread::cancelGroupExecution();
51
                 return false;
52
             }
53
             const Coord &bmin = bbox.min(), &bmax = bbox.max();
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_PointAdvect.h (+45 lines)
Added Link Here
1
--- openvdb/openvdb/tools/PointAdvect.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/PointAdvect.h
3
@@ -10,16 +10,19 @@
4
 #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
5
 #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
6
 
7
-#include <openvdb/openvdb.h>
8
-#include <openvdb/math/Math.h>             // min
9
-#include <openvdb/Types.h>                 // Vec3 types and version number
10
-#include <openvdb/Grid.h>                  // grid
11
-#include <openvdb/util/NullInterrupter.h>
12
+#include "openvdb/openvdb.h"
13
+#include "openvdb/Types.h"                 // Vec3 types and version number
14
+#include "openvdb/Grid.h"                  // grid
15
+#include "openvdb/math/Math.h"             // min
16
+#include "openvdb/util/NullInterrupter.h"
17
+#include "openvdb/thread/Threading.h"
18
 #include "Interpolation.h"                 // sampling
19
 #include "VelocityFields.h"                // VelocityIntegrator
20
+
21
 #include <tbb/blocked_range.h>             // threading
22
 #include <tbb/parallel_for.h>              // threading
23
 #include <tbb/task.h>                      // for cancel
24
+
25
 #include <vector>
26
 
27
 
28
@@ -167,7 +170,7 @@ class PointAdvect (public)
29
     void operator() (const tbb::blocked_range<size_t> &range) const
30
     {
31
         if (mInterrupter && mInterrupter->wasInterrupted()) {
32
-            tbb::task::self().cancel_group_execution();
33
+            thread::cancelGroupExecution();
34
         }
35
 
36
         VelocityFieldIntegrator  velField(*mVelGrid);
37
@@ -307,7 +310,7 @@ class ConstrainedPointAdvect (public)
38
     void operator() (const tbb::blocked_range<size_t> &range) const
39
     {
40
         if (mInterrupter && mInterrupter->wasInterrupted()) {
41
-            tbb::task::self().cancel_group_execution();
42
+            thread::cancelGroupExecution();
43
         }
44
 
45
         VelocityIntegratorType velField(*mVelGrid);
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_PointIndexGrid.h (+19 lines)
Added Link Here
1
--- openvdb/openvdb/tools/PointIndexGrid.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/PointIndexGrid.h
3
@@ -16,6 +16,7 @@
4
 #ifndef OPENVDB_TOOLS_POINT_INDEX_GRID_HAS_BEEN_INCLUDED
5
 #define OPENVDB_TOOLS_POINT_INDEX_GRID_HAS_BEEN_INCLUDED
6
 
7
+#include "openvdb/thread/Threading.h"
8
 #include "PointPartitioner.h"
9
 
10
 #include <openvdb/version.h>
11
@@ -355,7 +356,7 @@ struct ValidPartitioningOp
12
     void operator()(LeafT &leaf, size_t /*leafIndex*/) const
13
     {
14
         if ((*mHasChanged)) {
15
-            tbb::task::self().cancel_group_execution();
16
+            thread::cancelGroupExecution();
17
             return;
18
         }
19
 
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_PointPartitioner.h (+20 lines)
Added Link Here
1
--- openvdb/openvdb/tools/PointPartitioner.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/PointPartitioner.h
3
@@ -23,7 +23,7 @@
4
 
5
 #include <tbb/blocked_range.h>
6
 #include <tbb/parallel_for.h>
7
-#include <tbb/task_scheduler_init.h>
8
+#include <tbb/task_arena.h>
9
 
10
 #include <algorithm>
11
 #include <cmath> // for std::isfinite()
12
@@ -764,7 +764,7 @@ inline void binAndSegment(
13
     using IndexPairListMap = std::map<Coord, IndexPairListPtr>;
14
     using IndexPairListMapPtr = std::shared_ptr<IndexPairListMap>;
15
 
16
-    size_t numTasks = 1, numThreads = size_t(tbb::task_scheduler_init::default_num_threads());
17
+    size_t numTasks = 1, numThreads = size_t(tbb::this_task_arena::max_concurrency());
18
     if (points.size() > (numThreads * 2)) numTasks = numThreads * 2;
19
     else if (points.size() > numThreads) numTasks = numThreads;
20
 
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_PointsToMask.h (+34 lines)
Added Link Here
1
--- openvdb/openvdb/tools/PointsToMask.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/PointsToMask.h
3
@@ -46,14 +46,18 @@
4
 #ifndef OPENVDB_TOOLS_POINTSTOMASK_HAS_BEEN_INCLUDED
5
 #define OPENVDB_TOOLS_POINTSTOMASK_HAS_BEEN_INCLUDED
6
 
7
+
8
+#include "openvdb/openvdb.h" // for MaskGrid
9
+#include "openvdb/Grid.h"
10
+#include "openvdb/Types.h"
11
+#include "openvdb/util/NullInterrupter.h"
12
+#include "openvdb/thread/Threading.h"
13
+
14
 #include <tbb/enumerable_thread_specific.h>
15
 #include <tbb/parallel_for.h>
16
 #include <tbb/parallel_reduce.h>
17
 #include <tbb/blocked_range.h>
18
-#include <openvdb/openvdb.h> // for MaskGrid
19
-#include <openvdb/Grid.h>
20
-#include <openvdb/Types.h>
21
-#include <openvdb/util/NullInterrupter.h>
22
+
23
 #include <vector>
24
 
25
 
26
@@ -150,7 +154,7 @@ class PointsToMask (private)
27
     bool interrupt() const
28
     {
29
         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
30
-            tbb::task::self().cancel_group_execution();
31
+            thread::cancelGroupExecution();
32
             return true;
33
         }
34
         return false;
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_VolumeAdvect.h (+34 lines)
Added Link Here
1
--- openvdb/openvdb/tools/VolumeAdvect.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/VolumeAdvect.h
3
@@ -13,15 +13,18 @@
4
 #ifndef OPENVDB_TOOLS_VOLUME_ADVECT_HAS_BEEN_INCLUDED
5
 #define OPENVDB_TOOLS_VOLUME_ADVECT_HAS_BEEN_INCLUDED
6
 
7
-#include <tbb/parallel_for.h>
8
-#include <openvdb/Types.h>
9
-#include <openvdb/math/Math.h>
10
-#include <openvdb/util/NullInterrupter.h>
11
+#include "openvdb/Types.h"
12
+#include "openvdb/math/Math.h"
13
+#include "openvdb/util/NullInterrupter.h"
14
+#include "openvdb/thread/Threading.h"
15
 #include "Interpolation.h"// for Sampler
16
 #include "VelocityFields.h" // for VelocityIntegrator
17
 #include "Morphology.h"//for dilateActiveValues
18
 #include "Prune.h"// for prune
19
 #include "Statistics.h" // for extrema
20
+
21
+#include <tbb/parallel_for.h>
22
+
23
 #include <functional>
24
 
25
 
26
@@ -294,7 +297,7 @@ class VolumeAdvection (private)
27
     bool interrupt() const
28
     {
29
         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
30
-            tbb::task::self().cancel_group_execution();
31
+            thread::cancelGroupExecution();
32
             return true;
33
         }
34
         return false;
(-)misc/openvdb/files/patch-openvdb_openvdb_tools_VolumeToMesh.h (+20 lines)
Added Link Here
1
--- openvdb/openvdb/tools/VolumeToMesh.h.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/tools/VolumeToMesh.h
3
@@ -18,7 +18,7 @@
4
 #include <tbb/blocked_range.h>
5
 #include <tbb/parallel_for.h>
6
 #include <tbb/parallel_reduce.h>
7
-#include <tbb/task_scheduler_init.h>
8
+#include <tbb/task_arena.h>
9
 
10
 #include <cmath> // for std::isfinite()
11
 #include <map>
12
@@ -388,7 +388,7 @@ inline void
13
 fillArray(ValueType* array, const ValueType& val, const size_t length)
14
 {
15
     const auto grainSize = std::max<size_t>(
16
-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
17
+        length / tbb::this_task_arena::max_concurrency(), 1024);
18
     const tbb::blocked_range<size_t> range(0, length, grainSize);
19
     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
20
 }
(-)misc/openvdb/files/patch-openvdb_openvdb_unittest_TestCoord.cc (+13 lines)
Added Link Here
1
--- openvdb/openvdb/unittest/TestCoord.cc.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/unittest/TestCoord.cc
3
@@ -2,9 +2,9 @@
4
 // SPDX-License-Identifier: MPL-2.0
5
 
6
 #include <openvdb/Types.h>
7
+#include <openvdb/math/Coord.h>
8
 
9
 #include <gtest/gtest.h>
10
-#include <tbb/tbb_stddef.h> // for tbb::split
11
 
12
 #include <unordered_map>
13
 #include <sstream>
(-)misc/openvdb/files/patch-openvdb_openvdb_unittest_TestFile.cc (+51 lines)
Added Link Here
1
--- openvdb/openvdb/unittest/TestFile.cc.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/unittest/TestFile.cc
3
@@ -13,8 +13,11 @@
4
 #include <openvdb/version.h>
5
 #include <openvdb/openvdb.h>
6
 #include "util.h" // for unittest_util::makeSphere()
7
+
8
 #include <gtest/gtest.h>
9
-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
10
+
11
+#include <thread>
12
+#include <chrono>
13
 #include <algorithm> // for std::sort()
14
 #include <cstdio> // for remove() and rename()
15
 #include <fstream>
16
@@ -2345,12 +2348,14 @@ TEST_F(TestFile, testAsync)
17
             helper.insert(id, filename);
18
         }
19
 
20
-        tbb::tick_count start = tbb::tick_count::now();
21
+        auto start = std::chrono::steady_clock::now();
22
         while (!helper.ids.empty()) {
23
-            if ((tbb::tick_count::now() - start).seconds() > 60) break; // time out after 1 minute
24
+            auto duration = std::chrono::duration_cast<std::chrono::seconds>(
25
+                std::chrono::steady_clock::now() - start);
26
+            if (size_t(duration.count()) > 60)  break; // time out after 1 minute
27
 
28
             // Wait one second for tasks to complete.
29
-            tbb::this_tbb_thread::sleep(tbb::tick_count::interval_t(1.0/*sec*/));
30
+            std::this_thread::sleep_for(std::chrono::seconds(1));
31
 
32
             // Poll each task in the pending map.
33
             std::set<io::Queue::Id> ids = helper.ids; // iterate over a copy
34
@@ -2380,7 +2385,7 @@ TEST_F(TestFile, testAsync)
35
             helper.insert(id, filename);
36
         }
37
         while (!queue.empty()) {
38
-            tbb::this_tbb_thread::sleep(tbb::tick_count::interval_t(1.0/*sec*/));
39
+            std::this_thread::sleep_for(std::chrono::seconds(1));
40
         }
41
     }
42
     {
43
@@ -2405,7 +2410,7 @@ TEST_F(TestFile, testAsync)
44
         EXPECT_THROW(queue.write(grids, io::Stream(file2)), openvdb::RuntimeError);
45
 
46
         while (!queue.empty()) {
47
-            tbb::this_tbb_thread::sleep(tbb::tick_count::interval_t(1.0/*sec*/));
48
+            std::this_thread::sleep_for(std::chrono::seconds(1));
49
         }
50
     }
51
 }
(-)misc/openvdb/files/patch-openvdb_openvdb_unittest_TestUtil.cc (+10 lines)
Added Link Here
1
--- openvdb/openvdb/unittest/TestUtil.cc.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/unittest/TestUtil.cc
3
@@ -8,7 +8,6 @@
4
 
5
 #include <gtest/gtest.h>
6
 
7
-#include <tbb/task_scheduler_init.h>
8
 #include <tbb/enumerable_thread_specific.h>
9
 #include <tbb/parallel_for.h>
10
 #include <tbb/blocked_range.h>
(-)misc/openvdb/files/patch-openvdb_openvdb_unittest_TestValueAccessor.cc (+81 lines)
Added Link Here
1
--- openvdb/openvdb/unittest/TestValueAccessor.cc.orig	2021-06-11 21:38:41 UTC
2
+++ openvdb/openvdb/unittest/TestValueAccessor.cc
3
@@ -6,6 +6,7 @@
4
 
5
 #include <gtest/gtest.h>
6
 #include <tbb/task.h>
7
+#include <tbb/task_group.h>
8
 
9
 #include <type_traits>
10
 
11
@@ -378,22 +379,21 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
12
     //using AccessorT = openvdb::tree::ValueAccessor<Tree4Type>;
13
 
14
     // Task to perform multiple reads through a shared accessor
15
-    struct ReadTask: public tbb::task {
16
+    struct ReadTask {
17
         AccessorT& acc;
18
         ReadTask(AccessorT& c): acc(c) {}
19
-        tbb::task* execute()
20
+        void execute()
21
         {
22
             for (int i = -MAX_COORD; i < MAX_COORD; ++i) {
23
                 ASSERT_DOUBLES_EXACTLY_EQUAL(double(i), acc.getValue(openvdb::Coord(i)));
24
             }
25
-            return nullptr;
26
         }
27
     };
28
     // Task to perform multiple writes through a shared accessor
29
-    struct WriteTask: public tbb::task {
30
+    struct WriteTask {
31
         AccessorT& acc;
32
         WriteTask(AccessorT& c): acc(c) {}
33
-        tbb::task* execute()
34
+        void execute()
35
         {
36
             for (int i = -MAX_COORD; i < MAX_COORD; ++i) {
37
                 float f = acc.getValue(openvdb::Coord(i));
38
@@ -401,26 +401,20 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
39
                 acc.setValue(openvdb::Coord(i), float(i));
40
                 ASSERT_DOUBLES_EXACTLY_EQUAL(float(i), acc.getValue(openvdb::Coord(i)));
41
             }
42
-            return nullptr;
43
         }
44
     };
45
     // Parent task to spawn multiple parallel read and write tasks
46
-    struct RootTask: public tbb::task {
47
+    struct RootTask {
48
         AccessorT& acc;
49
         RootTask(AccessorT& c): acc(c) {}
50
-        tbb::task* execute()
51
+        void execute()
52
         {
53
-            ReadTask* r[3]; WriteTask* w[3];
54
+            tbb::task_group tasks;
55
             for (int i = 0; i < 3; ++i) {
56
-                r[i] = new(allocate_child()) ReadTask(acc);
57
-                w[i] = new(allocate_child()) WriteTask(acc);
58
+                tasks.run([&] { ReadTask r(acc); r.execute(); });
59
+                tasks.run([&] { WriteTask w(acc); w.execute(); });
60
             }
61
-            set_ref_count(6 /*children*/ + 1 /*wait*/);
62
-            for (int i = 0; i < 3; ++i) {
63
-                spawn(*r[i]); spawn(*w[i]);
64
-            }
65
-            wait_for_all();
66
-            return nullptr;
67
+            tasks.wait();
68
         }
69
     };
70
 
71
@@ -432,8 +426,8 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
72
     }
73
 
74
     // Run multiple read and write tasks in parallel.
75
-    RootTask& root = *new(tbb::task::allocate_root()) RootTask(acc);
76
-    tbb::task::spawn_root_and_wait(root);
77
+    RootTask root(acc);
78
+    root.execute();
79
 
80
 #undef MAX_COORD
81
 }
(-)misc/openvdb/pkg-plist (+1 lines)
Lines 64-69 include/openvdb/points/PointSample.h Link Here
64
include/openvdb/points/PointScatter.h
64
include/openvdb/points/PointScatter.h
65
include/openvdb/points/StreamCompression.h
65
include/openvdb/points/StreamCompression.h
66
%%PYTHON%%include/openvdb/python/pyopenvdb.h
66
%%PYTHON%%include/openvdb/python/pyopenvdb.h
67
include/openvdb/thread/Threading.h
67
include/openvdb/tools/Activate.h
68
include/openvdb/tools/Activate.h
68
include/openvdb/tools/ChangeBackground.h
69
include/openvdb/tools/ChangeBackground.h
69
include/openvdb/tools/Clip.h
70
include/openvdb/tools/Clip.h

Return to bug 252788