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