Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] tbb: update to 2021.3.0
@ 2021-07-24 10:00 Logarithmus
  2021-07-24 10:20 ` [PR PATCH] [Updated] " Logarithmus
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Logarithmus @ 2021-07-24 10:00 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 845 bytes --]

There is a new pull request by Logarithmus against master on the void-packages repository

https://github.com/Logarithmus/void-packages tbb-2021
https://github.com/void-linux/void-packages/pull/32166

tbb: update to 2021.3.0
- hwloc: add libpciaccess-devel make dependency
- tbb: update to 2021.3.0.
- OpenSubdiv: update to 3.4.4.
- PrusaSlicer: update to 2.3.3.
- blender: update to 2.93.1.
- embree: update to 3.13.0.
- openimageio: update to 2.2.16.0.
- openimagedenoise: update to 1.4.1.
- openvdb: update to 8.1.0.
- paraview: update to 5.9.1.
- occt: revbump due to tbb update

#### Have the results of the proposed changes been tested?
- [x] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me


A patch file from https://github.com/void-linux/void-packages/pull/32166.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-tbb-2021-32166.patch --]
[-- Type: text/x-diff, Size: 87230 bytes --]

From ba2f07bdef94398ab7fbe45353500c9aad2e6edf Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 17 Jul 2021 23:57:52 +0300
Subject: [PATCH 01/11] hwloc: add libpciaccess-devel make dependency

---
 srcpkgs/hwloc/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/hwloc/template b/srcpkgs/hwloc/template
index 818db269cebb..ce0f61acd9c7 100644
--- a/srcpkgs/hwloc/template
+++ b/srcpkgs/hwloc/template
@@ -1,10 +1,10 @@
 # Template file for 'hwloc'
 pkgname=hwloc
 version=2.5.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="cairo-devel ncurses-devel libxml2-devel eudev-libudev-devel"
+makedepends="cairo-devel ncurses-devel libxml2-devel libpciaccess-devel eudev-libudev-devel"
 short_desc="Portable abstraction of hierarchical hardware architectures"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
 license="BSD-3-Clause"
@@ -31,7 +31,7 @@ libhwloc_package() {
 
 libhwloc-devel_package() {
 	short_desc+=" - development files"
-	depends="libhwloc>=${version}_${revision}"
+	depends="${makedepends} libhwloc>=${version}_${revision}"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/share/man/man3

From 8f8617ccd3a366bbe08f69d80a365b4463aa5c50 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 02:50:26 +0300
Subject: [PATCH 02/11] tbb: update to 2021.3.0.

---
 common/shlibs                                |   6 +-
 srcpkgs/tbb/patches/00-hwloc-2.5.patch       | 367 +++++++++++++++++++
 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch |  52 +++
 srcpkgs/tbb/patches/hostname-usage.patch     |  11 -
 srcpkgs/tbb/patches/musl.patch               |   4 +-
 srcpkgs/tbb/template                         |  63 +---
 6 files changed, 433 insertions(+), 70 deletions(-)
 create mode 100644 srcpkgs/tbb/patches/00-hwloc-2.5.patch
 create mode 100644 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
 delete mode 100644 srcpkgs/tbb/patches/hostname-usage.patch

diff --git a/common/shlibs b/common/shlibs
index a7afbf2a56f7..6b7ca5fbc249 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2376,12 +2376,10 @@ libanthy-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthydic-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthyinput-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthygobject-1.0.so.5 ibus-anthy-1.5.6_1
-libtbbmalloc_proxy_debug.so.2 tbb-4.3_1
 libtbbmalloc_proxy.so.2 tbb-4.3_1
 libtbbmalloc.so.2 tbb-4.3_1
-libtbb_debug.so.2 tbb-4.3_1
-libtbb.so.2 tbb-4.3_1
-libtbbmalloc_debug.so.2 tbb-4.3_1
+libtbb.so.12 tbb-2021.3.0_1
+libtbbbind_2_5.so.3 tbb-2021.3.0_1
 libembree.so.2 embree-2.5.1_1
 libgtkimageview.so.0 gtkimageview-1.6.4_1
 libgoocanvas-2.0.so.9 goocanvas-2.0.4_1
diff --git a/srcpkgs/tbb/patches/00-hwloc-2.5.patch b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
new file mode 100644
index 000000000000..9c4c9285c71d
--- /dev/null
+++ b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
@@ -0,0 +1,367 @@
+Adjusted by Artur Sinila <freesoftware@logarithmus.dev>
+
+From e96dbf4b48e689ab810b0428d0858a6abc2c83bd Mon Sep 17 00:00:00 2001
+From: Ivan Kochin <iv.kochin@gmail.com>
+Date: Thu, 1 Jul 2021 15:07:39 +0300
+Subject: [PATCH] Upgrade from HWLOC 2.4 to HWLOC 2.5 (#448)
+
+* Upgrade from HWLOC 2.4 to HWLOC 2.5
+* Introduce tbbbind_2_5 library
+* Remove tbbbind_2_4 library
+* Use the HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING topology flag (introduces as a part of HWLOC 2.5) to restrict topology discovering to process binding
+* Fix testing on Linux
+* Apply review comments
+* Improve wording: variable -> substring
+* Use right tbbbind version for incompatible hwlocs test
+* Rework option semantic
+* Update README.md for CMake
+* Rework readme
+* Update cmake/README.md
+
+Signed-off-by: Kochin, Ivan <kochin.ivan@intel.com>
+
+Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
+---
+ CMakeLists.txt                         |  3 ++-
+ cmake/README.md                        | 11 +++++---
+ cmake/hwloc_detection.cmake            |  9 ++++---
+ src/tbb/governor.cpp                   |  4 +--
+ src/tbbbind/CMakeLists.txt             |  2 +-
+ src/tbbbind/tbb_bind.cpp               | 23 +++++++++++-----
+ test/CMakeLists.txt                    | 30 ++++++++++-----------
+ test/common/common_arena_constraints.h | 37 ++++++++++++++++++++++----
+ 8 files changed, 82 insertions(+), 37 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 34a23d400..301899aca 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -100,6 +100,7 @@ option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Win
+ option(TBB4PY_BUILD "Enable tbb4py build" OFF)
+ option(TBB_CPF "Enable preview features of the library" OFF)
+ option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
++option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
+ 
+ if (NOT DEFINED BUILD_SHARED_LIBS)
+     set(BUILD_SHARED_LIBS ON)
+@@ -195,7 +196,7 @@ else()
+         add_subdirectory(src/tbbmalloc)
+         add_subdirectory(src/tbbmalloc_proxy)
+         if (APPLE)
+-            message(STATUS "TBBBind build target is disabled due to unsupported environment")
++            message(STATUS "TBBBind build targets are disabled due to unsupported environment")
+         else()
+             add_subdirectory(src/tbbbind)
+         endif()
+diff --git a/cmake/README.md b/cmake/README.md
+index 36fc303f9..b58c2ff6a 100644
+--- a/cmake/README.md
++++ b/cmake/README.md
+@@ -13,6 +13,7 @@ TBB4PY_BUILD:BOOL - Enable  Intel(R) oneAPI Threading Building Blocks (oneTBB) P
+ TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
+ TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
+ TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
++TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)
+ ```
+ 
+ ## Configure, build and test
+@@ -42,9 +43,9 @@ Some useful options:
+ 
+ #### TBBBind library configuration
+ 
+-The TBBbind library has two versions: `tbbbind` and `tbbbind_2_0`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.x.
++The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0` and `tbbbind_2_5`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.1-2.4, `tbbbind_2_5` links with HWLOC 2.5 and later.
+ 
+-To enable the TBBBind library build or special tests that performed inside the HWLOC environment, please specify the following CMake variables:
++The search for a suitable version of the HWLOC library is enabled by default, but if you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
+ 
+  - `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux or path to `.lib` file on Windows.
+  - `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version includes directory.
+@@ -52,7 +53,11 @@ To enable the TBBBind library build or special tests that performed inside the H
+ Windows requires one additional variable for correct TBBBind library building:
+  - `CMAKE_HWLOC_<HWLOC_VER>_DLL_PATH` - path to the corresponding HWLOC version `.dll` file.
+ 
+-`HWLOC_VER` variable used above can be replaced with one of the two values: `1_11` for the `tbbbind` library configuration and `2` for the `tbbbind_2_0` library configuration.
++`HWLOC_VER` substring used above can be replaced with one of the three values: `1_11` for the `tbbbind` library configuration, `2` for the `tbbbind_2_0`, and `2_5` for the `tbbbind_2_5` library configuration.
++
++If you specify variables for several TBBBind versions, then building process for all of these versions will be performed during single build session.
++
++Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
+ 
+ ### Build
+ 
+diff --git a/cmake/hwloc_detection.cmake b/cmake/hwloc_detection.cmake
+index e1eeca5fa..de7f3c047 100644
+--- a/cmake/hwloc_detection.cmake
++++ b/cmake/hwloc_detection.cmake
+@@ -12,7 +12,7 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
+-list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_4)
++list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_5)
+ 
+ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
+     if (NOT WIN32)
+@@ -55,10 +56,10 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
+         if (HWLOC_FOUND)
+             if (HWLOC_VERSION VERSION_LESS 2)
+                 set(TBBBIND_LIBRARY_NAME tbbbind)
+-            elseif(HWLOC_VERSION VERSION_LESS 2.4)
++            elseif(HWLOC_VERSION VERSION_LESS 2.5)
+                 set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
+             else()
+-                set(TBBBIND_LIBRARY_NAME tbbbind_2_4)
++                set(TBBBIND_LIBRARY_NAME tbbbind_2_5)
+             endif()
+         endif()
+     endif()
+diff --git a/src/tbb/governor.cpp b/src/tbb/governor.cpp
+index bf4e402d1..b842e075f 100644
+--- a/src/tbb/governor.cpp
++++ b/src/tbb/governor.cpp
+@@ -362,7 +362,7 @@ static const unsigned LinkTableSize = sizeof(TbbBindLinkTable) / sizeof(dynamic_
+ 
+ #define TBBBIND_NAME LIBRARY_PREFIX "tbbbind" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #define TBBBIND_2_0_NAME LIBRARY_PREFIX "tbbbind_2_0" DEBUG_SUFFIX LIBRARY_EXTENSION
+-#define TBBBIND_2_4_NAME LIBRARY_PREFIX "tbbbind_2_4" DEBUG_SUFFIX LIBRARY_EXTENSION
++#define TBBBIND_2_5_NAME LIBRARY_PREFIX "tbbbind_2_5" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #endif /* _WIN32 || _WIN64 || __linux__ */
+ 
+ // Representation of system hardware topology information on the TBB side.
+@@ -389,7 +389,7 @@ const char* load_tbbbind_shared_object() {
+     GetNativeSystemInfo(&si);
+     if (si.dwNumberOfProcessors > 32) return nullptr;
+ #endif /* _WIN32 && !_WIN64 */
+-    for (const auto& tbbbind_version : {TBBBIND_2_4_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
++    for (const auto& tbbbind_version : {TBBBIND_2_5_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
+         if (dynamic_link(tbbbind_version, TbbBindLinkTable, LinkTableSize)) {
+             return tbbbind_version;
+         }
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index 029893751..e5cdbf8bb 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -99,7 +99,7 @@ if (NOT DEFINED HWLOC_TARGET_EXPLICITLY_DEFINED AND DEFINED HWLOC_LIBRARIES)
+ else()
+     tbbbind_build(tbbbind     HWLOC::hwloc_1_11)
+     tbbbind_build(tbbbind_2_0 HWLOC::hwloc_2   )
+-    tbbbind_build(tbbbind_2_4 HWLOC::hwloc_2_4 )
++    tbbbind_build(tbbbind_2_5 HWLOC::hwloc_2_5 )
+ endif()
+ 
+ 
+diff --git a/src/tbbbind/tbb_bind.cpp b/src/tbbbind/tbb_bind.cpp
+index 97be308c7..88c956acb 100644
+--- a/src/tbbbind/tbb_bind.cpp
++++ b/src/tbbbind/tbb_bind.cpp
+@@ -34,7 +34,8 @@
+ #pragma GCC diagnostic pop
+ #endif
+ 
+-#define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ 
+ // Most of hwloc calls returns negative exit code on error.
+ // This macro tracks error codes that are returned from the hwloc interfaces.
+@@ -85,6 +86,16 @@ class platform_topology {
+         // Parse topology
+         if ( hwloc_topology_init( &topology ) == 0 ) {
+             initialization_state = topology_allocated;
++#if __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++            if ( groups_num == 1 &&
++                 hwloc_topology_set_flags(topology,
++                     HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                     HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
++                 ) != 0
++            ) {
++                return;
++            }
++#endif
+             if ( hwloc_topology_load( topology ) == 0 ) {
+                 initialization_state = topology_loaded;
+             }
+@@ -135,7 +146,7 @@ class platform_topology {
+             numa_indexes_list.resize(numa_nodes_count);
+             hwloc_obj_t node_buffer;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 numa_indexes_list[counter] = static_cast<int>(node_buffer->logical_index);
+ 
+                 if ( numa_indexes_list[counter] > max_numa_index ) {
+@@ -150,7 +161,7 @@ class platform_topology {
+             numa_affinity_masks_list.resize(max_numa_index + 1);
+             int index = 0;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 index = static_cast<int>(node_buffer->logical_index);
+ 
+                 hwloc_cpuset_t& current_mask = numa_affinity_masks_list[index];
+@@ -168,7 +179,7 @@ class platform_topology {
+             core_types_indexes_list.push_back(-1);
+             return;
+         }
+-#if __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
++#if __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
+         __TBB_ASSERT(hwloc_get_api_version() >= 0x20400, "Hybrid CPUs support interfaces required HWLOC >= 2.4");
+         // Parsing the hybrid CPU topology
+         int core_types_number = hwloc_cpukinds_get_nr(topology, 0);
+@@ -196,9 +207,9 @@ class platform_topology {
+                 }
+             }
+         }
+-#else /*!__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#else /*!__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+         bool core_types_parsing_broken{true};
+-#endif /*__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#endif /*__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+ 
+         if (core_types_parsing_broken) {
+             for (auto& core_type_mask : core_types_affinity_masks_list) {
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index bdae9e2b1..c2b9d6dba 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -275,9 +275,9 @@ function(tbb_add_tbbbind_test)
+         FAIL_REGULAR_EXPRESSION "Status:.*FAILURE"
+     )
+ 
+-    if (TARGET HWLOC::hwloc_2_4 AND NOT HWLOC_2_4_TESTS_STATUS_SHOWN)
+-        message(STATUS "HWLOC 2.4 dependent tests were enabled.")
+-        set(HWLOC_2_4_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
++    if (TARGET HWLOC::hwloc_2_5 AND NOT HWLOC_2_5_TESTS_STATUS_SHOWN)
++        message(STATUS "HWLOC 2.5 dependent tests were enabled.")
++        set(HWLOC_2_5_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
+     endif()
+ 
+     if (TARGET HWLOC::hwloc_2 AND NOT HWLOC_2_TESTS_STATUS_SHOWN)
+@@ -291,22 +291,22 @@ function(tbb_add_tbbbind_test)
+     endif()
+ 
+     list(APPEND HWLOC_TEST_CASES
+-        hwloc_2_4
++        hwloc_2_5
+         hwloc_2
+         hwloc_1_11
+-        hwloc_2_4_hwloc_2
+-        hwloc_2_4_hwloc_1_11
++        hwloc_2_5_hwloc_2
++        hwloc_2_5_hwloc_1_11
+         hwloc_2_hwloc_1_11
+-        hwloc_2_4_hwloc_2_hwloc_1_11
++        hwloc_2_5_hwloc_2_hwloc_1_11
+     )
+ 
+-    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_4 "hwloc_2_4")
++    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_5 "hwloc_2_5")
+     list(APPEND HWLOC_TEST_CASE_1_VARS tbbbind_2   "hwloc_2")
+     list(APPEND HWLOC_TEST_CASE_2_VARS tbbbind     "hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2")
+-    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_4 "hwloc_2_4,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2")
++    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_5 "hwloc_2_5,hwloc_1_11")
+     list(APPEND HWLOC_TEST_CASE_5_VARS tbbbind_2   "hwloc_2,hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2,hwloc_1_11")
+ 
+     foreach(TEST_CASE ${HWLOC_TEST_CASES})
+         list(FIND HWLOC_TEST_CASES ${TEST_CASE} TEST_CASE_INDEX)
+@@ -331,7 +331,7 @@ endfunction()
+ # Copy libraries to test folder to make it visible during tests execution if external TBB is tested.
+ # TODO: check and update for multi-config generators.
+ if (TBB_FOUND)
+-    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_4)
++    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_5)
+     foreach(_component ${_tbb_test_components})
+         if (TARGET TBB::${_component})
+             get_property(${_component}_lib_file_location TARGET TBB::${_component} PROPERTY LOCATION)
+@@ -593,6 +593,6 @@ if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
+     tbb_add_test(SUBDIR tbbmalloc NAME test_malloc_new_handler DEPENDENCIES TBB::tbbmalloc_proxy)
+ endif()
+ 
+-unset(HWLOC_2_4_TESTS_STATUS_SHOWN)
++unset(HWLOC_2_5_TESTS_STATUS_SHOWN)
+ unset(HWLOC_2_TESTS_STATUS_SHOWN)
+ unset(HWLOC_1_11_TESTS_STATUS_SHOWN)
+diff --git a/test/common/common_arena_constraints.h b/test/common/common_arena_constraints.h
+index 2a0b1ea97..5efc71082 100644
+--- a/test/common/common_arena_constraints.h
++++ b/test/common/common_arena_constraints.h
+@@ -38,9 +38,26 @@
+ 
+ #if (_WIN32 || _WIN64) && __TBB_HWLOC_VALID_ENVIRONMENT
+ #include <windows.h>
+-int get_processors_groups_count() { return GetActiveProcessorGroupCount(); }
++int get_processors_group_count() {
++    SYSTEM_INFO si;
++    GetNativeSystemInfo(&si);
++    DWORD_PTR pam, sam, m = 1;
++    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
++    int nproc = 0;
++    for ( std::size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
++        if ( pam & m )
++            ++nproc;
++    }
++    // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present
++    if ( nproc == (int)si.dwNumberOfProcessors  ) {
++        // The process does not have restricting affinity mask and multiple processor groups are possible
++        return (int)GetActiveProcessorGroupCount();
++    } else {
++        return 1;
++    }
++}
+ #else
+-int get_processors_groups_count() { return 1; }
++int get_processors_group_count() { return 1; }
+ #endif
+ 
+ //TODO: Write a test that checks for memory leaks during dynamic link/unlink of TBBbind.
+@@ -69,6 +86,7 @@ int get_processors_groups_count() { return 1; }
+ #endif
+ 
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ // At this moment the hybrid CPUs HWLOC interfaces returns unexpected results on some Windows machines
+ // in the 32-bit arch mode.
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_VALID (!_WIN32 || _WIN64)
+@@ -153,9 +171,18 @@ class system_info {
+ 
+     system_info() {
+         hwloc_require_ex(hwloc_topology_init, &topology);
++#if __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++        if ( get_processors_group_count() == 1 ) {
++            REQUIRE(
++                hwloc_topology_set_flags(topology,
++                    HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                    HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING) == 0
++            );
++        }
++#endif
+         hwloc_require_ex(hwloc_topology_load, topology);
+ 
+-        if ( get_processors_groups_count() > 1 ) {
++        if ( get_processors_group_count() > 1 ) {
+             process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
+         } else {
+             process_cpuset = hwloc_bitmap_alloc();
+@@ -434,7 +461,7 @@ system_info::affinity_mask get_arena_affinity(tbb::task_arena& ta) {
+                 barrier.wait();
+                 tbb::spin_mutex::scoped_lock lock(affinity_mutex);
+                 system_info::affinity_mask thread_affinity = system_info::allocate_current_affinity_mask();
+-                if (get_processors_groups_count() == 1) {
++                if (get_processors_group_count() == 1) {
+                     REQUIRE_MESSAGE(hwloc_bitmap_isequal(thread_affinity, arena_affinity),
+                         "Threads have different masks on machine without several processors groups.");
+                 }
+@@ -532,7 +559,7 @@ constraints_container generate_constraints_variety() {
+         }
+ 
+         // Some constraints may cause unexpected behavior, which would be fixed later.
+-        if (get_processors_groups_count() > 1) {
++        if (get_processors_group_count() > 1) {
+             for(auto it = results.begin(); it != results.end(); ++it) {
+                 if (it->max_threads_per_core != tbb::task_arena::automatic
+                    && (it->numa_id == tbb::task_arena::automatic || tbb::info::numa_nodes().size() == 1)
diff --git a/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
new file mode 100644
index 000000000000..279ebc4397cd
--- /dev/null
+++ b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
@@ -0,0 +1,52 @@
+Based on https://github.com/oneapi-src/oneTBB/pull/498
+Tweaked a bit to work on `v2021.3.0`
+
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index e5cdbf8bb..a4033210a 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -37,6 +37,10 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+         ${HWLOC_INCLUDE_DIRS} # pkg-config defined
+     )
++	target_link_directories(${TBBBIND_NAME}
++		PRIVATE
++		${HWLOC_LIBRARY_DIRS} # pkg-config defined
++	)
+ 
+     target_compile_options(${TBBBIND_NAME}
+         PRIVATE
+@@ -69,7 +69,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     else()
+         target_link_libraries(${TBBBIND_NAME}
+@@ -76,7 +76,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     endif()
+ 
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index b768759d5..3eb8357e6 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -258,7 +258,12 @@ function(tbb_add_tbbbind_test)
+         )
+         set_property(
+             TARGET ${_tbbbind_test_NAME}
+-            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARY_DIRS} ${HWLOC_LIBRARIES}
++            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARIES}
++            APPEND
++        )
++        set_property(
++            TARGET ${_tbbbind_test_NAME}
++			PROPERTY LINK_DIRECTORIES ${HWLOC_LIBRARY_DIRS}
+             APPEND
+         )
+         set_property(
diff --git a/srcpkgs/tbb/patches/hostname-usage.patch b/srcpkgs/tbb/patches/hostname-usage.patch
deleted file mode 100644
index 4aefeff192b5..000000000000
--- a/srcpkgs/tbb/patches/hostname-usage.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/build/version_info_linux.sh
-+++ b/build/version_info_linux.sh
-@@ -20,7 +20,7 @@
- 
- # Script used to generate version info string
- echo "#define __TBB_VERSION_STRINGS(N) \\"
--echo '#N": BUILD_HOST'"\t\t"`hostname -s`" ("`uname -m`")"'" ENDL \'
-+echo '#N": BUILD_HOST'"\t\t"`hostname`" ("`uname -m`")"'" ENDL \'
- # find OS name in *-release and issue* files by filtering blank lines and lsb-release content out
- echo '#N": BUILD_OS'"\t\t"`lsb_release -sd 2>/dev/null | grep -ih '[a-z] ' - /etc/*release /etc/issue 2>/dev/null | head -1 | sed -e 's/["\\\\]//g'`'" ENDL \'
- echo '#N": BUILD_KERNEL'"\t"`uname -srv`'" ENDL \'
diff --git a/srcpkgs/tbb/patches/musl.patch b/srcpkgs/tbb/patches/musl.patch
index a8867eb53793..ec89c6a95fc6 100644
--- a/srcpkgs/tbb/patches/musl.patch
+++ b/srcpkgs/tbb/patches/musl.patch
@@ -1,5 +1,5 @@
---- a/src/tbbmalloc/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
-+++ b/src/tbbmalloc/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
+--- a/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
++++ b/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
 @@ -28,6 +28,7 @@
  // of aligned_alloc as required by new C++ standard, this makes it hard to
  // redefine aligned_alloc here. However, running on systems with new libc
diff --git a/srcpkgs/tbb/template b/srcpkgs/tbb/template
index aeef6ebdd061..47655829f744 100644
--- a/srcpkgs/tbb/template
+++ b/srcpkgs/tbb/template
@@ -1,76 +1,33 @@
 # Template file for 'tbb'
 pkgname=tbb
-version=2020.U3
+version=2021.3.0
 revision=1
-# version rewrite: 2017_U7 (upstream) => 2017.7 (xbps)
-_ver=${version/./_}
-wrksrc="oneTBB-${_ver}"
-build_style=gnu-makefile
-hostmakedepends="cmake"
+wrksrc="oneTBB-${version}"
+build_style=cmake
+makedepends="libhwloc-devel libgomp-devel"
 short_desc="Intel Threading Building Blocks"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
 license="Apache-2.0"
 homepage="https://www.threadingbuildingblocks.org"
-distfiles="https://github.com/oneapi-src/oneTBB/archive/${_ver}.tar.gz"
-checksum=2103cc6238c935664f87680618f6684d57501d4a2fa8ea8f6c97ad6ff7dc722a
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*)
-		make_build_args="arch=intel64"
-		;;
-	i686*)
-		make_build_args="arch=ia32"
-		;;
-	armv7l*)
-		make_build_args="arch=armv7"
-		;;
-	aarch64*)
-		make_build_args="arch=arm64"
-		;;
-	ppc64*)
-		make_build_args="arch=ppc64"
-		;;
-	ppc*)
-		make_build_args="arch=ppc32"
-		;;
-	*)
-		# make sure to fall back instead of letting host uname control it
-		make_build_args="arch=generic"
-		;;
-esac
-
-post_extract() {
-	sed -i 's|CPLUS = g..|CPLUS = $(CXX)|g' build/linux.gcc.inc
-	sed -i 's|CONLY = gcc|CONLY = $(CC)|g' build/linux.gcc.inc
+distfiles="https://github.com/oneapi-src/oneTBB/archive/v${version}.tar.gz"
+checksum=8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e
 
+pre_patch() {
 	# alternative might be:
 	# https://git.alpinelinux.org/cgit/aports/tree/testing/libtbb/glibc-struct-mallinfo.patch
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		vsed -e "s@#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__@@" \
-		  -i src/tbbmalloc/proxy.h
+		  -i src/tbbmalloc_proxy/proxy.h
 	fi
 }
 
-do_install() {
-	vmkdir usr/lib
-	vcopy build/linux_*/*.so* usr/lib
-	vmkdir usr/include/tbb
-	vcopy include/tbb/* usr/include/tbb
-
-	cmake \
-		-DINSTALL_DIR=$DESTDIR/usr/lib/cmake/TBB \
-		-DSYSTEM_NAME=Linux \
-		-DLIB_REL_PATH=../.. \
-		-DINC_REL_PATH=../../../include \
-		-P cmake/tbb_config_installer.cmake
-}
-
 tbb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
-		vmove "usr/lib/*.so"
 		vmove usr/lib/cmake
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.so
 	}
 }

From bd0946d7b4179d36a7dec8d223699195b7706470 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 03/11] OpenSubdiv: update to 3.4.4.

---
 srcpkgs/OpenSubdiv/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/OpenSubdiv/template b/srcpkgs/OpenSubdiv/template
index b7a5e16efbcf..dfbf29cc1a52 100644
--- a/srcpkgs/OpenSubdiv/template
+++ b/srcpkgs/OpenSubdiv/template
@@ -1,6 +1,6 @@
 # Template file for 'OpenSubdiv'
 pkgname=OpenSubdiv
-version=3.4.3
+version=3.4.4
 revision=1
 wrksrc="OpenSubdiv-${version//./_}"
 build_style=cmake
@@ -13,7 +13,7 @@ maintainer="John <me@johnnynator.dev>"
 license="Apache-2.0"
 homepage="http://graphics.pixar.com/opensubdiv/docs/intro.html"
 distfiles="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${version//./_}.tar.gz"
-checksum=7b22eb27d636ab0c1e03722c7a5a5bd4f11664ee65c9b48f341a6d0ce7f36745
+checksum=20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" OpenSubdiv"

From b0dc3c83f6fc367d07b686cc4d836e0ce6e87b2b Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 04/11] PrusaSlicer: update to 2.3.3.

---
 srcpkgs/PrusaSlicer/patches/cross.patch | 11 -----------
 srcpkgs/PrusaSlicer/template            |  4 ++--
 2 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 srcpkgs/PrusaSlicer/patches/cross.patch

diff --git a/srcpkgs/PrusaSlicer/patches/cross.patch b/srcpkgs/PrusaSlicer/patches/cross.patch
deleted file mode 100644
index d64a450d9e9f..000000000000
--- a/srcpkgs/PrusaSlicer/patches/cross.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/avrdude/CMakeLists.txt	2020-06-04 09:19:26.017251215 +0200
-+++ b/src/avrdude/CMakeLists.txt	2020-06-04 09:19:36.468250771 +0200
-@@ -83,7 +83,7 @@ add_executable(avrdude-conf-gen conf-gen
- add_custom_command(
-     DEPENDS avrdude-conf-gen ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf
-     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
--    COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-+    COMMAND avrdude-conf-gen avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- 
diff --git a/srcpkgs/PrusaSlicer/template b/srcpkgs/PrusaSlicer/template
index dd0e76cb8017..a93832ac02e4 100644
--- a/srcpkgs/PrusaSlicer/template
+++ b/srcpkgs/PrusaSlicer/template
@@ -1,6 +1,6 @@
 # Template file for 'PrusaSlicer'
 pkgname=PrusaSlicer
-version=2.3.0
+version=2.3.3
 revision=1
 wrksrc="PrusaSlicer-version_${version}"
 build_style=cmake
@@ -16,7 +16,7 @@ maintainer="Jasper Chan <jasperchan515@gmail.com>"
 license="GPL-3.0-or-later"
 homepage="https://www.prusa3d.com/prusaslicer/"
 distfiles="https://github.com/prusa3d/Prusaslicer/archive/version_${version}.tar.gz"
-checksum=cd3bac5e29b5441fc4690f28cd7b1064e97dc00207bbdc88f7bd7832308d6ca5
+checksum=deda209505f740ac3d6f59cb2a960f4df908269ee09bd30cd4edb9fc472d29ac
 nocross="https://build.voidlinux.org/builders/armv7l_builder/builds/25230/steps/shell_3/logs/stdio"
 
 Slic3rPE_package() {

From b3e4fd2451a9e77773a19248cbd500f12e282c1d Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 05/11] blender: update to 2.93.1.

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index af946c2b7999..8318317c82bf 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,6 +1,6 @@
 # Template file for 'blender'
 pkgname=blender
-version=2.93.0
+version=2.93.1
 revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"

From 20822e06afe87fc103b25d7cde9d7cf8c9a5c586 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 06/11] embree: update to 3.13.0.

---
 srcpkgs/embree/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/embree/template b/srcpkgs/embree/template
index 575b9bcb401c..b6f376d30efa 100644
--- a/srcpkgs/embree/template
+++ b/srcpkgs/embree/template
@@ -1,8 +1,8 @@
 # Template file for 'embree'
 pkgname=embree
-version=2.17.7
-revision=2
-archs="x86_64"
+version=3.13.0
+revision=1
+archs="x86_64*"
 build_style=cmake
 configure_args="-DTBB_ROOT=/usr -DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF"
 hostmakedepends="ispc"

From d635044f33254d1cfb5c43005bc6fae2be82f7c8 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 03:34:43 +0300
Subject: [PATCH 07/11] openimageio: update to 2.2.16.0.

---
 srcpkgs/openimageio/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index de8e1cd04409..3bfdd4e0ed1e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,11 +1,11 @@
 # Template file for 'openimageio'
 pkgname=openimageio
-version=2.2.15.1
+version=2.2.16.0
 revision=1
 wrksrc="oiio-Release-${version}"
 build_style=cmake
 configure_args="-DUSE_OPENGL=0 -DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=1
- -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0"
+ -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0 -DCMAKE_CXX_STANDARD=14"
 hostmakedepends="pkg-config git"
 makedepends="boost-devel giflib-devel libraw-devel libopenjpeg-devel libwebp-devel
  libjpeg-turbo-devel tiff-devel libpng-devel libopenexr-devel freetype-devel
@@ -17,7 +17,7 @@ license="BSD-3-Clause"
 homepage="https://sites.google.com/site/openimageio/home"
 changelog="https://raw.githubusercontent.com/OpenImageIO/oiio/release/CHANGES.md"
 distfiles="https://github.com/OpenImageIO/oiio/archive/Release-${version}.tar.gz"
-checksum=f222c6b51a40aabbc80ddf4055535be9af1ffa907452fa6d1ffa7674854aab17
+checksum=d1a59f32dbba3ba71ad2e62e107034d1c5287bca1b0696474e927d504cd05ef4
 # Runs checks even for features we disabled.
 make_check=no
 

From 7ad6081c27a766fa77112b53888d111a67e0d30b Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 08/11] openimagedenoise: update to 1.4.1.

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index c73913b4e9d7..14055aff1c27 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,6 +1,6 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
-version=1.4.0
+version=1.4.1
 revision=1
 archs="x86_64*"
 wrksrc=oidn-${version}

From 4915178ec55370ae03bd4e0f36fc45cb8ac296c2 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 09/11] openvdb: update to 8.1.0.

---
 common/shlibs                             |    2 +-
 srcpkgs/openvdb/patches/00-tbb-2021.patch | 1320 +++++++++++++++++++++
 srcpkgs/openvdb/template                  |   16 +-
 3 files changed, 1325 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/openvdb/patches/00-tbb-2021.patch

diff --git a/common/shlibs b/common/shlibs
index 6b7ca5fbc249..2a7acdb253a7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3883,7 +3883,7 @@ libjanet.so.1.16 janet-1.16.0_1
 libOpenImageDenoise.so.1 openimagedenoise-1.3.0_1
 libcbang0.so cbang-1.6.0_3
 libblosc.so.1 c-blosc-1.17.1_1
-libopenvdb.so.7.0 openvdb-7.0.0_1
+libopenvdb.so.8.1 openvdb-8.1.0_1
 libAlembic.so.1.7 alembic-1.7.13_1
 libmodsecurity.so.3 modsecurity-3.0.4_1
 libraven.so.0 budgie-desktop-10.5.1_1
diff --git a/srcpkgs/openvdb/patches/00-tbb-2021.patch b/srcpkgs/openvdb/patches/00-tbb-2021.patch
new file mode 100644
index 000000000000..271104af3df9
--- /dev/null
+++ b/srcpkgs/openvdb/patches/00-tbb-2021.patch
@@ -0,0 +1,1320 @@
+https://github.com/AcademySoftwareFoundation/openvdb/pull/1027
+Should be dropped after 8.1.1 release.
+
+diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake
+index d41436b1c..06de2b3f3 100644
+--- a/cmake/FindTBB.cmake
++++ b/cmake/FindTBB.cmake
+@@ -169,8 +169,22 @@ find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
+   PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
+ )
+ 
+-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" ""
+@@ -178,7 +192,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" ""
+@@ -192,6 +206,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
+ # ------------------------------------------------------------------------
+diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt
+index 88543df3a..929fe94d1 100644
+--- a/openvdb/openvdb/CMakeLists.txt
++++ b/openvdb/openvdb/CMakeLists.txt
+@@ -437,6 +437,10 @@ set(OPENVDB_LIBRARY_UTIL_INCLUDE_FILES
+   util/Util.h
+ )
+ 
++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} DESTINATION ${OPENVDB_INST
+ 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)
+diff --git a/openvdb/openvdb/cmd/openvdb_render.cc b/openvdb/openvdb/cmd/openvdb_render.cc
+index ee5b737c5..2c9831ba3 100644
+--- a/openvdb/openvdb/cmd/openvdb_render.cc
++++ b/openvdb/openvdb/cmd/openvdb_render.cc
+@@ -19,7 +19,14 @@
+ #include <OpenEXR/ImfHeader.h>
+ #include <OpenEXR/ImfOutputFile.h>
+ #include <OpenEXR/ImfPixelType.h>
+-#include <tbb/task_scheduler_init.h>
++
++// 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 <tbb/global_control.h>
+ #include <tbb/tick_count.h>
+ 
+ #include <algorithm>
+@@ -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<tbb::global_control> 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();
+ 
+diff --git a/openvdb/openvdb/io/Queue.cc b/openvdb/openvdb/io/Queue.cc
+index ef5d2961a..20ff1a0c1 100644
+--- a/openvdb/openvdb/io/Queue.cc
++++ b/openvdb/openvdb/io/Queue.cc
+@@ -5,20 +5,22 @@
+ /// @author Peter Cucka
+ 
+ #include "Queue.h"
+-
+ #include "File.h"
+ #include "Stream.h"
+-#include <openvdb/Exceptions.h>
+-#include <openvdb/util/logging.h>
++#include "openvdb/Exceptions.h"
++#include "openvdb/util/logging.h"
++
+ #include <tbb/concurrent_hash_map.h>
+-#include <tbb/task.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
+-#include <tbb/tick_count.h>
++#include <tbb/task_arena.h>
++
++#include <thread>
+ #include <algorithm> // for std::max()
+ #include <atomic>
+ #include <iostream>
+ #include <map>
+ #include <mutex>
++#include <chrono>
++
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -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
+ 
+ 
+ // 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
+         : 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
+             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<Queue::Id, Queue::Status>;
+ 
+-
+     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::milliseconds>(
++                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;
+ }
+ 
+diff --git a/openvdb/openvdb/math/Coord.h b/openvdb/openvdb/math/Coord.h
+index 504b5e9a4..2e9cfed5d 100644
+--- a/openvdb/openvdb/math/Coord.h
++++ b/openvdb/openvdb/math/Coord.h
+@@ -13,8 +13,7 @@
+ #include "Math.h"
+ #include "Vec3.h"
+ 
+-namespace tbb { class split; } // forward declaration
+-
++#include <tbb/blocked_range.h> // for tbb::split
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+diff --git a/openvdb/openvdb/points/PointSample.h b/openvdb/openvdb/points/PointSample.h
+index a122cc4fb..27ec3fb29 100644
+--- a/openvdb/openvdb/points/PointSample.h
++++ b/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 <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tools/Interpolation.h>
++#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 <sstream>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -299,7 +299,7 @@ class PointDataSampler
+             using TargetHandleT = AttributeWriteHandle<typename SamplerWrapperT::ValueType>;
+ 
+             if (util::wasInterrupted(interrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return;
+             }
+ 
+diff --git a/openvdb/openvdb/thread/Threading.h b/openvdb/openvdb/thread/Threading.h
+new file mode 100644
+index 000000000..0c3b356e3
+--- /dev/null
++++ b/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 <tbb/blocked_range.h>
++#include <tbb/task.h>
++#include <tbb/task_group.h>
++
++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
+diff --git a/openvdb/openvdb/tools/Composite.h b/openvdb/openvdb/tools/Composite.h
+index 6bc170bf7..88ff86f9f 100644
+--- a/openvdb/openvdb/tools/Composite.h
++++ b/openvdb/openvdb/tools/Composite.h
+@@ -24,7 +24,6 @@
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include <type_traits>
+ #include <functional>
+diff --git a/openvdb/openvdb/tools/Diagnostics.h b/openvdb/openvdb/tools/Diagnostics.h
+index 694d2155f..e5844e448 100644
+--- a/openvdb/openvdb/tools/Diagnostics.h
++++ b/openvdb/openvdb/tools/Diagnostics.h
+@@ -11,14 +11,17 @@
+ #ifndef OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ 
+-#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/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 <tbb/blocked_range.h>
+ #include <tbb/parallel_reduce.h>
++
+ #include <cmath> // for std::isnan(), std::isfinite()
+ #include <set>
+ #include <sstream>
+@@ -26,7 +29,6 @@
+ #include <type_traits>
+ #include <vector>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -1160,13 +1162,13 @@ InactiveVoxelValues<TreeType>::operator()(const tbb::blocked_range<size_t>& rang
+ {
+     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<typename TreeType>
+ inline void
+ InactiveTileValues<TreeType>::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();
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/tools/Filter.h b/openvdb/openvdb/tools/Filter.h
+index 408c75541..b70212520 100644
+--- a/openvdb/openvdb/tools/Filter.h
++++ b/openvdb/openvdb/tools/Filter.h
+@@ -14,21 +14,24 @@
+ #ifndef OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ 
+-#include <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
++#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 <tbb/parallel_for.h>
++#include <tbb/concurrent_vector.h>
++
+ #include <algorithm> // for std::max()
+ #include <functional>
+ #include <type_traits>
+-#include <tbb/concurrent_vector.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -833,7 +836,7 @@ inline bool
+ Filter<GridT, MaskT, InterruptT>::wasInterrupted()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return true;
+     }
+     return false;
+diff --git a/openvdb/openvdb/tools/GridOperators.h b/openvdb/openvdb/tools/GridOperators.h
+index 31305a1ab..78fafead9 100644
+--- a/openvdb/openvdb/tools/GridOperators.h
++++ b/openvdb/openvdb/tools/GridOperators.h
+@@ -9,14 +9,15 @@
+ #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/Grid.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
++#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 <tbb/parallel_for.h>
+ 
++#include <tbb/parallel_for.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -383,7 +384,9 @@ class GridOperator
+     /// 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) {
+diff --git a/openvdb/openvdb/tools/LevelSetMeasure.h b/openvdb/openvdb/tools/LevelSetMeasure.h
+index efe19074d..59969cdcf 100644
+--- a/openvdb/openvdb/tools/LevelSetMeasure.h
++++ b/openvdb/openvdb/tools/LevelSetMeasure.h
+@@ -8,18 +8,21 @@
+ #ifndef OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/math/Math.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/Grid.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/math/FiniteDifference.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/math/Stencils.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
+ #include <tbb/parallel_sort.h>
+ #include <tbb/parallel_invoke.h>
++
+ #include <type_traits>
+ 
+ namespace openvdb {
+@@ -329,7 +332,7 @@ inline bool
+ LevelSetMeasure<GridT, InterruptT>::checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/LevelSetTracker.h b/openvdb/openvdb/tools/LevelSetTracker.h
+index cbdc267e8..bfc8004e7 100644
+--- a/openvdb/openvdb/tools/LevelSetTracker.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/tree/LeafManager.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -383,7 +385,7 @@ LevelSetTracker<GridT, InterruptT>::
+ checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/MeshToVolume.h b/openvdb/openvdb/tools/MeshToVolume.h
+index 6643c8f05..de3406eda 100644
+--- a/openvdb/openvdb/tools/MeshToVolume.h
++++ b/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 <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/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 <tbb/parallel_reduce.h>
+ #include <tbb/partitioner.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm> // for std::sort()
+ #include <cmath> // 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<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+@@ -1989,7 +1990,7 @@ class VoxelizePolygons
+         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
+ 
+         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) {
+diff --git a/openvdb/openvdb/tools/Morphology.h b/openvdb/openvdb/tools/Morphology.h
+index 736982ef5..0a1e71009 100644
+--- a/openvdb/openvdb/tools/Morphology.h
++++ b/openvdb/openvdb/tools/Morphology.h
+@@ -24,7 +24,7 @@
+ #include "openvdb/tree/ValueAccessor.h"
+ #include "openvdb/tree/LeafManager.h"
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ 
+@@ -726,7 +726,7 @@ void Morphology<TreeType>::dilateVoxels(const size_t iter,
+         }
+ 
+         // @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
+diff --git a/openvdb/openvdb/tools/ParticlesToLevelSet.h b/openvdb/openvdb/tools/ParticlesToLevelSet.h
+index 739af2b69..f9c19911c 100644
+--- a/openvdb/openvdb/tools/ParticlesToLevelSet.h
++++ b/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 <tbb/parallel_reduce.h>
+-#include <tbb/blocked_range.h>
+-#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/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 <tbb/parallel_reduce.h>
++#include <tbb/blocked_range.h>
++
+ #include <functional>
+ #include <iostream>
+ #include <type_traits>
+@@ -738,7 +742,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         for (Coord c = lo; c.x() <= hi.x(); ++c.x()) {
+             //only check interrupter every 32'th scan in x
+             if (!(count++ & ((1<<5)-1)) && util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Real x2 = math::Pow2(c.x() - P[0]);
+@@ -804,7 +808,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         // Densely fill the remaining regions.
+         for (const auto& bbox: padding) {
+             if (util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Coord &bmin = bbox.min(), &bmax = bbox.max();
+diff --git a/openvdb/openvdb/tools/PointAdvect.h b/openvdb/openvdb/tools/PointAdvect.h
+index 12b1177ad..e487bfb3e 100644
+--- a/openvdb/openvdb/tools/PointAdvect.h
++++ b/openvdb/openvdb/tools/PointAdvect.h
+@@ -10,16 +10,19 @@
+ #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/openvdb.h>
+-#include <openvdb/math/Math.h>             // min
+-#include <openvdb/Types.h>                 // Vec3 types and version number
+-#include <openvdb/Grid.h>                  // grid
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/blocked_range.h>             // threading
+ #include <tbb/parallel_for.h>              // threading
+ #include <tbb/task.h>                      // for cancel
++
+ #include <vector>
+ 
+ 
+@@ -167,7 +170,7 @@ class PointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityFieldIntegrator  velField(*mVelGrid);
+@@ -307,7 +310,7 @@ class ConstrainedPointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityIntegratorType velField(*mVelGrid);
+diff --git a/openvdb/openvdb/tools/PointIndexGrid.h b/openvdb/openvdb/tools/PointIndexGrid.h
+index e9ebf96f7..b2e378a79 100644
+--- a/openvdb/openvdb/tools/PointIndexGrid.h
++++ b/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 <openvdb/version.h>
+@@ -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;
+         }
+ 
+diff --git a/openvdb/openvdb/tools/PointPartitioner.h b/openvdb/openvdb/tools/PointPartitioner.h
+index ccf50ab05..f7f6fc13d 100644
+--- a/openvdb/openvdb/tools/PointPartitioner.h
++++ b/openvdb/openvdb/tools/PointPartitioner.h
+@@ -23,7 +23,7 @@
+ 
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm>
+ #include <cmath> // for std::isfinite()
+@@ -764,7 +764,7 @@ inline void binAndSegment(
+     using IndexPairListMap = std::map<Coord, IndexPairListPtr>;
+     using IndexPairListMapPtr = std::shared_ptr<IndexPairListMap>;
+ 
+-    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;
+ 
+diff --git a/openvdb/openvdb/tools/PointsToMask.h b/openvdb/openvdb/tools/PointsToMask.h
+index 592ab7a15..8a276fb04 100644
+--- a/openvdb/openvdb/tools/PointsToMask.h
++++ b/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 <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/blocked_range.h>
+-#include <openvdb/openvdb.h> // for MaskGrid
+-#include <openvdb/Grid.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/util/NullInterrupter.h>
++
+ #include <vector>
+ 
+ 
+@@ -150,7 +154,7 @@ class PointsToMask
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeAdvect.h b/openvdb/openvdb/tools/VolumeAdvect.h
+index e7eec740e..f38eaa9c2 100644
+--- a/openvdb/openvdb/tools/VolumeAdvect.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/math/Math.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ 
+ 
+@@ -294,7 +297,7 @@ class VolumeAdvection
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeToMesh.h b/openvdb/openvdb/tools/VolumeToMesh.h
+index a834dd3b3..a446f806a 100644
+--- a/openvdb/openvdb/tools/VolumeToMesh.h
++++ b/openvdb/openvdb/tools/VolumeToMesh.h
+@@ -18,7 +18,7 @@
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <cmath> // for std::isfinite()
+ #include <map>
+@@ -388,7 +388,7 @@ inline void
+ fillArray(ValueType* array, const ValueType& val, const size_t length)
+ {
+     const auto grainSize = std::max<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+diff --git a/openvdb/openvdb/unittest/TestCoord.cc b/openvdb/openvdb/unittest/TestCoord.cc
+index be1c24ced..148690041 100644
+--- a/openvdb/openvdb/unittest/TestCoord.cc
++++ b/openvdb/openvdb/unittest/TestCoord.cc
+@@ -2,9 +2,9 @@
+ // SPDX-License-Identifier: MPL-2.0
+ 
+ #include <openvdb/Types.h>
++#include <openvdb/math/Coord.h>
+ 
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_stddef.h> // for tbb::split
+ 
+ #include <unordered_map>
+ #include <sstream>
+diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc
+index 8074166d2..053448f30 100644
+--- a/openvdb/openvdb/unittest/TestFile.cc
++++ b/openvdb/openvdb/unittest/TestFile.cc
+@@ -13,8 +13,11 @@
+ #include <openvdb/version.h>
+ #include <openvdb/openvdb.h>
+ #include "util.h" // for unittest_util::makeSphere()
++
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
++
++#include <thread>
++#include <chrono>
+ #include <algorithm> // for std::sort()
+ #include <cstdio> // for remove() and rename()
+ #include <fstream>
+@@ -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::seconds>(
++                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<io::Queue::Id> 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));
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc
+index 70e7df5f7..6b2204771 100644
+--- a/openvdb/openvdb/unittest/TestUtil.cc
++++ b/openvdb/openvdb/unittest/TestUtil.cc
+@@ -8,7 +8,6 @@
+ 
+ #include <gtest/gtest.h>
+ 
+-#include <tbb/task_scheduler_init.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/blocked_range.h>
+diff --git a/openvdb/openvdb/unittest/TestValueAccessor.cc b/openvdb/openvdb/unittest/TestValueAccessor.cc
+index fd2dd5d81..5c1cbb18b 100644
+--- a/openvdb/openvdb/unittest/TestValueAccessor.cc
++++ b/openvdb/openvdb/unittest/TestValueAccessor.cc
+@@ -6,6 +6,7 @@
+ 
+ #include <gtest/gtest.h>
+ #include <tbb/task.h>
++#include <tbb/task_group.h>
+ 
+ #include <type_traits>
+ 
+@@ -378,22 +379,21 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
+     //using AccessorT = openvdb::tree::ValueAccessor<Tree4Type>;
+ 
+     // 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
+ }
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+index 0e1b4d855..6d9bb528b 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+@@ -20,6 +20,7 @@
+ #include <openvdb/tools/GridTransformer.h>
+ #include <openvdb/tools/PointIndexGrid.h>
+ #include <openvdb/tools/Prune.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <CH/CH_Manager.h>
+ #include <CVEX/CVEX_Context.h>
+@@ -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;
+             }
+ 
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+index 757fdc8c6..dbee74b32 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+@@ -16,13 +16,11 @@
+ #include <openvdb_houdini/SOP_NodeVDB.h>
+ 
+ #include <openvdb/tools/Interpolation.h>  // for box sampler
++#include <openvdb/thread/Threading.h>
+ #include <openvdb/points/PointCount.h>
+ #include <openvdb/points/PointSample.h>
+ #include <openvdb/points/IndexFilter.h>   // for MultiGroupFilter
+ 
+-#include <tbb/tick_count.h>                 // for timing
+-#include <tbb/task.h>                       // for cancel
+-
+ #include <UT/UT_Interrupt.h>
+ #include <GA/GA_PageHandle.h>
+ #include <GA/GA_PageIterator.h>
+@@ -38,6 +36,7 @@
+ #include <stdexcept>
+ #include <string>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ 
+@@ -327,7 +326,7 @@ class PointSampler
+     {
+ 
+         if (mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            openvdb::thread::cancelGroupExecution();
+         }
+         const GridType& grid = UTvdbGridCast<GridType>(mGrid);
+         // task local grid accessor
+@@ -481,7 +480,7 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Context& context)
+         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_Context& context)
+             }
+         }
+ 
+-        // 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::milliseconds>(
++                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;
+         }
+ 
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+index 3d559f8cc..d63ed1591 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
++++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+@@ -47,11 +47,8 @@ struct NodeInfo {
+ 
+ typedef std::vector<NodeInfo> 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, const MTypeId& typeId,
+     node.type               = type;
+     node.classification     = classification;
+ 
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (!gNodes) {
+         OPENVDB_START_THREADSAFE_STATIC_WRITE
+@@ -85,7 +82,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, const MTypeId& typeId,
+ void
+ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+@@ -109,7 +106,7 @@ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ void
+ NodeRegistry::deregisterNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.h b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+index b58bd6f2c..6a04b1eaf 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBUtil.h
++++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+@@ -14,8 +14,7 @@
+ #include <openvdb/tree/LeafManager.h>
+ #include <openvdb/tools/VolumeToMesh.h>
+ #include <openvdb/util/Formats.h> // printBytes
+-
+-#include <tbb/tick_count.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <maya/M3dView.h>
+ #include <maya/MString.h>
+@@ -40,6 +39,7 @@
+ #include <string>
+ #include <type_traits>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ ////////////////////////////////////////
+@@ -116,11 +116,15 @@ insertFrameNumber(std::string& str, const MTime& time, int numberingScheme = 0);
+ 
+ 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::milliseconds>(
++            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<std::chrono::steady_clock> mStamp;
+ };
+ 
+ 
+diff --git a/pendingchanges/tbb2021.txt b/pendingchanges/tbb2021.txt
+new file mode 100644
+index 000000000..8109c2552
+--- /dev/null
++++ b/pendingchanges/tbb2021.txt
+@@ -0,0 +1,6 @@
++Improvements:
++  - Moved from the deprecated TBB task scheduler to TBB arenas. Various methods now respect the TBB arena state they were invoked from.
++  - Introduced a new thread/Threading.h header to consolidate calls to third-party threading methods.
++
++Build:
++  - Added support for TBB 2021.
diff --git a/srcpkgs/openvdb/template b/srcpkgs/openvdb/template
index 72fde5bc6375..d420a3ee5f5d 100644
--- a/srcpkgs/openvdb/template
+++ b/srcpkgs/openvdb/template
@@ -1,26 +1,18 @@
 # Template file for 'openvdb'
 pkgname=openvdb
-version=7.0.0
+version=8.1.0
 revision=1
 build_style=cmake
 configure_args="-DOPENVDB_BUILD_VDB_VIEW=1"
 hostmakedepends="pkg-config"
-makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel glfw-devel"
+makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel
+ glfw-devel jemalloc-devel"
 short_desc="Sparse volume data structure and tools"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MPL-2.0"
 homepage="https://openvdb.org"
 distfiles="https://github.com/AcademySoftwareFoundation/openvdb/archive/v${version}.tar.gz"
-checksum=97bc8ae35ef7ccbf49a4e25cb73e8c2eccae6b235bac86f2150707efcd1e910d
-
-if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
-	makedepends+=" libatomic-devel"
-fi
-
-post_patch() {
-	[ "$XBPS_TARGET_NO_ATOMIC8" ] || return 0
-	vsed -i 's,ZLIB::ZLIB,ZLIB::ZLIB atomic,' openvdb/CMakeLists.txt
-}
+checksum=3e09d47331429be7409a3a3c27fdd3c297f96d31d2153febe194e664a99d6183
 
 post_install() {
 	vlicense LICENSE

From f52f14c7c4dbe988111baa612e26926c13c3edbc Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 10/11] paraview: update to 5.9.1.

---
 srcpkgs/paraview/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/paraview/template b/srcpkgs/paraview/template
index 20a7f5589677..e6c3941ce90a 100644
--- a/srcpkgs/paraview/template
+++ b/srcpkgs/paraview/template
@@ -1,7 +1,7 @@
 # Template file for 'paraview'
 pkgname=paraview
-version=5.8.1
-revision=3
+version=5.9.1
+revision=1
 wrksrc=ParaView-v${version}
 build_style=cmake
 configure_args="-DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr

From 0d3445c9fcd4f6f2a63dd41ef6cc0dc7b6e946a1 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 11/11] occt: revbump due to tbb update

---
 srcpkgs/occt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/occt/template b/srcpkgs/occt/template
index 9298edc76e08..006f89ebb8ce 100644
--- a/srcpkgs/occt/template
+++ b/srcpkgs/occt/template
@@ -2,7 +2,7 @@
 pkgname=occt
 reverts=7.5.0_1
 version=7.4.0p1
-revision=3
+revision=4
 _gittag="V${version//./_}"
 wrksrc=occt-${_gittag}
 build_style=cmake

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PR PATCH] [Updated] tbb: update to 2021.3.0
  2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
@ 2021-07-24 10:20 ` Logarithmus
  2021-07-24 11:13 ` Logarithmus
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Logarithmus @ 2021-07-24 10:20 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

There is an updated pull request by Logarithmus against master on the void-packages repository

https://github.com/Logarithmus/void-packages tbb-2021
https://github.com/void-linux/void-packages/pull/32166

tbb: update to 2021.3.0
Follow-up of https://github.com/void-linux/void-packages/pull/27746, @thypon & @olafmersmann might be interested.
**TODO** fix reverse dependencies:
- [ ] OpenSubdiv: update to 3.4.4.
- [ ] PrusaSlicer: update to 2.3.3.
- [ ] lender: update to 2.93.1.
- [ ] embree: update to 3.13.0.
- [ ] openimageio: update to 2.2.16.0.
- [ ] openimagedenoise: update to 1.4.1.
- [ ] openvdb: update to 8.1.0.
- [ ] paraview: update to 5.9.1.
- [ ] occt: revbump due to tbb update

#### Have the results of the proposed changes been tested?
- [x] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me


A patch file from https://github.com/void-linux/void-packages/pull/32166.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-tbb-2021-32166.patch --]
[-- Type: text/x-diff, Size: 87251 bytes --]

From 529fb7f0a06208b2c8105b05d1724e6db364eacf Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 17 Jul 2021 23:57:52 +0300
Subject: [PATCH 01/11] hwloc: add libpciaccess-devel make dependency

---
 srcpkgs/hwloc/template | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/hwloc/template b/srcpkgs/hwloc/template
index 818db269cebb..925937535735 100644
--- a/srcpkgs/hwloc/template
+++ b/srcpkgs/hwloc/template
@@ -1,10 +1,11 @@
 # Template file for 'hwloc'
 pkgname=hwloc
 version=2.5.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="cairo-devel ncurses-devel libxml2-devel eudev-libudev-devel"
+makedepends="cairo-devel ncurses-devel libxml2-devel libpciaccess-devel eudev-libudev-devel"
+checkdepends="tar"
 short_desc="Portable abstraction of hierarchical hardware architectures"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
 license="BSD-3-Clause"
@@ -31,7 +32,7 @@ libhwloc_package() {
 
 libhwloc-devel_package() {
 	short_desc+=" - development files"
-	depends="libhwloc>=${version}_${revision}"
+	depends="${makedepends} libhwloc>=${version}_${revision}"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/share/man/man3

From 6d480793a70e4252536905dd76af1a4d16baa372 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 02:50:26 +0300
Subject: [PATCH 02/11] tbb: update to 2021.3.0.

---
 common/shlibs                                |   6 +-
 srcpkgs/tbb/patches/00-hwloc-2.5.patch       | 367 +++++++++++++++++++
 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch |  52 +++
 srcpkgs/tbb/patches/hostname-usage.patch     |  11 -
 srcpkgs/tbb/patches/musl.patch               |   4 +-
 srcpkgs/tbb/template                         |  63 +---
 6 files changed, 433 insertions(+), 70 deletions(-)
 create mode 100644 srcpkgs/tbb/patches/00-hwloc-2.5.patch
 create mode 100644 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
 delete mode 100644 srcpkgs/tbb/patches/hostname-usage.patch

diff --git a/common/shlibs b/common/shlibs
index a7afbf2a56f7..6b7ca5fbc249 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2376,12 +2376,10 @@ libanthy-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthydic-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthyinput-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthygobject-1.0.so.5 ibus-anthy-1.5.6_1
-libtbbmalloc_proxy_debug.so.2 tbb-4.3_1
 libtbbmalloc_proxy.so.2 tbb-4.3_1
 libtbbmalloc.so.2 tbb-4.3_1
-libtbb_debug.so.2 tbb-4.3_1
-libtbb.so.2 tbb-4.3_1
-libtbbmalloc_debug.so.2 tbb-4.3_1
+libtbb.so.12 tbb-2021.3.0_1
+libtbbbind_2_5.so.3 tbb-2021.3.0_1
 libembree.so.2 embree-2.5.1_1
 libgtkimageview.so.0 gtkimageview-1.6.4_1
 libgoocanvas-2.0.so.9 goocanvas-2.0.4_1
diff --git a/srcpkgs/tbb/patches/00-hwloc-2.5.patch b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
new file mode 100644
index 000000000000..9c4c9285c71d
--- /dev/null
+++ b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
@@ -0,0 +1,367 @@
+Adjusted by Artur Sinila <freesoftware@logarithmus.dev>
+
+From e96dbf4b48e689ab810b0428d0858a6abc2c83bd Mon Sep 17 00:00:00 2001
+From: Ivan Kochin <iv.kochin@gmail.com>
+Date: Thu, 1 Jul 2021 15:07:39 +0300
+Subject: [PATCH] Upgrade from HWLOC 2.4 to HWLOC 2.5 (#448)
+
+* Upgrade from HWLOC 2.4 to HWLOC 2.5
+* Introduce tbbbind_2_5 library
+* Remove tbbbind_2_4 library
+* Use the HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING topology flag (introduces as a part of HWLOC 2.5) to restrict topology discovering to process binding
+* Fix testing on Linux
+* Apply review comments
+* Improve wording: variable -> substring
+* Use right tbbbind version for incompatible hwlocs test
+* Rework option semantic
+* Update README.md for CMake
+* Rework readme
+* Update cmake/README.md
+
+Signed-off-by: Kochin, Ivan <kochin.ivan@intel.com>
+
+Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
+---
+ CMakeLists.txt                         |  3 ++-
+ cmake/README.md                        | 11 +++++---
+ cmake/hwloc_detection.cmake            |  9 ++++---
+ src/tbb/governor.cpp                   |  4 +--
+ src/tbbbind/CMakeLists.txt             |  2 +-
+ src/tbbbind/tbb_bind.cpp               | 23 +++++++++++-----
+ test/CMakeLists.txt                    | 30 ++++++++++-----------
+ test/common/common_arena_constraints.h | 37 ++++++++++++++++++++++----
+ 8 files changed, 82 insertions(+), 37 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 34a23d400..301899aca 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -100,6 +100,7 @@ option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Win
+ option(TBB4PY_BUILD "Enable tbb4py build" OFF)
+ option(TBB_CPF "Enable preview features of the library" OFF)
+ option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
++option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
+ 
+ if (NOT DEFINED BUILD_SHARED_LIBS)
+     set(BUILD_SHARED_LIBS ON)
+@@ -195,7 +196,7 @@ else()
+         add_subdirectory(src/tbbmalloc)
+         add_subdirectory(src/tbbmalloc_proxy)
+         if (APPLE)
+-            message(STATUS "TBBBind build target is disabled due to unsupported environment")
++            message(STATUS "TBBBind build targets are disabled due to unsupported environment")
+         else()
+             add_subdirectory(src/tbbbind)
+         endif()
+diff --git a/cmake/README.md b/cmake/README.md
+index 36fc303f9..b58c2ff6a 100644
+--- a/cmake/README.md
++++ b/cmake/README.md
+@@ -13,6 +13,7 @@ TBB4PY_BUILD:BOOL - Enable  Intel(R) oneAPI Threading Building Blocks (oneTBB) P
+ TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
+ TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
+ TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
++TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)
+ ```
+ 
+ ## Configure, build and test
+@@ -42,9 +43,9 @@ Some useful options:
+ 
+ #### TBBBind library configuration
+ 
+-The TBBbind library has two versions: `tbbbind` and `tbbbind_2_0`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.x.
++The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0` and `tbbbind_2_5`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.1-2.4, `tbbbind_2_5` links with HWLOC 2.5 and later.
+ 
+-To enable the TBBBind library build or special tests that performed inside the HWLOC environment, please specify the following CMake variables:
++The search for a suitable version of the HWLOC library is enabled by default, but if you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
+ 
+  - `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux or path to `.lib` file on Windows.
+  - `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version includes directory.
+@@ -52,7 +53,11 @@ To enable the TBBBind library build or special tests that performed inside the H
+ Windows requires one additional variable for correct TBBBind library building:
+  - `CMAKE_HWLOC_<HWLOC_VER>_DLL_PATH` - path to the corresponding HWLOC version `.dll` file.
+ 
+-`HWLOC_VER` variable used above can be replaced with one of the two values: `1_11` for the `tbbbind` library configuration and `2` for the `tbbbind_2_0` library configuration.
++`HWLOC_VER` substring used above can be replaced with one of the three values: `1_11` for the `tbbbind` library configuration, `2` for the `tbbbind_2_0`, and `2_5` for the `tbbbind_2_5` library configuration.
++
++If you specify variables for several TBBBind versions, then building process for all of these versions will be performed during single build session.
++
++Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
+ 
+ ### Build
+ 
+diff --git a/cmake/hwloc_detection.cmake b/cmake/hwloc_detection.cmake
+index e1eeca5fa..de7f3c047 100644
+--- a/cmake/hwloc_detection.cmake
++++ b/cmake/hwloc_detection.cmake
+@@ -12,7 +12,7 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
+-list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_4)
++list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_5)
+ 
+ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
+     if (NOT WIN32)
+@@ -55,10 +56,10 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
+         if (HWLOC_FOUND)
+             if (HWLOC_VERSION VERSION_LESS 2)
+                 set(TBBBIND_LIBRARY_NAME tbbbind)
+-            elseif(HWLOC_VERSION VERSION_LESS 2.4)
++            elseif(HWLOC_VERSION VERSION_LESS 2.5)
+                 set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
+             else()
+-                set(TBBBIND_LIBRARY_NAME tbbbind_2_4)
++                set(TBBBIND_LIBRARY_NAME tbbbind_2_5)
+             endif()
+         endif()
+     endif()
+diff --git a/src/tbb/governor.cpp b/src/tbb/governor.cpp
+index bf4e402d1..b842e075f 100644
+--- a/src/tbb/governor.cpp
++++ b/src/tbb/governor.cpp
+@@ -362,7 +362,7 @@ static const unsigned LinkTableSize = sizeof(TbbBindLinkTable) / sizeof(dynamic_
+ 
+ #define TBBBIND_NAME LIBRARY_PREFIX "tbbbind" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #define TBBBIND_2_0_NAME LIBRARY_PREFIX "tbbbind_2_0" DEBUG_SUFFIX LIBRARY_EXTENSION
+-#define TBBBIND_2_4_NAME LIBRARY_PREFIX "tbbbind_2_4" DEBUG_SUFFIX LIBRARY_EXTENSION
++#define TBBBIND_2_5_NAME LIBRARY_PREFIX "tbbbind_2_5" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #endif /* _WIN32 || _WIN64 || __linux__ */
+ 
+ // Representation of system hardware topology information on the TBB side.
+@@ -389,7 +389,7 @@ const char* load_tbbbind_shared_object() {
+     GetNativeSystemInfo(&si);
+     if (si.dwNumberOfProcessors > 32) return nullptr;
+ #endif /* _WIN32 && !_WIN64 */
+-    for (const auto& tbbbind_version : {TBBBIND_2_4_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
++    for (const auto& tbbbind_version : {TBBBIND_2_5_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
+         if (dynamic_link(tbbbind_version, TbbBindLinkTable, LinkTableSize)) {
+             return tbbbind_version;
+         }
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index 029893751..e5cdbf8bb 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -99,7 +99,7 @@ if (NOT DEFINED HWLOC_TARGET_EXPLICITLY_DEFINED AND DEFINED HWLOC_LIBRARIES)
+ else()
+     tbbbind_build(tbbbind     HWLOC::hwloc_1_11)
+     tbbbind_build(tbbbind_2_0 HWLOC::hwloc_2   )
+-    tbbbind_build(tbbbind_2_4 HWLOC::hwloc_2_4 )
++    tbbbind_build(tbbbind_2_5 HWLOC::hwloc_2_5 )
+ endif()
+ 
+ 
+diff --git a/src/tbbbind/tbb_bind.cpp b/src/tbbbind/tbb_bind.cpp
+index 97be308c7..88c956acb 100644
+--- a/src/tbbbind/tbb_bind.cpp
++++ b/src/tbbbind/tbb_bind.cpp
+@@ -34,7 +34,8 @@
+ #pragma GCC diagnostic pop
+ #endif
+ 
+-#define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ 
+ // Most of hwloc calls returns negative exit code on error.
+ // This macro tracks error codes that are returned from the hwloc interfaces.
+@@ -85,6 +86,16 @@ class platform_topology {
+         // Parse topology
+         if ( hwloc_topology_init( &topology ) == 0 ) {
+             initialization_state = topology_allocated;
++#if __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++            if ( groups_num == 1 &&
++                 hwloc_topology_set_flags(topology,
++                     HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                     HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
++                 ) != 0
++            ) {
++                return;
++            }
++#endif
+             if ( hwloc_topology_load( topology ) == 0 ) {
+                 initialization_state = topology_loaded;
+             }
+@@ -135,7 +146,7 @@ class platform_topology {
+             numa_indexes_list.resize(numa_nodes_count);
+             hwloc_obj_t node_buffer;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 numa_indexes_list[counter] = static_cast<int>(node_buffer->logical_index);
+ 
+                 if ( numa_indexes_list[counter] > max_numa_index ) {
+@@ -150,7 +161,7 @@ class platform_topology {
+             numa_affinity_masks_list.resize(max_numa_index + 1);
+             int index = 0;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 index = static_cast<int>(node_buffer->logical_index);
+ 
+                 hwloc_cpuset_t& current_mask = numa_affinity_masks_list[index];
+@@ -168,7 +179,7 @@ class platform_topology {
+             core_types_indexes_list.push_back(-1);
+             return;
+         }
+-#if __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
++#if __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
+         __TBB_ASSERT(hwloc_get_api_version() >= 0x20400, "Hybrid CPUs support interfaces required HWLOC >= 2.4");
+         // Parsing the hybrid CPU topology
+         int core_types_number = hwloc_cpukinds_get_nr(topology, 0);
+@@ -196,9 +207,9 @@ class platform_topology {
+                 }
+             }
+         }
+-#else /*!__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#else /*!__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+         bool core_types_parsing_broken{true};
+-#endif /*__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#endif /*__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+ 
+         if (core_types_parsing_broken) {
+             for (auto& core_type_mask : core_types_affinity_masks_list) {
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index bdae9e2b1..c2b9d6dba 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -275,9 +275,9 @@ function(tbb_add_tbbbind_test)
+         FAIL_REGULAR_EXPRESSION "Status:.*FAILURE"
+     )
+ 
+-    if (TARGET HWLOC::hwloc_2_4 AND NOT HWLOC_2_4_TESTS_STATUS_SHOWN)
+-        message(STATUS "HWLOC 2.4 dependent tests were enabled.")
+-        set(HWLOC_2_4_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
++    if (TARGET HWLOC::hwloc_2_5 AND NOT HWLOC_2_5_TESTS_STATUS_SHOWN)
++        message(STATUS "HWLOC 2.5 dependent tests were enabled.")
++        set(HWLOC_2_5_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
+     endif()
+ 
+     if (TARGET HWLOC::hwloc_2 AND NOT HWLOC_2_TESTS_STATUS_SHOWN)
+@@ -291,22 +291,22 @@ function(tbb_add_tbbbind_test)
+     endif()
+ 
+     list(APPEND HWLOC_TEST_CASES
+-        hwloc_2_4
++        hwloc_2_5
+         hwloc_2
+         hwloc_1_11
+-        hwloc_2_4_hwloc_2
+-        hwloc_2_4_hwloc_1_11
++        hwloc_2_5_hwloc_2
++        hwloc_2_5_hwloc_1_11
+         hwloc_2_hwloc_1_11
+-        hwloc_2_4_hwloc_2_hwloc_1_11
++        hwloc_2_5_hwloc_2_hwloc_1_11
+     )
+ 
+-    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_4 "hwloc_2_4")
++    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_5 "hwloc_2_5")
+     list(APPEND HWLOC_TEST_CASE_1_VARS tbbbind_2   "hwloc_2")
+     list(APPEND HWLOC_TEST_CASE_2_VARS tbbbind     "hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2")
+-    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_4 "hwloc_2_4,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2")
++    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_5 "hwloc_2_5,hwloc_1_11")
+     list(APPEND HWLOC_TEST_CASE_5_VARS tbbbind_2   "hwloc_2,hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2,hwloc_1_11")
+ 
+     foreach(TEST_CASE ${HWLOC_TEST_CASES})
+         list(FIND HWLOC_TEST_CASES ${TEST_CASE} TEST_CASE_INDEX)
+@@ -331,7 +331,7 @@ endfunction()
+ # Copy libraries to test folder to make it visible during tests execution if external TBB is tested.
+ # TODO: check and update for multi-config generators.
+ if (TBB_FOUND)
+-    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_4)
++    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_5)
+     foreach(_component ${_tbb_test_components})
+         if (TARGET TBB::${_component})
+             get_property(${_component}_lib_file_location TARGET TBB::${_component} PROPERTY LOCATION)
+@@ -593,6 +593,6 @@ if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
+     tbb_add_test(SUBDIR tbbmalloc NAME test_malloc_new_handler DEPENDENCIES TBB::tbbmalloc_proxy)
+ endif()
+ 
+-unset(HWLOC_2_4_TESTS_STATUS_SHOWN)
++unset(HWLOC_2_5_TESTS_STATUS_SHOWN)
+ unset(HWLOC_2_TESTS_STATUS_SHOWN)
+ unset(HWLOC_1_11_TESTS_STATUS_SHOWN)
+diff --git a/test/common/common_arena_constraints.h b/test/common/common_arena_constraints.h
+index 2a0b1ea97..5efc71082 100644
+--- a/test/common/common_arena_constraints.h
++++ b/test/common/common_arena_constraints.h
+@@ -38,9 +38,26 @@
+ 
+ #if (_WIN32 || _WIN64) && __TBB_HWLOC_VALID_ENVIRONMENT
+ #include <windows.h>
+-int get_processors_groups_count() { return GetActiveProcessorGroupCount(); }
++int get_processors_group_count() {
++    SYSTEM_INFO si;
++    GetNativeSystemInfo(&si);
++    DWORD_PTR pam, sam, m = 1;
++    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
++    int nproc = 0;
++    for ( std::size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
++        if ( pam & m )
++            ++nproc;
++    }
++    // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present
++    if ( nproc == (int)si.dwNumberOfProcessors  ) {
++        // The process does not have restricting affinity mask and multiple processor groups are possible
++        return (int)GetActiveProcessorGroupCount();
++    } else {
++        return 1;
++    }
++}
+ #else
+-int get_processors_groups_count() { return 1; }
++int get_processors_group_count() { return 1; }
+ #endif
+ 
+ //TODO: Write a test that checks for memory leaks during dynamic link/unlink of TBBbind.
+@@ -69,6 +86,7 @@ int get_processors_groups_count() { return 1; }
+ #endif
+ 
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ // At this moment the hybrid CPUs HWLOC interfaces returns unexpected results on some Windows machines
+ // in the 32-bit arch mode.
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_VALID (!_WIN32 || _WIN64)
+@@ -153,9 +171,18 @@ class system_info {
+ 
+     system_info() {
+         hwloc_require_ex(hwloc_topology_init, &topology);
++#if __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++        if ( get_processors_group_count() == 1 ) {
++            REQUIRE(
++                hwloc_topology_set_flags(topology,
++                    HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                    HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING) == 0
++            );
++        }
++#endif
+         hwloc_require_ex(hwloc_topology_load, topology);
+ 
+-        if ( get_processors_groups_count() > 1 ) {
++        if ( get_processors_group_count() > 1 ) {
+             process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
+         } else {
+             process_cpuset = hwloc_bitmap_alloc();
+@@ -434,7 +461,7 @@ system_info::affinity_mask get_arena_affinity(tbb::task_arena& ta) {
+                 barrier.wait();
+                 tbb::spin_mutex::scoped_lock lock(affinity_mutex);
+                 system_info::affinity_mask thread_affinity = system_info::allocate_current_affinity_mask();
+-                if (get_processors_groups_count() == 1) {
++                if (get_processors_group_count() == 1) {
+                     REQUIRE_MESSAGE(hwloc_bitmap_isequal(thread_affinity, arena_affinity),
+                         "Threads have different masks on machine without several processors groups.");
+                 }
+@@ -532,7 +559,7 @@ constraints_container generate_constraints_variety() {
+         }
+ 
+         // Some constraints may cause unexpected behavior, which would be fixed later.
+-        if (get_processors_groups_count() > 1) {
++        if (get_processors_group_count() > 1) {
+             for(auto it = results.begin(); it != results.end(); ++it) {
+                 if (it->max_threads_per_core != tbb::task_arena::automatic
+                    && (it->numa_id == tbb::task_arena::automatic || tbb::info::numa_nodes().size() == 1)
diff --git a/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
new file mode 100644
index 000000000000..279ebc4397cd
--- /dev/null
+++ b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
@@ -0,0 +1,52 @@
+Based on https://github.com/oneapi-src/oneTBB/pull/498
+Tweaked a bit to work on `v2021.3.0`
+
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index e5cdbf8bb..a4033210a 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -37,6 +37,10 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+         ${HWLOC_INCLUDE_DIRS} # pkg-config defined
+     )
++	target_link_directories(${TBBBIND_NAME}
++		PRIVATE
++		${HWLOC_LIBRARY_DIRS} # pkg-config defined
++	)
+ 
+     target_compile_options(${TBBBIND_NAME}
+         PRIVATE
+@@ -69,7 +69,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     else()
+         target_link_libraries(${TBBBIND_NAME}
+@@ -76,7 +76,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     endif()
+ 
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index b768759d5..3eb8357e6 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -258,7 +258,12 @@ function(tbb_add_tbbbind_test)
+         )
+         set_property(
+             TARGET ${_tbbbind_test_NAME}
+-            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARY_DIRS} ${HWLOC_LIBRARIES}
++            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARIES}
++            APPEND
++        )
++        set_property(
++            TARGET ${_tbbbind_test_NAME}
++			PROPERTY LINK_DIRECTORIES ${HWLOC_LIBRARY_DIRS}
+             APPEND
+         )
+         set_property(
diff --git a/srcpkgs/tbb/patches/hostname-usage.patch b/srcpkgs/tbb/patches/hostname-usage.patch
deleted file mode 100644
index 4aefeff192b5..000000000000
--- a/srcpkgs/tbb/patches/hostname-usage.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/build/version_info_linux.sh
-+++ b/build/version_info_linux.sh
-@@ -20,7 +20,7 @@
- 
- # Script used to generate version info string
- echo "#define __TBB_VERSION_STRINGS(N) \\"
--echo '#N": BUILD_HOST'"\t\t"`hostname -s`" ("`uname -m`")"'" ENDL \'
-+echo '#N": BUILD_HOST'"\t\t"`hostname`" ("`uname -m`")"'" ENDL \'
- # find OS name in *-release and issue* files by filtering blank lines and lsb-release content out
- echo '#N": BUILD_OS'"\t\t"`lsb_release -sd 2>/dev/null | grep -ih '[a-z] ' - /etc/*release /etc/issue 2>/dev/null | head -1 | sed -e 's/["\\\\]//g'`'" ENDL \'
- echo '#N": BUILD_KERNEL'"\t"`uname -srv`'" ENDL \'
diff --git a/srcpkgs/tbb/patches/musl.patch b/srcpkgs/tbb/patches/musl.patch
index a8867eb53793..ec89c6a95fc6 100644
--- a/srcpkgs/tbb/patches/musl.patch
+++ b/srcpkgs/tbb/patches/musl.patch
@@ -1,5 +1,5 @@
---- a/src/tbbmalloc/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
-+++ b/src/tbbmalloc/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
+--- a/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
++++ b/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
 @@ -28,6 +28,7 @@
  // of aligned_alloc as required by new C++ standard, this makes it hard to
  // redefine aligned_alloc here. However, running on systems with new libc
diff --git a/srcpkgs/tbb/template b/srcpkgs/tbb/template
index aeef6ebdd061..47655829f744 100644
--- a/srcpkgs/tbb/template
+++ b/srcpkgs/tbb/template
@@ -1,76 +1,33 @@
 # Template file for 'tbb'
 pkgname=tbb
-version=2020.U3
+version=2021.3.0
 revision=1
-# version rewrite: 2017_U7 (upstream) => 2017.7 (xbps)
-_ver=${version/./_}
-wrksrc="oneTBB-${_ver}"
-build_style=gnu-makefile
-hostmakedepends="cmake"
+wrksrc="oneTBB-${version}"
+build_style=cmake
+makedepends="libhwloc-devel libgomp-devel"
 short_desc="Intel Threading Building Blocks"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
 license="Apache-2.0"
 homepage="https://www.threadingbuildingblocks.org"
-distfiles="https://github.com/oneapi-src/oneTBB/archive/${_ver}.tar.gz"
-checksum=2103cc6238c935664f87680618f6684d57501d4a2fa8ea8f6c97ad6ff7dc722a
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*)
-		make_build_args="arch=intel64"
-		;;
-	i686*)
-		make_build_args="arch=ia32"
-		;;
-	armv7l*)
-		make_build_args="arch=armv7"
-		;;
-	aarch64*)
-		make_build_args="arch=arm64"
-		;;
-	ppc64*)
-		make_build_args="arch=ppc64"
-		;;
-	ppc*)
-		make_build_args="arch=ppc32"
-		;;
-	*)
-		# make sure to fall back instead of letting host uname control it
-		make_build_args="arch=generic"
-		;;
-esac
-
-post_extract() {
-	sed -i 's|CPLUS = g..|CPLUS = $(CXX)|g' build/linux.gcc.inc
-	sed -i 's|CONLY = gcc|CONLY = $(CC)|g' build/linux.gcc.inc
+distfiles="https://github.com/oneapi-src/oneTBB/archive/v${version}.tar.gz"
+checksum=8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e
 
+pre_patch() {
 	# alternative might be:
 	# https://git.alpinelinux.org/cgit/aports/tree/testing/libtbb/glibc-struct-mallinfo.patch
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		vsed -e "s@#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__@@" \
-		  -i src/tbbmalloc/proxy.h
+		  -i src/tbbmalloc_proxy/proxy.h
 	fi
 }
 
-do_install() {
-	vmkdir usr/lib
-	vcopy build/linux_*/*.so* usr/lib
-	vmkdir usr/include/tbb
-	vcopy include/tbb/* usr/include/tbb
-
-	cmake \
-		-DINSTALL_DIR=$DESTDIR/usr/lib/cmake/TBB \
-		-DSYSTEM_NAME=Linux \
-		-DLIB_REL_PATH=../.. \
-		-DINC_REL_PATH=../../../include \
-		-P cmake/tbb_config_installer.cmake
-}
-
 tbb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
-		vmove "usr/lib/*.so"
 		vmove usr/lib/cmake
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.so
 	}
 }

From d3c41d24b5b6bf30baccb02091323c9681ddfcb2 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 03/11] OpenSubdiv: update to 3.4.4.

---
 srcpkgs/OpenSubdiv/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/OpenSubdiv/template b/srcpkgs/OpenSubdiv/template
index b7a5e16efbcf..dfbf29cc1a52 100644
--- a/srcpkgs/OpenSubdiv/template
+++ b/srcpkgs/OpenSubdiv/template
@@ -1,6 +1,6 @@
 # Template file for 'OpenSubdiv'
 pkgname=OpenSubdiv
-version=3.4.3
+version=3.4.4
 revision=1
 wrksrc="OpenSubdiv-${version//./_}"
 build_style=cmake
@@ -13,7 +13,7 @@ maintainer="John <me@johnnynator.dev>"
 license="Apache-2.0"
 homepage="http://graphics.pixar.com/opensubdiv/docs/intro.html"
 distfiles="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${version//./_}.tar.gz"
-checksum=7b22eb27d636ab0c1e03722c7a5a5bd4f11664ee65c9b48f341a6d0ce7f36745
+checksum=20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" OpenSubdiv"

From f91c2c2ca89f3791ebd634f14017b78aafbe66ca Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 04/11] PrusaSlicer: update to 2.3.3.

---
 srcpkgs/PrusaSlicer/patches/cross.patch | 11 -----------
 srcpkgs/PrusaSlicer/template            |  4 ++--
 2 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 srcpkgs/PrusaSlicer/patches/cross.patch

diff --git a/srcpkgs/PrusaSlicer/patches/cross.patch b/srcpkgs/PrusaSlicer/patches/cross.patch
deleted file mode 100644
index d64a450d9e9f..000000000000
--- a/srcpkgs/PrusaSlicer/patches/cross.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/avrdude/CMakeLists.txt	2020-06-04 09:19:26.017251215 +0200
-+++ b/src/avrdude/CMakeLists.txt	2020-06-04 09:19:36.468250771 +0200
-@@ -83,7 +83,7 @@ add_executable(avrdude-conf-gen conf-gen
- add_custom_command(
-     DEPENDS avrdude-conf-gen ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf
-     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
--    COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-+    COMMAND avrdude-conf-gen avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- 
diff --git a/srcpkgs/PrusaSlicer/template b/srcpkgs/PrusaSlicer/template
index dd0e76cb8017..a93832ac02e4 100644
--- a/srcpkgs/PrusaSlicer/template
+++ b/srcpkgs/PrusaSlicer/template
@@ -1,6 +1,6 @@
 # Template file for 'PrusaSlicer'
 pkgname=PrusaSlicer
-version=2.3.0
+version=2.3.3
 revision=1
 wrksrc="PrusaSlicer-version_${version}"
 build_style=cmake
@@ -16,7 +16,7 @@ maintainer="Jasper Chan <jasperchan515@gmail.com>"
 license="GPL-3.0-or-later"
 homepage="https://www.prusa3d.com/prusaslicer/"
 distfiles="https://github.com/prusa3d/Prusaslicer/archive/version_${version}.tar.gz"
-checksum=cd3bac5e29b5441fc4690f28cd7b1064e97dc00207bbdc88f7bd7832308d6ca5
+checksum=deda209505f740ac3d6f59cb2a960f4df908269ee09bd30cd4edb9fc472d29ac
 nocross="https://build.voidlinux.org/builders/armv7l_builder/builds/25230/steps/shell_3/logs/stdio"
 
 Slic3rPE_package() {

From 59d76ef2b0245216301283bc3ee39385098d37b1 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 05/11] blender: update to 2.93.1.

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index af946c2b7999..8318317c82bf 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,6 +1,6 @@
 # Template file for 'blender'
 pkgname=blender
-version=2.93.0
+version=2.93.1
 revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"

From a3a78affa6305843a94ab5542814b8d04487413b Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 06/11] embree: update to 3.13.0.

---
 srcpkgs/embree/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/embree/template b/srcpkgs/embree/template
index 575b9bcb401c..b6f376d30efa 100644
--- a/srcpkgs/embree/template
+++ b/srcpkgs/embree/template
@@ -1,8 +1,8 @@
 # Template file for 'embree'
 pkgname=embree
-version=2.17.7
-revision=2
-archs="x86_64"
+version=3.13.0
+revision=1
+archs="x86_64*"
 build_style=cmake
 configure_args="-DTBB_ROOT=/usr -DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF"
 hostmakedepends="ispc"

From 09d0efed8f107127c4aecc869e844dce40b4827d Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 03:34:43 +0300
Subject: [PATCH 07/11] openimageio: update to 2.2.16.0.

---
 srcpkgs/openimageio/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index de8e1cd04409..3bfdd4e0ed1e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,11 +1,11 @@
 # Template file for 'openimageio'
 pkgname=openimageio
-version=2.2.15.1
+version=2.2.16.0
 revision=1
 wrksrc="oiio-Release-${version}"
 build_style=cmake
 configure_args="-DUSE_OPENGL=0 -DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=1
- -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0"
+ -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0 -DCMAKE_CXX_STANDARD=14"
 hostmakedepends="pkg-config git"
 makedepends="boost-devel giflib-devel libraw-devel libopenjpeg-devel libwebp-devel
  libjpeg-turbo-devel tiff-devel libpng-devel libopenexr-devel freetype-devel
@@ -17,7 +17,7 @@ license="BSD-3-Clause"
 homepage="https://sites.google.com/site/openimageio/home"
 changelog="https://raw.githubusercontent.com/OpenImageIO/oiio/release/CHANGES.md"
 distfiles="https://github.com/OpenImageIO/oiio/archive/Release-${version}.tar.gz"
-checksum=f222c6b51a40aabbc80ddf4055535be9af1ffa907452fa6d1ffa7674854aab17
+checksum=d1a59f32dbba3ba71ad2e62e107034d1c5287bca1b0696474e927d504cd05ef4
 # Runs checks even for features we disabled.
 make_check=no
 

From 1d9242fb80b5b53953b1e58b968b674615eaeec6 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 08/11] openimagedenoise: update to 1.4.1.

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index c73913b4e9d7..14055aff1c27 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,6 +1,6 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
-version=1.4.0
+version=1.4.1
 revision=1
 archs="x86_64*"
 wrksrc=oidn-${version}

From 1fa50f7314a95ecd5db4237f027646017e55e01f Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 09/11] openvdb: update to 8.1.0.

---
 common/shlibs                             |    2 +-
 srcpkgs/openvdb/patches/00-tbb-2021.patch | 1320 +++++++++++++++++++++
 srcpkgs/openvdb/template                  |   16 +-
 3 files changed, 1325 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/openvdb/patches/00-tbb-2021.patch

diff --git a/common/shlibs b/common/shlibs
index 6b7ca5fbc249..2a7acdb253a7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3883,7 +3883,7 @@ libjanet.so.1.16 janet-1.16.0_1
 libOpenImageDenoise.so.1 openimagedenoise-1.3.0_1
 libcbang0.so cbang-1.6.0_3
 libblosc.so.1 c-blosc-1.17.1_1
-libopenvdb.so.7.0 openvdb-7.0.0_1
+libopenvdb.so.8.1 openvdb-8.1.0_1
 libAlembic.so.1.7 alembic-1.7.13_1
 libmodsecurity.so.3 modsecurity-3.0.4_1
 libraven.so.0 budgie-desktop-10.5.1_1
diff --git a/srcpkgs/openvdb/patches/00-tbb-2021.patch b/srcpkgs/openvdb/patches/00-tbb-2021.patch
new file mode 100644
index 000000000000..271104af3df9
--- /dev/null
+++ b/srcpkgs/openvdb/patches/00-tbb-2021.patch
@@ -0,0 +1,1320 @@
+https://github.com/AcademySoftwareFoundation/openvdb/pull/1027
+Should be dropped after 8.1.1 release.
+
+diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake
+index d41436b1c..06de2b3f3 100644
+--- a/cmake/FindTBB.cmake
++++ b/cmake/FindTBB.cmake
+@@ -169,8 +169,22 @@ find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
+   PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
+ )
+ 
+-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" ""
+@@ -178,7 +192,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" ""
+@@ -192,6 +206,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
+ # ------------------------------------------------------------------------
+diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt
+index 88543df3a..929fe94d1 100644
+--- a/openvdb/openvdb/CMakeLists.txt
++++ b/openvdb/openvdb/CMakeLists.txt
+@@ -437,6 +437,10 @@ set(OPENVDB_LIBRARY_UTIL_INCLUDE_FILES
+   util/Util.h
+ )
+ 
++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} DESTINATION ${OPENVDB_INST
+ 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)
+diff --git a/openvdb/openvdb/cmd/openvdb_render.cc b/openvdb/openvdb/cmd/openvdb_render.cc
+index ee5b737c5..2c9831ba3 100644
+--- a/openvdb/openvdb/cmd/openvdb_render.cc
++++ b/openvdb/openvdb/cmd/openvdb_render.cc
+@@ -19,7 +19,14 @@
+ #include <OpenEXR/ImfHeader.h>
+ #include <OpenEXR/ImfOutputFile.h>
+ #include <OpenEXR/ImfPixelType.h>
+-#include <tbb/task_scheduler_init.h>
++
++// 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 <tbb/global_control.h>
+ #include <tbb/tick_count.h>
+ 
+ #include <algorithm>
+@@ -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<tbb::global_control> 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();
+ 
+diff --git a/openvdb/openvdb/io/Queue.cc b/openvdb/openvdb/io/Queue.cc
+index ef5d2961a..20ff1a0c1 100644
+--- a/openvdb/openvdb/io/Queue.cc
++++ b/openvdb/openvdb/io/Queue.cc
+@@ -5,20 +5,22 @@
+ /// @author Peter Cucka
+ 
+ #include "Queue.h"
+-
+ #include "File.h"
+ #include "Stream.h"
+-#include <openvdb/Exceptions.h>
+-#include <openvdb/util/logging.h>
++#include "openvdb/Exceptions.h"
++#include "openvdb/util/logging.h"
++
+ #include <tbb/concurrent_hash_map.h>
+-#include <tbb/task.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
+-#include <tbb/tick_count.h>
++#include <tbb/task_arena.h>
++
++#include <thread>
+ #include <algorithm> // for std::max()
+ #include <atomic>
+ #include <iostream>
+ #include <map>
+ #include <mutex>
++#include <chrono>
++
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -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
+ 
+ 
+ // 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
+         : 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
+             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<Queue::Id, Queue::Status>;
+ 
+-
+     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::milliseconds>(
++                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;
+ }
+ 
+diff --git a/openvdb/openvdb/math/Coord.h b/openvdb/openvdb/math/Coord.h
+index 504b5e9a4..2e9cfed5d 100644
+--- a/openvdb/openvdb/math/Coord.h
++++ b/openvdb/openvdb/math/Coord.h
+@@ -13,8 +13,7 @@
+ #include "Math.h"
+ #include "Vec3.h"
+ 
+-namespace tbb { class split; } // forward declaration
+-
++#include <tbb/blocked_range.h> // for tbb::split
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+diff --git a/openvdb/openvdb/points/PointSample.h b/openvdb/openvdb/points/PointSample.h
+index a122cc4fb..27ec3fb29 100644
+--- a/openvdb/openvdb/points/PointSample.h
++++ b/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 <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tools/Interpolation.h>
++#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 <sstream>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -299,7 +299,7 @@ class PointDataSampler
+             using TargetHandleT = AttributeWriteHandle<typename SamplerWrapperT::ValueType>;
+ 
+             if (util::wasInterrupted(interrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return;
+             }
+ 
+diff --git a/openvdb/openvdb/thread/Threading.h b/openvdb/openvdb/thread/Threading.h
+new file mode 100644
+index 000000000..0c3b356e3
+--- /dev/null
++++ b/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 <tbb/blocked_range.h>
++#include <tbb/task.h>
++#include <tbb/task_group.h>
++
++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
+diff --git a/openvdb/openvdb/tools/Composite.h b/openvdb/openvdb/tools/Composite.h
+index 6bc170bf7..88ff86f9f 100644
+--- a/openvdb/openvdb/tools/Composite.h
++++ b/openvdb/openvdb/tools/Composite.h
+@@ -24,7 +24,6 @@
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include <type_traits>
+ #include <functional>
+diff --git a/openvdb/openvdb/tools/Diagnostics.h b/openvdb/openvdb/tools/Diagnostics.h
+index 694d2155f..e5844e448 100644
+--- a/openvdb/openvdb/tools/Diagnostics.h
++++ b/openvdb/openvdb/tools/Diagnostics.h
+@@ -11,14 +11,17 @@
+ #ifndef OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ 
+-#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/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 <tbb/blocked_range.h>
+ #include <tbb/parallel_reduce.h>
++
+ #include <cmath> // for std::isnan(), std::isfinite()
+ #include <set>
+ #include <sstream>
+@@ -26,7 +29,6 @@
+ #include <type_traits>
+ #include <vector>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -1160,13 +1162,13 @@ InactiveVoxelValues<TreeType>::operator()(const tbb::blocked_range<size_t>& rang
+ {
+     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<typename TreeType>
+ inline void
+ InactiveTileValues<TreeType>::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();
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/tools/Filter.h b/openvdb/openvdb/tools/Filter.h
+index 408c75541..b70212520 100644
+--- a/openvdb/openvdb/tools/Filter.h
++++ b/openvdb/openvdb/tools/Filter.h
+@@ -14,21 +14,24 @@
+ #ifndef OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ 
+-#include <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
++#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 <tbb/parallel_for.h>
++#include <tbb/concurrent_vector.h>
++
+ #include <algorithm> // for std::max()
+ #include <functional>
+ #include <type_traits>
+-#include <tbb/concurrent_vector.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -833,7 +836,7 @@ inline bool
+ Filter<GridT, MaskT, InterruptT>::wasInterrupted()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return true;
+     }
+     return false;
+diff --git a/openvdb/openvdb/tools/GridOperators.h b/openvdb/openvdb/tools/GridOperators.h
+index 31305a1ab..78fafead9 100644
+--- a/openvdb/openvdb/tools/GridOperators.h
++++ b/openvdb/openvdb/tools/GridOperators.h
+@@ -9,14 +9,15 @@
+ #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/Grid.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
++#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 <tbb/parallel_for.h>
+ 
++#include <tbb/parallel_for.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -383,7 +384,9 @@ class GridOperator
+     /// 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) {
+diff --git a/openvdb/openvdb/tools/LevelSetMeasure.h b/openvdb/openvdb/tools/LevelSetMeasure.h
+index efe19074d..59969cdcf 100644
+--- a/openvdb/openvdb/tools/LevelSetMeasure.h
++++ b/openvdb/openvdb/tools/LevelSetMeasure.h
+@@ -8,18 +8,21 @@
+ #ifndef OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/math/Math.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/Grid.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/math/FiniteDifference.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/math/Stencils.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
+ #include <tbb/parallel_sort.h>
+ #include <tbb/parallel_invoke.h>
++
+ #include <type_traits>
+ 
+ namespace openvdb {
+@@ -329,7 +332,7 @@ inline bool
+ LevelSetMeasure<GridT, InterruptT>::checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/LevelSetTracker.h b/openvdb/openvdb/tools/LevelSetTracker.h
+index cbdc267e8..bfc8004e7 100644
+--- a/openvdb/openvdb/tools/LevelSetTracker.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/tree/LeafManager.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -383,7 +385,7 @@ LevelSetTracker<GridT, InterruptT>::
+ checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/MeshToVolume.h b/openvdb/openvdb/tools/MeshToVolume.h
+index 6643c8f05..de3406eda 100644
+--- a/openvdb/openvdb/tools/MeshToVolume.h
++++ b/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 <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/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 <tbb/parallel_reduce.h>
+ #include <tbb/partitioner.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm> // for std::sort()
+ #include <cmath> // 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<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+@@ -1989,7 +1990,7 @@ class VoxelizePolygons
+         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
+ 
+         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) {
+diff --git a/openvdb/openvdb/tools/Morphology.h b/openvdb/openvdb/tools/Morphology.h
+index 736982ef5..0a1e71009 100644
+--- a/openvdb/openvdb/tools/Morphology.h
++++ b/openvdb/openvdb/tools/Morphology.h
+@@ -24,7 +24,7 @@
+ #include "openvdb/tree/ValueAccessor.h"
+ #include "openvdb/tree/LeafManager.h"
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ 
+@@ -726,7 +726,7 @@ void Morphology<TreeType>::dilateVoxels(const size_t iter,
+         }
+ 
+         // @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
+diff --git a/openvdb/openvdb/tools/ParticlesToLevelSet.h b/openvdb/openvdb/tools/ParticlesToLevelSet.h
+index 739af2b69..f9c19911c 100644
+--- a/openvdb/openvdb/tools/ParticlesToLevelSet.h
++++ b/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 <tbb/parallel_reduce.h>
+-#include <tbb/blocked_range.h>
+-#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/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 <tbb/parallel_reduce.h>
++#include <tbb/blocked_range.h>
++
+ #include <functional>
+ #include <iostream>
+ #include <type_traits>
+@@ -738,7 +742,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         for (Coord c = lo; c.x() <= hi.x(); ++c.x()) {
+             //only check interrupter every 32'th scan in x
+             if (!(count++ & ((1<<5)-1)) && util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Real x2 = math::Pow2(c.x() - P[0]);
+@@ -804,7 +808,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         // Densely fill the remaining regions.
+         for (const auto& bbox: padding) {
+             if (util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Coord &bmin = bbox.min(), &bmax = bbox.max();
+diff --git a/openvdb/openvdb/tools/PointAdvect.h b/openvdb/openvdb/tools/PointAdvect.h
+index 12b1177ad..e487bfb3e 100644
+--- a/openvdb/openvdb/tools/PointAdvect.h
++++ b/openvdb/openvdb/tools/PointAdvect.h
+@@ -10,16 +10,19 @@
+ #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/openvdb.h>
+-#include <openvdb/math/Math.h>             // min
+-#include <openvdb/Types.h>                 // Vec3 types and version number
+-#include <openvdb/Grid.h>                  // grid
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/blocked_range.h>             // threading
+ #include <tbb/parallel_for.h>              // threading
+ #include <tbb/task.h>                      // for cancel
++
+ #include <vector>
+ 
+ 
+@@ -167,7 +170,7 @@ class PointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityFieldIntegrator  velField(*mVelGrid);
+@@ -307,7 +310,7 @@ class ConstrainedPointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityIntegratorType velField(*mVelGrid);
+diff --git a/openvdb/openvdb/tools/PointIndexGrid.h b/openvdb/openvdb/tools/PointIndexGrid.h
+index e9ebf96f7..b2e378a79 100644
+--- a/openvdb/openvdb/tools/PointIndexGrid.h
++++ b/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 <openvdb/version.h>
+@@ -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;
+         }
+ 
+diff --git a/openvdb/openvdb/tools/PointPartitioner.h b/openvdb/openvdb/tools/PointPartitioner.h
+index ccf50ab05..f7f6fc13d 100644
+--- a/openvdb/openvdb/tools/PointPartitioner.h
++++ b/openvdb/openvdb/tools/PointPartitioner.h
+@@ -23,7 +23,7 @@
+ 
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm>
+ #include <cmath> // for std::isfinite()
+@@ -764,7 +764,7 @@ inline void binAndSegment(
+     using IndexPairListMap = std::map<Coord, IndexPairListPtr>;
+     using IndexPairListMapPtr = std::shared_ptr<IndexPairListMap>;
+ 
+-    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;
+ 
+diff --git a/openvdb/openvdb/tools/PointsToMask.h b/openvdb/openvdb/tools/PointsToMask.h
+index 592ab7a15..8a276fb04 100644
+--- a/openvdb/openvdb/tools/PointsToMask.h
++++ b/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 <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/blocked_range.h>
+-#include <openvdb/openvdb.h> // for MaskGrid
+-#include <openvdb/Grid.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/util/NullInterrupter.h>
++
+ #include <vector>
+ 
+ 
+@@ -150,7 +154,7 @@ class PointsToMask
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeAdvect.h b/openvdb/openvdb/tools/VolumeAdvect.h
+index e7eec740e..f38eaa9c2 100644
+--- a/openvdb/openvdb/tools/VolumeAdvect.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/math/Math.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ 
+ 
+@@ -294,7 +297,7 @@ class VolumeAdvection
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeToMesh.h b/openvdb/openvdb/tools/VolumeToMesh.h
+index a834dd3b3..a446f806a 100644
+--- a/openvdb/openvdb/tools/VolumeToMesh.h
++++ b/openvdb/openvdb/tools/VolumeToMesh.h
+@@ -18,7 +18,7 @@
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <cmath> // for std::isfinite()
+ #include <map>
+@@ -388,7 +388,7 @@ inline void
+ fillArray(ValueType* array, const ValueType& val, const size_t length)
+ {
+     const auto grainSize = std::max<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+diff --git a/openvdb/openvdb/unittest/TestCoord.cc b/openvdb/openvdb/unittest/TestCoord.cc
+index be1c24ced..148690041 100644
+--- a/openvdb/openvdb/unittest/TestCoord.cc
++++ b/openvdb/openvdb/unittest/TestCoord.cc
+@@ -2,9 +2,9 @@
+ // SPDX-License-Identifier: MPL-2.0
+ 
+ #include <openvdb/Types.h>
++#include <openvdb/math/Coord.h>
+ 
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_stddef.h> // for tbb::split
+ 
+ #include <unordered_map>
+ #include <sstream>
+diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc
+index 8074166d2..053448f30 100644
+--- a/openvdb/openvdb/unittest/TestFile.cc
++++ b/openvdb/openvdb/unittest/TestFile.cc
+@@ -13,8 +13,11 @@
+ #include <openvdb/version.h>
+ #include <openvdb/openvdb.h>
+ #include "util.h" // for unittest_util::makeSphere()
++
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
++
++#include <thread>
++#include <chrono>
+ #include <algorithm> // for std::sort()
+ #include <cstdio> // for remove() and rename()
+ #include <fstream>
+@@ -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::seconds>(
++                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<io::Queue::Id> 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));
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc
+index 70e7df5f7..6b2204771 100644
+--- a/openvdb/openvdb/unittest/TestUtil.cc
++++ b/openvdb/openvdb/unittest/TestUtil.cc
+@@ -8,7 +8,6 @@
+ 
+ #include <gtest/gtest.h>
+ 
+-#include <tbb/task_scheduler_init.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/blocked_range.h>
+diff --git a/openvdb/openvdb/unittest/TestValueAccessor.cc b/openvdb/openvdb/unittest/TestValueAccessor.cc
+index fd2dd5d81..5c1cbb18b 100644
+--- a/openvdb/openvdb/unittest/TestValueAccessor.cc
++++ b/openvdb/openvdb/unittest/TestValueAccessor.cc
+@@ -6,6 +6,7 @@
+ 
+ #include <gtest/gtest.h>
+ #include <tbb/task.h>
++#include <tbb/task_group.h>
+ 
+ #include <type_traits>
+ 
+@@ -378,22 +379,21 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
+     //using AccessorT = openvdb::tree::ValueAccessor<Tree4Type>;
+ 
+     // 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
+ }
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+index 0e1b4d855..6d9bb528b 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+@@ -20,6 +20,7 @@
+ #include <openvdb/tools/GridTransformer.h>
+ #include <openvdb/tools/PointIndexGrid.h>
+ #include <openvdb/tools/Prune.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <CH/CH_Manager.h>
+ #include <CVEX/CVEX_Context.h>
+@@ -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;
+             }
+ 
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+index 757fdc8c6..dbee74b32 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+@@ -16,13 +16,11 @@
+ #include <openvdb_houdini/SOP_NodeVDB.h>
+ 
+ #include <openvdb/tools/Interpolation.h>  // for box sampler
++#include <openvdb/thread/Threading.h>
+ #include <openvdb/points/PointCount.h>
+ #include <openvdb/points/PointSample.h>
+ #include <openvdb/points/IndexFilter.h>   // for MultiGroupFilter
+ 
+-#include <tbb/tick_count.h>                 // for timing
+-#include <tbb/task.h>                       // for cancel
+-
+ #include <UT/UT_Interrupt.h>
+ #include <GA/GA_PageHandle.h>
+ #include <GA/GA_PageIterator.h>
+@@ -38,6 +36,7 @@
+ #include <stdexcept>
+ #include <string>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ 
+@@ -327,7 +326,7 @@ class PointSampler
+     {
+ 
+         if (mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            openvdb::thread::cancelGroupExecution();
+         }
+         const GridType& grid = UTvdbGridCast<GridType>(mGrid);
+         // task local grid accessor
+@@ -481,7 +480,7 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Context& context)
+         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_Context& context)
+             }
+         }
+ 
+-        // 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::milliseconds>(
++                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;
+         }
+ 
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+index 3d559f8cc..d63ed1591 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
++++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+@@ -47,11 +47,8 @@ struct NodeInfo {
+ 
+ typedef std::vector<NodeInfo> 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, const MTypeId& typeId,
+     node.type               = type;
+     node.classification     = classification;
+ 
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (!gNodes) {
+         OPENVDB_START_THREADSAFE_STATIC_WRITE
+@@ -85,7 +82,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, const MTypeId& typeId,
+ void
+ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+@@ -109,7 +106,7 @@ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ void
+ NodeRegistry::deregisterNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.h b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+index b58bd6f2c..6a04b1eaf 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBUtil.h
++++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+@@ -14,8 +14,7 @@
+ #include <openvdb/tree/LeafManager.h>
+ #include <openvdb/tools/VolumeToMesh.h>
+ #include <openvdb/util/Formats.h> // printBytes
+-
+-#include <tbb/tick_count.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <maya/M3dView.h>
+ #include <maya/MString.h>
+@@ -40,6 +39,7 @@
+ #include <string>
+ #include <type_traits>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ ////////////////////////////////////////
+@@ -116,11 +116,15 @@ insertFrameNumber(std::string& str, const MTime& time, int numberingScheme = 0);
+ 
+ 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::milliseconds>(
++            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<std::chrono::steady_clock> mStamp;
+ };
+ 
+ 
+diff --git a/pendingchanges/tbb2021.txt b/pendingchanges/tbb2021.txt
+new file mode 100644
+index 000000000..8109c2552
+--- /dev/null
++++ b/pendingchanges/tbb2021.txt
+@@ -0,0 +1,6 @@
++Improvements:
++  - Moved from the deprecated TBB task scheduler to TBB arenas. Various methods now respect the TBB arena state they were invoked from.
++  - Introduced a new thread/Threading.h header to consolidate calls to third-party threading methods.
++
++Build:
++  - Added support for TBB 2021.
diff --git a/srcpkgs/openvdb/template b/srcpkgs/openvdb/template
index 72fde5bc6375..d420a3ee5f5d 100644
--- a/srcpkgs/openvdb/template
+++ b/srcpkgs/openvdb/template
@@ -1,26 +1,18 @@
 # Template file for 'openvdb'
 pkgname=openvdb
-version=7.0.0
+version=8.1.0
 revision=1
 build_style=cmake
 configure_args="-DOPENVDB_BUILD_VDB_VIEW=1"
 hostmakedepends="pkg-config"
-makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel glfw-devel"
+makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel
+ glfw-devel jemalloc-devel"
 short_desc="Sparse volume data structure and tools"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MPL-2.0"
 homepage="https://openvdb.org"
 distfiles="https://github.com/AcademySoftwareFoundation/openvdb/archive/v${version}.tar.gz"
-checksum=97bc8ae35ef7ccbf49a4e25cb73e8c2eccae6b235bac86f2150707efcd1e910d
-
-if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
-	makedepends+=" libatomic-devel"
-fi
-
-post_patch() {
-	[ "$XBPS_TARGET_NO_ATOMIC8" ] || return 0
-	vsed -i 's,ZLIB::ZLIB,ZLIB::ZLIB atomic,' openvdb/CMakeLists.txt
-}
+checksum=3e09d47331429be7409a3a3c27fdd3c297f96d31d2153febe194e664a99d6183
 
 post_install() {
 	vlicense LICENSE

From 24c2c3a3d2b7783583a965c020e1dfdbe5f32d67 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 10/11] paraview: update to 5.9.1.

---
 srcpkgs/paraview/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/paraview/template b/srcpkgs/paraview/template
index 20a7f5589677..e6c3941ce90a 100644
--- a/srcpkgs/paraview/template
+++ b/srcpkgs/paraview/template
@@ -1,7 +1,7 @@
 # Template file for 'paraview'
 pkgname=paraview
-version=5.8.1
-revision=3
+version=5.9.1
+revision=1
 wrksrc=ParaView-v${version}
 build_style=cmake
 configure_args="-DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr

From a68da290575ea85cc7a7c68f4e664677eb94dbd7 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 11/11] occt: revbump due to tbb update

---
 srcpkgs/occt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/occt/template b/srcpkgs/occt/template
index 9298edc76e08..006f89ebb8ce 100644
--- a/srcpkgs/occt/template
+++ b/srcpkgs/occt/template
@@ -2,7 +2,7 @@
 pkgname=occt
 reverts=7.5.0_1
 version=7.4.0p1
-revision=3
+revision=4
 _gittag="V${version//./_}"
 wrksrc=occt-${_gittag}
 build_style=cmake

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PR PATCH] [Updated] tbb: update to 2021.3.0
  2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
  2021-07-24 10:20 ` [PR PATCH] [Updated] " Logarithmus
@ 2021-07-24 11:13 ` Logarithmus
  2021-07-24 11:36 ` Logarithmus
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Logarithmus @ 2021-07-24 11:13 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

There is an updated pull request by Logarithmus against master on the void-packages repository

https://github.com/Logarithmus/void-packages tbb-2021
https://github.com/void-linux/void-packages/pull/32166

tbb: update to 2021.3.0
Follow-up of https://github.com/void-linux/void-packages/pull/27746, @thypon & @olafmersmann might be interested.
**TODO** fix reverse dependencies:
- [ ] OpenSubdiv: update to 3.4.4.
- [ ] PrusaSlicer: update to 2.3.3.
- [ ] lender: update to 2.93.1.
- [ ] embree: update to 3.13.0.
- [ ] openimageio: update to 2.2.16.0.
- [ ] openimagedenoise: update to 1.4.1.
- [ ] openvdb: update to 8.1.0.
- [ ] paraview: update to 5.9.1.
- [ ] occt: revbump due to tbb update

#### Have the results of the proposed changes been tested?
- [x] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me


A patch file from https://github.com/void-linux/void-packages/pull/32166.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-tbb-2021-32166.patch --]
[-- Type: text/x-diff, Size: 87281 bytes --]

From 5388466ffc39337af66ad8dbb63891fbd3a57c2e Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 17 Jul 2021 23:57:52 +0300
Subject: [PATCH 01/11] hwloc: add libpciaccess-devel make dependency

---
 srcpkgs/hwloc/template | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/hwloc/template b/srcpkgs/hwloc/template
index 818db269cebb..6eec662d0d6e 100644
--- a/srcpkgs/hwloc/template
+++ b/srcpkgs/hwloc/template
@@ -1,10 +1,12 @@
 # Template file for 'hwloc'
 pkgname=hwloc
 version=2.5.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="cairo-devel ncurses-devel libxml2-devel eudev-libudev-devel"
+makedepends="cairo-devel ncurses-devel libxml2-devel libpciaccess-devel eudev-libudev-devel"
+checkdepends="tar"
+make_check_args="VERBOSE=1"
 short_desc="Portable abstraction of hierarchical hardware architectures"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
 license="BSD-3-Clause"
@@ -31,7 +33,7 @@ libhwloc_package() {
 
 libhwloc-devel_package() {
 	short_desc+=" - development files"
-	depends="libhwloc>=${version}_${revision}"
+	depends="${makedepends} libhwloc>=${version}_${revision}"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/share/man/man3

From f7b70dbeff31e391694f273d63581d646cf10858 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 02:50:26 +0300
Subject: [PATCH 02/11] tbb: update to 2021.3.0.

---
 common/shlibs                                |   6 +-
 srcpkgs/tbb/patches/00-hwloc-2.5.patch       | 367 +++++++++++++++++++
 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch |  52 +++
 srcpkgs/tbb/patches/hostname-usage.patch     |  11 -
 srcpkgs/tbb/patches/musl.patch               |   4 +-
 srcpkgs/tbb/template                         |  63 +---
 6 files changed, 433 insertions(+), 70 deletions(-)
 create mode 100644 srcpkgs/tbb/patches/00-hwloc-2.5.patch
 create mode 100644 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
 delete mode 100644 srcpkgs/tbb/patches/hostname-usage.patch

diff --git a/common/shlibs b/common/shlibs
index a7afbf2a56f7..6b7ca5fbc249 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2376,12 +2376,10 @@ libanthy-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthydic-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthyinput-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthygobject-1.0.so.5 ibus-anthy-1.5.6_1
-libtbbmalloc_proxy_debug.so.2 tbb-4.3_1
 libtbbmalloc_proxy.so.2 tbb-4.3_1
 libtbbmalloc.so.2 tbb-4.3_1
-libtbb_debug.so.2 tbb-4.3_1
-libtbb.so.2 tbb-4.3_1
-libtbbmalloc_debug.so.2 tbb-4.3_1
+libtbb.so.12 tbb-2021.3.0_1
+libtbbbind_2_5.so.3 tbb-2021.3.0_1
 libembree.so.2 embree-2.5.1_1
 libgtkimageview.so.0 gtkimageview-1.6.4_1
 libgoocanvas-2.0.so.9 goocanvas-2.0.4_1
diff --git a/srcpkgs/tbb/patches/00-hwloc-2.5.patch b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
new file mode 100644
index 000000000000..9c4c9285c71d
--- /dev/null
+++ b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
@@ -0,0 +1,367 @@
+Adjusted by Artur Sinila <freesoftware@logarithmus.dev>
+
+From e96dbf4b48e689ab810b0428d0858a6abc2c83bd Mon Sep 17 00:00:00 2001
+From: Ivan Kochin <iv.kochin@gmail.com>
+Date: Thu, 1 Jul 2021 15:07:39 +0300
+Subject: [PATCH] Upgrade from HWLOC 2.4 to HWLOC 2.5 (#448)
+
+* Upgrade from HWLOC 2.4 to HWLOC 2.5
+* Introduce tbbbind_2_5 library
+* Remove tbbbind_2_4 library
+* Use the HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING topology flag (introduces as a part of HWLOC 2.5) to restrict topology discovering to process binding
+* Fix testing on Linux
+* Apply review comments
+* Improve wording: variable -> substring
+* Use right tbbbind version for incompatible hwlocs test
+* Rework option semantic
+* Update README.md for CMake
+* Rework readme
+* Update cmake/README.md
+
+Signed-off-by: Kochin, Ivan <kochin.ivan@intel.com>
+
+Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
+---
+ CMakeLists.txt                         |  3 ++-
+ cmake/README.md                        | 11 +++++---
+ cmake/hwloc_detection.cmake            |  9 ++++---
+ src/tbb/governor.cpp                   |  4 +--
+ src/tbbbind/CMakeLists.txt             |  2 +-
+ src/tbbbind/tbb_bind.cpp               | 23 +++++++++++-----
+ test/CMakeLists.txt                    | 30 ++++++++++-----------
+ test/common/common_arena_constraints.h | 37 ++++++++++++++++++++++----
+ 8 files changed, 82 insertions(+), 37 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 34a23d400..301899aca 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -100,6 +100,7 @@ option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Win
+ option(TBB4PY_BUILD "Enable tbb4py build" OFF)
+ option(TBB_CPF "Enable preview features of the library" OFF)
+ option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
++option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
+ 
+ if (NOT DEFINED BUILD_SHARED_LIBS)
+     set(BUILD_SHARED_LIBS ON)
+@@ -195,7 +196,7 @@ else()
+         add_subdirectory(src/tbbmalloc)
+         add_subdirectory(src/tbbmalloc_proxy)
+         if (APPLE)
+-            message(STATUS "TBBBind build target is disabled due to unsupported environment")
++            message(STATUS "TBBBind build targets are disabled due to unsupported environment")
+         else()
+             add_subdirectory(src/tbbbind)
+         endif()
+diff --git a/cmake/README.md b/cmake/README.md
+index 36fc303f9..b58c2ff6a 100644
+--- a/cmake/README.md
++++ b/cmake/README.md
+@@ -13,6 +13,7 @@ TBB4PY_BUILD:BOOL - Enable  Intel(R) oneAPI Threading Building Blocks (oneTBB) P
+ TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
+ TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
+ TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
++TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)
+ ```
+ 
+ ## Configure, build and test
+@@ -42,9 +43,9 @@ Some useful options:
+ 
+ #### TBBBind library configuration
+ 
+-The TBBbind library has two versions: `tbbbind` and `tbbbind_2_0`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.x.
++The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0` and `tbbbind_2_5`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.1-2.4, `tbbbind_2_5` links with HWLOC 2.5 and later.
+ 
+-To enable the TBBBind library build or special tests that performed inside the HWLOC environment, please specify the following CMake variables:
++The search for a suitable version of the HWLOC library is enabled by default, but if you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
+ 
+  - `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux or path to `.lib` file on Windows.
+  - `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version includes directory.
+@@ -52,7 +53,11 @@ To enable the TBBBind library build or special tests that performed inside the H
+ Windows requires one additional variable for correct TBBBind library building:
+  - `CMAKE_HWLOC_<HWLOC_VER>_DLL_PATH` - path to the corresponding HWLOC version `.dll` file.
+ 
+-`HWLOC_VER` variable used above can be replaced with one of the two values: `1_11` for the `tbbbind` library configuration and `2` for the `tbbbind_2_0` library configuration.
++`HWLOC_VER` substring used above can be replaced with one of the three values: `1_11` for the `tbbbind` library configuration, `2` for the `tbbbind_2_0`, and `2_5` for the `tbbbind_2_5` library configuration.
++
++If you specify variables for several TBBBind versions, then building process for all of these versions will be performed during single build session.
++
++Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
+ 
+ ### Build
+ 
+diff --git a/cmake/hwloc_detection.cmake b/cmake/hwloc_detection.cmake
+index e1eeca5fa..de7f3c047 100644
+--- a/cmake/hwloc_detection.cmake
++++ b/cmake/hwloc_detection.cmake
+@@ -12,7 +12,7 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
+-list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_4)
++list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_5)
+ 
+ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
+     if (NOT WIN32)
+@@ -55,10 +56,10 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
+         if (HWLOC_FOUND)
+             if (HWLOC_VERSION VERSION_LESS 2)
+                 set(TBBBIND_LIBRARY_NAME tbbbind)
+-            elseif(HWLOC_VERSION VERSION_LESS 2.4)
++            elseif(HWLOC_VERSION VERSION_LESS 2.5)
+                 set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
+             else()
+-                set(TBBBIND_LIBRARY_NAME tbbbind_2_4)
++                set(TBBBIND_LIBRARY_NAME tbbbind_2_5)
+             endif()
+         endif()
+     endif()
+diff --git a/src/tbb/governor.cpp b/src/tbb/governor.cpp
+index bf4e402d1..b842e075f 100644
+--- a/src/tbb/governor.cpp
++++ b/src/tbb/governor.cpp
+@@ -362,7 +362,7 @@ static const unsigned LinkTableSize = sizeof(TbbBindLinkTable) / sizeof(dynamic_
+ 
+ #define TBBBIND_NAME LIBRARY_PREFIX "tbbbind" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #define TBBBIND_2_0_NAME LIBRARY_PREFIX "tbbbind_2_0" DEBUG_SUFFIX LIBRARY_EXTENSION
+-#define TBBBIND_2_4_NAME LIBRARY_PREFIX "tbbbind_2_4" DEBUG_SUFFIX LIBRARY_EXTENSION
++#define TBBBIND_2_5_NAME LIBRARY_PREFIX "tbbbind_2_5" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #endif /* _WIN32 || _WIN64 || __linux__ */
+ 
+ // Representation of system hardware topology information on the TBB side.
+@@ -389,7 +389,7 @@ const char* load_tbbbind_shared_object() {
+     GetNativeSystemInfo(&si);
+     if (si.dwNumberOfProcessors > 32) return nullptr;
+ #endif /* _WIN32 && !_WIN64 */
+-    for (const auto& tbbbind_version : {TBBBIND_2_4_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
++    for (const auto& tbbbind_version : {TBBBIND_2_5_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
+         if (dynamic_link(tbbbind_version, TbbBindLinkTable, LinkTableSize)) {
+             return tbbbind_version;
+         }
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index 029893751..e5cdbf8bb 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -99,7 +99,7 @@ if (NOT DEFINED HWLOC_TARGET_EXPLICITLY_DEFINED AND DEFINED HWLOC_LIBRARIES)
+ else()
+     tbbbind_build(tbbbind     HWLOC::hwloc_1_11)
+     tbbbind_build(tbbbind_2_0 HWLOC::hwloc_2   )
+-    tbbbind_build(tbbbind_2_4 HWLOC::hwloc_2_4 )
++    tbbbind_build(tbbbind_2_5 HWLOC::hwloc_2_5 )
+ endif()
+ 
+ 
+diff --git a/src/tbbbind/tbb_bind.cpp b/src/tbbbind/tbb_bind.cpp
+index 97be308c7..88c956acb 100644
+--- a/src/tbbbind/tbb_bind.cpp
++++ b/src/tbbbind/tbb_bind.cpp
+@@ -34,7 +34,8 @@
+ #pragma GCC diagnostic pop
+ #endif
+ 
+-#define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ 
+ // Most of hwloc calls returns negative exit code on error.
+ // This macro tracks error codes that are returned from the hwloc interfaces.
+@@ -85,6 +86,16 @@ class platform_topology {
+         // Parse topology
+         if ( hwloc_topology_init( &topology ) == 0 ) {
+             initialization_state = topology_allocated;
++#if __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++            if ( groups_num == 1 &&
++                 hwloc_topology_set_flags(topology,
++                     HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                     HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
++                 ) != 0
++            ) {
++                return;
++            }
++#endif
+             if ( hwloc_topology_load( topology ) == 0 ) {
+                 initialization_state = topology_loaded;
+             }
+@@ -135,7 +146,7 @@ class platform_topology {
+             numa_indexes_list.resize(numa_nodes_count);
+             hwloc_obj_t node_buffer;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 numa_indexes_list[counter] = static_cast<int>(node_buffer->logical_index);
+ 
+                 if ( numa_indexes_list[counter] > max_numa_index ) {
+@@ -150,7 +161,7 @@ class platform_topology {
+             numa_affinity_masks_list.resize(max_numa_index + 1);
+             int index = 0;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 index = static_cast<int>(node_buffer->logical_index);
+ 
+                 hwloc_cpuset_t& current_mask = numa_affinity_masks_list[index];
+@@ -168,7 +179,7 @@ class platform_topology {
+             core_types_indexes_list.push_back(-1);
+             return;
+         }
+-#if __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
++#if __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
+         __TBB_ASSERT(hwloc_get_api_version() >= 0x20400, "Hybrid CPUs support interfaces required HWLOC >= 2.4");
+         // Parsing the hybrid CPU topology
+         int core_types_number = hwloc_cpukinds_get_nr(topology, 0);
+@@ -196,9 +207,9 @@ class platform_topology {
+                 }
+             }
+         }
+-#else /*!__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#else /*!__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+         bool core_types_parsing_broken{true};
+-#endif /*__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#endif /*__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+ 
+         if (core_types_parsing_broken) {
+             for (auto& core_type_mask : core_types_affinity_masks_list) {
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index bdae9e2b1..c2b9d6dba 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -275,9 +275,9 @@ function(tbb_add_tbbbind_test)
+         FAIL_REGULAR_EXPRESSION "Status:.*FAILURE"
+     )
+ 
+-    if (TARGET HWLOC::hwloc_2_4 AND NOT HWLOC_2_4_TESTS_STATUS_SHOWN)
+-        message(STATUS "HWLOC 2.4 dependent tests were enabled.")
+-        set(HWLOC_2_4_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
++    if (TARGET HWLOC::hwloc_2_5 AND NOT HWLOC_2_5_TESTS_STATUS_SHOWN)
++        message(STATUS "HWLOC 2.5 dependent tests were enabled.")
++        set(HWLOC_2_5_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
+     endif()
+ 
+     if (TARGET HWLOC::hwloc_2 AND NOT HWLOC_2_TESTS_STATUS_SHOWN)
+@@ -291,22 +291,22 @@ function(tbb_add_tbbbind_test)
+     endif()
+ 
+     list(APPEND HWLOC_TEST_CASES
+-        hwloc_2_4
++        hwloc_2_5
+         hwloc_2
+         hwloc_1_11
+-        hwloc_2_4_hwloc_2
+-        hwloc_2_4_hwloc_1_11
++        hwloc_2_5_hwloc_2
++        hwloc_2_5_hwloc_1_11
+         hwloc_2_hwloc_1_11
+-        hwloc_2_4_hwloc_2_hwloc_1_11
++        hwloc_2_5_hwloc_2_hwloc_1_11
+     )
+ 
+-    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_4 "hwloc_2_4")
++    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_5 "hwloc_2_5")
+     list(APPEND HWLOC_TEST_CASE_1_VARS tbbbind_2   "hwloc_2")
+     list(APPEND HWLOC_TEST_CASE_2_VARS tbbbind     "hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2")
+-    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_4 "hwloc_2_4,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2")
++    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_5 "hwloc_2_5,hwloc_1_11")
+     list(APPEND HWLOC_TEST_CASE_5_VARS tbbbind_2   "hwloc_2,hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2,hwloc_1_11")
+ 
+     foreach(TEST_CASE ${HWLOC_TEST_CASES})
+         list(FIND HWLOC_TEST_CASES ${TEST_CASE} TEST_CASE_INDEX)
+@@ -331,7 +331,7 @@ endfunction()
+ # Copy libraries to test folder to make it visible during tests execution if external TBB is tested.
+ # TODO: check and update for multi-config generators.
+ if (TBB_FOUND)
+-    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_4)
++    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_5)
+     foreach(_component ${_tbb_test_components})
+         if (TARGET TBB::${_component})
+             get_property(${_component}_lib_file_location TARGET TBB::${_component} PROPERTY LOCATION)
+@@ -593,6 +593,6 @@ if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
+     tbb_add_test(SUBDIR tbbmalloc NAME test_malloc_new_handler DEPENDENCIES TBB::tbbmalloc_proxy)
+ endif()
+ 
+-unset(HWLOC_2_4_TESTS_STATUS_SHOWN)
++unset(HWLOC_2_5_TESTS_STATUS_SHOWN)
+ unset(HWLOC_2_TESTS_STATUS_SHOWN)
+ unset(HWLOC_1_11_TESTS_STATUS_SHOWN)
+diff --git a/test/common/common_arena_constraints.h b/test/common/common_arena_constraints.h
+index 2a0b1ea97..5efc71082 100644
+--- a/test/common/common_arena_constraints.h
++++ b/test/common/common_arena_constraints.h
+@@ -38,9 +38,26 @@
+ 
+ #if (_WIN32 || _WIN64) && __TBB_HWLOC_VALID_ENVIRONMENT
+ #include <windows.h>
+-int get_processors_groups_count() { return GetActiveProcessorGroupCount(); }
++int get_processors_group_count() {
++    SYSTEM_INFO si;
++    GetNativeSystemInfo(&si);
++    DWORD_PTR pam, sam, m = 1;
++    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
++    int nproc = 0;
++    for ( std::size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
++        if ( pam & m )
++            ++nproc;
++    }
++    // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present
++    if ( nproc == (int)si.dwNumberOfProcessors  ) {
++        // The process does not have restricting affinity mask and multiple processor groups are possible
++        return (int)GetActiveProcessorGroupCount();
++    } else {
++        return 1;
++    }
++}
+ #else
+-int get_processors_groups_count() { return 1; }
++int get_processors_group_count() { return 1; }
+ #endif
+ 
+ //TODO: Write a test that checks for memory leaks during dynamic link/unlink of TBBbind.
+@@ -69,6 +86,7 @@ int get_processors_groups_count() { return 1; }
+ #endif
+ 
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ // At this moment the hybrid CPUs HWLOC interfaces returns unexpected results on some Windows machines
+ // in the 32-bit arch mode.
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_VALID (!_WIN32 || _WIN64)
+@@ -153,9 +171,18 @@ class system_info {
+ 
+     system_info() {
+         hwloc_require_ex(hwloc_topology_init, &topology);
++#if __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++        if ( get_processors_group_count() == 1 ) {
++            REQUIRE(
++                hwloc_topology_set_flags(topology,
++                    HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                    HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING) == 0
++            );
++        }
++#endif
+         hwloc_require_ex(hwloc_topology_load, topology);
+ 
+-        if ( get_processors_groups_count() > 1 ) {
++        if ( get_processors_group_count() > 1 ) {
+             process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
+         } else {
+             process_cpuset = hwloc_bitmap_alloc();
+@@ -434,7 +461,7 @@ system_info::affinity_mask get_arena_affinity(tbb::task_arena& ta) {
+                 barrier.wait();
+                 tbb::spin_mutex::scoped_lock lock(affinity_mutex);
+                 system_info::affinity_mask thread_affinity = system_info::allocate_current_affinity_mask();
+-                if (get_processors_groups_count() == 1) {
++                if (get_processors_group_count() == 1) {
+                     REQUIRE_MESSAGE(hwloc_bitmap_isequal(thread_affinity, arena_affinity),
+                         "Threads have different masks on machine without several processors groups.");
+                 }
+@@ -532,7 +559,7 @@ constraints_container generate_constraints_variety() {
+         }
+ 
+         // Some constraints may cause unexpected behavior, which would be fixed later.
+-        if (get_processors_groups_count() > 1) {
++        if (get_processors_group_count() > 1) {
+             for(auto it = results.begin(); it != results.end(); ++it) {
+                 if (it->max_threads_per_core != tbb::task_arena::automatic
+                    && (it->numa_id == tbb::task_arena::automatic || tbb::info::numa_nodes().size() == 1)
diff --git a/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
new file mode 100644
index 000000000000..279ebc4397cd
--- /dev/null
+++ b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
@@ -0,0 +1,52 @@
+Based on https://github.com/oneapi-src/oneTBB/pull/498
+Tweaked a bit to work on `v2021.3.0`
+
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index e5cdbf8bb..a4033210a 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -37,6 +37,10 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+         ${HWLOC_INCLUDE_DIRS} # pkg-config defined
+     )
++	target_link_directories(${TBBBIND_NAME}
++		PRIVATE
++		${HWLOC_LIBRARY_DIRS} # pkg-config defined
++	)
+ 
+     target_compile_options(${TBBBIND_NAME}
+         PRIVATE
+@@ -69,7 +69,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     else()
+         target_link_libraries(${TBBBIND_NAME}
+@@ -76,7 +76,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     endif()
+ 
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index b768759d5..3eb8357e6 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -258,7 +258,12 @@ function(tbb_add_tbbbind_test)
+         )
+         set_property(
+             TARGET ${_tbbbind_test_NAME}
+-            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARY_DIRS} ${HWLOC_LIBRARIES}
++            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARIES}
++            APPEND
++        )
++        set_property(
++            TARGET ${_tbbbind_test_NAME}
++			PROPERTY LINK_DIRECTORIES ${HWLOC_LIBRARY_DIRS}
+             APPEND
+         )
+         set_property(
diff --git a/srcpkgs/tbb/patches/hostname-usage.patch b/srcpkgs/tbb/patches/hostname-usage.patch
deleted file mode 100644
index 4aefeff192b5..000000000000
--- a/srcpkgs/tbb/patches/hostname-usage.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/build/version_info_linux.sh
-+++ b/build/version_info_linux.sh
-@@ -20,7 +20,7 @@
- 
- # Script used to generate version info string
- echo "#define __TBB_VERSION_STRINGS(N) \\"
--echo '#N": BUILD_HOST'"\t\t"`hostname -s`" ("`uname -m`")"'" ENDL \'
-+echo '#N": BUILD_HOST'"\t\t"`hostname`" ("`uname -m`")"'" ENDL \'
- # find OS name in *-release and issue* files by filtering blank lines and lsb-release content out
- echo '#N": BUILD_OS'"\t\t"`lsb_release -sd 2>/dev/null | grep -ih '[a-z] ' - /etc/*release /etc/issue 2>/dev/null | head -1 | sed -e 's/["\\\\]//g'`'" ENDL \'
- echo '#N": BUILD_KERNEL'"\t"`uname -srv`'" ENDL \'
diff --git a/srcpkgs/tbb/patches/musl.patch b/srcpkgs/tbb/patches/musl.patch
index a8867eb53793..ec89c6a95fc6 100644
--- a/srcpkgs/tbb/patches/musl.patch
+++ b/srcpkgs/tbb/patches/musl.patch
@@ -1,5 +1,5 @@
---- a/src/tbbmalloc/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
-+++ b/src/tbbmalloc/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
+--- a/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
++++ b/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
 @@ -28,6 +28,7 @@
  // of aligned_alloc as required by new C++ standard, this makes it hard to
  // redefine aligned_alloc here. However, running on systems with new libc
diff --git a/srcpkgs/tbb/template b/srcpkgs/tbb/template
index aeef6ebdd061..47655829f744 100644
--- a/srcpkgs/tbb/template
+++ b/srcpkgs/tbb/template
@@ -1,76 +1,33 @@
 # Template file for 'tbb'
 pkgname=tbb
-version=2020.U3
+version=2021.3.0
 revision=1
-# version rewrite: 2017_U7 (upstream) => 2017.7 (xbps)
-_ver=${version/./_}
-wrksrc="oneTBB-${_ver}"
-build_style=gnu-makefile
-hostmakedepends="cmake"
+wrksrc="oneTBB-${version}"
+build_style=cmake
+makedepends="libhwloc-devel libgomp-devel"
 short_desc="Intel Threading Building Blocks"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
 license="Apache-2.0"
 homepage="https://www.threadingbuildingblocks.org"
-distfiles="https://github.com/oneapi-src/oneTBB/archive/${_ver}.tar.gz"
-checksum=2103cc6238c935664f87680618f6684d57501d4a2fa8ea8f6c97ad6ff7dc722a
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*)
-		make_build_args="arch=intel64"
-		;;
-	i686*)
-		make_build_args="arch=ia32"
-		;;
-	armv7l*)
-		make_build_args="arch=armv7"
-		;;
-	aarch64*)
-		make_build_args="arch=arm64"
-		;;
-	ppc64*)
-		make_build_args="arch=ppc64"
-		;;
-	ppc*)
-		make_build_args="arch=ppc32"
-		;;
-	*)
-		# make sure to fall back instead of letting host uname control it
-		make_build_args="arch=generic"
-		;;
-esac
-
-post_extract() {
-	sed -i 's|CPLUS = g..|CPLUS = $(CXX)|g' build/linux.gcc.inc
-	sed -i 's|CONLY = gcc|CONLY = $(CC)|g' build/linux.gcc.inc
+distfiles="https://github.com/oneapi-src/oneTBB/archive/v${version}.tar.gz"
+checksum=8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e
 
+pre_patch() {
 	# alternative might be:
 	# https://git.alpinelinux.org/cgit/aports/tree/testing/libtbb/glibc-struct-mallinfo.patch
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		vsed -e "s@#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__@@" \
-		  -i src/tbbmalloc/proxy.h
+		  -i src/tbbmalloc_proxy/proxy.h
 	fi
 }
 
-do_install() {
-	vmkdir usr/lib
-	vcopy build/linux_*/*.so* usr/lib
-	vmkdir usr/include/tbb
-	vcopy include/tbb/* usr/include/tbb
-
-	cmake \
-		-DINSTALL_DIR=$DESTDIR/usr/lib/cmake/TBB \
-		-DSYSTEM_NAME=Linux \
-		-DLIB_REL_PATH=../.. \
-		-DINC_REL_PATH=../../../include \
-		-P cmake/tbb_config_installer.cmake
-}
-
 tbb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
-		vmove "usr/lib/*.so"
 		vmove usr/lib/cmake
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.so
 	}
 }

From 9e753ac89a28c638a6fd582d8e27c3ef40e55e90 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 03/11] OpenSubdiv: update to 3.4.4.

---
 srcpkgs/OpenSubdiv/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/OpenSubdiv/template b/srcpkgs/OpenSubdiv/template
index b7a5e16efbcf..dfbf29cc1a52 100644
--- a/srcpkgs/OpenSubdiv/template
+++ b/srcpkgs/OpenSubdiv/template
@@ -1,6 +1,6 @@
 # Template file for 'OpenSubdiv'
 pkgname=OpenSubdiv
-version=3.4.3
+version=3.4.4
 revision=1
 wrksrc="OpenSubdiv-${version//./_}"
 build_style=cmake
@@ -13,7 +13,7 @@ maintainer="John <me@johnnynator.dev>"
 license="Apache-2.0"
 homepage="http://graphics.pixar.com/opensubdiv/docs/intro.html"
 distfiles="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${version//./_}.tar.gz"
-checksum=7b22eb27d636ab0c1e03722c7a5a5bd4f11664ee65c9b48f341a6d0ce7f36745
+checksum=20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" OpenSubdiv"

From 543113463eec94becac4a623889a8a1d23b8d638 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 04/11] PrusaSlicer: update to 2.3.3.

---
 srcpkgs/PrusaSlicer/patches/cross.patch | 11 -----------
 srcpkgs/PrusaSlicer/template            |  4 ++--
 2 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 srcpkgs/PrusaSlicer/patches/cross.patch

diff --git a/srcpkgs/PrusaSlicer/patches/cross.patch b/srcpkgs/PrusaSlicer/patches/cross.patch
deleted file mode 100644
index d64a450d9e9f..000000000000
--- a/srcpkgs/PrusaSlicer/patches/cross.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/avrdude/CMakeLists.txt	2020-06-04 09:19:26.017251215 +0200
-+++ b/src/avrdude/CMakeLists.txt	2020-06-04 09:19:36.468250771 +0200
-@@ -83,7 +83,7 @@ add_executable(avrdude-conf-gen conf-gen
- add_custom_command(
-     DEPENDS avrdude-conf-gen ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf
-     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
--    COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-+    COMMAND avrdude-conf-gen avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- 
diff --git a/srcpkgs/PrusaSlicer/template b/srcpkgs/PrusaSlicer/template
index dd0e76cb8017..a93832ac02e4 100644
--- a/srcpkgs/PrusaSlicer/template
+++ b/srcpkgs/PrusaSlicer/template
@@ -1,6 +1,6 @@
 # Template file for 'PrusaSlicer'
 pkgname=PrusaSlicer
-version=2.3.0
+version=2.3.3
 revision=1
 wrksrc="PrusaSlicer-version_${version}"
 build_style=cmake
@@ -16,7 +16,7 @@ maintainer="Jasper Chan <jasperchan515@gmail.com>"
 license="GPL-3.0-or-later"
 homepage="https://www.prusa3d.com/prusaslicer/"
 distfiles="https://github.com/prusa3d/Prusaslicer/archive/version_${version}.tar.gz"
-checksum=cd3bac5e29b5441fc4690f28cd7b1064e97dc00207bbdc88f7bd7832308d6ca5
+checksum=deda209505f740ac3d6f59cb2a960f4df908269ee09bd30cd4edb9fc472d29ac
 nocross="https://build.voidlinux.org/builders/armv7l_builder/builds/25230/steps/shell_3/logs/stdio"
 
 Slic3rPE_package() {

From e2f38a09f7688fda6c06e8be6d6f2bab37086020 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 05/11] blender: update to 2.93.1.

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index af946c2b7999..8318317c82bf 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,6 +1,6 @@
 # Template file for 'blender'
 pkgname=blender
-version=2.93.0
+version=2.93.1
 revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"

From 65f6f1d1b4009948c05f3bd7b51e7749c049ac59 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 06/11] embree: update to 3.13.0.

---
 srcpkgs/embree/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/embree/template b/srcpkgs/embree/template
index 575b9bcb401c..b6f376d30efa 100644
--- a/srcpkgs/embree/template
+++ b/srcpkgs/embree/template
@@ -1,8 +1,8 @@
 # Template file for 'embree'
 pkgname=embree
-version=2.17.7
-revision=2
-archs="x86_64"
+version=3.13.0
+revision=1
+archs="x86_64*"
 build_style=cmake
 configure_args="-DTBB_ROOT=/usr -DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF"
 hostmakedepends="ispc"

From ec4237d1e5ae4993facd95710b3138d14faaaabc Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 03:34:43 +0300
Subject: [PATCH 07/11] openimageio: update to 2.2.16.0.

---
 srcpkgs/openimageio/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index de8e1cd04409..3bfdd4e0ed1e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,11 +1,11 @@
 # Template file for 'openimageio'
 pkgname=openimageio
-version=2.2.15.1
+version=2.2.16.0
 revision=1
 wrksrc="oiio-Release-${version}"
 build_style=cmake
 configure_args="-DUSE_OPENGL=0 -DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=1
- -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0"
+ -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0 -DCMAKE_CXX_STANDARD=14"
 hostmakedepends="pkg-config git"
 makedepends="boost-devel giflib-devel libraw-devel libopenjpeg-devel libwebp-devel
  libjpeg-turbo-devel tiff-devel libpng-devel libopenexr-devel freetype-devel
@@ -17,7 +17,7 @@ license="BSD-3-Clause"
 homepage="https://sites.google.com/site/openimageio/home"
 changelog="https://raw.githubusercontent.com/OpenImageIO/oiio/release/CHANGES.md"
 distfiles="https://github.com/OpenImageIO/oiio/archive/Release-${version}.tar.gz"
-checksum=f222c6b51a40aabbc80ddf4055535be9af1ffa907452fa6d1ffa7674854aab17
+checksum=d1a59f32dbba3ba71ad2e62e107034d1c5287bca1b0696474e927d504cd05ef4
 # Runs checks even for features we disabled.
 make_check=no
 

From cf26cc84284f03f8521433789a3c5a66a1a8626d Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 08/11] openimagedenoise: update to 1.4.1.

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index c73913b4e9d7..14055aff1c27 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,6 +1,6 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
-version=1.4.0
+version=1.4.1
 revision=1
 archs="x86_64*"
 wrksrc=oidn-${version}

From 19a3ab7b0bd1fbf8dd758d0faa9a506f379d745d Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 09/11] openvdb: update to 8.1.0.

---
 common/shlibs                             |    2 +-
 srcpkgs/openvdb/patches/00-tbb-2021.patch | 1320 +++++++++++++++++++++
 srcpkgs/openvdb/template                  |   16 +-
 3 files changed, 1325 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/openvdb/patches/00-tbb-2021.patch

diff --git a/common/shlibs b/common/shlibs
index 6b7ca5fbc249..2a7acdb253a7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3883,7 +3883,7 @@ libjanet.so.1.16 janet-1.16.0_1
 libOpenImageDenoise.so.1 openimagedenoise-1.3.0_1
 libcbang0.so cbang-1.6.0_3
 libblosc.so.1 c-blosc-1.17.1_1
-libopenvdb.so.7.0 openvdb-7.0.0_1
+libopenvdb.so.8.1 openvdb-8.1.0_1
 libAlembic.so.1.7 alembic-1.7.13_1
 libmodsecurity.so.3 modsecurity-3.0.4_1
 libraven.so.0 budgie-desktop-10.5.1_1
diff --git a/srcpkgs/openvdb/patches/00-tbb-2021.patch b/srcpkgs/openvdb/patches/00-tbb-2021.patch
new file mode 100644
index 000000000000..271104af3df9
--- /dev/null
+++ b/srcpkgs/openvdb/patches/00-tbb-2021.patch
@@ -0,0 +1,1320 @@
+https://github.com/AcademySoftwareFoundation/openvdb/pull/1027
+Should be dropped after 8.1.1 release.
+
+diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake
+index d41436b1c..06de2b3f3 100644
+--- a/cmake/FindTBB.cmake
++++ b/cmake/FindTBB.cmake
+@@ -169,8 +169,22 @@ find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
+   PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
+ )
+ 
+-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" ""
+@@ -178,7 +192,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" ""
+@@ -192,6 +206,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
+ # ------------------------------------------------------------------------
+diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt
+index 88543df3a..929fe94d1 100644
+--- a/openvdb/openvdb/CMakeLists.txt
++++ b/openvdb/openvdb/CMakeLists.txt
+@@ -437,6 +437,10 @@ set(OPENVDB_LIBRARY_UTIL_INCLUDE_FILES
+   util/Util.h
+ )
+ 
++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} DESTINATION ${OPENVDB_INST
+ 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)
+diff --git a/openvdb/openvdb/cmd/openvdb_render.cc b/openvdb/openvdb/cmd/openvdb_render.cc
+index ee5b737c5..2c9831ba3 100644
+--- a/openvdb/openvdb/cmd/openvdb_render.cc
++++ b/openvdb/openvdb/cmd/openvdb_render.cc
+@@ -19,7 +19,14 @@
+ #include <OpenEXR/ImfHeader.h>
+ #include <OpenEXR/ImfOutputFile.h>
+ #include <OpenEXR/ImfPixelType.h>
+-#include <tbb/task_scheduler_init.h>
++
++// 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 <tbb/global_control.h>
+ #include <tbb/tick_count.h>
+ 
+ #include <algorithm>
+@@ -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<tbb::global_control> 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();
+ 
+diff --git a/openvdb/openvdb/io/Queue.cc b/openvdb/openvdb/io/Queue.cc
+index ef5d2961a..20ff1a0c1 100644
+--- a/openvdb/openvdb/io/Queue.cc
++++ b/openvdb/openvdb/io/Queue.cc
+@@ -5,20 +5,22 @@
+ /// @author Peter Cucka
+ 
+ #include "Queue.h"
+-
+ #include "File.h"
+ #include "Stream.h"
+-#include <openvdb/Exceptions.h>
+-#include <openvdb/util/logging.h>
++#include "openvdb/Exceptions.h"
++#include "openvdb/util/logging.h"
++
+ #include <tbb/concurrent_hash_map.h>
+-#include <tbb/task.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
+-#include <tbb/tick_count.h>
++#include <tbb/task_arena.h>
++
++#include <thread>
+ #include <algorithm> // for std::max()
+ #include <atomic>
+ #include <iostream>
+ #include <map>
+ #include <mutex>
++#include <chrono>
++
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -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
+ 
+ 
+ // 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
+         : 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
+             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<Queue::Id, Queue::Status>;
+ 
+-
+     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::milliseconds>(
++                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;
+ }
+ 
+diff --git a/openvdb/openvdb/math/Coord.h b/openvdb/openvdb/math/Coord.h
+index 504b5e9a4..2e9cfed5d 100644
+--- a/openvdb/openvdb/math/Coord.h
++++ b/openvdb/openvdb/math/Coord.h
+@@ -13,8 +13,7 @@
+ #include "Math.h"
+ #include "Vec3.h"
+ 
+-namespace tbb { class split; } // forward declaration
+-
++#include <tbb/blocked_range.h> // for tbb::split
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+diff --git a/openvdb/openvdb/points/PointSample.h b/openvdb/openvdb/points/PointSample.h
+index a122cc4fb..27ec3fb29 100644
+--- a/openvdb/openvdb/points/PointSample.h
++++ b/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 <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tools/Interpolation.h>
++#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 <sstream>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -299,7 +299,7 @@ class PointDataSampler
+             using TargetHandleT = AttributeWriteHandle<typename SamplerWrapperT::ValueType>;
+ 
+             if (util::wasInterrupted(interrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return;
+             }
+ 
+diff --git a/openvdb/openvdb/thread/Threading.h b/openvdb/openvdb/thread/Threading.h
+new file mode 100644
+index 000000000..0c3b356e3
+--- /dev/null
++++ b/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 <tbb/blocked_range.h>
++#include <tbb/task.h>
++#include <tbb/task_group.h>
++
++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
+diff --git a/openvdb/openvdb/tools/Composite.h b/openvdb/openvdb/tools/Composite.h
+index 6bc170bf7..88ff86f9f 100644
+--- a/openvdb/openvdb/tools/Composite.h
++++ b/openvdb/openvdb/tools/Composite.h
+@@ -24,7 +24,6 @@
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include <type_traits>
+ #include <functional>
+diff --git a/openvdb/openvdb/tools/Diagnostics.h b/openvdb/openvdb/tools/Diagnostics.h
+index 694d2155f..e5844e448 100644
+--- a/openvdb/openvdb/tools/Diagnostics.h
++++ b/openvdb/openvdb/tools/Diagnostics.h
+@@ -11,14 +11,17 @@
+ #ifndef OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ 
+-#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/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 <tbb/blocked_range.h>
+ #include <tbb/parallel_reduce.h>
++
+ #include <cmath> // for std::isnan(), std::isfinite()
+ #include <set>
+ #include <sstream>
+@@ -26,7 +29,6 @@
+ #include <type_traits>
+ #include <vector>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -1160,13 +1162,13 @@ InactiveVoxelValues<TreeType>::operator()(const tbb::blocked_range<size_t>& rang
+ {
+     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<typename TreeType>
+ inline void
+ InactiveTileValues<TreeType>::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();
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/tools/Filter.h b/openvdb/openvdb/tools/Filter.h
+index 408c75541..b70212520 100644
+--- a/openvdb/openvdb/tools/Filter.h
++++ b/openvdb/openvdb/tools/Filter.h
+@@ -14,21 +14,24 @@
+ #ifndef OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ 
+-#include <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
++#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 <tbb/parallel_for.h>
++#include <tbb/concurrent_vector.h>
++
+ #include <algorithm> // for std::max()
+ #include <functional>
+ #include <type_traits>
+-#include <tbb/concurrent_vector.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -833,7 +836,7 @@ inline bool
+ Filter<GridT, MaskT, InterruptT>::wasInterrupted()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return true;
+     }
+     return false;
+diff --git a/openvdb/openvdb/tools/GridOperators.h b/openvdb/openvdb/tools/GridOperators.h
+index 31305a1ab..78fafead9 100644
+--- a/openvdb/openvdb/tools/GridOperators.h
++++ b/openvdb/openvdb/tools/GridOperators.h
+@@ -9,14 +9,15 @@
+ #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/Grid.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
++#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 <tbb/parallel_for.h>
+ 
++#include <tbb/parallel_for.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -383,7 +384,9 @@ class GridOperator
+     /// 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) {
+diff --git a/openvdb/openvdb/tools/LevelSetMeasure.h b/openvdb/openvdb/tools/LevelSetMeasure.h
+index efe19074d..59969cdcf 100644
+--- a/openvdb/openvdb/tools/LevelSetMeasure.h
++++ b/openvdb/openvdb/tools/LevelSetMeasure.h
+@@ -8,18 +8,21 @@
+ #ifndef OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/math/Math.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/Grid.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/math/FiniteDifference.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/math/Stencils.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
+ #include <tbb/parallel_sort.h>
+ #include <tbb/parallel_invoke.h>
++
+ #include <type_traits>
+ 
+ namespace openvdb {
+@@ -329,7 +332,7 @@ inline bool
+ LevelSetMeasure<GridT, InterruptT>::checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/LevelSetTracker.h b/openvdb/openvdb/tools/LevelSetTracker.h
+index cbdc267e8..bfc8004e7 100644
+--- a/openvdb/openvdb/tools/LevelSetTracker.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/tree/LeafManager.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -383,7 +385,7 @@ LevelSetTracker<GridT, InterruptT>::
+ checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/MeshToVolume.h b/openvdb/openvdb/tools/MeshToVolume.h
+index 6643c8f05..de3406eda 100644
+--- a/openvdb/openvdb/tools/MeshToVolume.h
++++ b/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 <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/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 <tbb/parallel_reduce.h>
+ #include <tbb/partitioner.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm> // for std::sort()
+ #include <cmath> // 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<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+@@ -1989,7 +1990,7 @@ class VoxelizePolygons
+         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
+ 
+         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) {
+diff --git a/openvdb/openvdb/tools/Morphology.h b/openvdb/openvdb/tools/Morphology.h
+index 736982ef5..0a1e71009 100644
+--- a/openvdb/openvdb/tools/Morphology.h
++++ b/openvdb/openvdb/tools/Morphology.h
+@@ -24,7 +24,7 @@
+ #include "openvdb/tree/ValueAccessor.h"
+ #include "openvdb/tree/LeafManager.h"
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ 
+@@ -726,7 +726,7 @@ void Morphology<TreeType>::dilateVoxels(const size_t iter,
+         }
+ 
+         // @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
+diff --git a/openvdb/openvdb/tools/ParticlesToLevelSet.h b/openvdb/openvdb/tools/ParticlesToLevelSet.h
+index 739af2b69..f9c19911c 100644
+--- a/openvdb/openvdb/tools/ParticlesToLevelSet.h
++++ b/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 <tbb/parallel_reduce.h>
+-#include <tbb/blocked_range.h>
+-#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/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 <tbb/parallel_reduce.h>
++#include <tbb/blocked_range.h>
++
+ #include <functional>
+ #include <iostream>
+ #include <type_traits>
+@@ -738,7 +742,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         for (Coord c = lo; c.x() <= hi.x(); ++c.x()) {
+             //only check interrupter every 32'th scan in x
+             if (!(count++ & ((1<<5)-1)) && util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Real x2 = math::Pow2(c.x() - P[0]);
+@@ -804,7 +808,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         // Densely fill the remaining regions.
+         for (const auto& bbox: padding) {
+             if (util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Coord &bmin = bbox.min(), &bmax = bbox.max();
+diff --git a/openvdb/openvdb/tools/PointAdvect.h b/openvdb/openvdb/tools/PointAdvect.h
+index 12b1177ad..e487bfb3e 100644
+--- a/openvdb/openvdb/tools/PointAdvect.h
++++ b/openvdb/openvdb/tools/PointAdvect.h
+@@ -10,16 +10,19 @@
+ #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/openvdb.h>
+-#include <openvdb/math/Math.h>             // min
+-#include <openvdb/Types.h>                 // Vec3 types and version number
+-#include <openvdb/Grid.h>                  // grid
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/blocked_range.h>             // threading
+ #include <tbb/parallel_for.h>              // threading
+ #include <tbb/task.h>                      // for cancel
++
+ #include <vector>
+ 
+ 
+@@ -167,7 +170,7 @@ class PointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityFieldIntegrator  velField(*mVelGrid);
+@@ -307,7 +310,7 @@ class ConstrainedPointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityIntegratorType velField(*mVelGrid);
+diff --git a/openvdb/openvdb/tools/PointIndexGrid.h b/openvdb/openvdb/tools/PointIndexGrid.h
+index e9ebf96f7..b2e378a79 100644
+--- a/openvdb/openvdb/tools/PointIndexGrid.h
++++ b/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 <openvdb/version.h>
+@@ -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;
+         }
+ 
+diff --git a/openvdb/openvdb/tools/PointPartitioner.h b/openvdb/openvdb/tools/PointPartitioner.h
+index ccf50ab05..f7f6fc13d 100644
+--- a/openvdb/openvdb/tools/PointPartitioner.h
++++ b/openvdb/openvdb/tools/PointPartitioner.h
+@@ -23,7 +23,7 @@
+ 
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm>
+ #include <cmath> // for std::isfinite()
+@@ -764,7 +764,7 @@ inline void binAndSegment(
+     using IndexPairListMap = std::map<Coord, IndexPairListPtr>;
+     using IndexPairListMapPtr = std::shared_ptr<IndexPairListMap>;
+ 
+-    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;
+ 
+diff --git a/openvdb/openvdb/tools/PointsToMask.h b/openvdb/openvdb/tools/PointsToMask.h
+index 592ab7a15..8a276fb04 100644
+--- a/openvdb/openvdb/tools/PointsToMask.h
++++ b/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 <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/blocked_range.h>
+-#include <openvdb/openvdb.h> // for MaskGrid
+-#include <openvdb/Grid.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/util/NullInterrupter.h>
++
+ #include <vector>
+ 
+ 
+@@ -150,7 +154,7 @@ class PointsToMask
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeAdvect.h b/openvdb/openvdb/tools/VolumeAdvect.h
+index e7eec740e..f38eaa9c2 100644
+--- a/openvdb/openvdb/tools/VolumeAdvect.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/math/Math.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ 
+ 
+@@ -294,7 +297,7 @@ class VolumeAdvection
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeToMesh.h b/openvdb/openvdb/tools/VolumeToMesh.h
+index a834dd3b3..a446f806a 100644
+--- a/openvdb/openvdb/tools/VolumeToMesh.h
++++ b/openvdb/openvdb/tools/VolumeToMesh.h
+@@ -18,7 +18,7 @@
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <cmath> // for std::isfinite()
+ #include <map>
+@@ -388,7 +388,7 @@ inline void
+ fillArray(ValueType* array, const ValueType& val, const size_t length)
+ {
+     const auto grainSize = std::max<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+diff --git a/openvdb/openvdb/unittest/TestCoord.cc b/openvdb/openvdb/unittest/TestCoord.cc
+index be1c24ced..148690041 100644
+--- a/openvdb/openvdb/unittest/TestCoord.cc
++++ b/openvdb/openvdb/unittest/TestCoord.cc
+@@ -2,9 +2,9 @@
+ // SPDX-License-Identifier: MPL-2.0
+ 
+ #include <openvdb/Types.h>
++#include <openvdb/math/Coord.h>
+ 
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_stddef.h> // for tbb::split
+ 
+ #include <unordered_map>
+ #include <sstream>
+diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc
+index 8074166d2..053448f30 100644
+--- a/openvdb/openvdb/unittest/TestFile.cc
++++ b/openvdb/openvdb/unittest/TestFile.cc
+@@ -13,8 +13,11 @@
+ #include <openvdb/version.h>
+ #include <openvdb/openvdb.h>
+ #include "util.h" // for unittest_util::makeSphere()
++
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
++
++#include <thread>
++#include <chrono>
+ #include <algorithm> // for std::sort()
+ #include <cstdio> // for remove() and rename()
+ #include <fstream>
+@@ -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::seconds>(
++                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<io::Queue::Id> 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));
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc
+index 70e7df5f7..6b2204771 100644
+--- a/openvdb/openvdb/unittest/TestUtil.cc
++++ b/openvdb/openvdb/unittest/TestUtil.cc
+@@ -8,7 +8,6 @@
+ 
+ #include <gtest/gtest.h>
+ 
+-#include <tbb/task_scheduler_init.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/blocked_range.h>
+diff --git a/openvdb/openvdb/unittest/TestValueAccessor.cc b/openvdb/openvdb/unittest/TestValueAccessor.cc
+index fd2dd5d81..5c1cbb18b 100644
+--- a/openvdb/openvdb/unittest/TestValueAccessor.cc
++++ b/openvdb/openvdb/unittest/TestValueAccessor.cc
+@@ -6,6 +6,7 @@
+ 
+ #include <gtest/gtest.h>
+ #include <tbb/task.h>
++#include <tbb/task_group.h>
+ 
+ #include <type_traits>
+ 
+@@ -378,22 +379,21 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
+     //using AccessorT = openvdb::tree::ValueAccessor<Tree4Type>;
+ 
+     // 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
+ }
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+index 0e1b4d855..6d9bb528b 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+@@ -20,6 +20,7 @@
+ #include <openvdb/tools/GridTransformer.h>
+ #include <openvdb/tools/PointIndexGrid.h>
+ #include <openvdb/tools/Prune.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <CH/CH_Manager.h>
+ #include <CVEX/CVEX_Context.h>
+@@ -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;
+             }
+ 
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+index 757fdc8c6..dbee74b32 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+@@ -16,13 +16,11 @@
+ #include <openvdb_houdini/SOP_NodeVDB.h>
+ 
+ #include <openvdb/tools/Interpolation.h>  // for box sampler
++#include <openvdb/thread/Threading.h>
+ #include <openvdb/points/PointCount.h>
+ #include <openvdb/points/PointSample.h>
+ #include <openvdb/points/IndexFilter.h>   // for MultiGroupFilter
+ 
+-#include <tbb/tick_count.h>                 // for timing
+-#include <tbb/task.h>                       // for cancel
+-
+ #include <UT/UT_Interrupt.h>
+ #include <GA/GA_PageHandle.h>
+ #include <GA/GA_PageIterator.h>
+@@ -38,6 +36,7 @@
+ #include <stdexcept>
+ #include <string>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ 
+@@ -327,7 +326,7 @@ class PointSampler
+     {
+ 
+         if (mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            openvdb::thread::cancelGroupExecution();
+         }
+         const GridType& grid = UTvdbGridCast<GridType>(mGrid);
+         // task local grid accessor
+@@ -481,7 +480,7 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Context& context)
+         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_Context& context)
+             }
+         }
+ 
+-        // 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::milliseconds>(
++                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;
+         }
+ 
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+index 3d559f8cc..d63ed1591 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
++++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+@@ -47,11 +47,8 @@ struct NodeInfo {
+ 
+ typedef std::vector<NodeInfo> 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, const MTypeId& typeId,
+     node.type               = type;
+     node.classification     = classification;
+ 
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (!gNodes) {
+         OPENVDB_START_THREADSAFE_STATIC_WRITE
+@@ -85,7 +82,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, const MTypeId& typeId,
+ void
+ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+@@ -109,7 +106,7 @@ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ void
+ NodeRegistry::deregisterNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.h b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+index b58bd6f2c..6a04b1eaf 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBUtil.h
++++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+@@ -14,8 +14,7 @@
+ #include <openvdb/tree/LeafManager.h>
+ #include <openvdb/tools/VolumeToMesh.h>
+ #include <openvdb/util/Formats.h> // printBytes
+-
+-#include <tbb/tick_count.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <maya/M3dView.h>
+ #include <maya/MString.h>
+@@ -40,6 +39,7 @@
+ #include <string>
+ #include <type_traits>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ ////////////////////////////////////////
+@@ -116,11 +116,15 @@ insertFrameNumber(std::string& str, const MTime& time, int numberingScheme = 0);
+ 
+ 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::milliseconds>(
++            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<std::chrono::steady_clock> mStamp;
+ };
+ 
+ 
+diff --git a/pendingchanges/tbb2021.txt b/pendingchanges/tbb2021.txt
+new file mode 100644
+index 000000000..8109c2552
+--- /dev/null
++++ b/pendingchanges/tbb2021.txt
+@@ -0,0 +1,6 @@
++Improvements:
++  - Moved from the deprecated TBB task scheduler to TBB arenas. Various methods now respect the TBB arena state they were invoked from.
++  - Introduced a new thread/Threading.h header to consolidate calls to third-party threading methods.
++
++Build:
++  - Added support for TBB 2021.
diff --git a/srcpkgs/openvdb/template b/srcpkgs/openvdb/template
index 72fde5bc6375..d420a3ee5f5d 100644
--- a/srcpkgs/openvdb/template
+++ b/srcpkgs/openvdb/template
@@ -1,26 +1,18 @@
 # Template file for 'openvdb'
 pkgname=openvdb
-version=7.0.0
+version=8.1.0
 revision=1
 build_style=cmake
 configure_args="-DOPENVDB_BUILD_VDB_VIEW=1"
 hostmakedepends="pkg-config"
-makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel glfw-devel"
+makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel
+ glfw-devel jemalloc-devel"
 short_desc="Sparse volume data structure and tools"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MPL-2.0"
 homepage="https://openvdb.org"
 distfiles="https://github.com/AcademySoftwareFoundation/openvdb/archive/v${version}.tar.gz"
-checksum=97bc8ae35ef7ccbf49a4e25cb73e8c2eccae6b235bac86f2150707efcd1e910d
-
-if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
-	makedepends+=" libatomic-devel"
-fi
-
-post_patch() {
-	[ "$XBPS_TARGET_NO_ATOMIC8" ] || return 0
-	vsed -i 's,ZLIB::ZLIB,ZLIB::ZLIB atomic,' openvdb/CMakeLists.txt
-}
+checksum=3e09d47331429be7409a3a3c27fdd3c297f96d31d2153febe194e664a99d6183
 
 post_install() {
 	vlicense LICENSE

From 30a1e9dbba364a0777656ae2e28417f110b271fb Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 10/11] paraview: update to 5.9.1.

---
 srcpkgs/paraview/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/paraview/template b/srcpkgs/paraview/template
index 20a7f5589677..e6c3941ce90a 100644
--- a/srcpkgs/paraview/template
+++ b/srcpkgs/paraview/template
@@ -1,7 +1,7 @@
 # Template file for 'paraview'
 pkgname=paraview
-version=5.8.1
-revision=3
+version=5.9.1
+revision=1
 wrksrc=ParaView-v${version}
 build_style=cmake
 configure_args="-DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr

From 7704abe2da83ad06be631585b5dd00adf1a5cb6e Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 11/11] occt: revbump due to tbb update

---
 srcpkgs/occt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/occt/template b/srcpkgs/occt/template
index 9298edc76e08..006f89ebb8ce 100644
--- a/srcpkgs/occt/template
+++ b/srcpkgs/occt/template
@@ -2,7 +2,7 @@
 pkgname=occt
 reverts=7.5.0_1
 version=7.4.0p1
-revision=3
+revision=4
 _gittag="V${version//./_}"
 wrksrc=occt-${_gittag}
 build_style=cmake

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PR PATCH] [Updated] tbb: update to 2021.3.0
  2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
  2021-07-24 10:20 ` [PR PATCH] [Updated] " Logarithmus
  2021-07-24 11:13 ` Logarithmus
@ 2021-07-24 11:36 ` Logarithmus
  2021-07-24 12:32 ` Logarithmus
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Logarithmus @ 2021-07-24 11:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

There is an updated pull request by Logarithmus against master on the void-packages repository

https://github.com/Logarithmus/void-packages tbb-2021
https://github.com/void-linux/void-packages/pull/32166

tbb: update to 2021.3.0
Follow-up of https://github.com/void-linux/void-packages/pull/27746, @thypon & @olafmersmann might be interested.
**TODO** fix reverse dependencies:
- [ ] OpenSubdiv: update to 3.4.4.
- [ ] PrusaSlicer: update to 2.3.3.
- [ ] lender: update to 2.93.1.
- [ ] embree: update to 3.13.0.
- [ ] openimageio: update to 2.2.16.0.
- [ ] openimagedenoise: update to 1.4.1.
- [ ] openvdb: update to 8.1.0.
- [ ] paraview: update to 5.9.1.
- [ ] occt: revbump due to tbb update

#### Have the results of the proposed changes been tested?
- [x] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me


A patch file from https://github.com/void-linux/void-packages/pull/32166.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-tbb-2021-32166.patch --]
[-- Type: text/x-diff, Size: 88321 bytes --]

From 267b49acb694c21087d5852e322969db5d564632 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 17 Jul 2021 23:57:52 +0300
Subject: [PATCH 01/11] hwloc: add libpciaccess-devel make dependency

---
 .../hwloc/patches/00-get-area-memlocation.patch    | 14 ++++++++++++++
 srcpkgs/hwloc/template                             |  8 +++++---
 2 files changed, 19 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hwloc/patches/00-get-area-memlocation.patch

diff --git a/srcpkgs/hwloc/patches/00-get-area-memlocation.patch b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
new file mode 100644
index 000000000000..e9073817e4e6
--- /dev/null
+++ b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
@@ -0,0 +1,14 @@
+diff --git a/tests/hwloc/hwloc_get_area_memlocation.c b/tests/hwloc/hwloc_get_area_memlocation.c
+index 498dfae..ceb2521 100644
+--- a/tests/hwloc/hwloc_get_area_memlocation.c
++++ b/tests/hwloc/hwloc_get_area_memlocation.c
+@@ -39,6 +39,9 @@ int main(void)
+     fprintf(stderr, "hwloc_get_area_memlocation() failed with ENOSYS, aborting\n");
+     goto out_with_buffer;
+   }
++  if (err) {
++    fprintf(stderr, "err == %i, errno == %s", err, strerror(errno));
++  }
+   assert(!err);
+   hwloc_bitmap_asprintf(&s, set);
+   printf("address %p length %d allocated in nodeset %s\n", buffer, LEN, s);
diff --git a/srcpkgs/hwloc/template b/srcpkgs/hwloc/template
index 818db269cebb..6eec662d0d6e 100644
--- a/srcpkgs/hwloc/template
+++ b/srcpkgs/hwloc/template
@@ -1,10 +1,12 @@
 # Template file for 'hwloc'
 pkgname=hwloc
 version=2.5.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="cairo-devel ncurses-devel libxml2-devel eudev-libudev-devel"
+makedepends="cairo-devel ncurses-devel libxml2-devel libpciaccess-devel eudev-libudev-devel"
+checkdepends="tar"
+make_check_args="VERBOSE=1"
 short_desc="Portable abstraction of hierarchical hardware architectures"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
 license="BSD-3-Clause"
@@ -31,7 +33,7 @@ libhwloc_package() {
 
 libhwloc-devel_package() {
 	short_desc+=" - development files"
-	depends="libhwloc>=${version}_${revision}"
+	depends="${makedepends} libhwloc>=${version}_${revision}"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/share/man/man3

From 708034d8b379985e96b0cea4a70c422ef4f9ce4b Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 02:50:26 +0300
Subject: [PATCH 02/11] tbb: update to 2021.3.0.

---
 common/shlibs                                |   6 +-
 srcpkgs/tbb/patches/00-hwloc-2.5.patch       | 367 +++++++++++++++++++
 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch |  52 +++
 srcpkgs/tbb/patches/hostname-usage.patch     |  11 -
 srcpkgs/tbb/patches/musl.patch               |   4 +-
 srcpkgs/tbb/template                         |  63 +---
 6 files changed, 433 insertions(+), 70 deletions(-)
 create mode 100644 srcpkgs/tbb/patches/00-hwloc-2.5.patch
 create mode 100644 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
 delete mode 100644 srcpkgs/tbb/patches/hostname-usage.patch

diff --git a/common/shlibs b/common/shlibs
index a7afbf2a56f7..6b7ca5fbc249 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2376,12 +2376,10 @@ libanthy-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthydic-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthyinput-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthygobject-1.0.so.5 ibus-anthy-1.5.6_1
-libtbbmalloc_proxy_debug.so.2 tbb-4.3_1
 libtbbmalloc_proxy.so.2 tbb-4.3_1
 libtbbmalloc.so.2 tbb-4.3_1
-libtbb_debug.so.2 tbb-4.3_1
-libtbb.so.2 tbb-4.3_1
-libtbbmalloc_debug.so.2 tbb-4.3_1
+libtbb.so.12 tbb-2021.3.0_1
+libtbbbind_2_5.so.3 tbb-2021.3.0_1
 libembree.so.2 embree-2.5.1_1
 libgtkimageview.so.0 gtkimageview-1.6.4_1
 libgoocanvas-2.0.so.9 goocanvas-2.0.4_1
diff --git a/srcpkgs/tbb/patches/00-hwloc-2.5.patch b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
new file mode 100644
index 000000000000..9c4c9285c71d
--- /dev/null
+++ b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
@@ -0,0 +1,367 @@
+Adjusted by Artur Sinila <freesoftware@logarithmus.dev>
+
+From e96dbf4b48e689ab810b0428d0858a6abc2c83bd Mon Sep 17 00:00:00 2001
+From: Ivan Kochin <iv.kochin@gmail.com>
+Date: Thu, 1 Jul 2021 15:07:39 +0300
+Subject: [PATCH] Upgrade from HWLOC 2.4 to HWLOC 2.5 (#448)
+
+* Upgrade from HWLOC 2.4 to HWLOC 2.5
+* Introduce tbbbind_2_5 library
+* Remove tbbbind_2_4 library
+* Use the HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING topology flag (introduces as a part of HWLOC 2.5) to restrict topology discovering to process binding
+* Fix testing on Linux
+* Apply review comments
+* Improve wording: variable -> substring
+* Use right tbbbind version for incompatible hwlocs test
+* Rework option semantic
+* Update README.md for CMake
+* Rework readme
+* Update cmake/README.md
+
+Signed-off-by: Kochin, Ivan <kochin.ivan@intel.com>
+
+Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
+---
+ CMakeLists.txt                         |  3 ++-
+ cmake/README.md                        | 11 +++++---
+ cmake/hwloc_detection.cmake            |  9 ++++---
+ src/tbb/governor.cpp                   |  4 +--
+ src/tbbbind/CMakeLists.txt             |  2 +-
+ src/tbbbind/tbb_bind.cpp               | 23 +++++++++++-----
+ test/CMakeLists.txt                    | 30 ++++++++++-----------
+ test/common/common_arena_constraints.h | 37 ++++++++++++++++++++++----
+ 8 files changed, 82 insertions(+), 37 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 34a23d400..301899aca 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -100,6 +100,7 @@ option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Win
+ option(TBB4PY_BUILD "Enable tbb4py build" OFF)
+ option(TBB_CPF "Enable preview features of the library" OFF)
+ option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
++option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
+ 
+ if (NOT DEFINED BUILD_SHARED_LIBS)
+     set(BUILD_SHARED_LIBS ON)
+@@ -195,7 +196,7 @@ else()
+         add_subdirectory(src/tbbmalloc)
+         add_subdirectory(src/tbbmalloc_proxy)
+         if (APPLE)
+-            message(STATUS "TBBBind build target is disabled due to unsupported environment")
++            message(STATUS "TBBBind build targets are disabled due to unsupported environment")
+         else()
+             add_subdirectory(src/tbbbind)
+         endif()
+diff --git a/cmake/README.md b/cmake/README.md
+index 36fc303f9..b58c2ff6a 100644
+--- a/cmake/README.md
++++ b/cmake/README.md
+@@ -13,6 +13,7 @@ TBB4PY_BUILD:BOOL - Enable  Intel(R) oneAPI Threading Building Blocks (oneTBB) P
+ TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
+ TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
+ TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
++TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)
+ ```
+ 
+ ## Configure, build and test
+@@ -42,9 +43,9 @@ Some useful options:
+ 
+ #### TBBBind library configuration
+ 
+-The TBBbind library has two versions: `tbbbind` and `tbbbind_2_0`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.x.
++The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0` and `tbbbind_2_5`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.1-2.4, `tbbbind_2_5` links with HWLOC 2.5 and later.
+ 
+-To enable the TBBBind library build or special tests that performed inside the HWLOC environment, please specify the following CMake variables:
++The search for a suitable version of the HWLOC library is enabled by default, but if you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
+ 
+  - `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux or path to `.lib` file on Windows.
+  - `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version includes directory.
+@@ -52,7 +53,11 @@ To enable the TBBBind library build or special tests that performed inside the H
+ Windows requires one additional variable for correct TBBBind library building:
+  - `CMAKE_HWLOC_<HWLOC_VER>_DLL_PATH` - path to the corresponding HWLOC version `.dll` file.
+ 
+-`HWLOC_VER` variable used above can be replaced with one of the two values: `1_11` for the `tbbbind` library configuration and `2` for the `tbbbind_2_0` library configuration.
++`HWLOC_VER` substring used above can be replaced with one of the three values: `1_11` for the `tbbbind` library configuration, `2` for the `tbbbind_2_0`, and `2_5` for the `tbbbind_2_5` library configuration.
++
++If you specify variables for several TBBBind versions, then building process for all of these versions will be performed during single build session.
++
++Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
+ 
+ ### Build
+ 
+diff --git a/cmake/hwloc_detection.cmake b/cmake/hwloc_detection.cmake
+index e1eeca5fa..de7f3c047 100644
+--- a/cmake/hwloc_detection.cmake
++++ b/cmake/hwloc_detection.cmake
+@@ -12,7 +12,7 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
+-list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_4)
++list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_5)
+ 
+ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
+     if (NOT WIN32)
+@@ -55,10 +56,10 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
+         if (HWLOC_FOUND)
+             if (HWLOC_VERSION VERSION_LESS 2)
+                 set(TBBBIND_LIBRARY_NAME tbbbind)
+-            elseif(HWLOC_VERSION VERSION_LESS 2.4)
++            elseif(HWLOC_VERSION VERSION_LESS 2.5)
+                 set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
+             else()
+-                set(TBBBIND_LIBRARY_NAME tbbbind_2_4)
++                set(TBBBIND_LIBRARY_NAME tbbbind_2_5)
+             endif()
+         endif()
+     endif()
+diff --git a/src/tbb/governor.cpp b/src/tbb/governor.cpp
+index bf4e402d1..b842e075f 100644
+--- a/src/tbb/governor.cpp
++++ b/src/tbb/governor.cpp
+@@ -362,7 +362,7 @@ static const unsigned LinkTableSize = sizeof(TbbBindLinkTable) / sizeof(dynamic_
+ 
+ #define TBBBIND_NAME LIBRARY_PREFIX "tbbbind" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #define TBBBIND_2_0_NAME LIBRARY_PREFIX "tbbbind_2_0" DEBUG_SUFFIX LIBRARY_EXTENSION
+-#define TBBBIND_2_4_NAME LIBRARY_PREFIX "tbbbind_2_4" DEBUG_SUFFIX LIBRARY_EXTENSION
++#define TBBBIND_2_5_NAME LIBRARY_PREFIX "tbbbind_2_5" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #endif /* _WIN32 || _WIN64 || __linux__ */
+ 
+ // Representation of system hardware topology information on the TBB side.
+@@ -389,7 +389,7 @@ const char* load_tbbbind_shared_object() {
+     GetNativeSystemInfo(&si);
+     if (si.dwNumberOfProcessors > 32) return nullptr;
+ #endif /* _WIN32 && !_WIN64 */
+-    for (const auto& tbbbind_version : {TBBBIND_2_4_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
++    for (const auto& tbbbind_version : {TBBBIND_2_5_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
+         if (dynamic_link(tbbbind_version, TbbBindLinkTable, LinkTableSize)) {
+             return tbbbind_version;
+         }
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index 029893751..e5cdbf8bb 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -99,7 +99,7 @@ if (NOT DEFINED HWLOC_TARGET_EXPLICITLY_DEFINED AND DEFINED HWLOC_LIBRARIES)
+ else()
+     tbbbind_build(tbbbind     HWLOC::hwloc_1_11)
+     tbbbind_build(tbbbind_2_0 HWLOC::hwloc_2   )
+-    tbbbind_build(tbbbind_2_4 HWLOC::hwloc_2_4 )
++    tbbbind_build(tbbbind_2_5 HWLOC::hwloc_2_5 )
+ endif()
+ 
+ 
+diff --git a/src/tbbbind/tbb_bind.cpp b/src/tbbbind/tbb_bind.cpp
+index 97be308c7..88c956acb 100644
+--- a/src/tbbbind/tbb_bind.cpp
++++ b/src/tbbbind/tbb_bind.cpp
+@@ -34,7 +34,8 @@
+ #pragma GCC diagnostic pop
+ #endif
+ 
+-#define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ 
+ // Most of hwloc calls returns negative exit code on error.
+ // This macro tracks error codes that are returned from the hwloc interfaces.
+@@ -85,6 +86,16 @@ class platform_topology {
+         // Parse topology
+         if ( hwloc_topology_init( &topology ) == 0 ) {
+             initialization_state = topology_allocated;
++#if __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++            if ( groups_num == 1 &&
++                 hwloc_topology_set_flags(topology,
++                     HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                     HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
++                 ) != 0
++            ) {
++                return;
++            }
++#endif
+             if ( hwloc_topology_load( topology ) == 0 ) {
+                 initialization_state = topology_loaded;
+             }
+@@ -135,7 +146,7 @@ class platform_topology {
+             numa_indexes_list.resize(numa_nodes_count);
+             hwloc_obj_t node_buffer;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 numa_indexes_list[counter] = static_cast<int>(node_buffer->logical_index);
+ 
+                 if ( numa_indexes_list[counter] > max_numa_index ) {
+@@ -150,7 +161,7 @@ class platform_topology {
+             numa_affinity_masks_list.resize(max_numa_index + 1);
+             int index = 0;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 index = static_cast<int>(node_buffer->logical_index);
+ 
+                 hwloc_cpuset_t& current_mask = numa_affinity_masks_list[index];
+@@ -168,7 +179,7 @@ class platform_topology {
+             core_types_indexes_list.push_back(-1);
+             return;
+         }
+-#if __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
++#if __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
+         __TBB_ASSERT(hwloc_get_api_version() >= 0x20400, "Hybrid CPUs support interfaces required HWLOC >= 2.4");
+         // Parsing the hybrid CPU topology
+         int core_types_number = hwloc_cpukinds_get_nr(topology, 0);
+@@ -196,9 +207,9 @@ class platform_topology {
+                 }
+             }
+         }
+-#else /*!__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#else /*!__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+         bool core_types_parsing_broken{true};
+-#endif /*__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#endif /*__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+ 
+         if (core_types_parsing_broken) {
+             for (auto& core_type_mask : core_types_affinity_masks_list) {
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index bdae9e2b1..c2b9d6dba 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -275,9 +275,9 @@ function(tbb_add_tbbbind_test)
+         FAIL_REGULAR_EXPRESSION "Status:.*FAILURE"
+     )
+ 
+-    if (TARGET HWLOC::hwloc_2_4 AND NOT HWLOC_2_4_TESTS_STATUS_SHOWN)
+-        message(STATUS "HWLOC 2.4 dependent tests were enabled.")
+-        set(HWLOC_2_4_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
++    if (TARGET HWLOC::hwloc_2_5 AND NOT HWLOC_2_5_TESTS_STATUS_SHOWN)
++        message(STATUS "HWLOC 2.5 dependent tests were enabled.")
++        set(HWLOC_2_5_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
+     endif()
+ 
+     if (TARGET HWLOC::hwloc_2 AND NOT HWLOC_2_TESTS_STATUS_SHOWN)
+@@ -291,22 +291,22 @@ function(tbb_add_tbbbind_test)
+     endif()
+ 
+     list(APPEND HWLOC_TEST_CASES
+-        hwloc_2_4
++        hwloc_2_5
+         hwloc_2
+         hwloc_1_11
+-        hwloc_2_4_hwloc_2
+-        hwloc_2_4_hwloc_1_11
++        hwloc_2_5_hwloc_2
++        hwloc_2_5_hwloc_1_11
+         hwloc_2_hwloc_1_11
+-        hwloc_2_4_hwloc_2_hwloc_1_11
++        hwloc_2_5_hwloc_2_hwloc_1_11
+     )
+ 
+-    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_4 "hwloc_2_4")
++    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_5 "hwloc_2_5")
+     list(APPEND HWLOC_TEST_CASE_1_VARS tbbbind_2   "hwloc_2")
+     list(APPEND HWLOC_TEST_CASE_2_VARS tbbbind     "hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2")
+-    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_4 "hwloc_2_4,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2")
++    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_5 "hwloc_2_5,hwloc_1_11")
+     list(APPEND HWLOC_TEST_CASE_5_VARS tbbbind_2   "hwloc_2,hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2,hwloc_1_11")
+ 
+     foreach(TEST_CASE ${HWLOC_TEST_CASES})
+         list(FIND HWLOC_TEST_CASES ${TEST_CASE} TEST_CASE_INDEX)
+@@ -331,7 +331,7 @@ endfunction()
+ # Copy libraries to test folder to make it visible during tests execution if external TBB is tested.
+ # TODO: check and update for multi-config generators.
+ if (TBB_FOUND)
+-    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_4)
++    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_5)
+     foreach(_component ${_tbb_test_components})
+         if (TARGET TBB::${_component})
+             get_property(${_component}_lib_file_location TARGET TBB::${_component} PROPERTY LOCATION)
+@@ -593,6 +593,6 @@ if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
+     tbb_add_test(SUBDIR tbbmalloc NAME test_malloc_new_handler DEPENDENCIES TBB::tbbmalloc_proxy)
+ endif()
+ 
+-unset(HWLOC_2_4_TESTS_STATUS_SHOWN)
++unset(HWLOC_2_5_TESTS_STATUS_SHOWN)
+ unset(HWLOC_2_TESTS_STATUS_SHOWN)
+ unset(HWLOC_1_11_TESTS_STATUS_SHOWN)
+diff --git a/test/common/common_arena_constraints.h b/test/common/common_arena_constraints.h
+index 2a0b1ea97..5efc71082 100644
+--- a/test/common/common_arena_constraints.h
++++ b/test/common/common_arena_constraints.h
+@@ -38,9 +38,26 @@
+ 
+ #if (_WIN32 || _WIN64) && __TBB_HWLOC_VALID_ENVIRONMENT
+ #include <windows.h>
+-int get_processors_groups_count() { return GetActiveProcessorGroupCount(); }
++int get_processors_group_count() {
++    SYSTEM_INFO si;
++    GetNativeSystemInfo(&si);
++    DWORD_PTR pam, sam, m = 1;
++    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
++    int nproc = 0;
++    for ( std::size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
++        if ( pam & m )
++            ++nproc;
++    }
++    // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present
++    if ( nproc == (int)si.dwNumberOfProcessors  ) {
++        // The process does not have restricting affinity mask and multiple processor groups are possible
++        return (int)GetActiveProcessorGroupCount();
++    } else {
++        return 1;
++    }
++}
+ #else
+-int get_processors_groups_count() { return 1; }
++int get_processors_group_count() { return 1; }
+ #endif
+ 
+ //TODO: Write a test that checks for memory leaks during dynamic link/unlink of TBBbind.
+@@ -69,6 +86,7 @@ int get_processors_groups_count() { return 1; }
+ #endif
+ 
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ // At this moment the hybrid CPUs HWLOC interfaces returns unexpected results on some Windows machines
+ // in the 32-bit arch mode.
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_VALID (!_WIN32 || _WIN64)
+@@ -153,9 +171,18 @@ class system_info {
+ 
+     system_info() {
+         hwloc_require_ex(hwloc_topology_init, &topology);
++#if __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++        if ( get_processors_group_count() == 1 ) {
++            REQUIRE(
++                hwloc_topology_set_flags(topology,
++                    HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                    HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING) == 0
++            );
++        }
++#endif
+         hwloc_require_ex(hwloc_topology_load, topology);
+ 
+-        if ( get_processors_groups_count() > 1 ) {
++        if ( get_processors_group_count() > 1 ) {
+             process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
+         } else {
+             process_cpuset = hwloc_bitmap_alloc();
+@@ -434,7 +461,7 @@ system_info::affinity_mask get_arena_affinity(tbb::task_arena& ta) {
+                 barrier.wait();
+                 tbb::spin_mutex::scoped_lock lock(affinity_mutex);
+                 system_info::affinity_mask thread_affinity = system_info::allocate_current_affinity_mask();
+-                if (get_processors_groups_count() == 1) {
++                if (get_processors_group_count() == 1) {
+                     REQUIRE_MESSAGE(hwloc_bitmap_isequal(thread_affinity, arena_affinity),
+                         "Threads have different masks on machine without several processors groups.");
+                 }
+@@ -532,7 +559,7 @@ constraints_container generate_constraints_variety() {
+         }
+ 
+         // Some constraints may cause unexpected behavior, which would be fixed later.
+-        if (get_processors_groups_count() > 1) {
++        if (get_processors_group_count() > 1) {
+             for(auto it = results.begin(); it != results.end(); ++it) {
+                 if (it->max_threads_per_core != tbb::task_arena::automatic
+                    && (it->numa_id == tbb::task_arena::automatic || tbb::info::numa_nodes().size() == 1)
diff --git a/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
new file mode 100644
index 000000000000..279ebc4397cd
--- /dev/null
+++ b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
@@ -0,0 +1,52 @@
+Based on https://github.com/oneapi-src/oneTBB/pull/498
+Tweaked a bit to work on `v2021.3.0`
+
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index e5cdbf8bb..a4033210a 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -37,6 +37,10 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+         ${HWLOC_INCLUDE_DIRS} # pkg-config defined
+     )
++	target_link_directories(${TBBBIND_NAME}
++		PRIVATE
++		${HWLOC_LIBRARY_DIRS} # pkg-config defined
++	)
+ 
+     target_compile_options(${TBBBIND_NAME}
+         PRIVATE
+@@ -69,7 +69,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     else()
+         target_link_libraries(${TBBBIND_NAME}
+@@ -76,7 +76,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     endif()
+ 
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index b768759d5..3eb8357e6 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -258,7 +258,12 @@ function(tbb_add_tbbbind_test)
+         )
+         set_property(
+             TARGET ${_tbbbind_test_NAME}
+-            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARY_DIRS} ${HWLOC_LIBRARIES}
++            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARIES}
++            APPEND
++        )
++        set_property(
++            TARGET ${_tbbbind_test_NAME}
++			PROPERTY LINK_DIRECTORIES ${HWLOC_LIBRARY_DIRS}
+             APPEND
+         )
+         set_property(
diff --git a/srcpkgs/tbb/patches/hostname-usage.patch b/srcpkgs/tbb/patches/hostname-usage.patch
deleted file mode 100644
index 4aefeff192b5..000000000000
--- a/srcpkgs/tbb/patches/hostname-usage.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/build/version_info_linux.sh
-+++ b/build/version_info_linux.sh
-@@ -20,7 +20,7 @@
- 
- # Script used to generate version info string
- echo "#define __TBB_VERSION_STRINGS(N) \\"
--echo '#N": BUILD_HOST'"\t\t"`hostname -s`" ("`uname -m`")"'" ENDL \'
-+echo '#N": BUILD_HOST'"\t\t"`hostname`" ("`uname -m`")"'" ENDL \'
- # find OS name in *-release and issue* files by filtering blank lines and lsb-release content out
- echo '#N": BUILD_OS'"\t\t"`lsb_release -sd 2>/dev/null | grep -ih '[a-z] ' - /etc/*release /etc/issue 2>/dev/null | head -1 | sed -e 's/["\\\\]//g'`'" ENDL \'
- echo '#N": BUILD_KERNEL'"\t"`uname -srv`'" ENDL \'
diff --git a/srcpkgs/tbb/patches/musl.patch b/srcpkgs/tbb/patches/musl.patch
index a8867eb53793..ec89c6a95fc6 100644
--- a/srcpkgs/tbb/patches/musl.patch
+++ b/srcpkgs/tbb/patches/musl.patch
@@ -1,5 +1,5 @@
---- a/src/tbbmalloc/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
-+++ b/src/tbbmalloc/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
+--- a/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
++++ b/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
 @@ -28,6 +28,7 @@
  // of aligned_alloc as required by new C++ standard, this makes it hard to
  // redefine aligned_alloc here. However, running on systems with new libc
diff --git a/srcpkgs/tbb/template b/srcpkgs/tbb/template
index aeef6ebdd061..47655829f744 100644
--- a/srcpkgs/tbb/template
+++ b/srcpkgs/tbb/template
@@ -1,76 +1,33 @@
 # Template file for 'tbb'
 pkgname=tbb
-version=2020.U3
+version=2021.3.0
 revision=1
-# version rewrite: 2017_U7 (upstream) => 2017.7 (xbps)
-_ver=${version/./_}
-wrksrc="oneTBB-${_ver}"
-build_style=gnu-makefile
-hostmakedepends="cmake"
+wrksrc="oneTBB-${version}"
+build_style=cmake
+makedepends="libhwloc-devel libgomp-devel"
 short_desc="Intel Threading Building Blocks"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
 license="Apache-2.0"
 homepage="https://www.threadingbuildingblocks.org"
-distfiles="https://github.com/oneapi-src/oneTBB/archive/${_ver}.tar.gz"
-checksum=2103cc6238c935664f87680618f6684d57501d4a2fa8ea8f6c97ad6ff7dc722a
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*)
-		make_build_args="arch=intel64"
-		;;
-	i686*)
-		make_build_args="arch=ia32"
-		;;
-	armv7l*)
-		make_build_args="arch=armv7"
-		;;
-	aarch64*)
-		make_build_args="arch=arm64"
-		;;
-	ppc64*)
-		make_build_args="arch=ppc64"
-		;;
-	ppc*)
-		make_build_args="arch=ppc32"
-		;;
-	*)
-		# make sure to fall back instead of letting host uname control it
-		make_build_args="arch=generic"
-		;;
-esac
-
-post_extract() {
-	sed -i 's|CPLUS = g..|CPLUS = $(CXX)|g' build/linux.gcc.inc
-	sed -i 's|CONLY = gcc|CONLY = $(CC)|g' build/linux.gcc.inc
+distfiles="https://github.com/oneapi-src/oneTBB/archive/v${version}.tar.gz"
+checksum=8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e
 
+pre_patch() {
 	# alternative might be:
 	# https://git.alpinelinux.org/cgit/aports/tree/testing/libtbb/glibc-struct-mallinfo.patch
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		vsed -e "s@#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__@@" \
-		  -i src/tbbmalloc/proxy.h
+		  -i src/tbbmalloc_proxy/proxy.h
 	fi
 }
 
-do_install() {
-	vmkdir usr/lib
-	vcopy build/linux_*/*.so* usr/lib
-	vmkdir usr/include/tbb
-	vcopy include/tbb/* usr/include/tbb
-
-	cmake \
-		-DINSTALL_DIR=$DESTDIR/usr/lib/cmake/TBB \
-		-DSYSTEM_NAME=Linux \
-		-DLIB_REL_PATH=../.. \
-		-DINC_REL_PATH=../../../include \
-		-P cmake/tbb_config_installer.cmake
-}
-
 tbb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
-		vmove "usr/lib/*.so"
 		vmove usr/lib/cmake
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.so
 	}
 }

From e4be6e0e735fe1dbd118142eed7610c233f2bab6 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 03/11] OpenSubdiv: update to 3.4.4.

---
 srcpkgs/OpenSubdiv/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/OpenSubdiv/template b/srcpkgs/OpenSubdiv/template
index b7a5e16efbcf..dfbf29cc1a52 100644
--- a/srcpkgs/OpenSubdiv/template
+++ b/srcpkgs/OpenSubdiv/template
@@ -1,6 +1,6 @@
 # Template file for 'OpenSubdiv'
 pkgname=OpenSubdiv
-version=3.4.3
+version=3.4.4
 revision=1
 wrksrc="OpenSubdiv-${version//./_}"
 build_style=cmake
@@ -13,7 +13,7 @@ maintainer="John <me@johnnynator.dev>"
 license="Apache-2.0"
 homepage="http://graphics.pixar.com/opensubdiv/docs/intro.html"
 distfiles="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${version//./_}.tar.gz"
-checksum=7b22eb27d636ab0c1e03722c7a5a5bd4f11664ee65c9b48f341a6d0ce7f36745
+checksum=20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" OpenSubdiv"

From dc326cb0ff879bb7fad7d8dfa5c43a825745eaf4 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 04/11] PrusaSlicer: update to 2.3.3.

---
 srcpkgs/PrusaSlicer/patches/cross.patch | 11 -----------
 srcpkgs/PrusaSlicer/template            |  4 ++--
 2 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 srcpkgs/PrusaSlicer/patches/cross.patch

diff --git a/srcpkgs/PrusaSlicer/patches/cross.patch b/srcpkgs/PrusaSlicer/patches/cross.patch
deleted file mode 100644
index d64a450d9e9f..000000000000
--- a/srcpkgs/PrusaSlicer/patches/cross.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/avrdude/CMakeLists.txt	2020-06-04 09:19:26.017251215 +0200
-+++ b/src/avrdude/CMakeLists.txt	2020-06-04 09:19:36.468250771 +0200
-@@ -83,7 +83,7 @@ add_executable(avrdude-conf-gen conf-gen
- add_custom_command(
-     DEPENDS avrdude-conf-gen ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf
-     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
--    COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-+    COMMAND avrdude-conf-gen avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- 
diff --git a/srcpkgs/PrusaSlicer/template b/srcpkgs/PrusaSlicer/template
index dd0e76cb8017..a93832ac02e4 100644
--- a/srcpkgs/PrusaSlicer/template
+++ b/srcpkgs/PrusaSlicer/template
@@ -1,6 +1,6 @@
 # Template file for 'PrusaSlicer'
 pkgname=PrusaSlicer
-version=2.3.0
+version=2.3.3
 revision=1
 wrksrc="PrusaSlicer-version_${version}"
 build_style=cmake
@@ -16,7 +16,7 @@ maintainer="Jasper Chan <jasperchan515@gmail.com>"
 license="GPL-3.0-or-later"
 homepage="https://www.prusa3d.com/prusaslicer/"
 distfiles="https://github.com/prusa3d/Prusaslicer/archive/version_${version}.tar.gz"
-checksum=cd3bac5e29b5441fc4690f28cd7b1064e97dc00207bbdc88f7bd7832308d6ca5
+checksum=deda209505f740ac3d6f59cb2a960f4df908269ee09bd30cd4edb9fc472d29ac
 nocross="https://build.voidlinux.org/builders/armv7l_builder/builds/25230/steps/shell_3/logs/stdio"
 
 Slic3rPE_package() {

From 110b590ecb3efeebca96f96cb5df52dac2f38cf5 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 05/11] blender: update to 2.93.1.

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index af946c2b7999..8318317c82bf 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,6 +1,6 @@
 # Template file for 'blender'
 pkgname=blender
-version=2.93.0
+version=2.93.1
 revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"

From 0dae96c1c9e7d2e9ffa8fb6d01cb859f194d86c6 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 06/11] embree: update to 3.13.0.

---
 srcpkgs/embree/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/embree/template b/srcpkgs/embree/template
index 575b9bcb401c..b6f376d30efa 100644
--- a/srcpkgs/embree/template
+++ b/srcpkgs/embree/template
@@ -1,8 +1,8 @@
 # Template file for 'embree'
 pkgname=embree
-version=2.17.7
-revision=2
-archs="x86_64"
+version=3.13.0
+revision=1
+archs="x86_64*"
 build_style=cmake
 configure_args="-DTBB_ROOT=/usr -DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF"
 hostmakedepends="ispc"

From b0b8b82b64742d5bdb84bea4e9465f03ef14a9df Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 03:34:43 +0300
Subject: [PATCH 07/11] openimageio: update to 2.2.16.0.

---
 srcpkgs/openimageio/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index de8e1cd04409..3bfdd4e0ed1e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,11 +1,11 @@
 # Template file for 'openimageio'
 pkgname=openimageio
-version=2.2.15.1
+version=2.2.16.0
 revision=1
 wrksrc="oiio-Release-${version}"
 build_style=cmake
 configure_args="-DUSE_OPENGL=0 -DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=1
- -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0"
+ -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0 -DCMAKE_CXX_STANDARD=14"
 hostmakedepends="pkg-config git"
 makedepends="boost-devel giflib-devel libraw-devel libopenjpeg-devel libwebp-devel
  libjpeg-turbo-devel tiff-devel libpng-devel libopenexr-devel freetype-devel
@@ -17,7 +17,7 @@ license="BSD-3-Clause"
 homepage="https://sites.google.com/site/openimageio/home"
 changelog="https://raw.githubusercontent.com/OpenImageIO/oiio/release/CHANGES.md"
 distfiles="https://github.com/OpenImageIO/oiio/archive/Release-${version}.tar.gz"
-checksum=f222c6b51a40aabbc80ddf4055535be9af1ffa907452fa6d1ffa7674854aab17
+checksum=d1a59f32dbba3ba71ad2e62e107034d1c5287bca1b0696474e927d504cd05ef4
 # Runs checks even for features we disabled.
 make_check=no
 

From bca42706709bf3faef0d97d8812b7fdb92dd3758 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 08/11] openimagedenoise: update to 1.4.1.

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index c73913b4e9d7..14055aff1c27 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,6 +1,6 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
-version=1.4.0
+version=1.4.1
 revision=1
 archs="x86_64*"
 wrksrc=oidn-${version}

From f0a5e91e280ac5a5f77620ddaab8be13221998f7 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 09/11] openvdb: update to 8.1.0.

---
 common/shlibs                             |    2 +-
 srcpkgs/openvdb/patches/00-tbb-2021.patch | 1320 +++++++++++++++++++++
 srcpkgs/openvdb/template                  |   16 +-
 3 files changed, 1325 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/openvdb/patches/00-tbb-2021.patch

diff --git a/common/shlibs b/common/shlibs
index 6b7ca5fbc249..2a7acdb253a7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3883,7 +3883,7 @@ libjanet.so.1.16 janet-1.16.0_1
 libOpenImageDenoise.so.1 openimagedenoise-1.3.0_1
 libcbang0.so cbang-1.6.0_3
 libblosc.so.1 c-blosc-1.17.1_1
-libopenvdb.so.7.0 openvdb-7.0.0_1
+libopenvdb.so.8.1 openvdb-8.1.0_1
 libAlembic.so.1.7 alembic-1.7.13_1
 libmodsecurity.so.3 modsecurity-3.0.4_1
 libraven.so.0 budgie-desktop-10.5.1_1
diff --git a/srcpkgs/openvdb/patches/00-tbb-2021.patch b/srcpkgs/openvdb/patches/00-tbb-2021.patch
new file mode 100644
index 000000000000..271104af3df9
--- /dev/null
+++ b/srcpkgs/openvdb/patches/00-tbb-2021.patch
@@ -0,0 +1,1320 @@
+https://github.com/AcademySoftwareFoundation/openvdb/pull/1027
+Should be dropped after 8.1.1 release.
+
+diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake
+index d41436b1c..06de2b3f3 100644
+--- a/cmake/FindTBB.cmake
++++ b/cmake/FindTBB.cmake
+@@ -169,8 +169,22 @@ find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
+   PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
+ )
+ 
+-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" ""
+@@ -178,7 +192,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" ""
+@@ -192,6 +206,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
+ # ------------------------------------------------------------------------
+diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt
+index 88543df3a..929fe94d1 100644
+--- a/openvdb/openvdb/CMakeLists.txt
++++ b/openvdb/openvdb/CMakeLists.txt
+@@ -437,6 +437,10 @@ set(OPENVDB_LIBRARY_UTIL_INCLUDE_FILES
+   util/Util.h
+ )
+ 
++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} DESTINATION ${OPENVDB_INST
+ 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)
+diff --git a/openvdb/openvdb/cmd/openvdb_render.cc b/openvdb/openvdb/cmd/openvdb_render.cc
+index ee5b737c5..2c9831ba3 100644
+--- a/openvdb/openvdb/cmd/openvdb_render.cc
++++ b/openvdb/openvdb/cmd/openvdb_render.cc
+@@ -19,7 +19,14 @@
+ #include <OpenEXR/ImfHeader.h>
+ #include <OpenEXR/ImfOutputFile.h>
+ #include <OpenEXR/ImfPixelType.h>
+-#include <tbb/task_scheduler_init.h>
++
++// 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 <tbb/global_control.h>
+ #include <tbb/tick_count.h>
+ 
+ #include <algorithm>
+@@ -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<tbb::global_control> 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();
+ 
+diff --git a/openvdb/openvdb/io/Queue.cc b/openvdb/openvdb/io/Queue.cc
+index ef5d2961a..20ff1a0c1 100644
+--- a/openvdb/openvdb/io/Queue.cc
++++ b/openvdb/openvdb/io/Queue.cc
+@@ -5,20 +5,22 @@
+ /// @author Peter Cucka
+ 
+ #include "Queue.h"
+-
+ #include "File.h"
+ #include "Stream.h"
+-#include <openvdb/Exceptions.h>
+-#include <openvdb/util/logging.h>
++#include "openvdb/Exceptions.h"
++#include "openvdb/util/logging.h"
++
+ #include <tbb/concurrent_hash_map.h>
+-#include <tbb/task.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
+-#include <tbb/tick_count.h>
++#include <tbb/task_arena.h>
++
++#include <thread>
+ #include <algorithm> // for std::max()
+ #include <atomic>
+ #include <iostream>
+ #include <map>
+ #include <mutex>
++#include <chrono>
++
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -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
+ 
+ 
+ // 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
+         : 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
+             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<Queue::Id, Queue::Status>;
+ 
+-
+     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::milliseconds>(
++                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;
+ }
+ 
+diff --git a/openvdb/openvdb/math/Coord.h b/openvdb/openvdb/math/Coord.h
+index 504b5e9a4..2e9cfed5d 100644
+--- a/openvdb/openvdb/math/Coord.h
++++ b/openvdb/openvdb/math/Coord.h
+@@ -13,8 +13,7 @@
+ #include "Math.h"
+ #include "Vec3.h"
+ 
+-namespace tbb { class split; } // forward declaration
+-
++#include <tbb/blocked_range.h> // for tbb::split
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+diff --git a/openvdb/openvdb/points/PointSample.h b/openvdb/openvdb/points/PointSample.h
+index a122cc4fb..27ec3fb29 100644
+--- a/openvdb/openvdb/points/PointSample.h
++++ b/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 <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tools/Interpolation.h>
++#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 <sstream>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -299,7 +299,7 @@ class PointDataSampler
+             using TargetHandleT = AttributeWriteHandle<typename SamplerWrapperT::ValueType>;
+ 
+             if (util::wasInterrupted(interrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return;
+             }
+ 
+diff --git a/openvdb/openvdb/thread/Threading.h b/openvdb/openvdb/thread/Threading.h
+new file mode 100644
+index 000000000..0c3b356e3
+--- /dev/null
++++ b/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 <tbb/blocked_range.h>
++#include <tbb/task.h>
++#include <tbb/task_group.h>
++
++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
+diff --git a/openvdb/openvdb/tools/Composite.h b/openvdb/openvdb/tools/Composite.h
+index 6bc170bf7..88ff86f9f 100644
+--- a/openvdb/openvdb/tools/Composite.h
++++ b/openvdb/openvdb/tools/Composite.h
+@@ -24,7 +24,6 @@
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include <type_traits>
+ #include <functional>
+diff --git a/openvdb/openvdb/tools/Diagnostics.h b/openvdb/openvdb/tools/Diagnostics.h
+index 694d2155f..e5844e448 100644
+--- a/openvdb/openvdb/tools/Diagnostics.h
++++ b/openvdb/openvdb/tools/Diagnostics.h
+@@ -11,14 +11,17 @@
+ #ifndef OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ 
+-#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/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 <tbb/blocked_range.h>
+ #include <tbb/parallel_reduce.h>
++
+ #include <cmath> // for std::isnan(), std::isfinite()
+ #include <set>
+ #include <sstream>
+@@ -26,7 +29,6 @@
+ #include <type_traits>
+ #include <vector>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -1160,13 +1162,13 @@ InactiveVoxelValues<TreeType>::operator()(const tbb::blocked_range<size_t>& rang
+ {
+     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<typename TreeType>
+ inline void
+ InactiveTileValues<TreeType>::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();
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/tools/Filter.h b/openvdb/openvdb/tools/Filter.h
+index 408c75541..b70212520 100644
+--- a/openvdb/openvdb/tools/Filter.h
++++ b/openvdb/openvdb/tools/Filter.h
+@@ -14,21 +14,24 @@
+ #ifndef OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ 
+-#include <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
++#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 <tbb/parallel_for.h>
++#include <tbb/concurrent_vector.h>
++
+ #include <algorithm> // for std::max()
+ #include <functional>
+ #include <type_traits>
+-#include <tbb/concurrent_vector.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -833,7 +836,7 @@ inline bool
+ Filter<GridT, MaskT, InterruptT>::wasInterrupted()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return true;
+     }
+     return false;
+diff --git a/openvdb/openvdb/tools/GridOperators.h b/openvdb/openvdb/tools/GridOperators.h
+index 31305a1ab..78fafead9 100644
+--- a/openvdb/openvdb/tools/GridOperators.h
++++ b/openvdb/openvdb/tools/GridOperators.h
+@@ -9,14 +9,15 @@
+ #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/Grid.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
++#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 <tbb/parallel_for.h>
+ 
++#include <tbb/parallel_for.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -383,7 +384,9 @@ class GridOperator
+     /// 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) {
+diff --git a/openvdb/openvdb/tools/LevelSetMeasure.h b/openvdb/openvdb/tools/LevelSetMeasure.h
+index efe19074d..59969cdcf 100644
+--- a/openvdb/openvdb/tools/LevelSetMeasure.h
++++ b/openvdb/openvdb/tools/LevelSetMeasure.h
+@@ -8,18 +8,21 @@
+ #ifndef OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/math/Math.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/Grid.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/math/FiniteDifference.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/math/Stencils.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
+ #include <tbb/parallel_sort.h>
+ #include <tbb/parallel_invoke.h>
++
+ #include <type_traits>
+ 
+ namespace openvdb {
+@@ -329,7 +332,7 @@ inline bool
+ LevelSetMeasure<GridT, InterruptT>::checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/LevelSetTracker.h b/openvdb/openvdb/tools/LevelSetTracker.h
+index cbdc267e8..bfc8004e7 100644
+--- a/openvdb/openvdb/tools/LevelSetTracker.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/tree/LeafManager.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -383,7 +385,7 @@ LevelSetTracker<GridT, InterruptT>::
+ checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/MeshToVolume.h b/openvdb/openvdb/tools/MeshToVolume.h
+index 6643c8f05..de3406eda 100644
+--- a/openvdb/openvdb/tools/MeshToVolume.h
++++ b/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 <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/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 <tbb/parallel_reduce.h>
+ #include <tbb/partitioner.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm> // for std::sort()
+ #include <cmath> // 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<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+@@ -1989,7 +1990,7 @@ class VoxelizePolygons
+         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
+ 
+         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) {
+diff --git a/openvdb/openvdb/tools/Morphology.h b/openvdb/openvdb/tools/Morphology.h
+index 736982ef5..0a1e71009 100644
+--- a/openvdb/openvdb/tools/Morphology.h
++++ b/openvdb/openvdb/tools/Morphology.h
+@@ -24,7 +24,7 @@
+ #include "openvdb/tree/ValueAccessor.h"
+ #include "openvdb/tree/LeafManager.h"
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ 
+@@ -726,7 +726,7 @@ void Morphology<TreeType>::dilateVoxels(const size_t iter,
+         }
+ 
+         // @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
+diff --git a/openvdb/openvdb/tools/ParticlesToLevelSet.h b/openvdb/openvdb/tools/ParticlesToLevelSet.h
+index 739af2b69..f9c19911c 100644
+--- a/openvdb/openvdb/tools/ParticlesToLevelSet.h
++++ b/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 <tbb/parallel_reduce.h>
+-#include <tbb/blocked_range.h>
+-#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/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 <tbb/parallel_reduce.h>
++#include <tbb/blocked_range.h>
++
+ #include <functional>
+ #include <iostream>
+ #include <type_traits>
+@@ -738,7 +742,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         for (Coord c = lo; c.x() <= hi.x(); ++c.x()) {
+             //only check interrupter every 32'th scan in x
+             if (!(count++ & ((1<<5)-1)) && util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Real x2 = math::Pow2(c.x() - P[0]);
+@@ -804,7 +808,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         // Densely fill the remaining regions.
+         for (const auto& bbox: padding) {
+             if (util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Coord &bmin = bbox.min(), &bmax = bbox.max();
+diff --git a/openvdb/openvdb/tools/PointAdvect.h b/openvdb/openvdb/tools/PointAdvect.h
+index 12b1177ad..e487bfb3e 100644
+--- a/openvdb/openvdb/tools/PointAdvect.h
++++ b/openvdb/openvdb/tools/PointAdvect.h
+@@ -10,16 +10,19 @@
+ #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/openvdb.h>
+-#include <openvdb/math/Math.h>             // min
+-#include <openvdb/Types.h>                 // Vec3 types and version number
+-#include <openvdb/Grid.h>                  // grid
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/blocked_range.h>             // threading
+ #include <tbb/parallel_for.h>              // threading
+ #include <tbb/task.h>                      // for cancel
++
+ #include <vector>
+ 
+ 
+@@ -167,7 +170,7 @@ class PointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityFieldIntegrator  velField(*mVelGrid);
+@@ -307,7 +310,7 @@ class ConstrainedPointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityIntegratorType velField(*mVelGrid);
+diff --git a/openvdb/openvdb/tools/PointIndexGrid.h b/openvdb/openvdb/tools/PointIndexGrid.h
+index e9ebf96f7..b2e378a79 100644
+--- a/openvdb/openvdb/tools/PointIndexGrid.h
++++ b/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 <openvdb/version.h>
+@@ -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;
+         }
+ 
+diff --git a/openvdb/openvdb/tools/PointPartitioner.h b/openvdb/openvdb/tools/PointPartitioner.h
+index ccf50ab05..f7f6fc13d 100644
+--- a/openvdb/openvdb/tools/PointPartitioner.h
++++ b/openvdb/openvdb/tools/PointPartitioner.h
+@@ -23,7 +23,7 @@
+ 
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm>
+ #include <cmath> // for std::isfinite()
+@@ -764,7 +764,7 @@ inline void binAndSegment(
+     using IndexPairListMap = std::map<Coord, IndexPairListPtr>;
+     using IndexPairListMapPtr = std::shared_ptr<IndexPairListMap>;
+ 
+-    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;
+ 
+diff --git a/openvdb/openvdb/tools/PointsToMask.h b/openvdb/openvdb/tools/PointsToMask.h
+index 592ab7a15..8a276fb04 100644
+--- a/openvdb/openvdb/tools/PointsToMask.h
++++ b/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 <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/blocked_range.h>
+-#include <openvdb/openvdb.h> // for MaskGrid
+-#include <openvdb/Grid.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/util/NullInterrupter.h>
++
+ #include <vector>
+ 
+ 
+@@ -150,7 +154,7 @@ class PointsToMask
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeAdvect.h b/openvdb/openvdb/tools/VolumeAdvect.h
+index e7eec740e..f38eaa9c2 100644
+--- a/openvdb/openvdb/tools/VolumeAdvect.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/math/Math.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ 
+ 
+@@ -294,7 +297,7 @@ class VolumeAdvection
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeToMesh.h b/openvdb/openvdb/tools/VolumeToMesh.h
+index a834dd3b3..a446f806a 100644
+--- a/openvdb/openvdb/tools/VolumeToMesh.h
++++ b/openvdb/openvdb/tools/VolumeToMesh.h
+@@ -18,7 +18,7 @@
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <cmath> // for std::isfinite()
+ #include <map>
+@@ -388,7 +388,7 @@ inline void
+ fillArray(ValueType* array, const ValueType& val, const size_t length)
+ {
+     const auto grainSize = std::max<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+diff --git a/openvdb/openvdb/unittest/TestCoord.cc b/openvdb/openvdb/unittest/TestCoord.cc
+index be1c24ced..148690041 100644
+--- a/openvdb/openvdb/unittest/TestCoord.cc
++++ b/openvdb/openvdb/unittest/TestCoord.cc
+@@ -2,9 +2,9 @@
+ // SPDX-License-Identifier: MPL-2.0
+ 
+ #include <openvdb/Types.h>
++#include <openvdb/math/Coord.h>
+ 
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_stddef.h> // for tbb::split
+ 
+ #include <unordered_map>
+ #include <sstream>
+diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc
+index 8074166d2..053448f30 100644
+--- a/openvdb/openvdb/unittest/TestFile.cc
++++ b/openvdb/openvdb/unittest/TestFile.cc
+@@ -13,8 +13,11 @@
+ #include <openvdb/version.h>
+ #include <openvdb/openvdb.h>
+ #include "util.h" // for unittest_util::makeSphere()
++
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
++
++#include <thread>
++#include <chrono>
+ #include <algorithm> // for std::sort()
+ #include <cstdio> // for remove() and rename()
+ #include <fstream>
+@@ -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::seconds>(
++                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<io::Queue::Id> 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));
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc
+index 70e7df5f7..6b2204771 100644
+--- a/openvdb/openvdb/unittest/TestUtil.cc
++++ b/openvdb/openvdb/unittest/TestUtil.cc
+@@ -8,7 +8,6 @@
+ 
+ #include <gtest/gtest.h>
+ 
+-#include <tbb/task_scheduler_init.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/blocked_range.h>
+diff --git a/openvdb/openvdb/unittest/TestValueAccessor.cc b/openvdb/openvdb/unittest/TestValueAccessor.cc
+index fd2dd5d81..5c1cbb18b 100644
+--- a/openvdb/openvdb/unittest/TestValueAccessor.cc
++++ b/openvdb/openvdb/unittest/TestValueAccessor.cc
+@@ -6,6 +6,7 @@
+ 
+ #include <gtest/gtest.h>
+ #include <tbb/task.h>
++#include <tbb/task_group.h>
+ 
+ #include <type_traits>
+ 
+@@ -378,22 +379,21 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
+     //using AccessorT = openvdb::tree::ValueAccessor<Tree4Type>;
+ 
+     // 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
+ }
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+index 0e1b4d855..6d9bb528b 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+@@ -20,6 +20,7 @@
+ #include <openvdb/tools/GridTransformer.h>
+ #include <openvdb/tools/PointIndexGrid.h>
+ #include <openvdb/tools/Prune.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <CH/CH_Manager.h>
+ #include <CVEX/CVEX_Context.h>
+@@ -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;
+             }
+ 
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+index 757fdc8c6..dbee74b32 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+@@ -16,13 +16,11 @@
+ #include <openvdb_houdini/SOP_NodeVDB.h>
+ 
+ #include <openvdb/tools/Interpolation.h>  // for box sampler
++#include <openvdb/thread/Threading.h>
+ #include <openvdb/points/PointCount.h>
+ #include <openvdb/points/PointSample.h>
+ #include <openvdb/points/IndexFilter.h>   // for MultiGroupFilter
+ 
+-#include <tbb/tick_count.h>                 // for timing
+-#include <tbb/task.h>                       // for cancel
+-
+ #include <UT/UT_Interrupt.h>
+ #include <GA/GA_PageHandle.h>
+ #include <GA/GA_PageIterator.h>
+@@ -38,6 +36,7 @@
+ #include <stdexcept>
+ #include <string>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ 
+@@ -327,7 +326,7 @@ class PointSampler
+     {
+ 
+         if (mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            openvdb::thread::cancelGroupExecution();
+         }
+         const GridType& grid = UTvdbGridCast<GridType>(mGrid);
+         // task local grid accessor
+@@ -481,7 +480,7 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Context& context)
+         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_Context& context)
+             }
+         }
+ 
+-        // 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::milliseconds>(
++                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;
+         }
+ 
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+index 3d559f8cc..d63ed1591 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
++++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+@@ -47,11 +47,8 @@ struct NodeInfo {
+ 
+ typedef std::vector<NodeInfo> 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, const MTypeId& typeId,
+     node.type               = type;
+     node.classification     = classification;
+ 
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (!gNodes) {
+         OPENVDB_START_THREADSAFE_STATIC_WRITE
+@@ -85,7 +82,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, const MTypeId& typeId,
+ void
+ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+@@ -109,7 +106,7 @@ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ void
+ NodeRegistry::deregisterNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.h b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+index b58bd6f2c..6a04b1eaf 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBUtil.h
++++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+@@ -14,8 +14,7 @@
+ #include <openvdb/tree/LeafManager.h>
+ #include <openvdb/tools/VolumeToMesh.h>
+ #include <openvdb/util/Formats.h> // printBytes
+-
+-#include <tbb/tick_count.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <maya/M3dView.h>
+ #include <maya/MString.h>
+@@ -40,6 +39,7 @@
+ #include <string>
+ #include <type_traits>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ ////////////////////////////////////////
+@@ -116,11 +116,15 @@ insertFrameNumber(std::string& str, const MTime& time, int numberingScheme = 0);
+ 
+ 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::milliseconds>(
++            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<std::chrono::steady_clock> mStamp;
+ };
+ 
+ 
+diff --git a/pendingchanges/tbb2021.txt b/pendingchanges/tbb2021.txt
+new file mode 100644
+index 000000000..8109c2552
+--- /dev/null
++++ b/pendingchanges/tbb2021.txt
+@@ -0,0 +1,6 @@
++Improvements:
++  - Moved from the deprecated TBB task scheduler to TBB arenas. Various methods now respect the TBB arena state they were invoked from.
++  - Introduced a new thread/Threading.h header to consolidate calls to third-party threading methods.
++
++Build:
++  - Added support for TBB 2021.
diff --git a/srcpkgs/openvdb/template b/srcpkgs/openvdb/template
index 72fde5bc6375..d420a3ee5f5d 100644
--- a/srcpkgs/openvdb/template
+++ b/srcpkgs/openvdb/template
@@ -1,26 +1,18 @@
 # Template file for 'openvdb'
 pkgname=openvdb
-version=7.0.0
+version=8.1.0
 revision=1
 build_style=cmake
 configure_args="-DOPENVDB_BUILD_VDB_VIEW=1"
 hostmakedepends="pkg-config"
-makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel glfw-devel"
+makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel
+ glfw-devel jemalloc-devel"
 short_desc="Sparse volume data structure and tools"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MPL-2.0"
 homepage="https://openvdb.org"
 distfiles="https://github.com/AcademySoftwareFoundation/openvdb/archive/v${version}.tar.gz"
-checksum=97bc8ae35ef7ccbf49a4e25cb73e8c2eccae6b235bac86f2150707efcd1e910d
-
-if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
-	makedepends+=" libatomic-devel"
-fi
-
-post_patch() {
-	[ "$XBPS_TARGET_NO_ATOMIC8" ] || return 0
-	vsed -i 's,ZLIB::ZLIB,ZLIB::ZLIB atomic,' openvdb/CMakeLists.txt
-}
+checksum=3e09d47331429be7409a3a3c27fdd3c297f96d31d2153febe194e664a99d6183
 
 post_install() {
 	vlicense LICENSE

From dd7fb24072f86acbcaf6d8de5205bf2111990506 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 10/11] paraview: update to 5.9.1.

---
 srcpkgs/paraview/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/paraview/template b/srcpkgs/paraview/template
index 20a7f5589677..e6c3941ce90a 100644
--- a/srcpkgs/paraview/template
+++ b/srcpkgs/paraview/template
@@ -1,7 +1,7 @@
 # Template file for 'paraview'
 pkgname=paraview
-version=5.8.1
-revision=3
+version=5.9.1
+revision=1
 wrksrc=ParaView-v${version}
 build_style=cmake
 configure_args="-DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr

From b33720b202f0262ae559f2386b181b70e0631ef9 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 11/11] occt: revbump due to tbb update

---
 srcpkgs/occt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/occt/template b/srcpkgs/occt/template
index 9298edc76e08..006f89ebb8ce 100644
--- a/srcpkgs/occt/template
+++ b/srcpkgs/occt/template
@@ -2,7 +2,7 @@
 pkgname=occt
 reverts=7.5.0_1
 version=7.4.0p1
-revision=3
+revision=4
 _gittag="V${version//./_}"
 wrksrc=occt-${_gittag}
 build_style=cmake

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PR PATCH] [Updated] tbb: update to 2021.3.0
  2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
                   ` (2 preceding siblings ...)
  2021-07-24 11:36 ` Logarithmus
@ 2021-07-24 12:32 ` Logarithmus
  2021-07-24 15:06 ` Logarithmus
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Logarithmus @ 2021-07-24 12:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

There is an updated pull request by Logarithmus against master on the void-packages repository

https://github.com/Logarithmus/void-packages tbb-2021
https://github.com/void-linux/void-packages/pull/32166

tbb: update to 2021.3.0
Follow-up of https://github.com/void-linux/void-packages/pull/27746, @thypon & @olafmersmann might be interested.
**TODO** fix reverse dependencies:
- [ ] OpenSubdiv: update to 3.4.4.
- [ ] PrusaSlicer: update to 2.3.3.
- [ ] lender: update to 2.93.1.
- [ ] embree: update to 3.13.0.
- [ ] openimageio: update to 2.2.16.0.
- [ ] openimagedenoise: update to 1.4.1.
- [ ] openvdb: update to 8.1.0.
- [ ] paraview: update to 5.9.1.
- [ ] occt: revbump due to tbb update

#### Have the results of the proposed changes been tested?
- [x] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me


A patch file from https://github.com/void-linux/void-packages/pull/32166.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-tbb-2021-32166.patch --]
[-- Type: text/x-diff, Size: 88609 bytes --]

From 80e56eebd3e7bc6f7b9486f3a7c75dca5ad766fd Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 17 Jul 2021 23:57:52 +0300
Subject: [PATCH 01/11] hwloc: add libpciaccess-devel make dependency

---
 .../patches/00-get-area-memlocation.patch      | 18 ++++++++++++++++++
 srcpkgs/hwloc/template                         |  8 +++++---
 2 files changed, 23 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hwloc/patches/00-get-area-memlocation.patch

diff --git a/srcpkgs/hwloc/patches/00-get-area-memlocation.patch b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
new file mode 100644
index 000000000000..e398a80e046d
--- /dev/null
+++ b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
@@ -0,0 +1,18 @@
+diff --git a/tests/hwloc/hwloc_get_area_memlocation.c b/tests/hwloc/hwloc_get_area_memlocation.c
+index 498dfae..999d95b 100644
+--- a/tests/hwloc/hwloc_get_area_memlocation.c
++++ b/tests/hwloc/hwloc_get_area_memlocation.c
+@@ -34,11 +34,13 @@ int main(void)
+   assert(buffer);
+   printf("buffer %p length %d\n", buffer, LEN);
+ 
++  fprintf(stderr, "Before memloation\nerr == %i, errno == %s\n", err, strerror(errno));
+   err = hwloc_get_area_memlocation(topology, buffer, LEN, set, HWLOC_MEMBIND_BYNODESET);
+   if (err < 0 && errno == ENOSYS) {
+     fprintf(stderr, "hwloc_get_area_memlocation() failed with ENOSYS, aborting\n");
+     goto out_with_buffer;
+   }
++  fprintf(stderr, "After memlocation\nerr == %i, errno == %s\n", err, strerror(errno));
+   assert(!err);
+   hwloc_bitmap_asprintf(&s, set);
+   printf("address %p length %d allocated in nodeset %s\n", buffer, LEN, s);
diff --git a/srcpkgs/hwloc/template b/srcpkgs/hwloc/template
index 818db269cebb..6eec662d0d6e 100644
--- a/srcpkgs/hwloc/template
+++ b/srcpkgs/hwloc/template
@@ -1,10 +1,12 @@
 # Template file for 'hwloc'
 pkgname=hwloc
 version=2.5.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="cairo-devel ncurses-devel libxml2-devel eudev-libudev-devel"
+makedepends="cairo-devel ncurses-devel libxml2-devel libpciaccess-devel eudev-libudev-devel"
+checkdepends="tar"
+make_check_args="VERBOSE=1"
 short_desc="Portable abstraction of hierarchical hardware architectures"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
 license="BSD-3-Clause"
@@ -31,7 +33,7 @@ libhwloc_package() {
 
 libhwloc-devel_package() {
 	short_desc+=" - development files"
-	depends="libhwloc>=${version}_${revision}"
+	depends="${makedepends} libhwloc>=${version}_${revision}"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/share/man/man3

From 14ad1bfa40be1eda08bfe91cc01002ad33830459 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 02:50:26 +0300
Subject: [PATCH 02/11] tbb: update to 2021.3.0.

---
 common/shlibs                                |   6 +-
 srcpkgs/tbb/patches/00-hwloc-2.5.patch       | 367 +++++++++++++++++++
 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch |  52 +++
 srcpkgs/tbb/patches/hostname-usage.patch     |  11 -
 srcpkgs/tbb/patches/musl.patch               |   4 +-
 srcpkgs/tbb/template                         |  63 +---
 6 files changed, 433 insertions(+), 70 deletions(-)
 create mode 100644 srcpkgs/tbb/patches/00-hwloc-2.5.patch
 create mode 100644 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
 delete mode 100644 srcpkgs/tbb/patches/hostname-usage.patch

diff --git a/common/shlibs b/common/shlibs
index a7afbf2a56f7..6b7ca5fbc249 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2376,12 +2376,10 @@ libanthy-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthydic-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthyinput-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthygobject-1.0.so.5 ibus-anthy-1.5.6_1
-libtbbmalloc_proxy_debug.so.2 tbb-4.3_1
 libtbbmalloc_proxy.so.2 tbb-4.3_1
 libtbbmalloc.so.2 tbb-4.3_1
-libtbb_debug.so.2 tbb-4.3_1
-libtbb.so.2 tbb-4.3_1
-libtbbmalloc_debug.so.2 tbb-4.3_1
+libtbb.so.12 tbb-2021.3.0_1
+libtbbbind_2_5.so.3 tbb-2021.3.0_1
 libembree.so.2 embree-2.5.1_1
 libgtkimageview.so.0 gtkimageview-1.6.4_1
 libgoocanvas-2.0.so.9 goocanvas-2.0.4_1
diff --git a/srcpkgs/tbb/patches/00-hwloc-2.5.patch b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
new file mode 100644
index 000000000000..9c4c9285c71d
--- /dev/null
+++ b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
@@ -0,0 +1,367 @@
+Adjusted by Artur Sinila <freesoftware@logarithmus.dev>
+
+From e96dbf4b48e689ab810b0428d0858a6abc2c83bd Mon Sep 17 00:00:00 2001
+From: Ivan Kochin <iv.kochin@gmail.com>
+Date: Thu, 1 Jul 2021 15:07:39 +0300
+Subject: [PATCH] Upgrade from HWLOC 2.4 to HWLOC 2.5 (#448)
+
+* Upgrade from HWLOC 2.4 to HWLOC 2.5
+* Introduce tbbbind_2_5 library
+* Remove tbbbind_2_4 library
+* Use the HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING topology flag (introduces as a part of HWLOC 2.5) to restrict topology discovering to process binding
+* Fix testing on Linux
+* Apply review comments
+* Improve wording: variable -> substring
+* Use right tbbbind version for incompatible hwlocs test
+* Rework option semantic
+* Update README.md for CMake
+* Rework readme
+* Update cmake/README.md
+
+Signed-off-by: Kochin, Ivan <kochin.ivan@intel.com>
+
+Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
+---
+ CMakeLists.txt                         |  3 ++-
+ cmake/README.md                        | 11 +++++---
+ cmake/hwloc_detection.cmake            |  9 ++++---
+ src/tbb/governor.cpp                   |  4 +--
+ src/tbbbind/CMakeLists.txt             |  2 +-
+ src/tbbbind/tbb_bind.cpp               | 23 +++++++++++-----
+ test/CMakeLists.txt                    | 30 ++++++++++-----------
+ test/common/common_arena_constraints.h | 37 ++++++++++++++++++++++----
+ 8 files changed, 82 insertions(+), 37 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 34a23d400..301899aca 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -100,6 +100,7 @@ option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Win
+ option(TBB4PY_BUILD "Enable tbb4py build" OFF)
+ option(TBB_CPF "Enable preview features of the library" OFF)
+ option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
++option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
+ 
+ if (NOT DEFINED BUILD_SHARED_LIBS)
+     set(BUILD_SHARED_LIBS ON)
+@@ -195,7 +196,7 @@ else()
+         add_subdirectory(src/tbbmalloc)
+         add_subdirectory(src/tbbmalloc_proxy)
+         if (APPLE)
+-            message(STATUS "TBBBind build target is disabled due to unsupported environment")
++            message(STATUS "TBBBind build targets are disabled due to unsupported environment")
+         else()
+             add_subdirectory(src/tbbbind)
+         endif()
+diff --git a/cmake/README.md b/cmake/README.md
+index 36fc303f9..b58c2ff6a 100644
+--- a/cmake/README.md
++++ b/cmake/README.md
+@@ -13,6 +13,7 @@ TBB4PY_BUILD:BOOL - Enable  Intel(R) oneAPI Threading Building Blocks (oneTBB) P
+ TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
+ TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
+ TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
++TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)
+ ```
+ 
+ ## Configure, build and test
+@@ -42,9 +43,9 @@ Some useful options:
+ 
+ #### TBBBind library configuration
+ 
+-The TBBbind library has two versions: `tbbbind` and `tbbbind_2_0`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.x.
++The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0` and `tbbbind_2_5`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.1-2.4, `tbbbind_2_5` links with HWLOC 2.5 and later.
+ 
+-To enable the TBBBind library build or special tests that performed inside the HWLOC environment, please specify the following CMake variables:
++The search for a suitable version of the HWLOC library is enabled by default, but if you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
+ 
+  - `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux or path to `.lib` file on Windows.
+  - `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version includes directory.
+@@ -52,7 +53,11 @@ To enable the TBBBind library build or special tests that performed inside the H
+ Windows requires one additional variable for correct TBBBind library building:
+  - `CMAKE_HWLOC_<HWLOC_VER>_DLL_PATH` - path to the corresponding HWLOC version `.dll` file.
+ 
+-`HWLOC_VER` variable used above can be replaced with one of the two values: `1_11` for the `tbbbind` library configuration and `2` for the `tbbbind_2_0` library configuration.
++`HWLOC_VER` substring used above can be replaced with one of the three values: `1_11` for the `tbbbind` library configuration, `2` for the `tbbbind_2_0`, and `2_5` for the `tbbbind_2_5` library configuration.
++
++If you specify variables for several TBBBind versions, then building process for all of these versions will be performed during single build session.
++
++Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
+ 
+ ### Build
+ 
+diff --git a/cmake/hwloc_detection.cmake b/cmake/hwloc_detection.cmake
+index e1eeca5fa..de7f3c047 100644
+--- a/cmake/hwloc_detection.cmake
++++ b/cmake/hwloc_detection.cmake
+@@ -12,7 +12,7 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
+-list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_4)
++list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_5)
+ 
+ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
+     if (NOT WIN32)
+@@ -55,10 +56,10 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
+         if (HWLOC_FOUND)
+             if (HWLOC_VERSION VERSION_LESS 2)
+                 set(TBBBIND_LIBRARY_NAME tbbbind)
+-            elseif(HWLOC_VERSION VERSION_LESS 2.4)
++            elseif(HWLOC_VERSION VERSION_LESS 2.5)
+                 set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
+             else()
+-                set(TBBBIND_LIBRARY_NAME tbbbind_2_4)
++                set(TBBBIND_LIBRARY_NAME tbbbind_2_5)
+             endif()
+         endif()
+     endif()
+diff --git a/src/tbb/governor.cpp b/src/tbb/governor.cpp
+index bf4e402d1..b842e075f 100644
+--- a/src/tbb/governor.cpp
++++ b/src/tbb/governor.cpp
+@@ -362,7 +362,7 @@ static const unsigned LinkTableSize = sizeof(TbbBindLinkTable) / sizeof(dynamic_
+ 
+ #define TBBBIND_NAME LIBRARY_PREFIX "tbbbind" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #define TBBBIND_2_0_NAME LIBRARY_PREFIX "tbbbind_2_0" DEBUG_SUFFIX LIBRARY_EXTENSION
+-#define TBBBIND_2_4_NAME LIBRARY_PREFIX "tbbbind_2_4" DEBUG_SUFFIX LIBRARY_EXTENSION
++#define TBBBIND_2_5_NAME LIBRARY_PREFIX "tbbbind_2_5" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #endif /* _WIN32 || _WIN64 || __linux__ */
+ 
+ // Representation of system hardware topology information on the TBB side.
+@@ -389,7 +389,7 @@ const char* load_tbbbind_shared_object() {
+     GetNativeSystemInfo(&si);
+     if (si.dwNumberOfProcessors > 32) return nullptr;
+ #endif /* _WIN32 && !_WIN64 */
+-    for (const auto& tbbbind_version : {TBBBIND_2_4_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
++    for (const auto& tbbbind_version : {TBBBIND_2_5_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
+         if (dynamic_link(tbbbind_version, TbbBindLinkTable, LinkTableSize)) {
+             return tbbbind_version;
+         }
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index 029893751..e5cdbf8bb 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -99,7 +99,7 @@ if (NOT DEFINED HWLOC_TARGET_EXPLICITLY_DEFINED AND DEFINED HWLOC_LIBRARIES)
+ else()
+     tbbbind_build(tbbbind     HWLOC::hwloc_1_11)
+     tbbbind_build(tbbbind_2_0 HWLOC::hwloc_2   )
+-    tbbbind_build(tbbbind_2_4 HWLOC::hwloc_2_4 )
++    tbbbind_build(tbbbind_2_5 HWLOC::hwloc_2_5 )
+ endif()
+ 
+ 
+diff --git a/src/tbbbind/tbb_bind.cpp b/src/tbbbind/tbb_bind.cpp
+index 97be308c7..88c956acb 100644
+--- a/src/tbbbind/tbb_bind.cpp
++++ b/src/tbbbind/tbb_bind.cpp
+@@ -34,7 +34,8 @@
+ #pragma GCC diagnostic pop
+ #endif
+ 
+-#define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ 
+ // Most of hwloc calls returns negative exit code on error.
+ // This macro tracks error codes that are returned from the hwloc interfaces.
+@@ -85,6 +86,16 @@ class platform_topology {
+         // Parse topology
+         if ( hwloc_topology_init( &topology ) == 0 ) {
+             initialization_state = topology_allocated;
++#if __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++            if ( groups_num == 1 &&
++                 hwloc_topology_set_flags(topology,
++                     HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                     HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
++                 ) != 0
++            ) {
++                return;
++            }
++#endif
+             if ( hwloc_topology_load( topology ) == 0 ) {
+                 initialization_state = topology_loaded;
+             }
+@@ -135,7 +146,7 @@ class platform_topology {
+             numa_indexes_list.resize(numa_nodes_count);
+             hwloc_obj_t node_buffer;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 numa_indexes_list[counter] = static_cast<int>(node_buffer->logical_index);
+ 
+                 if ( numa_indexes_list[counter] > max_numa_index ) {
+@@ -150,7 +161,7 @@ class platform_topology {
+             numa_affinity_masks_list.resize(max_numa_index + 1);
+             int index = 0;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 index = static_cast<int>(node_buffer->logical_index);
+ 
+                 hwloc_cpuset_t& current_mask = numa_affinity_masks_list[index];
+@@ -168,7 +179,7 @@ class platform_topology {
+             core_types_indexes_list.push_back(-1);
+             return;
+         }
+-#if __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
++#if __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
+         __TBB_ASSERT(hwloc_get_api_version() >= 0x20400, "Hybrid CPUs support interfaces required HWLOC >= 2.4");
+         // Parsing the hybrid CPU topology
+         int core_types_number = hwloc_cpukinds_get_nr(topology, 0);
+@@ -196,9 +207,9 @@ class platform_topology {
+                 }
+             }
+         }
+-#else /*!__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#else /*!__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+         bool core_types_parsing_broken{true};
+-#endif /*__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#endif /*__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+ 
+         if (core_types_parsing_broken) {
+             for (auto& core_type_mask : core_types_affinity_masks_list) {
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index bdae9e2b1..c2b9d6dba 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -275,9 +275,9 @@ function(tbb_add_tbbbind_test)
+         FAIL_REGULAR_EXPRESSION "Status:.*FAILURE"
+     )
+ 
+-    if (TARGET HWLOC::hwloc_2_4 AND NOT HWLOC_2_4_TESTS_STATUS_SHOWN)
+-        message(STATUS "HWLOC 2.4 dependent tests were enabled.")
+-        set(HWLOC_2_4_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
++    if (TARGET HWLOC::hwloc_2_5 AND NOT HWLOC_2_5_TESTS_STATUS_SHOWN)
++        message(STATUS "HWLOC 2.5 dependent tests were enabled.")
++        set(HWLOC_2_5_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
+     endif()
+ 
+     if (TARGET HWLOC::hwloc_2 AND NOT HWLOC_2_TESTS_STATUS_SHOWN)
+@@ -291,22 +291,22 @@ function(tbb_add_tbbbind_test)
+     endif()
+ 
+     list(APPEND HWLOC_TEST_CASES
+-        hwloc_2_4
++        hwloc_2_5
+         hwloc_2
+         hwloc_1_11
+-        hwloc_2_4_hwloc_2
+-        hwloc_2_4_hwloc_1_11
++        hwloc_2_5_hwloc_2
++        hwloc_2_5_hwloc_1_11
+         hwloc_2_hwloc_1_11
+-        hwloc_2_4_hwloc_2_hwloc_1_11
++        hwloc_2_5_hwloc_2_hwloc_1_11
+     )
+ 
+-    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_4 "hwloc_2_4")
++    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_5 "hwloc_2_5")
+     list(APPEND HWLOC_TEST_CASE_1_VARS tbbbind_2   "hwloc_2")
+     list(APPEND HWLOC_TEST_CASE_2_VARS tbbbind     "hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2")
+-    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_4 "hwloc_2_4,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2")
++    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_5 "hwloc_2_5,hwloc_1_11")
+     list(APPEND HWLOC_TEST_CASE_5_VARS tbbbind_2   "hwloc_2,hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2,hwloc_1_11")
+ 
+     foreach(TEST_CASE ${HWLOC_TEST_CASES})
+         list(FIND HWLOC_TEST_CASES ${TEST_CASE} TEST_CASE_INDEX)
+@@ -331,7 +331,7 @@ endfunction()
+ # Copy libraries to test folder to make it visible during tests execution if external TBB is tested.
+ # TODO: check and update for multi-config generators.
+ if (TBB_FOUND)
+-    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_4)
++    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_5)
+     foreach(_component ${_tbb_test_components})
+         if (TARGET TBB::${_component})
+             get_property(${_component}_lib_file_location TARGET TBB::${_component} PROPERTY LOCATION)
+@@ -593,6 +593,6 @@ if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
+     tbb_add_test(SUBDIR tbbmalloc NAME test_malloc_new_handler DEPENDENCIES TBB::tbbmalloc_proxy)
+ endif()
+ 
+-unset(HWLOC_2_4_TESTS_STATUS_SHOWN)
++unset(HWLOC_2_5_TESTS_STATUS_SHOWN)
+ unset(HWLOC_2_TESTS_STATUS_SHOWN)
+ unset(HWLOC_1_11_TESTS_STATUS_SHOWN)
+diff --git a/test/common/common_arena_constraints.h b/test/common/common_arena_constraints.h
+index 2a0b1ea97..5efc71082 100644
+--- a/test/common/common_arena_constraints.h
++++ b/test/common/common_arena_constraints.h
+@@ -38,9 +38,26 @@
+ 
+ #if (_WIN32 || _WIN64) && __TBB_HWLOC_VALID_ENVIRONMENT
+ #include <windows.h>
+-int get_processors_groups_count() { return GetActiveProcessorGroupCount(); }
++int get_processors_group_count() {
++    SYSTEM_INFO si;
++    GetNativeSystemInfo(&si);
++    DWORD_PTR pam, sam, m = 1;
++    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
++    int nproc = 0;
++    for ( std::size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
++        if ( pam & m )
++            ++nproc;
++    }
++    // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present
++    if ( nproc == (int)si.dwNumberOfProcessors  ) {
++        // The process does not have restricting affinity mask and multiple processor groups are possible
++        return (int)GetActiveProcessorGroupCount();
++    } else {
++        return 1;
++    }
++}
+ #else
+-int get_processors_groups_count() { return 1; }
++int get_processors_group_count() { return 1; }
+ #endif
+ 
+ //TODO: Write a test that checks for memory leaks during dynamic link/unlink of TBBbind.
+@@ -69,6 +86,7 @@ int get_processors_groups_count() { return 1; }
+ #endif
+ 
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ // At this moment the hybrid CPUs HWLOC interfaces returns unexpected results on some Windows machines
+ // in the 32-bit arch mode.
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_VALID (!_WIN32 || _WIN64)
+@@ -153,9 +171,18 @@ class system_info {
+ 
+     system_info() {
+         hwloc_require_ex(hwloc_topology_init, &topology);
++#if __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++        if ( get_processors_group_count() == 1 ) {
++            REQUIRE(
++                hwloc_topology_set_flags(topology,
++                    HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                    HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING) == 0
++            );
++        }
++#endif
+         hwloc_require_ex(hwloc_topology_load, topology);
+ 
+-        if ( get_processors_groups_count() > 1 ) {
++        if ( get_processors_group_count() > 1 ) {
+             process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
+         } else {
+             process_cpuset = hwloc_bitmap_alloc();
+@@ -434,7 +461,7 @@ system_info::affinity_mask get_arena_affinity(tbb::task_arena& ta) {
+                 barrier.wait();
+                 tbb::spin_mutex::scoped_lock lock(affinity_mutex);
+                 system_info::affinity_mask thread_affinity = system_info::allocate_current_affinity_mask();
+-                if (get_processors_groups_count() == 1) {
++                if (get_processors_group_count() == 1) {
+                     REQUIRE_MESSAGE(hwloc_bitmap_isequal(thread_affinity, arena_affinity),
+                         "Threads have different masks on machine without several processors groups.");
+                 }
+@@ -532,7 +559,7 @@ constraints_container generate_constraints_variety() {
+         }
+ 
+         // Some constraints may cause unexpected behavior, which would be fixed later.
+-        if (get_processors_groups_count() > 1) {
++        if (get_processors_group_count() > 1) {
+             for(auto it = results.begin(); it != results.end(); ++it) {
+                 if (it->max_threads_per_core != tbb::task_arena::automatic
+                    && (it->numa_id == tbb::task_arena::automatic || tbb::info::numa_nodes().size() == 1)
diff --git a/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
new file mode 100644
index 000000000000..279ebc4397cd
--- /dev/null
+++ b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
@@ -0,0 +1,52 @@
+Based on https://github.com/oneapi-src/oneTBB/pull/498
+Tweaked a bit to work on `v2021.3.0`
+
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index e5cdbf8bb..a4033210a 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -37,6 +37,10 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+         ${HWLOC_INCLUDE_DIRS} # pkg-config defined
+     )
++	target_link_directories(${TBBBIND_NAME}
++		PRIVATE
++		${HWLOC_LIBRARY_DIRS} # pkg-config defined
++	)
+ 
+     target_compile_options(${TBBBIND_NAME}
+         PRIVATE
+@@ -69,7 +69,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     else()
+         target_link_libraries(${TBBBIND_NAME}
+@@ -76,7 +76,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     endif()
+ 
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index b768759d5..3eb8357e6 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -258,7 +258,12 @@ function(tbb_add_tbbbind_test)
+         )
+         set_property(
+             TARGET ${_tbbbind_test_NAME}
+-            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARY_DIRS} ${HWLOC_LIBRARIES}
++            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARIES}
++            APPEND
++        )
++        set_property(
++            TARGET ${_tbbbind_test_NAME}
++			PROPERTY LINK_DIRECTORIES ${HWLOC_LIBRARY_DIRS}
+             APPEND
+         )
+         set_property(
diff --git a/srcpkgs/tbb/patches/hostname-usage.patch b/srcpkgs/tbb/patches/hostname-usage.patch
deleted file mode 100644
index 4aefeff192b5..000000000000
--- a/srcpkgs/tbb/patches/hostname-usage.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/build/version_info_linux.sh
-+++ b/build/version_info_linux.sh
-@@ -20,7 +20,7 @@
- 
- # Script used to generate version info string
- echo "#define __TBB_VERSION_STRINGS(N) \\"
--echo '#N": BUILD_HOST'"\t\t"`hostname -s`" ("`uname -m`")"'" ENDL \'
-+echo '#N": BUILD_HOST'"\t\t"`hostname`" ("`uname -m`")"'" ENDL \'
- # find OS name in *-release and issue* files by filtering blank lines and lsb-release content out
- echo '#N": BUILD_OS'"\t\t"`lsb_release -sd 2>/dev/null | grep -ih '[a-z] ' - /etc/*release /etc/issue 2>/dev/null | head -1 | sed -e 's/["\\\\]//g'`'" ENDL \'
- echo '#N": BUILD_KERNEL'"\t"`uname -srv`'" ENDL \'
diff --git a/srcpkgs/tbb/patches/musl.patch b/srcpkgs/tbb/patches/musl.patch
index a8867eb53793..ec89c6a95fc6 100644
--- a/srcpkgs/tbb/patches/musl.patch
+++ b/srcpkgs/tbb/patches/musl.patch
@@ -1,5 +1,5 @@
---- a/src/tbbmalloc/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
-+++ b/src/tbbmalloc/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
+--- a/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
++++ b/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
 @@ -28,6 +28,7 @@
  // of aligned_alloc as required by new C++ standard, this makes it hard to
  // redefine aligned_alloc here. However, running on systems with new libc
diff --git a/srcpkgs/tbb/template b/srcpkgs/tbb/template
index aeef6ebdd061..47655829f744 100644
--- a/srcpkgs/tbb/template
+++ b/srcpkgs/tbb/template
@@ -1,76 +1,33 @@
 # Template file for 'tbb'
 pkgname=tbb
-version=2020.U3
+version=2021.3.0
 revision=1
-# version rewrite: 2017_U7 (upstream) => 2017.7 (xbps)
-_ver=${version/./_}
-wrksrc="oneTBB-${_ver}"
-build_style=gnu-makefile
-hostmakedepends="cmake"
+wrksrc="oneTBB-${version}"
+build_style=cmake
+makedepends="libhwloc-devel libgomp-devel"
 short_desc="Intel Threading Building Blocks"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
 license="Apache-2.0"
 homepage="https://www.threadingbuildingblocks.org"
-distfiles="https://github.com/oneapi-src/oneTBB/archive/${_ver}.tar.gz"
-checksum=2103cc6238c935664f87680618f6684d57501d4a2fa8ea8f6c97ad6ff7dc722a
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*)
-		make_build_args="arch=intel64"
-		;;
-	i686*)
-		make_build_args="arch=ia32"
-		;;
-	armv7l*)
-		make_build_args="arch=armv7"
-		;;
-	aarch64*)
-		make_build_args="arch=arm64"
-		;;
-	ppc64*)
-		make_build_args="arch=ppc64"
-		;;
-	ppc*)
-		make_build_args="arch=ppc32"
-		;;
-	*)
-		# make sure to fall back instead of letting host uname control it
-		make_build_args="arch=generic"
-		;;
-esac
-
-post_extract() {
-	sed -i 's|CPLUS = g..|CPLUS = $(CXX)|g' build/linux.gcc.inc
-	sed -i 's|CONLY = gcc|CONLY = $(CC)|g' build/linux.gcc.inc
+distfiles="https://github.com/oneapi-src/oneTBB/archive/v${version}.tar.gz"
+checksum=8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e
 
+pre_patch() {
 	# alternative might be:
 	# https://git.alpinelinux.org/cgit/aports/tree/testing/libtbb/glibc-struct-mallinfo.patch
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		vsed -e "s@#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__@@" \
-		  -i src/tbbmalloc/proxy.h
+		  -i src/tbbmalloc_proxy/proxy.h
 	fi
 }
 
-do_install() {
-	vmkdir usr/lib
-	vcopy build/linux_*/*.so* usr/lib
-	vmkdir usr/include/tbb
-	vcopy include/tbb/* usr/include/tbb
-
-	cmake \
-		-DINSTALL_DIR=$DESTDIR/usr/lib/cmake/TBB \
-		-DSYSTEM_NAME=Linux \
-		-DLIB_REL_PATH=../.. \
-		-DINC_REL_PATH=../../../include \
-		-P cmake/tbb_config_installer.cmake
-}
-
 tbb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
-		vmove "usr/lib/*.so"
 		vmove usr/lib/cmake
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.so
 	}
 }

From 58ac9ae5d54bd2e3523233976b54cefef4e7f6b7 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 03/11] OpenSubdiv: update to 3.4.4.

---
 srcpkgs/OpenSubdiv/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/OpenSubdiv/template b/srcpkgs/OpenSubdiv/template
index b7a5e16efbcf..dfbf29cc1a52 100644
--- a/srcpkgs/OpenSubdiv/template
+++ b/srcpkgs/OpenSubdiv/template
@@ -1,6 +1,6 @@
 # Template file for 'OpenSubdiv'
 pkgname=OpenSubdiv
-version=3.4.3
+version=3.4.4
 revision=1
 wrksrc="OpenSubdiv-${version//./_}"
 build_style=cmake
@@ -13,7 +13,7 @@ maintainer="John <me@johnnynator.dev>"
 license="Apache-2.0"
 homepage="http://graphics.pixar.com/opensubdiv/docs/intro.html"
 distfiles="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${version//./_}.tar.gz"
-checksum=7b22eb27d636ab0c1e03722c7a5a5bd4f11664ee65c9b48f341a6d0ce7f36745
+checksum=20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" OpenSubdiv"

From 0cce9a9c569c8ead61a5c61995fa4b3c87fe6100 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 04/11] PrusaSlicer: update to 2.3.3.

---
 srcpkgs/PrusaSlicer/patches/cross.patch | 11 -----------
 srcpkgs/PrusaSlicer/template            |  4 ++--
 2 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 srcpkgs/PrusaSlicer/patches/cross.patch

diff --git a/srcpkgs/PrusaSlicer/patches/cross.patch b/srcpkgs/PrusaSlicer/patches/cross.patch
deleted file mode 100644
index d64a450d9e9f..000000000000
--- a/srcpkgs/PrusaSlicer/patches/cross.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/avrdude/CMakeLists.txt	2020-06-04 09:19:26.017251215 +0200
-+++ b/src/avrdude/CMakeLists.txt	2020-06-04 09:19:36.468250771 +0200
-@@ -83,7 +83,7 @@ add_executable(avrdude-conf-gen conf-gen
- add_custom_command(
-     DEPENDS avrdude-conf-gen ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf
-     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
--    COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-+    COMMAND avrdude-conf-gen avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- 
diff --git a/srcpkgs/PrusaSlicer/template b/srcpkgs/PrusaSlicer/template
index dd0e76cb8017..a93832ac02e4 100644
--- a/srcpkgs/PrusaSlicer/template
+++ b/srcpkgs/PrusaSlicer/template
@@ -1,6 +1,6 @@
 # Template file for 'PrusaSlicer'
 pkgname=PrusaSlicer
-version=2.3.0
+version=2.3.3
 revision=1
 wrksrc="PrusaSlicer-version_${version}"
 build_style=cmake
@@ -16,7 +16,7 @@ maintainer="Jasper Chan <jasperchan515@gmail.com>"
 license="GPL-3.0-or-later"
 homepage="https://www.prusa3d.com/prusaslicer/"
 distfiles="https://github.com/prusa3d/Prusaslicer/archive/version_${version}.tar.gz"
-checksum=cd3bac5e29b5441fc4690f28cd7b1064e97dc00207bbdc88f7bd7832308d6ca5
+checksum=deda209505f740ac3d6f59cb2a960f4df908269ee09bd30cd4edb9fc472d29ac
 nocross="https://build.voidlinux.org/builders/armv7l_builder/builds/25230/steps/shell_3/logs/stdio"
 
 Slic3rPE_package() {

From 6e51deb8106170ac686ebfd2205f6d89524968ad Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 05/11] blender: update to 2.93.1.

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index af946c2b7999..8318317c82bf 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,6 +1,6 @@
 # Template file for 'blender'
 pkgname=blender
-version=2.93.0
+version=2.93.1
 revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"

From 9c32dd199aad6d41af4197a4cdedcb3d05b136fd Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 06/11] embree: update to 3.13.0.

---
 srcpkgs/embree/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/embree/template b/srcpkgs/embree/template
index 575b9bcb401c..b6f376d30efa 100644
--- a/srcpkgs/embree/template
+++ b/srcpkgs/embree/template
@@ -1,8 +1,8 @@
 # Template file for 'embree'
 pkgname=embree
-version=2.17.7
-revision=2
-archs="x86_64"
+version=3.13.0
+revision=1
+archs="x86_64*"
 build_style=cmake
 configure_args="-DTBB_ROOT=/usr -DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF"
 hostmakedepends="ispc"

From c7ee6b56ca53aee247edf115de88f3181b96c2bd Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 03:34:43 +0300
Subject: [PATCH 07/11] openimageio: update to 2.2.16.0.

---
 srcpkgs/openimageio/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index de8e1cd04409..3bfdd4e0ed1e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,11 +1,11 @@
 # Template file for 'openimageio'
 pkgname=openimageio
-version=2.2.15.1
+version=2.2.16.0
 revision=1
 wrksrc="oiio-Release-${version}"
 build_style=cmake
 configure_args="-DUSE_OPENGL=0 -DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=1
- -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0"
+ -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0 -DCMAKE_CXX_STANDARD=14"
 hostmakedepends="pkg-config git"
 makedepends="boost-devel giflib-devel libraw-devel libopenjpeg-devel libwebp-devel
  libjpeg-turbo-devel tiff-devel libpng-devel libopenexr-devel freetype-devel
@@ -17,7 +17,7 @@ license="BSD-3-Clause"
 homepage="https://sites.google.com/site/openimageio/home"
 changelog="https://raw.githubusercontent.com/OpenImageIO/oiio/release/CHANGES.md"
 distfiles="https://github.com/OpenImageIO/oiio/archive/Release-${version}.tar.gz"
-checksum=f222c6b51a40aabbc80ddf4055535be9af1ffa907452fa6d1ffa7674854aab17
+checksum=d1a59f32dbba3ba71ad2e62e107034d1c5287bca1b0696474e927d504cd05ef4
 # Runs checks even for features we disabled.
 make_check=no
 

From 749df30055fcbdae12bdad23247bef55f9f9ee14 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 08/11] openimagedenoise: update to 1.4.1.

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index c73913b4e9d7..14055aff1c27 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,6 +1,6 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
-version=1.4.0
+version=1.4.1
 revision=1
 archs="x86_64*"
 wrksrc=oidn-${version}

From e30cd818f3f1d503a5efd5ec5bab1dc9c64794a5 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 09/11] openvdb: update to 8.1.0.

---
 common/shlibs                             |    2 +-
 srcpkgs/openvdb/patches/00-tbb-2021.patch | 1320 +++++++++++++++++++++
 srcpkgs/openvdb/template                  |   16 +-
 3 files changed, 1325 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/openvdb/patches/00-tbb-2021.patch

diff --git a/common/shlibs b/common/shlibs
index 6b7ca5fbc249..2a7acdb253a7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3883,7 +3883,7 @@ libjanet.so.1.16 janet-1.16.0_1
 libOpenImageDenoise.so.1 openimagedenoise-1.3.0_1
 libcbang0.so cbang-1.6.0_3
 libblosc.so.1 c-blosc-1.17.1_1
-libopenvdb.so.7.0 openvdb-7.0.0_1
+libopenvdb.so.8.1 openvdb-8.1.0_1
 libAlembic.so.1.7 alembic-1.7.13_1
 libmodsecurity.so.3 modsecurity-3.0.4_1
 libraven.so.0 budgie-desktop-10.5.1_1
diff --git a/srcpkgs/openvdb/patches/00-tbb-2021.patch b/srcpkgs/openvdb/patches/00-tbb-2021.patch
new file mode 100644
index 000000000000..271104af3df9
--- /dev/null
+++ b/srcpkgs/openvdb/patches/00-tbb-2021.patch
@@ -0,0 +1,1320 @@
+https://github.com/AcademySoftwareFoundation/openvdb/pull/1027
+Should be dropped after 8.1.1 release.
+
+diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake
+index d41436b1c..06de2b3f3 100644
+--- a/cmake/FindTBB.cmake
++++ b/cmake/FindTBB.cmake
+@@ -169,8 +169,22 @@ find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
+   PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
+ )
+ 
+-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" ""
+@@ -178,7 +192,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" ""
+@@ -192,6 +206,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
+ # ------------------------------------------------------------------------
+diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt
+index 88543df3a..929fe94d1 100644
+--- a/openvdb/openvdb/CMakeLists.txt
++++ b/openvdb/openvdb/CMakeLists.txt
+@@ -437,6 +437,10 @@ set(OPENVDB_LIBRARY_UTIL_INCLUDE_FILES
+   util/Util.h
+ )
+ 
++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} DESTINATION ${OPENVDB_INST
+ 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)
+diff --git a/openvdb/openvdb/cmd/openvdb_render.cc b/openvdb/openvdb/cmd/openvdb_render.cc
+index ee5b737c5..2c9831ba3 100644
+--- a/openvdb/openvdb/cmd/openvdb_render.cc
++++ b/openvdb/openvdb/cmd/openvdb_render.cc
+@@ -19,7 +19,14 @@
+ #include <OpenEXR/ImfHeader.h>
+ #include <OpenEXR/ImfOutputFile.h>
+ #include <OpenEXR/ImfPixelType.h>
+-#include <tbb/task_scheduler_init.h>
++
++// 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 <tbb/global_control.h>
+ #include <tbb/tick_count.h>
+ 
+ #include <algorithm>
+@@ -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<tbb::global_control> 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();
+ 
+diff --git a/openvdb/openvdb/io/Queue.cc b/openvdb/openvdb/io/Queue.cc
+index ef5d2961a..20ff1a0c1 100644
+--- a/openvdb/openvdb/io/Queue.cc
++++ b/openvdb/openvdb/io/Queue.cc
+@@ -5,20 +5,22 @@
+ /// @author Peter Cucka
+ 
+ #include "Queue.h"
+-
+ #include "File.h"
+ #include "Stream.h"
+-#include <openvdb/Exceptions.h>
+-#include <openvdb/util/logging.h>
++#include "openvdb/Exceptions.h"
++#include "openvdb/util/logging.h"
++
+ #include <tbb/concurrent_hash_map.h>
+-#include <tbb/task.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
+-#include <tbb/tick_count.h>
++#include <tbb/task_arena.h>
++
++#include <thread>
+ #include <algorithm> // for std::max()
+ #include <atomic>
+ #include <iostream>
+ #include <map>
+ #include <mutex>
++#include <chrono>
++
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -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
+ 
+ 
+ // 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
+         : 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
+             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<Queue::Id, Queue::Status>;
+ 
+-
+     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::milliseconds>(
++                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;
+ }
+ 
+diff --git a/openvdb/openvdb/math/Coord.h b/openvdb/openvdb/math/Coord.h
+index 504b5e9a4..2e9cfed5d 100644
+--- a/openvdb/openvdb/math/Coord.h
++++ b/openvdb/openvdb/math/Coord.h
+@@ -13,8 +13,7 @@
+ #include "Math.h"
+ #include "Vec3.h"
+ 
+-namespace tbb { class split; } // forward declaration
+-
++#include <tbb/blocked_range.h> // for tbb::split
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+diff --git a/openvdb/openvdb/points/PointSample.h b/openvdb/openvdb/points/PointSample.h
+index a122cc4fb..27ec3fb29 100644
+--- a/openvdb/openvdb/points/PointSample.h
++++ b/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 <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tools/Interpolation.h>
++#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 <sstream>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -299,7 +299,7 @@ class PointDataSampler
+             using TargetHandleT = AttributeWriteHandle<typename SamplerWrapperT::ValueType>;
+ 
+             if (util::wasInterrupted(interrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return;
+             }
+ 
+diff --git a/openvdb/openvdb/thread/Threading.h b/openvdb/openvdb/thread/Threading.h
+new file mode 100644
+index 000000000..0c3b356e3
+--- /dev/null
++++ b/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 <tbb/blocked_range.h>
++#include <tbb/task.h>
++#include <tbb/task_group.h>
++
++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
+diff --git a/openvdb/openvdb/tools/Composite.h b/openvdb/openvdb/tools/Composite.h
+index 6bc170bf7..88ff86f9f 100644
+--- a/openvdb/openvdb/tools/Composite.h
++++ b/openvdb/openvdb/tools/Composite.h
+@@ -24,7 +24,6 @@
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include <type_traits>
+ #include <functional>
+diff --git a/openvdb/openvdb/tools/Diagnostics.h b/openvdb/openvdb/tools/Diagnostics.h
+index 694d2155f..e5844e448 100644
+--- a/openvdb/openvdb/tools/Diagnostics.h
++++ b/openvdb/openvdb/tools/Diagnostics.h
+@@ -11,14 +11,17 @@
+ #ifndef OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ 
+-#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/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 <tbb/blocked_range.h>
+ #include <tbb/parallel_reduce.h>
++
+ #include <cmath> // for std::isnan(), std::isfinite()
+ #include <set>
+ #include <sstream>
+@@ -26,7 +29,6 @@
+ #include <type_traits>
+ #include <vector>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -1160,13 +1162,13 @@ InactiveVoxelValues<TreeType>::operator()(const tbb::blocked_range<size_t>& rang
+ {
+     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<typename TreeType>
+ inline void
+ InactiveTileValues<TreeType>::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();
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/tools/Filter.h b/openvdb/openvdb/tools/Filter.h
+index 408c75541..b70212520 100644
+--- a/openvdb/openvdb/tools/Filter.h
++++ b/openvdb/openvdb/tools/Filter.h
+@@ -14,21 +14,24 @@
+ #ifndef OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ 
+-#include <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
++#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 <tbb/parallel_for.h>
++#include <tbb/concurrent_vector.h>
++
+ #include <algorithm> // for std::max()
+ #include <functional>
+ #include <type_traits>
+-#include <tbb/concurrent_vector.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -833,7 +836,7 @@ inline bool
+ Filter<GridT, MaskT, InterruptT>::wasInterrupted()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return true;
+     }
+     return false;
+diff --git a/openvdb/openvdb/tools/GridOperators.h b/openvdb/openvdb/tools/GridOperators.h
+index 31305a1ab..78fafead9 100644
+--- a/openvdb/openvdb/tools/GridOperators.h
++++ b/openvdb/openvdb/tools/GridOperators.h
+@@ -9,14 +9,15 @@
+ #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/Grid.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
++#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 <tbb/parallel_for.h>
+ 
++#include <tbb/parallel_for.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -383,7 +384,9 @@ class GridOperator
+     /// 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) {
+diff --git a/openvdb/openvdb/tools/LevelSetMeasure.h b/openvdb/openvdb/tools/LevelSetMeasure.h
+index efe19074d..59969cdcf 100644
+--- a/openvdb/openvdb/tools/LevelSetMeasure.h
++++ b/openvdb/openvdb/tools/LevelSetMeasure.h
+@@ -8,18 +8,21 @@
+ #ifndef OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/math/Math.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/Grid.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/math/FiniteDifference.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/math/Stencils.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
+ #include <tbb/parallel_sort.h>
+ #include <tbb/parallel_invoke.h>
++
+ #include <type_traits>
+ 
+ namespace openvdb {
+@@ -329,7 +332,7 @@ inline bool
+ LevelSetMeasure<GridT, InterruptT>::checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/LevelSetTracker.h b/openvdb/openvdb/tools/LevelSetTracker.h
+index cbdc267e8..bfc8004e7 100644
+--- a/openvdb/openvdb/tools/LevelSetTracker.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/tree/LeafManager.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -383,7 +385,7 @@ LevelSetTracker<GridT, InterruptT>::
+ checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/MeshToVolume.h b/openvdb/openvdb/tools/MeshToVolume.h
+index 6643c8f05..de3406eda 100644
+--- a/openvdb/openvdb/tools/MeshToVolume.h
++++ b/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 <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/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 <tbb/parallel_reduce.h>
+ #include <tbb/partitioner.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm> // for std::sort()
+ #include <cmath> // 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<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+@@ -1989,7 +1990,7 @@ class VoxelizePolygons
+         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
+ 
+         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) {
+diff --git a/openvdb/openvdb/tools/Morphology.h b/openvdb/openvdb/tools/Morphology.h
+index 736982ef5..0a1e71009 100644
+--- a/openvdb/openvdb/tools/Morphology.h
++++ b/openvdb/openvdb/tools/Morphology.h
+@@ -24,7 +24,7 @@
+ #include "openvdb/tree/ValueAccessor.h"
+ #include "openvdb/tree/LeafManager.h"
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ 
+@@ -726,7 +726,7 @@ void Morphology<TreeType>::dilateVoxels(const size_t iter,
+         }
+ 
+         // @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
+diff --git a/openvdb/openvdb/tools/ParticlesToLevelSet.h b/openvdb/openvdb/tools/ParticlesToLevelSet.h
+index 739af2b69..f9c19911c 100644
+--- a/openvdb/openvdb/tools/ParticlesToLevelSet.h
++++ b/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 <tbb/parallel_reduce.h>
+-#include <tbb/blocked_range.h>
+-#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/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 <tbb/parallel_reduce.h>
++#include <tbb/blocked_range.h>
++
+ #include <functional>
+ #include <iostream>
+ #include <type_traits>
+@@ -738,7 +742,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         for (Coord c = lo; c.x() <= hi.x(); ++c.x()) {
+             //only check interrupter every 32'th scan in x
+             if (!(count++ & ((1<<5)-1)) && util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Real x2 = math::Pow2(c.x() - P[0]);
+@@ -804,7 +808,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         // Densely fill the remaining regions.
+         for (const auto& bbox: padding) {
+             if (util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Coord &bmin = bbox.min(), &bmax = bbox.max();
+diff --git a/openvdb/openvdb/tools/PointAdvect.h b/openvdb/openvdb/tools/PointAdvect.h
+index 12b1177ad..e487bfb3e 100644
+--- a/openvdb/openvdb/tools/PointAdvect.h
++++ b/openvdb/openvdb/tools/PointAdvect.h
+@@ -10,16 +10,19 @@
+ #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/openvdb.h>
+-#include <openvdb/math/Math.h>             // min
+-#include <openvdb/Types.h>                 // Vec3 types and version number
+-#include <openvdb/Grid.h>                  // grid
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/blocked_range.h>             // threading
+ #include <tbb/parallel_for.h>              // threading
+ #include <tbb/task.h>                      // for cancel
++
+ #include <vector>
+ 
+ 
+@@ -167,7 +170,7 @@ class PointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityFieldIntegrator  velField(*mVelGrid);
+@@ -307,7 +310,7 @@ class ConstrainedPointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityIntegratorType velField(*mVelGrid);
+diff --git a/openvdb/openvdb/tools/PointIndexGrid.h b/openvdb/openvdb/tools/PointIndexGrid.h
+index e9ebf96f7..b2e378a79 100644
+--- a/openvdb/openvdb/tools/PointIndexGrid.h
++++ b/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 <openvdb/version.h>
+@@ -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;
+         }
+ 
+diff --git a/openvdb/openvdb/tools/PointPartitioner.h b/openvdb/openvdb/tools/PointPartitioner.h
+index ccf50ab05..f7f6fc13d 100644
+--- a/openvdb/openvdb/tools/PointPartitioner.h
++++ b/openvdb/openvdb/tools/PointPartitioner.h
+@@ -23,7 +23,7 @@
+ 
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm>
+ #include <cmath> // for std::isfinite()
+@@ -764,7 +764,7 @@ inline void binAndSegment(
+     using IndexPairListMap = std::map<Coord, IndexPairListPtr>;
+     using IndexPairListMapPtr = std::shared_ptr<IndexPairListMap>;
+ 
+-    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;
+ 
+diff --git a/openvdb/openvdb/tools/PointsToMask.h b/openvdb/openvdb/tools/PointsToMask.h
+index 592ab7a15..8a276fb04 100644
+--- a/openvdb/openvdb/tools/PointsToMask.h
++++ b/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 <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/blocked_range.h>
+-#include <openvdb/openvdb.h> // for MaskGrid
+-#include <openvdb/Grid.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/util/NullInterrupter.h>
++
+ #include <vector>
+ 
+ 
+@@ -150,7 +154,7 @@ class PointsToMask
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeAdvect.h b/openvdb/openvdb/tools/VolumeAdvect.h
+index e7eec740e..f38eaa9c2 100644
+--- a/openvdb/openvdb/tools/VolumeAdvect.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/math/Math.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ 
+ 
+@@ -294,7 +297,7 @@ class VolumeAdvection
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeToMesh.h b/openvdb/openvdb/tools/VolumeToMesh.h
+index a834dd3b3..a446f806a 100644
+--- a/openvdb/openvdb/tools/VolumeToMesh.h
++++ b/openvdb/openvdb/tools/VolumeToMesh.h
+@@ -18,7 +18,7 @@
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <cmath> // for std::isfinite()
+ #include <map>
+@@ -388,7 +388,7 @@ inline void
+ fillArray(ValueType* array, const ValueType& val, const size_t length)
+ {
+     const auto grainSize = std::max<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+diff --git a/openvdb/openvdb/unittest/TestCoord.cc b/openvdb/openvdb/unittest/TestCoord.cc
+index be1c24ced..148690041 100644
+--- a/openvdb/openvdb/unittest/TestCoord.cc
++++ b/openvdb/openvdb/unittest/TestCoord.cc
+@@ -2,9 +2,9 @@
+ // SPDX-License-Identifier: MPL-2.0
+ 
+ #include <openvdb/Types.h>
++#include <openvdb/math/Coord.h>
+ 
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_stddef.h> // for tbb::split
+ 
+ #include <unordered_map>
+ #include <sstream>
+diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc
+index 8074166d2..053448f30 100644
+--- a/openvdb/openvdb/unittest/TestFile.cc
++++ b/openvdb/openvdb/unittest/TestFile.cc
+@@ -13,8 +13,11 @@
+ #include <openvdb/version.h>
+ #include <openvdb/openvdb.h>
+ #include "util.h" // for unittest_util::makeSphere()
++
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
++
++#include <thread>
++#include <chrono>
+ #include <algorithm> // for std::sort()
+ #include <cstdio> // for remove() and rename()
+ #include <fstream>
+@@ -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::seconds>(
++                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<io::Queue::Id> 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));
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc
+index 70e7df5f7..6b2204771 100644
+--- a/openvdb/openvdb/unittest/TestUtil.cc
++++ b/openvdb/openvdb/unittest/TestUtil.cc
+@@ -8,7 +8,6 @@
+ 
+ #include <gtest/gtest.h>
+ 
+-#include <tbb/task_scheduler_init.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/blocked_range.h>
+diff --git a/openvdb/openvdb/unittest/TestValueAccessor.cc b/openvdb/openvdb/unittest/TestValueAccessor.cc
+index fd2dd5d81..5c1cbb18b 100644
+--- a/openvdb/openvdb/unittest/TestValueAccessor.cc
++++ b/openvdb/openvdb/unittest/TestValueAccessor.cc
+@@ -6,6 +6,7 @@
+ 
+ #include <gtest/gtest.h>
+ #include <tbb/task.h>
++#include <tbb/task_group.h>
+ 
+ #include <type_traits>
+ 
+@@ -378,22 +379,21 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
+     //using AccessorT = openvdb::tree::ValueAccessor<Tree4Type>;
+ 
+     // 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
+ }
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+index 0e1b4d855..6d9bb528b 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+@@ -20,6 +20,7 @@
+ #include <openvdb/tools/GridTransformer.h>
+ #include <openvdb/tools/PointIndexGrid.h>
+ #include <openvdb/tools/Prune.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <CH/CH_Manager.h>
+ #include <CVEX/CVEX_Context.h>
+@@ -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;
+             }
+ 
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+index 757fdc8c6..dbee74b32 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+@@ -16,13 +16,11 @@
+ #include <openvdb_houdini/SOP_NodeVDB.h>
+ 
+ #include <openvdb/tools/Interpolation.h>  // for box sampler
++#include <openvdb/thread/Threading.h>
+ #include <openvdb/points/PointCount.h>
+ #include <openvdb/points/PointSample.h>
+ #include <openvdb/points/IndexFilter.h>   // for MultiGroupFilter
+ 
+-#include <tbb/tick_count.h>                 // for timing
+-#include <tbb/task.h>                       // for cancel
+-
+ #include <UT/UT_Interrupt.h>
+ #include <GA/GA_PageHandle.h>
+ #include <GA/GA_PageIterator.h>
+@@ -38,6 +36,7 @@
+ #include <stdexcept>
+ #include <string>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ 
+@@ -327,7 +326,7 @@ class PointSampler
+     {
+ 
+         if (mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            openvdb::thread::cancelGroupExecution();
+         }
+         const GridType& grid = UTvdbGridCast<GridType>(mGrid);
+         // task local grid accessor
+@@ -481,7 +480,7 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Context& context)
+         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_Context& context)
+             }
+         }
+ 
+-        // 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::milliseconds>(
++                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;
+         }
+ 
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+index 3d559f8cc..d63ed1591 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
++++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+@@ -47,11 +47,8 @@ struct NodeInfo {
+ 
+ typedef std::vector<NodeInfo> 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, const MTypeId& typeId,
+     node.type               = type;
+     node.classification     = classification;
+ 
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (!gNodes) {
+         OPENVDB_START_THREADSAFE_STATIC_WRITE
+@@ -85,7 +82,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, const MTypeId& typeId,
+ void
+ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+@@ -109,7 +106,7 @@ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ void
+ NodeRegistry::deregisterNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.h b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+index b58bd6f2c..6a04b1eaf 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBUtil.h
++++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+@@ -14,8 +14,7 @@
+ #include <openvdb/tree/LeafManager.h>
+ #include <openvdb/tools/VolumeToMesh.h>
+ #include <openvdb/util/Formats.h> // printBytes
+-
+-#include <tbb/tick_count.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <maya/M3dView.h>
+ #include <maya/MString.h>
+@@ -40,6 +39,7 @@
+ #include <string>
+ #include <type_traits>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ ////////////////////////////////////////
+@@ -116,11 +116,15 @@ insertFrameNumber(std::string& str, const MTime& time, int numberingScheme = 0);
+ 
+ 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::milliseconds>(
++            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<std::chrono::steady_clock> mStamp;
+ };
+ 
+ 
+diff --git a/pendingchanges/tbb2021.txt b/pendingchanges/tbb2021.txt
+new file mode 100644
+index 000000000..8109c2552
+--- /dev/null
++++ b/pendingchanges/tbb2021.txt
+@@ -0,0 +1,6 @@
++Improvements:
++  - Moved from the deprecated TBB task scheduler to TBB arenas. Various methods now respect the TBB arena state they were invoked from.
++  - Introduced a new thread/Threading.h header to consolidate calls to third-party threading methods.
++
++Build:
++  - Added support for TBB 2021.
diff --git a/srcpkgs/openvdb/template b/srcpkgs/openvdb/template
index 72fde5bc6375..d420a3ee5f5d 100644
--- a/srcpkgs/openvdb/template
+++ b/srcpkgs/openvdb/template
@@ -1,26 +1,18 @@
 # Template file for 'openvdb'
 pkgname=openvdb
-version=7.0.0
+version=8.1.0
 revision=1
 build_style=cmake
 configure_args="-DOPENVDB_BUILD_VDB_VIEW=1"
 hostmakedepends="pkg-config"
-makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel glfw-devel"
+makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel
+ glfw-devel jemalloc-devel"
 short_desc="Sparse volume data structure and tools"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MPL-2.0"
 homepage="https://openvdb.org"
 distfiles="https://github.com/AcademySoftwareFoundation/openvdb/archive/v${version}.tar.gz"
-checksum=97bc8ae35ef7ccbf49a4e25cb73e8c2eccae6b235bac86f2150707efcd1e910d
-
-if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
-	makedepends+=" libatomic-devel"
-fi
-
-post_patch() {
-	[ "$XBPS_TARGET_NO_ATOMIC8" ] || return 0
-	vsed -i 's,ZLIB::ZLIB,ZLIB::ZLIB atomic,' openvdb/CMakeLists.txt
-}
+checksum=3e09d47331429be7409a3a3c27fdd3c297f96d31d2153febe194e664a99d6183
 
 post_install() {
 	vlicense LICENSE

From 2e8bbc914059136d80d389577aed357a9af4672d Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 10/11] paraview: update to 5.9.1.

---
 srcpkgs/paraview/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/paraview/template b/srcpkgs/paraview/template
index 20a7f5589677..e6c3941ce90a 100644
--- a/srcpkgs/paraview/template
+++ b/srcpkgs/paraview/template
@@ -1,7 +1,7 @@
 # Template file for 'paraview'
 pkgname=paraview
-version=5.8.1
-revision=3
+version=5.9.1
+revision=1
 wrksrc=ParaView-v${version}
 build_style=cmake
 configure_args="-DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr

From 3e3eef017eebd9aa1f5627c0b4657b92e54cab9c Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 11/11] occt: revbump due to tbb update

---
 srcpkgs/occt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/occt/template b/srcpkgs/occt/template
index 9298edc76e08..006f89ebb8ce 100644
--- a/srcpkgs/occt/template
+++ b/srcpkgs/occt/template
@@ -2,7 +2,7 @@
 pkgname=occt
 reverts=7.5.0_1
 version=7.4.0p1
-revision=3
+revision=4
 _gittag="V${version//./_}"
 wrksrc=occt-${_gittag}
 build_style=cmake

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PR PATCH] [Updated] tbb: update to 2021.3.0
  2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
                   ` (3 preceding siblings ...)
  2021-07-24 12:32 ` Logarithmus
@ 2021-07-24 15:06 ` Logarithmus
  2021-07-24 15:32 ` Logarithmus
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Logarithmus @ 2021-07-24 15:06 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

There is an updated pull request by Logarithmus against master on the void-packages repository

https://github.com/Logarithmus/void-packages tbb-2021
https://github.com/void-linux/void-packages/pull/32166

tbb: update to 2021.3.0
Follow-up of https://github.com/void-linux/void-packages/pull/27746, @thypon & @olafmersmann might be interested.
**TODO** fix reverse dependencies:
- [ ] OpenSubdiv: update to 3.4.4.
- [ ] PrusaSlicer: update to 2.3.3.
- [ ] lender: update to 2.93.1.
- [ ] embree: update to 3.13.0.
- [ ] openimageio: update to 2.2.16.0.
- [ ] openimagedenoise: update to 1.4.1.
- [ ] openvdb: update to 8.1.0.
- [ ] paraview: update to 5.9.1.
- [ ] occt: revbump due to tbb update

#### Have the results of the proposed changes been tested?
- [x] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me


A patch file from https://github.com/void-linux/void-packages/pull/32166.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-tbb-2021-32166.patch --]
[-- Type: text/x-diff, Size: 90108 bytes --]

From 80e56eebd3e7bc6f7b9486f3a7c75dca5ad766fd Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 17 Jul 2021 23:57:52 +0300
Subject: [PATCH 01/12] hwloc: add libpciaccess-devel make dependency

---
 .../patches/00-get-area-memlocation.patch      | 18 ++++++++++++++++++
 srcpkgs/hwloc/template                         |  8 +++++---
 2 files changed, 23 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hwloc/patches/00-get-area-memlocation.patch

diff --git a/srcpkgs/hwloc/patches/00-get-area-memlocation.patch b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
new file mode 100644
index 000000000000..e398a80e046d
--- /dev/null
+++ b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
@@ -0,0 +1,18 @@
+diff --git a/tests/hwloc/hwloc_get_area_memlocation.c b/tests/hwloc/hwloc_get_area_memlocation.c
+index 498dfae..999d95b 100644
+--- a/tests/hwloc/hwloc_get_area_memlocation.c
++++ b/tests/hwloc/hwloc_get_area_memlocation.c
+@@ -34,11 +34,13 @@ int main(void)
+   assert(buffer);
+   printf("buffer %p length %d\n", buffer, LEN);
+ 
++  fprintf(stderr, "Before memloation\nerr == %i, errno == %s\n", err, strerror(errno));
+   err = hwloc_get_area_memlocation(topology, buffer, LEN, set, HWLOC_MEMBIND_BYNODESET);
+   if (err < 0 && errno == ENOSYS) {
+     fprintf(stderr, "hwloc_get_area_memlocation() failed with ENOSYS, aborting\n");
+     goto out_with_buffer;
+   }
++  fprintf(stderr, "After memlocation\nerr == %i, errno == %s\n", err, strerror(errno));
+   assert(!err);
+   hwloc_bitmap_asprintf(&s, set);
+   printf("address %p length %d allocated in nodeset %s\n", buffer, LEN, s);
diff --git a/srcpkgs/hwloc/template b/srcpkgs/hwloc/template
index 818db269cebb..6eec662d0d6e 100644
--- a/srcpkgs/hwloc/template
+++ b/srcpkgs/hwloc/template
@@ -1,10 +1,12 @@
 # Template file for 'hwloc'
 pkgname=hwloc
 version=2.5.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="cairo-devel ncurses-devel libxml2-devel eudev-libudev-devel"
+makedepends="cairo-devel ncurses-devel libxml2-devel libpciaccess-devel eudev-libudev-devel"
+checkdepends="tar"
+make_check_args="VERBOSE=1"
 short_desc="Portable abstraction of hierarchical hardware architectures"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
 license="BSD-3-Clause"
@@ -31,7 +33,7 @@ libhwloc_package() {
 
 libhwloc-devel_package() {
 	short_desc+=" - development files"
-	depends="libhwloc>=${version}_${revision}"
+	depends="${makedepends} libhwloc>=${version}_${revision}"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/share/man/man3

From 14ad1bfa40be1eda08bfe91cc01002ad33830459 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 02:50:26 +0300
Subject: [PATCH 02/12] tbb: update to 2021.3.0.

---
 common/shlibs                                |   6 +-
 srcpkgs/tbb/patches/00-hwloc-2.5.patch       | 367 +++++++++++++++++++
 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch |  52 +++
 srcpkgs/tbb/patches/hostname-usage.patch     |  11 -
 srcpkgs/tbb/patches/musl.patch               |   4 +-
 srcpkgs/tbb/template                         |  63 +---
 6 files changed, 433 insertions(+), 70 deletions(-)
 create mode 100644 srcpkgs/tbb/patches/00-hwloc-2.5.patch
 create mode 100644 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
 delete mode 100644 srcpkgs/tbb/patches/hostname-usage.patch

diff --git a/common/shlibs b/common/shlibs
index a7afbf2a56f7..6b7ca5fbc249 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2376,12 +2376,10 @@ libanthy-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthydic-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthyinput-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthygobject-1.0.so.5 ibus-anthy-1.5.6_1
-libtbbmalloc_proxy_debug.so.2 tbb-4.3_1
 libtbbmalloc_proxy.so.2 tbb-4.3_1
 libtbbmalloc.so.2 tbb-4.3_1
-libtbb_debug.so.2 tbb-4.3_1
-libtbb.so.2 tbb-4.3_1
-libtbbmalloc_debug.so.2 tbb-4.3_1
+libtbb.so.12 tbb-2021.3.0_1
+libtbbbind_2_5.so.3 tbb-2021.3.0_1
 libembree.so.2 embree-2.5.1_1
 libgtkimageview.so.0 gtkimageview-1.6.4_1
 libgoocanvas-2.0.so.9 goocanvas-2.0.4_1
diff --git a/srcpkgs/tbb/patches/00-hwloc-2.5.patch b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
new file mode 100644
index 000000000000..9c4c9285c71d
--- /dev/null
+++ b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
@@ -0,0 +1,367 @@
+Adjusted by Artur Sinila <freesoftware@logarithmus.dev>
+
+From e96dbf4b48e689ab810b0428d0858a6abc2c83bd Mon Sep 17 00:00:00 2001
+From: Ivan Kochin <iv.kochin@gmail.com>
+Date: Thu, 1 Jul 2021 15:07:39 +0300
+Subject: [PATCH] Upgrade from HWLOC 2.4 to HWLOC 2.5 (#448)
+
+* Upgrade from HWLOC 2.4 to HWLOC 2.5
+* Introduce tbbbind_2_5 library
+* Remove tbbbind_2_4 library
+* Use the HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING topology flag (introduces as a part of HWLOC 2.5) to restrict topology discovering to process binding
+* Fix testing on Linux
+* Apply review comments
+* Improve wording: variable -> substring
+* Use right tbbbind version for incompatible hwlocs test
+* Rework option semantic
+* Update README.md for CMake
+* Rework readme
+* Update cmake/README.md
+
+Signed-off-by: Kochin, Ivan <kochin.ivan@intel.com>
+
+Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
+---
+ CMakeLists.txt                         |  3 ++-
+ cmake/README.md                        | 11 +++++---
+ cmake/hwloc_detection.cmake            |  9 ++++---
+ src/tbb/governor.cpp                   |  4 +--
+ src/tbbbind/CMakeLists.txt             |  2 +-
+ src/tbbbind/tbb_bind.cpp               | 23 +++++++++++-----
+ test/CMakeLists.txt                    | 30 ++++++++++-----------
+ test/common/common_arena_constraints.h | 37 ++++++++++++++++++++++----
+ 8 files changed, 82 insertions(+), 37 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 34a23d400..301899aca 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -100,6 +100,7 @@ option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Win
+ option(TBB4PY_BUILD "Enable tbb4py build" OFF)
+ option(TBB_CPF "Enable preview features of the library" OFF)
+ option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
++option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
+ 
+ if (NOT DEFINED BUILD_SHARED_LIBS)
+     set(BUILD_SHARED_LIBS ON)
+@@ -195,7 +196,7 @@ else()
+         add_subdirectory(src/tbbmalloc)
+         add_subdirectory(src/tbbmalloc_proxy)
+         if (APPLE)
+-            message(STATUS "TBBBind build target is disabled due to unsupported environment")
++            message(STATUS "TBBBind build targets are disabled due to unsupported environment")
+         else()
+             add_subdirectory(src/tbbbind)
+         endif()
+diff --git a/cmake/README.md b/cmake/README.md
+index 36fc303f9..b58c2ff6a 100644
+--- a/cmake/README.md
++++ b/cmake/README.md
+@@ -13,6 +13,7 @@ TBB4PY_BUILD:BOOL - Enable  Intel(R) oneAPI Threading Building Blocks (oneTBB) P
+ TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
+ TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
+ TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
++TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)
+ ```
+ 
+ ## Configure, build and test
+@@ -42,9 +43,9 @@ Some useful options:
+ 
+ #### TBBBind library configuration
+ 
+-The TBBbind library has two versions: `tbbbind` and `tbbbind_2_0`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.x.
++The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0` and `tbbbind_2_5`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.1-2.4, `tbbbind_2_5` links with HWLOC 2.5 and later.
+ 
+-To enable the TBBBind library build or special tests that performed inside the HWLOC environment, please specify the following CMake variables:
++The search for a suitable version of the HWLOC library is enabled by default, but if you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
+ 
+  - `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux or path to `.lib` file on Windows.
+  - `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version includes directory.
+@@ -52,7 +53,11 @@ To enable the TBBBind library build or special tests that performed inside the H
+ Windows requires one additional variable for correct TBBBind library building:
+  - `CMAKE_HWLOC_<HWLOC_VER>_DLL_PATH` - path to the corresponding HWLOC version `.dll` file.
+ 
+-`HWLOC_VER` variable used above can be replaced with one of the two values: `1_11` for the `tbbbind` library configuration and `2` for the `tbbbind_2_0` library configuration.
++`HWLOC_VER` substring used above can be replaced with one of the three values: `1_11` for the `tbbbind` library configuration, `2` for the `tbbbind_2_0`, and `2_5` for the `tbbbind_2_5` library configuration.
++
++If you specify variables for several TBBBind versions, then building process for all of these versions will be performed during single build session.
++
++Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
+ 
+ ### Build
+ 
+diff --git a/cmake/hwloc_detection.cmake b/cmake/hwloc_detection.cmake
+index e1eeca5fa..de7f3c047 100644
+--- a/cmake/hwloc_detection.cmake
++++ b/cmake/hwloc_detection.cmake
+@@ -12,7 +12,7 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
+-list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_4)
++list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_5)
+ 
+ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
+     if (NOT WIN32)
+@@ -55,10 +56,10 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
+         if (HWLOC_FOUND)
+             if (HWLOC_VERSION VERSION_LESS 2)
+                 set(TBBBIND_LIBRARY_NAME tbbbind)
+-            elseif(HWLOC_VERSION VERSION_LESS 2.4)
++            elseif(HWLOC_VERSION VERSION_LESS 2.5)
+                 set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
+             else()
+-                set(TBBBIND_LIBRARY_NAME tbbbind_2_4)
++                set(TBBBIND_LIBRARY_NAME tbbbind_2_5)
+             endif()
+         endif()
+     endif()
+diff --git a/src/tbb/governor.cpp b/src/tbb/governor.cpp
+index bf4e402d1..b842e075f 100644
+--- a/src/tbb/governor.cpp
++++ b/src/tbb/governor.cpp
+@@ -362,7 +362,7 @@ static const unsigned LinkTableSize = sizeof(TbbBindLinkTable) / sizeof(dynamic_
+ 
+ #define TBBBIND_NAME LIBRARY_PREFIX "tbbbind" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #define TBBBIND_2_0_NAME LIBRARY_PREFIX "tbbbind_2_0" DEBUG_SUFFIX LIBRARY_EXTENSION
+-#define TBBBIND_2_4_NAME LIBRARY_PREFIX "tbbbind_2_4" DEBUG_SUFFIX LIBRARY_EXTENSION
++#define TBBBIND_2_5_NAME LIBRARY_PREFIX "tbbbind_2_5" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #endif /* _WIN32 || _WIN64 || __linux__ */
+ 
+ // Representation of system hardware topology information on the TBB side.
+@@ -389,7 +389,7 @@ const char* load_tbbbind_shared_object() {
+     GetNativeSystemInfo(&si);
+     if (si.dwNumberOfProcessors > 32) return nullptr;
+ #endif /* _WIN32 && !_WIN64 */
+-    for (const auto& tbbbind_version : {TBBBIND_2_4_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
++    for (const auto& tbbbind_version : {TBBBIND_2_5_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
+         if (dynamic_link(tbbbind_version, TbbBindLinkTable, LinkTableSize)) {
+             return tbbbind_version;
+         }
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index 029893751..e5cdbf8bb 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -99,7 +99,7 @@ if (NOT DEFINED HWLOC_TARGET_EXPLICITLY_DEFINED AND DEFINED HWLOC_LIBRARIES)
+ else()
+     tbbbind_build(tbbbind     HWLOC::hwloc_1_11)
+     tbbbind_build(tbbbind_2_0 HWLOC::hwloc_2   )
+-    tbbbind_build(tbbbind_2_4 HWLOC::hwloc_2_4 )
++    tbbbind_build(tbbbind_2_5 HWLOC::hwloc_2_5 )
+ endif()
+ 
+ 
+diff --git a/src/tbbbind/tbb_bind.cpp b/src/tbbbind/tbb_bind.cpp
+index 97be308c7..88c956acb 100644
+--- a/src/tbbbind/tbb_bind.cpp
++++ b/src/tbbbind/tbb_bind.cpp
+@@ -34,7 +34,8 @@
+ #pragma GCC diagnostic pop
+ #endif
+ 
+-#define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ 
+ // Most of hwloc calls returns negative exit code on error.
+ // This macro tracks error codes that are returned from the hwloc interfaces.
+@@ -85,6 +86,16 @@ class platform_topology {
+         // Parse topology
+         if ( hwloc_topology_init( &topology ) == 0 ) {
+             initialization_state = topology_allocated;
++#if __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++            if ( groups_num == 1 &&
++                 hwloc_topology_set_flags(topology,
++                     HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                     HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
++                 ) != 0
++            ) {
++                return;
++            }
++#endif
+             if ( hwloc_topology_load( topology ) == 0 ) {
+                 initialization_state = topology_loaded;
+             }
+@@ -135,7 +146,7 @@ class platform_topology {
+             numa_indexes_list.resize(numa_nodes_count);
+             hwloc_obj_t node_buffer;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 numa_indexes_list[counter] = static_cast<int>(node_buffer->logical_index);
+ 
+                 if ( numa_indexes_list[counter] > max_numa_index ) {
+@@ -150,7 +161,7 @@ class platform_topology {
+             numa_affinity_masks_list.resize(max_numa_index + 1);
+             int index = 0;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 index = static_cast<int>(node_buffer->logical_index);
+ 
+                 hwloc_cpuset_t& current_mask = numa_affinity_masks_list[index];
+@@ -168,7 +179,7 @@ class platform_topology {
+             core_types_indexes_list.push_back(-1);
+             return;
+         }
+-#if __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
++#if __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
+         __TBB_ASSERT(hwloc_get_api_version() >= 0x20400, "Hybrid CPUs support interfaces required HWLOC >= 2.4");
+         // Parsing the hybrid CPU topology
+         int core_types_number = hwloc_cpukinds_get_nr(topology, 0);
+@@ -196,9 +207,9 @@ class platform_topology {
+                 }
+             }
+         }
+-#else /*!__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#else /*!__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+         bool core_types_parsing_broken{true};
+-#endif /*__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#endif /*__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+ 
+         if (core_types_parsing_broken) {
+             for (auto& core_type_mask : core_types_affinity_masks_list) {
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index bdae9e2b1..c2b9d6dba 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -275,9 +275,9 @@ function(tbb_add_tbbbind_test)
+         FAIL_REGULAR_EXPRESSION "Status:.*FAILURE"
+     )
+ 
+-    if (TARGET HWLOC::hwloc_2_4 AND NOT HWLOC_2_4_TESTS_STATUS_SHOWN)
+-        message(STATUS "HWLOC 2.4 dependent tests were enabled.")
+-        set(HWLOC_2_4_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
++    if (TARGET HWLOC::hwloc_2_5 AND NOT HWLOC_2_5_TESTS_STATUS_SHOWN)
++        message(STATUS "HWLOC 2.5 dependent tests were enabled.")
++        set(HWLOC_2_5_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
+     endif()
+ 
+     if (TARGET HWLOC::hwloc_2 AND NOT HWLOC_2_TESTS_STATUS_SHOWN)
+@@ -291,22 +291,22 @@ function(tbb_add_tbbbind_test)
+     endif()
+ 
+     list(APPEND HWLOC_TEST_CASES
+-        hwloc_2_4
++        hwloc_2_5
+         hwloc_2
+         hwloc_1_11
+-        hwloc_2_4_hwloc_2
+-        hwloc_2_4_hwloc_1_11
++        hwloc_2_5_hwloc_2
++        hwloc_2_5_hwloc_1_11
+         hwloc_2_hwloc_1_11
+-        hwloc_2_4_hwloc_2_hwloc_1_11
++        hwloc_2_5_hwloc_2_hwloc_1_11
+     )
+ 
+-    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_4 "hwloc_2_4")
++    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_5 "hwloc_2_5")
+     list(APPEND HWLOC_TEST_CASE_1_VARS tbbbind_2   "hwloc_2")
+     list(APPEND HWLOC_TEST_CASE_2_VARS tbbbind     "hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2")
+-    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_4 "hwloc_2_4,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2")
++    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_5 "hwloc_2_5,hwloc_1_11")
+     list(APPEND HWLOC_TEST_CASE_5_VARS tbbbind_2   "hwloc_2,hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2,hwloc_1_11")
+ 
+     foreach(TEST_CASE ${HWLOC_TEST_CASES})
+         list(FIND HWLOC_TEST_CASES ${TEST_CASE} TEST_CASE_INDEX)
+@@ -331,7 +331,7 @@ endfunction()
+ # Copy libraries to test folder to make it visible during tests execution if external TBB is tested.
+ # TODO: check and update for multi-config generators.
+ if (TBB_FOUND)
+-    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_4)
++    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_5)
+     foreach(_component ${_tbb_test_components})
+         if (TARGET TBB::${_component})
+             get_property(${_component}_lib_file_location TARGET TBB::${_component} PROPERTY LOCATION)
+@@ -593,6 +593,6 @@ if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
+     tbb_add_test(SUBDIR tbbmalloc NAME test_malloc_new_handler DEPENDENCIES TBB::tbbmalloc_proxy)
+ endif()
+ 
+-unset(HWLOC_2_4_TESTS_STATUS_SHOWN)
++unset(HWLOC_2_5_TESTS_STATUS_SHOWN)
+ unset(HWLOC_2_TESTS_STATUS_SHOWN)
+ unset(HWLOC_1_11_TESTS_STATUS_SHOWN)
+diff --git a/test/common/common_arena_constraints.h b/test/common/common_arena_constraints.h
+index 2a0b1ea97..5efc71082 100644
+--- a/test/common/common_arena_constraints.h
++++ b/test/common/common_arena_constraints.h
+@@ -38,9 +38,26 @@
+ 
+ #if (_WIN32 || _WIN64) && __TBB_HWLOC_VALID_ENVIRONMENT
+ #include <windows.h>
+-int get_processors_groups_count() { return GetActiveProcessorGroupCount(); }
++int get_processors_group_count() {
++    SYSTEM_INFO si;
++    GetNativeSystemInfo(&si);
++    DWORD_PTR pam, sam, m = 1;
++    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
++    int nproc = 0;
++    for ( std::size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
++        if ( pam & m )
++            ++nproc;
++    }
++    // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present
++    if ( nproc == (int)si.dwNumberOfProcessors  ) {
++        // The process does not have restricting affinity mask and multiple processor groups are possible
++        return (int)GetActiveProcessorGroupCount();
++    } else {
++        return 1;
++    }
++}
+ #else
+-int get_processors_groups_count() { return 1; }
++int get_processors_group_count() { return 1; }
+ #endif
+ 
+ //TODO: Write a test that checks for memory leaks during dynamic link/unlink of TBBbind.
+@@ -69,6 +86,7 @@ int get_processors_groups_count() { return 1; }
+ #endif
+ 
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ // At this moment the hybrid CPUs HWLOC interfaces returns unexpected results on some Windows machines
+ // in the 32-bit arch mode.
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_VALID (!_WIN32 || _WIN64)
+@@ -153,9 +171,18 @@ class system_info {
+ 
+     system_info() {
+         hwloc_require_ex(hwloc_topology_init, &topology);
++#if __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++        if ( get_processors_group_count() == 1 ) {
++            REQUIRE(
++                hwloc_topology_set_flags(topology,
++                    HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                    HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING) == 0
++            );
++        }
++#endif
+         hwloc_require_ex(hwloc_topology_load, topology);
+ 
+-        if ( get_processors_groups_count() > 1 ) {
++        if ( get_processors_group_count() > 1 ) {
+             process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
+         } else {
+             process_cpuset = hwloc_bitmap_alloc();
+@@ -434,7 +461,7 @@ system_info::affinity_mask get_arena_affinity(tbb::task_arena& ta) {
+                 barrier.wait();
+                 tbb::spin_mutex::scoped_lock lock(affinity_mutex);
+                 system_info::affinity_mask thread_affinity = system_info::allocate_current_affinity_mask();
+-                if (get_processors_groups_count() == 1) {
++                if (get_processors_group_count() == 1) {
+                     REQUIRE_MESSAGE(hwloc_bitmap_isequal(thread_affinity, arena_affinity),
+                         "Threads have different masks on machine without several processors groups.");
+                 }
+@@ -532,7 +559,7 @@ constraints_container generate_constraints_variety() {
+         }
+ 
+         // Some constraints may cause unexpected behavior, which would be fixed later.
+-        if (get_processors_groups_count() > 1) {
++        if (get_processors_group_count() > 1) {
+             for(auto it = results.begin(); it != results.end(); ++it) {
+                 if (it->max_threads_per_core != tbb::task_arena::automatic
+                    && (it->numa_id == tbb::task_arena::automatic || tbb::info::numa_nodes().size() == 1)
diff --git a/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
new file mode 100644
index 000000000000..279ebc4397cd
--- /dev/null
+++ b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
@@ -0,0 +1,52 @@
+Based on https://github.com/oneapi-src/oneTBB/pull/498
+Tweaked a bit to work on `v2021.3.0`
+
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index e5cdbf8bb..a4033210a 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -37,6 +37,10 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+         ${HWLOC_INCLUDE_DIRS} # pkg-config defined
+     )
++	target_link_directories(${TBBBIND_NAME}
++		PRIVATE
++		${HWLOC_LIBRARY_DIRS} # pkg-config defined
++	)
+ 
+     target_compile_options(${TBBBIND_NAME}
+         PRIVATE
+@@ -69,7 +69,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     else()
+         target_link_libraries(${TBBBIND_NAME}
+@@ -76,7 +76,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     endif()
+ 
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index b768759d5..3eb8357e6 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -258,7 +258,12 @@ function(tbb_add_tbbbind_test)
+         )
+         set_property(
+             TARGET ${_tbbbind_test_NAME}
+-            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARY_DIRS} ${HWLOC_LIBRARIES}
++            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARIES}
++            APPEND
++        )
++        set_property(
++            TARGET ${_tbbbind_test_NAME}
++			PROPERTY LINK_DIRECTORIES ${HWLOC_LIBRARY_DIRS}
+             APPEND
+         )
+         set_property(
diff --git a/srcpkgs/tbb/patches/hostname-usage.patch b/srcpkgs/tbb/patches/hostname-usage.patch
deleted file mode 100644
index 4aefeff192b5..000000000000
--- a/srcpkgs/tbb/patches/hostname-usage.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/build/version_info_linux.sh
-+++ b/build/version_info_linux.sh
-@@ -20,7 +20,7 @@
- 
- # Script used to generate version info string
- echo "#define __TBB_VERSION_STRINGS(N) \\"
--echo '#N": BUILD_HOST'"\t\t"`hostname -s`" ("`uname -m`")"'" ENDL \'
-+echo '#N": BUILD_HOST'"\t\t"`hostname`" ("`uname -m`")"'" ENDL \'
- # find OS name in *-release and issue* files by filtering blank lines and lsb-release content out
- echo '#N": BUILD_OS'"\t\t"`lsb_release -sd 2>/dev/null | grep -ih '[a-z] ' - /etc/*release /etc/issue 2>/dev/null | head -1 | sed -e 's/["\\\\]//g'`'" ENDL \'
- echo '#N": BUILD_KERNEL'"\t"`uname -srv`'" ENDL \'
diff --git a/srcpkgs/tbb/patches/musl.patch b/srcpkgs/tbb/patches/musl.patch
index a8867eb53793..ec89c6a95fc6 100644
--- a/srcpkgs/tbb/patches/musl.patch
+++ b/srcpkgs/tbb/patches/musl.patch
@@ -1,5 +1,5 @@
---- a/src/tbbmalloc/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
-+++ b/src/tbbmalloc/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
+--- a/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
++++ b/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
 @@ -28,6 +28,7 @@
  // of aligned_alloc as required by new C++ standard, this makes it hard to
  // redefine aligned_alloc here. However, running on systems with new libc
diff --git a/srcpkgs/tbb/template b/srcpkgs/tbb/template
index aeef6ebdd061..47655829f744 100644
--- a/srcpkgs/tbb/template
+++ b/srcpkgs/tbb/template
@@ -1,76 +1,33 @@
 # Template file for 'tbb'
 pkgname=tbb
-version=2020.U3
+version=2021.3.0
 revision=1
-# version rewrite: 2017_U7 (upstream) => 2017.7 (xbps)
-_ver=${version/./_}
-wrksrc="oneTBB-${_ver}"
-build_style=gnu-makefile
-hostmakedepends="cmake"
+wrksrc="oneTBB-${version}"
+build_style=cmake
+makedepends="libhwloc-devel libgomp-devel"
 short_desc="Intel Threading Building Blocks"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
 license="Apache-2.0"
 homepage="https://www.threadingbuildingblocks.org"
-distfiles="https://github.com/oneapi-src/oneTBB/archive/${_ver}.tar.gz"
-checksum=2103cc6238c935664f87680618f6684d57501d4a2fa8ea8f6c97ad6ff7dc722a
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*)
-		make_build_args="arch=intel64"
-		;;
-	i686*)
-		make_build_args="arch=ia32"
-		;;
-	armv7l*)
-		make_build_args="arch=armv7"
-		;;
-	aarch64*)
-		make_build_args="arch=arm64"
-		;;
-	ppc64*)
-		make_build_args="arch=ppc64"
-		;;
-	ppc*)
-		make_build_args="arch=ppc32"
-		;;
-	*)
-		# make sure to fall back instead of letting host uname control it
-		make_build_args="arch=generic"
-		;;
-esac
-
-post_extract() {
-	sed -i 's|CPLUS = g..|CPLUS = $(CXX)|g' build/linux.gcc.inc
-	sed -i 's|CONLY = gcc|CONLY = $(CC)|g' build/linux.gcc.inc
+distfiles="https://github.com/oneapi-src/oneTBB/archive/v${version}.tar.gz"
+checksum=8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e
 
+pre_patch() {
 	# alternative might be:
 	# https://git.alpinelinux.org/cgit/aports/tree/testing/libtbb/glibc-struct-mallinfo.patch
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		vsed -e "s@#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__@@" \
-		  -i src/tbbmalloc/proxy.h
+		  -i src/tbbmalloc_proxy/proxy.h
 	fi
 }
 
-do_install() {
-	vmkdir usr/lib
-	vcopy build/linux_*/*.so* usr/lib
-	vmkdir usr/include/tbb
-	vcopy include/tbb/* usr/include/tbb
-
-	cmake \
-		-DINSTALL_DIR=$DESTDIR/usr/lib/cmake/TBB \
-		-DSYSTEM_NAME=Linux \
-		-DLIB_REL_PATH=../.. \
-		-DINC_REL_PATH=../../../include \
-		-P cmake/tbb_config_installer.cmake
-}
-
 tbb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
-		vmove "usr/lib/*.so"
 		vmove usr/lib/cmake
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.so
 	}
 }

From 58ac9ae5d54bd2e3523233976b54cefef4e7f6b7 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 03/12] OpenSubdiv: update to 3.4.4.

---
 srcpkgs/OpenSubdiv/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/OpenSubdiv/template b/srcpkgs/OpenSubdiv/template
index b7a5e16efbcf..dfbf29cc1a52 100644
--- a/srcpkgs/OpenSubdiv/template
+++ b/srcpkgs/OpenSubdiv/template
@@ -1,6 +1,6 @@
 # Template file for 'OpenSubdiv'
 pkgname=OpenSubdiv
-version=3.4.3
+version=3.4.4
 revision=1
 wrksrc="OpenSubdiv-${version//./_}"
 build_style=cmake
@@ -13,7 +13,7 @@ maintainer="John <me@johnnynator.dev>"
 license="Apache-2.0"
 homepage="http://graphics.pixar.com/opensubdiv/docs/intro.html"
 distfiles="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${version//./_}.tar.gz"
-checksum=7b22eb27d636ab0c1e03722c7a5a5bd4f11664ee65c9b48f341a6d0ce7f36745
+checksum=20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" OpenSubdiv"

From 0cce9a9c569c8ead61a5c61995fa4b3c87fe6100 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 04/12] PrusaSlicer: update to 2.3.3.

---
 srcpkgs/PrusaSlicer/patches/cross.patch | 11 -----------
 srcpkgs/PrusaSlicer/template            |  4 ++--
 2 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 srcpkgs/PrusaSlicer/patches/cross.patch

diff --git a/srcpkgs/PrusaSlicer/patches/cross.patch b/srcpkgs/PrusaSlicer/patches/cross.patch
deleted file mode 100644
index d64a450d9e9f..000000000000
--- a/srcpkgs/PrusaSlicer/patches/cross.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/avrdude/CMakeLists.txt	2020-06-04 09:19:26.017251215 +0200
-+++ b/src/avrdude/CMakeLists.txt	2020-06-04 09:19:36.468250771 +0200
-@@ -83,7 +83,7 @@ add_executable(avrdude-conf-gen conf-gen
- add_custom_command(
-     DEPENDS avrdude-conf-gen ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf
-     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
--    COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-+    COMMAND avrdude-conf-gen avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- 
diff --git a/srcpkgs/PrusaSlicer/template b/srcpkgs/PrusaSlicer/template
index dd0e76cb8017..a93832ac02e4 100644
--- a/srcpkgs/PrusaSlicer/template
+++ b/srcpkgs/PrusaSlicer/template
@@ -1,6 +1,6 @@
 # Template file for 'PrusaSlicer'
 pkgname=PrusaSlicer
-version=2.3.0
+version=2.3.3
 revision=1
 wrksrc="PrusaSlicer-version_${version}"
 build_style=cmake
@@ -16,7 +16,7 @@ maintainer="Jasper Chan <jasperchan515@gmail.com>"
 license="GPL-3.0-or-later"
 homepage="https://www.prusa3d.com/prusaslicer/"
 distfiles="https://github.com/prusa3d/Prusaslicer/archive/version_${version}.tar.gz"
-checksum=cd3bac5e29b5441fc4690f28cd7b1064e97dc00207bbdc88f7bd7832308d6ca5
+checksum=deda209505f740ac3d6f59cb2a960f4df908269ee09bd30cd4edb9fc472d29ac
 nocross="https://build.voidlinux.org/builders/armv7l_builder/builds/25230/steps/shell_3/logs/stdio"
 
 Slic3rPE_package() {

From 6e51deb8106170ac686ebfd2205f6d89524968ad Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 05/12] blender: update to 2.93.1.

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index af946c2b7999..8318317c82bf 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,6 +1,6 @@
 # Template file for 'blender'
 pkgname=blender
-version=2.93.0
+version=2.93.1
 revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"

From 9c32dd199aad6d41af4197a4cdedcb3d05b136fd Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 06/12] embree: update to 3.13.0.

---
 srcpkgs/embree/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/embree/template b/srcpkgs/embree/template
index 575b9bcb401c..b6f376d30efa 100644
--- a/srcpkgs/embree/template
+++ b/srcpkgs/embree/template
@@ -1,8 +1,8 @@
 # Template file for 'embree'
 pkgname=embree
-version=2.17.7
-revision=2
-archs="x86_64"
+version=3.13.0
+revision=1
+archs="x86_64*"
 build_style=cmake
 configure_args="-DTBB_ROOT=/usr -DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF"
 hostmakedepends="ispc"

From c7ee6b56ca53aee247edf115de88f3181b96c2bd Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 03:34:43 +0300
Subject: [PATCH 07/12] openimageio: update to 2.2.16.0.

---
 srcpkgs/openimageio/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index de8e1cd04409..3bfdd4e0ed1e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,11 +1,11 @@
 # Template file for 'openimageio'
 pkgname=openimageio
-version=2.2.15.1
+version=2.2.16.0
 revision=1
 wrksrc="oiio-Release-${version}"
 build_style=cmake
 configure_args="-DUSE_OPENGL=0 -DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=1
- -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0"
+ -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0 -DCMAKE_CXX_STANDARD=14"
 hostmakedepends="pkg-config git"
 makedepends="boost-devel giflib-devel libraw-devel libopenjpeg-devel libwebp-devel
  libjpeg-turbo-devel tiff-devel libpng-devel libopenexr-devel freetype-devel
@@ -17,7 +17,7 @@ license="BSD-3-Clause"
 homepage="https://sites.google.com/site/openimageio/home"
 changelog="https://raw.githubusercontent.com/OpenImageIO/oiio/release/CHANGES.md"
 distfiles="https://github.com/OpenImageIO/oiio/archive/Release-${version}.tar.gz"
-checksum=f222c6b51a40aabbc80ddf4055535be9af1ffa907452fa6d1ffa7674854aab17
+checksum=d1a59f32dbba3ba71ad2e62e107034d1c5287bca1b0696474e927d504cd05ef4
 # Runs checks even for features we disabled.
 make_check=no
 

From 749df30055fcbdae12bdad23247bef55f9f9ee14 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 08/12] openimagedenoise: update to 1.4.1.

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index c73913b4e9d7..14055aff1c27 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,6 +1,6 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
-version=1.4.0
+version=1.4.1
 revision=1
 archs="x86_64*"
 wrksrc=oidn-${version}

From e30cd818f3f1d503a5efd5ec5bab1dc9c64794a5 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 09/12] openvdb: update to 8.1.0.

---
 common/shlibs                             |    2 +-
 srcpkgs/openvdb/patches/00-tbb-2021.patch | 1320 +++++++++++++++++++++
 srcpkgs/openvdb/template                  |   16 +-
 3 files changed, 1325 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/openvdb/patches/00-tbb-2021.patch

diff --git a/common/shlibs b/common/shlibs
index 6b7ca5fbc249..2a7acdb253a7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3883,7 +3883,7 @@ libjanet.so.1.16 janet-1.16.0_1
 libOpenImageDenoise.so.1 openimagedenoise-1.3.0_1
 libcbang0.so cbang-1.6.0_3
 libblosc.so.1 c-blosc-1.17.1_1
-libopenvdb.so.7.0 openvdb-7.0.0_1
+libopenvdb.so.8.1 openvdb-8.1.0_1
 libAlembic.so.1.7 alembic-1.7.13_1
 libmodsecurity.so.3 modsecurity-3.0.4_1
 libraven.so.0 budgie-desktop-10.5.1_1
diff --git a/srcpkgs/openvdb/patches/00-tbb-2021.patch b/srcpkgs/openvdb/patches/00-tbb-2021.patch
new file mode 100644
index 000000000000..271104af3df9
--- /dev/null
+++ b/srcpkgs/openvdb/patches/00-tbb-2021.patch
@@ -0,0 +1,1320 @@
+https://github.com/AcademySoftwareFoundation/openvdb/pull/1027
+Should be dropped after 8.1.1 release.
+
+diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake
+index d41436b1c..06de2b3f3 100644
+--- a/cmake/FindTBB.cmake
++++ b/cmake/FindTBB.cmake
+@@ -169,8 +169,22 @@ find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
+   PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
+ )
+ 
+-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" ""
+@@ -178,7 +192,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" ""
+@@ -192,6 +206,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
+ # ------------------------------------------------------------------------
+diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt
+index 88543df3a..929fe94d1 100644
+--- a/openvdb/openvdb/CMakeLists.txt
++++ b/openvdb/openvdb/CMakeLists.txt
+@@ -437,6 +437,10 @@ set(OPENVDB_LIBRARY_UTIL_INCLUDE_FILES
+   util/Util.h
+ )
+ 
++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} DESTINATION ${OPENVDB_INST
+ 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)
+diff --git a/openvdb/openvdb/cmd/openvdb_render.cc b/openvdb/openvdb/cmd/openvdb_render.cc
+index ee5b737c5..2c9831ba3 100644
+--- a/openvdb/openvdb/cmd/openvdb_render.cc
++++ b/openvdb/openvdb/cmd/openvdb_render.cc
+@@ -19,7 +19,14 @@
+ #include <OpenEXR/ImfHeader.h>
+ #include <OpenEXR/ImfOutputFile.h>
+ #include <OpenEXR/ImfPixelType.h>
+-#include <tbb/task_scheduler_init.h>
++
++// 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 <tbb/global_control.h>
+ #include <tbb/tick_count.h>
+ 
+ #include <algorithm>
+@@ -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<tbb::global_control> 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();
+ 
+diff --git a/openvdb/openvdb/io/Queue.cc b/openvdb/openvdb/io/Queue.cc
+index ef5d2961a..20ff1a0c1 100644
+--- a/openvdb/openvdb/io/Queue.cc
++++ b/openvdb/openvdb/io/Queue.cc
+@@ -5,20 +5,22 @@
+ /// @author Peter Cucka
+ 
+ #include "Queue.h"
+-
+ #include "File.h"
+ #include "Stream.h"
+-#include <openvdb/Exceptions.h>
+-#include <openvdb/util/logging.h>
++#include "openvdb/Exceptions.h"
++#include "openvdb/util/logging.h"
++
+ #include <tbb/concurrent_hash_map.h>
+-#include <tbb/task.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
+-#include <tbb/tick_count.h>
++#include <tbb/task_arena.h>
++
++#include <thread>
+ #include <algorithm> // for std::max()
+ #include <atomic>
+ #include <iostream>
+ #include <map>
+ #include <mutex>
++#include <chrono>
++
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -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
+ 
+ 
+ // 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
+         : 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
+             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<Queue::Id, Queue::Status>;
+ 
+-
+     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::milliseconds>(
++                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;
+ }
+ 
+diff --git a/openvdb/openvdb/math/Coord.h b/openvdb/openvdb/math/Coord.h
+index 504b5e9a4..2e9cfed5d 100644
+--- a/openvdb/openvdb/math/Coord.h
++++ b/openvdb/openvdb/math/Coord.h
+@@ -13,8 +13,7 @@
+ #include "Math.h"
+ #include "Vec3.h"
+ 
+-namespace tbb { class split; } // forward declaration
+-
++#include <tbb/blocked_range.h> // for tbb::split
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+diff --git a/openvdb/openvdb/points/PointSample.h b/openvdb/openvdb/points/PointSample.h
+index a122cc4fb..27ec3fb29 100644
+--- a/openvdb/openvdb/points/PointSample.h
++++ b/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 <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tools/Interpolation.h>
++#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 <sstream>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -299,7 +299,7 @@ class PointDataSampler
+             using TargetHandleT = AttributeWriteHandle<typename SamplerWrapperT::ValueType>;
+ 
+             if (util::wasInterrupted(interrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return;
+             }
+ 
+diff --git a/openvdb/openvdb/thread/Threading.h b/openvdb/openvdb/thread/Threading.h
+new file mode 100644
+index 000000000..0c3b356e3
+--- /dev/null
++++ b/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 <tbb/blocked_range.h>
++#include <tbb/task.h>
++#include <tbb/task_group.h>
++
++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
+diff --git a/openvdb/openvdb/tools/Composite.h b/openvdb/openvdb/tools/Composite.h
+index 6bc170bf7..88ff86f9f 100644
+--- a/openvdb/openvdb/tools/Composite.h
++++ b/openvdb/openvdb/tools/Composite.h
+@@ -24,7 +24,6 @@
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include <type_traits>
+ #include <functional>
+diff --git a/openvdb/openvdb/tools/Diagnostics.h b/openvdb/openvdb/tools/Diagnostics.h
+index 694d2155f..e5844e448 100644
+--- a/openvdb/openvdb/tools/Diagnostics.h
++++ b/openvdb/openvdb/tools/Diagnostics.h
+@@ -11,14 +11,17 @@
+ #ifndef OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ 
+-#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/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 <tbb/blocked_range.h>
+ #include <tbb/parallel_reduce.h>
++
+ #include <cmath> // for std::isnan(), std::isfinite()
+ #include <set>
+ #include <sstream>
+@@ -26,7 +29,6 @@
+ #include <type_traits>
+ #include <vector>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -1160,13 +1162,13 @@ InactiveVoxelValues<TreeType>::operator()(const tbb::blocked_range<size_t>& rang
+ {
+     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<typename TreeType>
+ inline void
+ InactiveTileValues<TreeType>::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();
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/tools/Filter.h b/openvdb/openvdb/tools/Filter.h
+index 408c75541..b70212520 100644
+--- a/openvdb/openvdb/tools/Filter.h
++++ b/openvdb/openvdb/tools/Filter.h
+@@ -14,21 +14,24 @@
+ #ifndef OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ 
+-#include <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
++#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 <tbb/parallel_for.h>
++#include <tbb/concurrent_vector.h>
++
+ #include <algorithm> // for std::max()
+ #include <functional>
+ #include <type_traits>
+-#include <tbb/concurrent_vector.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -833,7 +836,7 @@ inline bool
+ Filter<GridT, MaskT, InterruptT>::wasInterrupted()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return true;
+     }
+     return false;
+diff --git a/openvdb/openvdb/tools/GridOperators.h b/openvdb/openvdb/tools/GridOperators.h
+index 31305a1ab..78fafead9 100644
+--- a/openvdb/openvdb/tools/GridOperators.h
++++ b/openvdb/openvdb/tools/GridOperators.h
+@@ -9,14 +9,15 @@
+ #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/Grid.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
++#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 <tbb/parallel_for.h>
+ 
++#include <tbb/parallel_for.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -383,7 +384,9 @@ class GridOperator
+     /// 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) {
+diff --git a/openvdb/openvdb/tools/LevelSetMeasure.h b/openvdb/openvdb/tools/LevelSetMeasure.h
+index efe19074d..59969cdcf 100644
+--- a/openvdb/openvdb/tools/LevelSetMeasure.h
++++ b/openvdb/openvdb/tools/LevelSetMeasure.h
+@@ -8,18 +8,21 @@
+ #ifndef OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/math/Math.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/Grid.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/math/FiniteDifference.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/math/Stencils.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
+ #include <tbb/parallel_sort.h>
+ #include <tbb/parallel_invoke.h>
++
+ #include <type_traits>
+ 
+ namespace openvdb {
+@@ -329,7 +332,7 @@ inline bool
+ LevelSetMeasure<GridT, InterruptT>::checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/LevelSetTracker.h b/openvdb/openvdb/tools/LevelSetTracker.h
+index cbdc267e8..bfc8004e7 100644
+--- a/openvdb/openvdb/tools/LevelSetTracker.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/tree/LeafManager.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -383,7 +385,7 @@ LevelSetTracker<GridT, InterruptT>::
+ checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/MeshToVolume.h b/openvdb/openvdb/tools/MeshToVolume.h
+index 6643c8f05..de3406eda 100644
+--- a/openvdb/openvdb/tools/MeshToVolume.h
++++ b/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 <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/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 <tbb/parallel_reduce.h>
+ #include <tbb/partitioner.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm> // for std::sort()
+ #include <cmath> // 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<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+@@ -1989,7 +1990,7 @@ class VoxelizePolygons
+         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
+ 
+         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) {
+diff --git a/openvdb/openvdb/tools/Morphology.h b/openvdb/openvdb/tools/Morphology.h
+index 736982ef5..0a1e71009 100644
+--- a/openvdb/openvdb/tools/Morphology.h
++++ b/openvdb/openvdb/tools/Morphology.h
+@@ -24,7 +24,7 @@
+ #include "openvdb/tree/ValueAccessor.h"
+ #include "openvdb/tree/LeafManager.h"
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ 
+@@ -726,7 +726,7 @@ void Morphology<TreeType>::dilateVoxels(const size_t iter,
+         }
+ 
+         // @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
+diff --git a/openvdb/openvdb/tools/ParticlesToLevelSet.h b/openvdb/openvdb/tools/ParticlesToLevelSet.h
+index 739af2b69..f9c19911c 100644
+--- a/openvdb/openvdb/tools/ParticlesToLevelSet.h
++++ b/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 <tbb/parallel_reduce.h>
+-#include <tbb/blocked_range.h>
+-#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/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 <tbb/parallel_reduce.h>
++#include <tbb/blocked_range.h>
++
+ #include <functional>
+ #include <iostream>
+ #include <type_traits>
+@@ -738,7 +742,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         for (Coord c = lo; c.x() <= hi.x(); ++c.x()) {
+             //only check interrupter every 32'th scan in x
+             if (!(count++ & ((1<<5)-1)) && util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Real x2 = math::Pow2(c.x() - P[0]);
+@@ -804,7 +808,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         // Densely fill the remaining regions.
+         for (const auto& bbox: padding) {
+             if (util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Coord &bmin = bbox.min(), &bmax = bbox.max();
+diff --git a/openvdb/openvdb/tools/PointAdvect.h b/openvdb/openvdb/tools/PointAdvect.h
+index 12b1177ad..e487bfb3e 100644
+--- a/openvdb/openvdb/tools/PointAdvect.h
++++ b/openvdb/openvdb/tools/PointAdvect.h
+@@ -10,16 +10,19 @@
+ #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/openvdb.h>
+-#include <openvdb/math/Math.h>             // min
+-#include <openvdb/Types.h>                 // Vec3 types and version number
+-#include <openvdb/Grid.h>                  // grid
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/blocked_range.h>             // threading
+ #include <tbb/parallel_for.h>              // threading
+ #include <tbb/task.h>                      // for cancel
++
+ #include <vector>
+ 
+ 
+@@ -167,7 +170,7 @@ class PointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityFieldIntegrator  velField(*mVelGrid);
+@@ -307,7 +310,7 @@ class ConstrainedPointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityIntegratorType velField(*mVelGrid);
+diff --git a/openvdb/openvdb/tools/PointIndexGrid.h b/openvdb/openvdb/tools/PointIndexGrid.h
+index e9ebf96f7..b2e378a79 100644
+--- a/openvdb/openvdb/tools/PointIndexGrid.h
++++ b/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 <openvdb/version.h>
+@@ -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;
+         }
+ 
+diff --git a/openvdb/openvdb/tools/PointPartitioner.h b/openvdb/openvdb/tools/PointPartitioner.h
+index ccf50ab05..f7f6fc13d 100644
+--- a/openvdb/openvdb/tools/PointPartitioner.h
++++ b/openvdb/openvdb/tools/PointPartitioner.h
+@@ -23,7 +23,7 @@
+ 
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm>
+ #include <cmath> // for std::isfinite()
+@@ -764,7 +764,7 @@ inline void binAndSegment(
+     using IndexPairListMap = std::map<Coord, IndexPairListPtr>;
+     using IndexPairListMapPtr = std::shared_ptr<IndexPairListMap>;
+ 
+-    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;
+ 
+diff --git a/openvdb/openvdb/tools/PointsToMask.h b/openvdb/openvdb/tools/PointsToMask.h
+index 592ab7a15..8a276fb04 100644
+--- a/openvdb/openvdb/tools/PointsToMask.h
++++ b/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 <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/blocked_range.h>
+-#include <openvdb/openvdb.h> // for MaskGrid
+-#include <openvdb/Grid.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/util/NullInterrupter.h>
++
+ #include <vector>
+ 
+ 
+@@ -150,7 +154,7 @@ class PointsToMask
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeAdvect.h b/openvdb/openvdb/tools/VolumeAdvect.h
+index e7eec740e..f38eaa9c2 100644
+--- a/openvdb/openvdb/tools/VolumeAdvect.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/math/Math.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ 
+ 
+@@ -294,7 +297,7 @@ class VolumeAdvection
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeToMesh.h b/openvdb/openvdb/tools/VolumeToMesh.h
+index a834dd3b3..a446f806a 100644
+--- a/openvdb/openvdb/tools/VolumeToMesh.h
++++ b/openvdb/openvdb/tools/VolumeToMesh.h
+@@ -18,7 +18,7 @@
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <cmath> // for std::isfinite()
+ #include <map>
+@@ -388,7 +388,7 @@ inline void
+ fillArray(ValueType* array, const ValueType& val, const size_t length)
+ {
+     const auto grainSize = std::max<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+diff --git a/openvdb/openvdb/unittest/TestCoord.cc b/openvdb/openvdb/unittest/TestCoord.cc
+index be1c24ced..148690041 100644
+--- a/openvdb/openvdb/unittest/TestCoord.cc
++++ b/openvdb/openvdb/unittest/TestCoord.cc
+@@ -2,9 +2,9 @@
+ // SPDX-License-Identifier: MPL-2.0
+ 
+ #include <openvdb/Types.h>
++#include <openvdb/math/Coord.h>
+ 
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_stddef.h> // for tbb::split
+ 
+ #include <unordered_map>
+ #include <sstream>
+diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc
+index 8074166d2..053448f30 100644
+--- a/openvdb/openvdb/unittest/TestFile.cc
++++ b/openvdb/openvdb/unittest/TestFile.cc
+@@ -13,8 +13,11 @@
+ #include <openvdb/version.h>
+ #include <openvdb/openvdb.h>
+ #include "util.h" // for unittest_util::makeSphere()
++
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
++
++#include <thread>
++#include <chrono>
+ #include <algorithm> // for std::sort()
+ #include <cstdio> // for remove() and rename()
+ #include <fstream>
+@@ -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::seconds>(
++                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<io::Queue::Id> 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));
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc
+index 70e7df5f7..6b2204771 100644
+--- a/openvdb/openvdb/unittest/TestUtil.cc
++++ b/openvdb/openvdb/unittest/TestUtil.cc
+@@ -8,7 +8,6 @@
+ 
+ #include <gtest/gtest.h>
+ 
+-#include <tbb/task_scheduler_init.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/blocked_range.h>
+diff --git a/openvdb/openvdb/unittest/TestValueAccessor.cc b/openvdb/openvdb/unittest/TestValueAccessor.cc
+index fd2dd5d81..5c1cbb18b 100644
+--- a/openvdb/openvdb/unittest/TestValueAccessor.cc
++++ b/openvdb/openvdb/unittest/TestValueAccessor.cc
+@@ -6,6 +6,7 @@
+ 
+ #include <gtest/gtest.h>
+ #include <tbb/task.h>
++#include <tbb/task_group.h>
+ 
+ #include <type_traits>
+ 
+@@ -378,22 +379,21 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
+     //using AccessorT = openvdb::tree::ValueAccessor<Tree4Type>;
+ 
+     // 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
+ }
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+index 0e1b4d855..6d9bb528b 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+@@ -20,6 +20,7 @@
+ #include <openvdb/tools/GridTransformer.h>
+ #include <openvdb/tools/PointIndexGrid.h>
+ #include <openvdb/tools/Prune.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <CH/CH_Manager.h>
+ #include <CVEX/CVEX_Context.h>
+@@ -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;
+             }
+ 
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+index 757fdc8c6..dbee74b32 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+@@ -16,13 +16,11 @@
+ #include <openvdb_houdini/SOP_NodeVDB.h>
+ 
+ #include <openvdb/tools/Interpolation.h>  // for box sampler
++#include <openvdb/thread/Threading.h>
+ #include <openvdb/points/PointCount.h>
+ #include <openvdb/points/PointSample.h>
+ #include <openvdb/points/IndexFilter.h>   // for MultiGroupFilter
+ 
+-#include <tbb/tick_count.h>                 // for timing
+-#include <tbb/task.h>                       // for cancel
+-
+ #include <UT/UT_Interrupt.h>
+ #include <GA/GA_PageHandle.h>
+ #include <GA/GA_PageIterator.h>
+@@ -38,6 +36,7 @@
+ #include <stdexcept>
+ #include <string>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ 
+@@ -327,7 +326,7 @@ class PointSampler
+     {
+ 
+         if (mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            openvdb::thread::cancelGroupExecution();
+         }
+         const GridType& grid = UTvdbGridCast<GridType>(mGrid);
+         // task local grid accessor
+@@ -481,7 +480,7 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Context& context)
+         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_Context& context)
+             }
+         }
+ 
+-        // 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::milliseconds>(
++                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;
+         }
+ 
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+index 3d559f8cc..d63ed1591 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
++++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+@@ -47,11 +47,8 @@ struct NodeInfo {
+ 
+ typedef std::vector<NodeInfo> 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, const MTypeId& typeId,
+     node.type               = type;
+     node.classification     = classification;
+ 
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (!gNodes) {
+         OPENVDB_START_THREADSAFE_STATIC_WRITE
+@@ -85,7 +82,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, const MTypeId& typeId,
+ void
+ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+@@ -109,7 +106,7 @@ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ void
+ NodeRegistry::deregisterNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.h b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+index b58bd6f2c..6a04b1eaf 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBUtil.h
++++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+@@ -14,8 +14,7 @@
+ #include <openvdb/tree/LeafManager.h>
+ #include <openvdb/tools/VolumeToMesh.h>
+ #include <openvdb/util/Formats.h> // printBytes
+-
+-#include <tbb/tick_count.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <maya/M3dView.h>
+ #include <maya/MString.h>
+@@ -40,6 +39,7 @@
+ #include <string>
+ #include <type_traits>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ ////////////////////////////////////////
+@@ -116,11 +116,15 @@ insertFrameNumber(std::string& str, const MTime& time, int numberingScheme = 0);
+ 
+ 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::milliseconds>(
++            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<std::chrono::steady_clock> mStamp;
+ };
+ 
+ 
+diff --git a/pendingchanges/tbb2021.txt b/pendingchanges/tbb2021.txt
+new file mode 100644
+index 000000000..8109c2552
+--- /dev/null
++++ b/pendingchanges/tbb2021.txt
+@@ -0,0 +1,6 @@
++Improvements:
++  - Moved from the deprecated TBB task scheduler to TBB arenas. Various methods now respect the TBB arena state they were invoked from.
++  - Introduced a new thread/Threading.h header to consolidate calls to third-party threading methods.
++
++Build:
++  - Added support for TBB 2021.
diff --git a/srcpkgs/openvdb/template b/srcpkgs/openvdb/template
index 72fde5bc6375..d420a3ee5f5d 100644
--- a/srcpkgs/openvdb/template
+++ b/srcpkgs/openvdb/template
@@ -1,26 +1,18 @@
 # Template file for 'openvdb'
 pkgname=openvdb
-version=7.0.0
+version=8.1.0
 revision=1
 build_style=cmake
 configure_args="-DOPENVDB_BUILD_VDB_VIEW=1"
 hostmakedepends="pkg-config"
-makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel glfw-devel"
+makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel
+ glfw-devel jemalloc-devel"
 short_desc="Sparse volume data structure and tools"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MPL-2.0"
 homepage="https://openvdb.org"
 distfiles="https://github.com/AcademySoftwareFoundation/openvdb/archive/v${version}.tar.gz"
-checksum=97bc8ae35ef7ccbf49a4e25cb73e8c2eccae6b235bac86f2150707efcd1e910d
-
-if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
-	makedepends+=" libatomic-devel"
-fi
-
-post_patch() {
-	[ "$XBPS_TARGET_NO_ATOMIC8" ] || return 0
-	vsed -i 's,ZLIB::ZLIB,ZLIB::ZLIB atomic,' openvdb/CMakeLists.txt
-}
+checksum=3e09d47331429be7409a3a3c27fdd3c297f96d31d2153febe194e664a99d6183
 
 post_install() {
 	vlicense LICENSE

From 2e8bbc914059136d80d389577aed357a9af4672d Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 10/12] paraview: update to 5.9.1.

---
 srcpkgs/paraview/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/paraview/template b/srcpkgs/paraview/template
index 20a7f5589677..e6c3941ce90a 100644
--- a/srcpkgs/paraview/template
+++ b/srcpkgs/paraview/template
@@ -1,7 +1,7 @@
 # Template file for 'paraview'
 pkgname=paraview
-version=5.8.1
-revision=3
+version=5.9.1
+revision=1
 wrksrc=ParaView-v${version}
 build_style=cmake
 configure_args="-DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr

From 3e3eef017eebd9aa1f5627c0b4657b92e54cab9c Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 11/12] occt: revbump due to tbb update

---
 srcpkgs/occt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/occt/template b/srcpkgs/occt/template
index 9298edc76e08..006f89ebb8ce 100644
--- a/srcpkgs/occt/template
+++ b/srcpkgs/occt/template
@@ -2,7 +2,7 @@
 pkgname=occt
 reverts=7.5.0_1
 version=7.4.0p1
-revision=3
+revision=4
 _gittag="V${version//./_}"
 wrksrc=occt-${_gittag}
 build_style=cmake

From 21a3aad6b15f931dd2bb9e60982fa3fdf9806817 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 18:05:52 +0300
Subject: [PATCH 12/12] hwloc

---
 srcpkgs/hwloc/patches/00-get-area-memlocation.patch | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hwloc/patches/00-get-area-memlocation.patch b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
index e398a80e046d..092157e45cd3 100644
--- a/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
+++ b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
@@ -1,12 +1,21 @@
 diff --git a/tests/hwloc/hwloc_get_area_memlocation.c b/tests/hwloc/hwloc_get_area_memlocation.c
-index 498dfae..999d95b 100644
+index 498dfae..8d77cf7 100644
 --- a/tests/hwloc/hwloc_get_area_memlocation.c
 +++ b/tests/hwloc/hwloc_get_area_memlocation.c
+@@ -8,7 +8,7 @@
+ #include <stdio.h>
+ #include <assert.h>
+ 
+-#define LEN 1048576
++#define LEN 1024
+ 
+ int main(void)
+ {
 @@ -34,11 +34,13 @@ int main(void)
    assert(buffer);
    printf("buffer %p length %d\n", buffer, LEN);
  
-+  fprintf(stderr, "Before memloation\nerr == %i, errno == %s\n", err, strerror(errno));
++  fprintf(stderr, "Before memlocation\nerr == %i, errno == %s\n", err, strerror(errno));
    err = hwloc_get_area_memlocation(topology, buffer, LEN, set, HWLOC_MEMBIND_BYNODESET);
    if (err < 0 && errno == ENOSYS) {
      fprintf(stderr, "hwloc_get_area_memlocation() failed with ENOSYS, aborting\n");

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PR PATCH] [Updated] tbb: update to 2021.3.0
  2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
                   ` (4 preceding siblings ...)
  2021-07-24 15:06 ` Logarithmus
@ 2021-07-24 15:32 ` Logarithmus
  2021-07-24 16:16 ` Logarithmus
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Logarithmus @ 2021-07-24 15:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

There is an updated pull request by Logarithmus against master on the void-packages repository

https://github.com/Logarithmus/void-packages tbb-2021
https://github.com/void-linux/void-packages/pull/32166

tbb: update to 2021.3.0
Follow-up of https://github.com/void-linux/void-packages/pull/27746, @thypon & @olafmersmann might be interested.
**TODO** fix reverse dependencies:
- [ ] OpenSubdiv: update to 3.4.4.
- [ ] PrusaSlicer: update to 2.3.3.
- [ ] lender: update to 2.93.1.
- [ ] embree: update to 3.13.0.
- [ ] openimageio: update to 2.2.16.0.
- [ ] openimagedenoise: update to 1.4.1.
- [ ] openvdb: update to 8.1.0.
- [ ] paraview: update to 5.9.1.
- [ ] occt: revbump due to tbb update

#### Have the results of the proposed changes been tested?
- [x] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me


A patch file from https://github.com/void-linux/void-packages/pull/32166.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-tbb-2021-32166.patch --]
[-- Type: text/x-diff, Size: 91968 bytes --]

From 80e56eebd3e7bc6f7b9486f3a7c75dca5ad766fd Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 17 Jul 2021 23:57:52 +0300
Subject: [PATCH 01/12] hwloc: add libpciaccess-devel make dependency

---
 .../patches/00-get-area-memlocation.patch      | 18 ++++++++++++++++++
 srcpkgs/hwloc/template                         |  8 +++++---
 2 files changed, 23 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hwloc/patches/00-get-area-memlocation.patch

diff --git a/srcpkgs/hwloc/patches/00-get-area-memlocation.patch b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
new file mode 100644
index 000000000000..e398a80e046d
--- /dev/null
+++ b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
@@ -0,0 +1,18 @@
+diff --git a/tests/hwloc/hwloc_get_area_memlocation.c b/tests/hwloc/hwloc_get_area_memlocation.c
+index 498dfae..999d95b 100644
+--- a/tests/hwloc/hwloc_get_area_memlocation.c
++++ b/tests/hwloc/hwloc_get_area_memlocation.c
+@@ -34,11 +34,13 @@ int main(void)
+   assert(buffer);
+   printf("buffer %p length %d\n", buffer, LEN);
+ 
++  fprintf(stderr, "Before memloation\nerr == %i, errno == %s\n", err, strerror(errno));
+   err = hwloc_get_area_memlocation(topology, buffer, LEN, set, HWLOC_MEMBIND_BYNODESET);
+   if (err < 0 && errno == ENOSYS) {
+     fprintf(stderr, "hwloc_get_area_memlocation() failed with ENOSYS, aborting\n");
+     goto out_with_buffer;
+   }
++  fprintf(stderr, "After memlocation\nerr == %i, errno == %s\n", err, strerror(errno));
+   assert(!err);
+   hwloc_bitmap_asprintf(&s, set);
+   printf("address %p length %d allocated in nodeset %s\n", buffer, LEN, s);
diff --git a/srcpkgs/hwloc/template b/srcpkgs/hwloc/template
index 818db269cebb..6eec662d0d6e 100644
--- a/srcpkgs/hwloc/template
+++ b/srcpkgs/hwloc/template
@@ -1,10 +1,12 @@
 # Template file for 'hwloc'
 pkgname=hwloc
 version=2.5.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="cairo-devel ncurses-devel libxml2-devel eudev-libudev-devel"
+makedepends="cairo-devel ncurses-devel libxml2-devel libpciaccess-devel eudev-libudev-devel"
+checkdepends="tar"
+make_check_args="VERBOSE=1"
 short_desc="Portable abstraction of hierarchical hardware architectures"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
 license="BSD-3-Clause"
@@ -31,7 +33,7 @@ libhwloc_package() {
 
 libhwloc-devel_package() {
 	short_desc+=" - development files"
-	depends="libhwloc>=${version}_${revision}"
+	depends="${makedepends} libhwloc>=${version}_${revision}"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/share/man/man3

From 14ad1bfa40be1eda08bfe91cc01002ad33830459 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 02:50:26 +0300
Subject: [PATCH 02/12] tbb: update to 2021.3.0.

---
 common/shlibs                                |   6 +-
 srcpkgs/tbb/patches/00-hwloc-2.5.patch       | 367 +++++++++++++++++++
 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch |  52 +++
 srcpkgs/tbb/patches/hostname-usage.patch     |  11 -
 srcpkgs/tbb/patches/musl.patch               |   4 +-
 srcpkgs/tbb/template                         |  63 +---
 6 files changed, 433 insertions(+), 70 deletions(-)
 create mode 100644 srcpkgs/tbb/patches/00-hwloc-2.5.patch
 create mode 100644 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
 delete mode 100644 srcpkgs/tbb/patches/hostname-usage.patch

diff --git a/common/shlibs b/common/shlibs
index a7afbf2a56f7..6b7ca5fbc249 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2376,12 +2376,10 @@ libanthy-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthydic-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthyinput-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthygobject-1.0.so.5 ibus-anthy-1.5.6_1
-libtbbmalloc_proxy_debug.so.2 tbb-4.3_1
 libtbbmalloc_proxy.so.2 tbb-4.3_1
 libtbbmalloc.so.2 tbb-4.3_1
-libtbb_debug.so.2 tbb-4.3_1
-libtbb.so.2 tbb-4.3_1
-libtbbmalloc_debug.so.2 tbb-4.3_1
+libtbb.so.12 tbb-2021.3.0_1
+libtbbbind_2_5.so.3 tbb-2021.3.0_1
 libembree.so.2 embree-2.5.1_1
 libgtkimageview.so.0 gtkimageview-1.6.4_1
 libgoocanvas-2.0.so.9 goocanvas-2.0.4_1
diff --git a/srcpkgs/tbb/patches/00-hwloc-2.5.patch b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
new file mode 100644
index 000000000000..9c4c9285c71d
--- /dev/null
+++ b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
@@ -0,0 +1,367 @@
+Adjusted by Artur Sinila <freesoftware@logarithmus.dev>
+
+From e96dbf4b48e689ab810b0428d0858a6abc2c83bd Mon Sep 17 00:00:00 2001
+From: Ivan Kochin <iv.kochin@gmail.com>
+Date: Thu, 1 Jul 2021 15:07:39 +0300
+Subject: [PATCH] Upgrade from HWLOC 2.4 to HWLOC 2.5 (#448)
+
+* Upgrade from HWLOC 2.4 to HWLOC 2.5
+* Introduce tbbbind_2_5 library
+* Remove tbbbind_2_4 library
+* Use the HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING topology flag (introduces as a part of HWLOC 2.5) to restrict topology discovering to process binding
+* Fix testing on Linux
+* Apply review comments
+* Improve wording: variable -> substring
+* Use right tbbbind version for incompatible hwlocs test
+* Rework option semantic
+* Update README.md for CMake
+* Rework readme
+* Update cmake/README.md
+
+Signed-off-by: Kochin, Ivan <kochin.ivan@intel.com>
+
+Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
+---
+ CMakeLists.txt                         |  3 ++-
+ cmake/README.md                        | 11 +++++---
+ cmake/hwloc_detection.cmake            |  9 ++++---
+ src/tbb/governor.cpp                   |  4 +--
+ src/tbbbind/CMakeLists.txt             |  2 +-
+ src/tbbbind/tbb_bind.cpp               | 23 +++++++++++-----
+ test/CMakeLists.txt                    | 30 ++++++++++-----------
+ test/common/common_arena_constraints.h | 37 ++++++++++++++++++++++----
+ 8 files changed, 82 insertions(+), 37 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 34a23d400..301899aca 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -100,6 +100,7 @@ option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Win
+ option(TBB4PY_BUILD "Enable tbb4py build" OFF)
+ option(TBB_CPF "Enable preview features of the library" OFF)
+ option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
++option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
+ 
+ if (NOT DEFINED BUILD_SHARED_LIBS)
+     set(BUILD_SHARED_LIBS ON)
+@@ -195,7 +196,7 @@ else()
+         add_subdirectory(src/tbbmalloc)
+         add_subdirectory(src/tbbmalloc_proxy)
+         if (APPLE)
+-            message(STATUS "TBBBind build target is disabled due to unsupported environment")
++            message(STATUS "TBBBind build targets are disabled due to unsupported environment")
+         else()
+             add_subdirectory(src/tbbbind)
+         endif()
+diff --git a/cmake/README.md b/cmake/README.md
+index 36fc303f9..b58c2ff6a 100644
+--- a/cmake/README.md
++++ b/cmake/README.md
+@@ -13,6 +13,7 @@ TBB4PY_BUILD:BOOL - Enable  Intel(R) oneAPI Threading Building Blocks (oneTBB) P
+ TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
+ TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
+ TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
++TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)
+ ```
+ 
+ ## Configure, build and test
+@@ -42,9 +43,9 @@ Some useful options:
+ 
+ #### TBBBind library configuration
+ 
+-The TBBbind library has two versions: `tbbbind` and `tbbbind_2_0`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.x.
++The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0` and `tbbbind_2_5`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.1-2.4, `tbbbind_2_5` links with HWLOC 2.5 and later.
+ 
+-To enable the TBBBind library build or special tests that performed inside the HWLOC environment, please specify the following CMake variables:
++The search for a suitable version of the HWLOC library is enabled by default, but if you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
+ 
+  - `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux or path to `.lib` file on Windows.
+  - `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version includes directory.
+@@ -52,7 +53,11 @@ To enable the TBBBind library build or special tests that performed inside the H
+ Windows requires one additional variable for correct TBBBind library building:
+  - `CMAKE_HWLOC_<HWLOC_VER>_DLL_PATH` - path to the corresponding HWLOC version `.dll` file.
+ 
+-`HWLOC_VER` variable used above can be replaced with one of the two values: `1_11` for the `tbbbind` library configuration and `2` for the `tbbbind_2_0` library configuration.
++`HWLOC_VER` substring used above can be replaced with one of the three values: `1_11` for the `tbbbind` library configuration, `2` for the `tbbbind_2_0`, and `2_5` for the `tbbbind_2_5` library configuration.
++
++If you specify variables for several TBBBind versions, then building process for all of these versions will be performed during single build session.
++
++Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
+ 
+ ### Build
+ 
+diff --git a/cmake/hwloc_detection.cmake b/cmake/hwloc_detection.cmake
+index e1eeca5fa..de7f3c047 100644
+--- a/cmake/hwloc_detection.cmake
++++ b/cmake/hwloc_detection.cmake
+@@ -12,7 +12,7 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
+-list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_4)
++list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_5)
+ 
+ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
+     if (NOT WIN32)
+@@ -55,10 +56,10 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
+         if (HWLOC_FOUND)
+             if (HWLOC_VERSION VERSION_LESS 2)
+                 set(TBBBIND_LIBRARY_NAME tbbbind)
+-            elseif(HWLOC_VERSION VERSION_LESS 2.4)
++            elseif(HWLOC_VERSION VERSION_LESS 2.5)
+                 set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
+             else()
+-                set(TBBBIND_LIBRARY_NAME tbbbind_2_4)
++                set(TBBBIND_LIBRARY_NAME tbbbind_2_5)
+             endif()
+         endif()
+     endif()
+diff --git a/src/tbb/governor.cpp b/src/tbb/governor.cpp
+index bf4e402d1..b842e075f 100644
+--- a/src/tbb/governor.cpp
++++ b/src/tbb/governor.cpp
+@@ -362,7 +362,7 @@ static const unsigned LinkTableSize = sizeof(TbbBindLinkTable) / sizeof(dynamic_
+ 
+ #define TBBBIND_NAME LIBRARY_PREFIX "tbbbind" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #define TBBBIND_2_0_NAME LIBRARY_PREFIX "tbbbind_2_0" DEBUG_SUFFIX LIBRARY_EXTENSION
+-#define TBBBIND_2_4_NAME LIBRARY_PREFIX "tbbbind_2_4" DEBUG_SUFFIX LIBRARY_EXTENSION
++#define TBBBIND_2_5_NAME LIBRARY_PREFIX "tbbbind_2_5" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #endif /* _WIN32 || _WIN64 || __linux__ */
+ 
+ // Representation of system hardware topology information on the TBB side.
+@@ -389,7 +389,7 @@ const char* load_tbbbind_shared_object() {
+     GetNativeSystemInfo(&si);
+     if (si.dwNumberOfProcessors > 32) return nullptr;
+ #endif /* _WIN32 && !_WIN64 */
+-    for (const auto& tbbbind_version : {TBBBIND_2_4_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
++    for (const auto& tbbbind_version : {TBBBIND_2_5_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
+         if (dynamic_link(tbbbind_version, TbbBindLinkTable, LinkTableSize)) {
+             return tbbbind_version;
+         }
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index 029893751..e5cdbf8bb 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -99,7 +99,7 @@ if (NOT DEFINED HWLOC_TARGET_EXPLICITLY_DEFINED AND DEFINED HWLOC_LIBRARIES)
+ else()
+     tbbbind_build(tbbbind     HWLOC::hwloc_1_11)
+     tbbbind_build(tbbbind_2_0 HWLOC::hwloc_2   )
+-    tbbbind_build(tbbbind_2_4 HWLOC::hwloc_2_4 )
++    tbbbind_build(tbbbind_2_5 HWLOC::hwloc_2_5 )
+ endif()
+ 
+ 
+diff --git a/src/tbbbind/tbb_bind.cpp b/src/tbbbind/tbb_bind.cpp
+index 97be308c7..88c956acb 100644
+--- a/src/tbbbind/tbb_bind.cpp
++++ b/src/tbbbind/tbb_bind.cpp
+@@ -34,7 +34,8 @@
+ #pragma GCC diagnostic pop
+ #endif
+ 
+-#define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ 
+ // Most of hwloc calls returns negative exit code on error.
+ // This macro tracks error codes that are returned from the hwloc interfaces.
+@@ -85,6 +86,16 @@ class platform_topology {
+         // Parse topology
+         if ( hwloc_topology_init( &topology ) == 0 ) {
+             initialization_state = topology_allocated;
++#if __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++            if ( groups_num == 1 &&
++                 hwloc_topology_set_flags(topology,
++                     HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                     HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
++                 ) != 0
++            ) {
++                return;
++            }
++#endif
+             if ( hwloc_topology_load( topology ) == 0 ) {
+                 initialization_state = topology_loaded;
+             }
+@@ -135,7 +146,7 @@ class platform_topology {
+             numa_indexes_list.resize(numa_nodes_count);
+             hwloc_obj_t node_buffer;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 numa_indexes_list[counter] = static_cast<int>(node_buffer->logical_index);
+ 
+                 if ( numa_indexes_list[counter] > max_numa_index ) {
+@@ -150,7 +161,7 @@ class platform_topology {
+             numa_affinity_masks_list.resize(max_numa_index + 1);
+             int index = 0;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 index = static_cast<int>(node_buffer->logical_index);
+ 
+                 hwloc_cpuset_t& current_mask = numa_affinity_masks_list[index];
+@@ -168,7 +179,7 @@ class platform_topology {
+             core_types_indexes_list.push_back(-1);
+             return;
+         }
+-#if __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
++#if __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
+         __TBB_ASSERT(hwloc_get_api_version() >= 0x20400, "Hybrid CPUs support interfaces required HWLOC >= 2.4");
+         // Parsing the hybrid CPU topology
+         int core_types_number = hwloc_cpukinds_get_nr(topology, 0);
+@@ -196,9 +207,9 @@ class platform_topology {
+                 }
+             }
+         }
+-#else /*!__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#else /*!__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+         bool core_types_parsing_broken{true};
+-#endif /*__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#endif /*__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+ 
+         if (core_types_parsing_broken) {
+             for (auto& core_type_mask : core_types_affinity_masks_list) {
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index bdae9e2b1..c2b9d6dba 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -275,9 +275,9 @@ function(tbb_add_tbbbind_test)
+         FAIL_REGULAR_EXPRESSION "Status:.*FAILURE"
+     )
+ 
+-    if (TARGET HWLOC::hwloc_2_4 AND NOT HWLOC_2_4_TESTS_STATUS_SHOWN)
+-        message(STATUS "HWLOC 2.4 dependent tests were enabled.")
+-        set(HWLOC_2_4_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
++    if (TARGET HWLOC::hwloc_2_5 AND NOT HWLOC_2_5_TESTS_STATUS_SHOWN)
++        message(STATUS "HWLOC 2.5 dependent tests were enabled.")
++        set(HWLOC_2_5_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
+     endif()
+ 
+     if (TARGET HWLOC::hwloc_2 AND NOT HWLOC_2_TESTS_STATUS_SHOWN)
+@@ -291,22 +291,22 @@ function(tbb_add_tbbbind_test)
+     endif()
+ 
+     list(APPEND HWLOC_TEST_CASES
+-        hwloc_2_4
++        hwloc_2_5
+         hwloc_2
+         hwloc_1_11
+-        hwloc_2_4_hwloc_2
+-        hwloc_2_4_hwloc_1_11
++        hwloc_2_5_hwloc_2
++        hwloc_2_5_hwloc_1_11
+         hwloc_2_hwloc_1_11
+-        hwloc_2_4_hwloc_2_hwloc_1_11
++        hwloc_2_5_hwloc_2_hwloc_1_11
+     )
+ 
+-    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_4 "hwloc_2_4")
++    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_5 "hwloc_2_5")
+     list(APPEND HWLOC_TEST_CASE_1_VARS tbbbind_2   "hwloc_2")
+     list(APPEND HWLOC_TEST_CASE_2_VARS tbbbind     "hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2")
+-    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_4 "hwloc_2_4,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2")
++    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_5 "hwloc_2_5,hwloc_1_11")
+     list(APPEND HWLOC_TEST_CASE_5_VARS tbbbind_2   "hwloc_2,hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2,hwloc_1_11")
+ 
+     foreach(TEST_CASE ${HWLOC_TEST_CASES})
+         list(FIND HWLOC_TEST_CASES ${TEST_CASE} TEST_CASE_INDEX)
+@@ -331,7 +331,7 @@ endfunction()
+ # Copy libraries to test folder to make it visible during tests execution if external TBB is tested.
+ # TODO: check and update for multi-config generators.
+ if (TBB_FOUND)
+-    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_4)
++    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_5)
+     foreach(_component ${_tbb_test_components})
+         if (TARGET TBB::${_component})
+             get_property(${_component}_lib_file_location TARGET TBB::${_component} PROPERTY LOCATION)
+@@ -593,6 +593,6 @@ if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
+     tbb_add_test(SUBDIR tbbmalloc NAME test_malloc_new_handler DEPENDENCIES TBB::tbbmalloc_proxy)
+ endif()
+ 
+-unset(HWLOC_2_4_TESTS_STATUS_SHOWN)
++unset(HWLOC_2_5_TESTS_STATUS_SHOWN)
+ unset(HWLOC_2_TESTS_STATUS_SHOWN)
+ unset(HWLOC_1_11_TESTS_STATUS_SHOWN)
+diff --git a/test/common/common_arena_constraints.h b/test/common/common_arena_constraints.h
+index 2a0b1ea97..5efc71082 100644
+--- a/test/common/common_arena_constraints.h
++++ b/test/common/common_arena_constraints.h
+@@ -38,9 +38,26 @@
+ 
+ #if (_WIN32 || _WIN64) && __TBB_HWLOC_VALID_ENVIRONMENT
+ #include <windows.h>
+-int get_processors_groups_count() { return GetActiveProcessorGroupCount(); }
++int get_processors_group_count() {
++    SYSTEM_INFO si;
++    GetNativeSystemInfo(&si);
++    DWORD_PTR pam, sam, m = 1;
++    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
++    int nproc = 0;
++    for ( std::size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
++        if ( pam & m )
++            ++nproc;
++    }
++    // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present
++    if ( nproc == (int)si.dwNumberOfProcessors  ) {
++        // The process does not have restricting affinity mask and multiple processor groups are possible
++        return (int)GetActiveProcessorGroupCount();
++    } else {
++        return 1;
++    }
++}
+ #else
+-int get_processors_groups_count() { return 1; }
++int get_processors_group_count() { return 1; }
+ #endif
+ 
+ //TODO: Write a test that checks for memory leaks during dynamic link/unlink of TBBbind.
+@@ -69,6 +86,7 @@ int get_processors_groups_count() { return 1; }
+ #endif
+ 
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ // At this moment the hybrid CPUs HWLOC interfaces returns unexpected results on some Windows machines
+ // in the 32-bit arch mode.
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_VALID (!_WIN32 || _WIN64)
+@@ -153,9 +171,18 @@ class system_info {
+ 
+     system_info() {
+         hwloc_require_ex(hwloc_topology_init, &topology);
++#if __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++        if ( get_processors_group_count() == 1 ) {
++            REQUIRE(
++                hwloc_topology_set_flags(topology,
++                    HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                    HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING) == 0
++            );
++        }
++#endif
+         hwloc_require_ex(hwloc_topology_load, topology);
+ 
+-        if ( get_processors_groups_count() > 1 ) {
++        if ( get_processors_group_count() > 1 ) {
+             process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
+         } else {
+             process_cpuset = hwloc_bitmap_alloc();
+@@ -434,7 +461,7 @@ system_info::affinity_mask get_arena_affinity(tbb::task_arena& ta) {
+                 barrier.wait();
+                 tbb::spin_mutex::scoped_lock lock(affinity_mutex);
+                 system_info::affinity_mask thread_affinity = system_info::allocate_current_affinity_mask();
+-                if (get_processors_groups_count() == 1) {
++                if (get_processors_group_count() == 1) {
+                     REQUIRE_MESSAGE(hwloc_bitmap_isequal(thread_affinity, arena_affinity),
+                         "Threads have different masks on machine without several processors groups.");
+                 }
+@@ -532,7 +559,7 @@ constraints_container generate_constraints_variety() {
+         }
+ 
+         // Some constraints may cause unexpected behavior, which would be fixed later.
+-        if (get_processors_groups_count() > 1) {
++        if (get_processors_group_count() > 1) {
+             for(auto it = results.begin(); it != results.end(); ++it) {
+                 if (it->max_threads_per_core != tbb::task_arena::automatic
+                    && (it->numa_id == tbb::task_arena::automatic || tbb::info::numa_nodes().size() == 1)
diff --git a/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
new file mode 100644
index 000000000000..279ebc4397cd
--- /dev/null
+++ b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
@@ -0,0 +1,52 @@
+Based on https://github.com/oneapi-src/oneTBB/pull/498
+Tweaked a bit to work on `v2021.3.0`
+
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index e5cdbf8bb..a4033210a 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -37,6 +37,10 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+         ${HWLOC_INCLUDE_DIRS} # pkg-config defined
+     )
++	target_link_directories(${TBBBIND_NAME}
++		PRIVATE
++		${HWLOC_LIBRARY_DIRS} # pkg-config defined
++	)
+ 
+     target_compile_options(${TBBBIND_NAME}
+         PRIVATE
+@@ -69,7 +69,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     else()
+         target_link_libraries(${TBBBIND_NAME}
+@@ -76,7 +76,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     endif()
+ 
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index b768759d5..3eb8357e6 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -258,7 +258,12 @@ function(tbb_add_tbbbind_test)
+         )
+         set_property(
+             TARGET ${_tbbbind_test_NAME}
+-            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARY_DIRS} ${HWLOC_LIBRARIES}
++            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARIES}
++            APPEND
++        )
++        set_property(
++            TARGET ${_tbbbind_test_NAME}
++			PROPERTY LINK_DIRECTORIES ${HWLOC_LIBRARY_DIRS}
+             APPEND
+         )
+         set_property(
diff --git a/srcpkgs/tbb/patches/hostname-usage.patch b/srcpkgs/tbb/patches/hostname-usage.patch
deleted file mode 100644
index 4aefeff192b5..000000000000
--- a/srcpkgs/tbb/patches/hostname-usage.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/build/version_info_linux.sh
-+++ b/build/version_info_linux.sh
-@@ -20,7 +20,7 @@
- 
- # Script used to generate version info string
- echo "#define __TBB_VERSION_STRINGS(N) \\"
--echo '#N": BUILD_HOST'"\t\t"`hostname -s`" ("`uname -m`")"'" ENDL \'
-+echo '#N": BUILD_HOST'"\t\t"`hostname`" ("`uname -m`")"'" ENDL \'
- # find OS name in *-release and issue* files by filtering blank lines and lsb-release content out
- echo '#N": BUILD_OS'"\t\t"`lsb_release -sd 2>/dev/null | grep -ih '[a-z] ' - /etc/*release /etc/issue 2>/dev/null | head -1 | sed -e 's/["\\\\]//g'`'" ENDL \'
- echo '#N": BUILD_KERNEL'"\t"`uname -srv`'" ENDL \'
diff --git a/srcpkgs/tbb/patches/musl.patch b/srcpkgs/tbb/patches/musl.patch
index a8867eb53793..ec89c6a95fc6 100644
--- a/srcpkgs/tbb/patches/musl.patch
+++ b/srcpkgs/tbb/patches/musl.patch
@@ -1,5 +1,5 @@
---- a/src/tbbmalloc/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
-+++ b/src/tbbmalloc/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
+--- a/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
++++ b/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
 @@ -28,6 +28,7 @@
  // of aligned_alloc as required by new C++ standard, this makes it hard to
  // redefine aligned_alloc here. However, running on systems with new libc
diff --git a/srcpkgs/tbb/template b/srcpkgs/tbb/template
index aeef6ebdd061..47655829f744 100644
--- a/srcpkgs/tbb/template
+++ b/srcpkgs/tbb/template
@@ -1,76 +1,33 @@
 # Template file for 'tbb'
 pkgname=tbb
-version=2020.U3
+version=2021.3.0
 revision=1
-# version rewrite: 2017_U7 (upstream) => 2017.7 (xbps)
-_ver=${version/./_}
-wrksrc="oneTBB-${_ver}"
-build_style=gnu-makefile
-hostmakedepends="cmake"
+wrksrc="oneTBB-${version}"
+build_style=cmake
+makedepends="libhwloc-devel libgomp-devel"
 short_desc="Intel Threading Building Blocks"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
 license="Apache-2.0"
 homepage="https://www.threadingbuildingblocks.org"
-distfiles="https://github.com/oneapi-src/oneTBB/archive/${_ver}.tar.gz"
-checksum=2103cc6238c935664f87680618f6684d57501d4a2fa8ea8f6c97ad6ff7dc722a
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*)
-		make_build_args="arch=intel64"
-		;;
-	i686*)
-		make_build_args="arch=ia32"
-		;;
-	armv7l*)
-		make_build_args="arch=armv7"
-		;;
-	aarch64*)
-		make_build_args="arch=arm64"
-		;;
-	ppc64*)
-		make_build_args="arch=ppc64"
-		;;
-	ppc*)
-		make_build_args="arch=ppc32"
-		;;
-	*)
-		# make sure to fall back instead of letting host uname control it
-		make_build_args="arch=generic"
-		;;
-esac
-
-post_extract() {
-	sed -i 's|CPLUS = g..|CPLUS = $(CXX)|g' build/linux.gcc.inc
-	sed -i 's|CONLY = gcc|CONLY = $(CC)|g' build/linux.gcc.inc
+distfiles="https://github.com/oneapi-src/oneTBB/archive/v${version}.tar.gz"
+checksum=8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e
 
+pre_patch() {
 	# alternative might be:
 	# https://git.alpinelinux.org/cgit/aports/tree/testing/libtbb/glibc-struct-mallinfo.patch
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		vsed -e "s@#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__@@" \
-		  -i src/tbbmalloc/proxy.h
+		  -i src/tbbmalloc_proxy/proxy.h
 	fi
 }
 
-do_install() {
-	vmkdir usr/lib
-	vcopy build/linux_*/*.so* usr/lib
-	vmkdir usr/include/tbb
-	vcopy include/tbb/* usr/include/tbb
-
-	cmake \
-		-DINSTALL_DIR=$DESTDIR/usr/lib/cmake/TBB \
-		-DSYSTEM_NAME=Linux \
-		-DLIB_REL_PATH=../.. \
-		-DINC_REL_PATH=../../../include \
-		-P cmake/tbb_config_installer.cmake
-}
-
 tbb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
-		vmove "usr/lib/*.so"
 		vmove usr/lib/cmake
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.so
 	}
 }

From 58ac9ae5d54bd2e3523233976b54cefef4e7f6b7 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 03/12] OpenSubdiv: update to 3.4.4.

---
 srcpkgs/OpenSubdiv/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/OpenSubdiv/template b/srcpkgs/OpenSubdiv/template
index b7a5e16efbcf..dfbf29cc1a52 100644
--- a/srcpkgs/OpenSubdiv/template
+++ b/srcpkgs/OpenSubdiv/template
@@ -1,6 +1,6 @@
 # Template file for 'OpenSubdiv'
 pkgname=OpenSubdiv
-version=3.4.3
+version=3.4.4
 revision=1
 wrksrc="OpenSubdiv-${version//./_}"
 build_style=cmake
@@ -13,7 +13,7 @@ maintainer="John <me@johnnynator.dev>"
 license="Apache-2.0"
 homepage="http://graphics.pixar.com/opensubdiv/docs/intro.html"
 distfiles="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${version//./_}.tar.gz"
-checksum=7b22eb27d636ab0c1e03722c7a5a5bd4f11664ee65c9b48f341a6d0ce7f36745
+checksum=20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" OpenSubdiv"

From 0cce9a9c569c8ead61a5c61995fa4b3c87fe6100 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 04/12] PrusaSlicer: update to 2.3.3.

---
 srcpkgs/PrusaSlicer/patches/cross.patch | 11 -----------
 srcpkgs/PrusaSlicer/template            |  4 ++--
 2 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 srcpkgs/PrusaSlicer/patches/cross.patch

diff --git a/srcpkgs/PrusaSlicer/patches/cross.patch b/srcpkgs/PrusaSlicer/patches/cross.patch
deleted file mode 100644
index d64a450d9e9f..000000000000
--- a/srcpkgs/PrusaSlicer/patches/cross.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/avrdude/CMakeLists.txt	2020-06-04 09:19:26.017251215 +0200
-+++ b/src/avrdude/CMakeLists.txt	2020-06-04 09:19:36.468250771 +0200
-@@ -83,7 +83,7 @@ add_executable(avrdude-conf-gen conf-gen
- add_custom_command(
-     DEPENDS avrdude-conf-gen ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf
-     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
--    COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-+    COMMAND avrdude-conf-gen avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- 
diff --git a/srcpkgs/PrusaSlicer/template b/srcpkgs/PrusaSlicer/template
index dd0e76cb8017..a93832ac02e4 100644
--- a/srcpkgs/PrusaSlicer/template
+++ b/srcpkgs/PrusaSlicer/template
@@ -1,6 +1,6 @@
 # Template file for 'PrusaSlicer'
 pkgname=PrusaSlicer
-version=2.3.0
+version=2.3.3
 revision=1
 wrksrc="PrusaSlicer-version_${version}"
 build_style=cmake
@@ -16,7 +16,7 @@ maintainer="Jasper Chan <jasperchan515@gmail.com>"
 license="GPL-3.0-or-later"
 homepage="https://www.prusa3d.com/prusaslicer/"
 distfiles="https://github.com/prusa3d/Prusaslicer/archive/version_${version}.tar.gz"
-checksum=cd3bac5e29b5441fc4690f28cd7b1064e97dc00207bbdc88f7bd7832308d6ca5
+checksum=deda209505f740ac3d6f59cb2a960f4df908269ee09bd30cd4edb9fc472d29ac
 nocross="https://build.voidlinux.org/builders/armv7l_builder/builds/25230/steps/shell_3/logs/stdio"
 
 Slic3rPE_package() {

From 6e51deb8106170ac686ebfd2205f6d89524968ad Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 05/12] blender: update to 2.93.1.

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index af946c2b7999..8318317c82bf 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,6 +1,6 @@
 # Template file for 'blender'
 pkgname=blender
-version=2.93.0
+version=2.93.1
 revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"

From 9c32dd199aad6d41af4197a4cdedcb3d05b136fd Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 06/12] embree: update to 3.13.0.

---
 srcpkgs/embree/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/embree/template b/srcpkgs/embree/template
index 575b9bcb401c..b6f376d30efa 100644
--- a/srcpkgs/embree/template
+++ b/srcpkgs/embree/template
@@ -1,8 +1,8 @@
 # Template file for 'embree'
 pkgname=embree
-version=2.17.7
-revision=2
-archs="x86_64"
+version=3.13.0
+revision=1
+archs="x86_64*"
 build_style=cmake
 configure_args="-DTBB_ROOT=/usr -DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF"
 hostmakedepends="ispc"

From c7ee6b56ca53aee247edf115de88f3181b96c2bd Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 03:34:43 +0300
Subject: [PATCH 07/12] openimageio: update to 2.2.16.0.

---
 srcpkgs/openimageio/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index de8e1cd04409..3bfdd4e0ed1e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,11 +1,11 @@
 # Template file for 'openimageio'
 pkgname=openimageio
-version=2.2.15.1
+version=2.2.16.0
 revision=1
 wrksrc="oiio-Release-${version}"
 build_style=cmake
 configure_args="-DUSE_OPENGL=0 -DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=1
- -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0"
+ -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0 -DCMAKE_CXX_STANDARD=14"
 hostmakedepends="pkg-config git"
 makedepends="boost-devel giflib-devel libraw-devel libopenjpeg-devel libwebp-devel
  libjpeg-turbo-devel tiff-devel libpng-devel libopenexr-devel freetype-devel
@@ -17,7 +17,7 @@ license="BSD-3-Clause"
 homepage="https://sites.google.com/site/openimageio/home"
 changelog="https://raw.githubusercontent.com/OpenImageIO/oiio/release/CHANGES.md"
 distfiles="https://github.com/OpenImageIO/oiio/archive/Release-${version}.tar.gz"
-checksum=f222c6b51a40aabbc80ddf4055535be9af1ffa907452fa6d1ffa7674854aab17
+checksum=d1a59f32dbba3ba71ad2e62e107034d1c5287bca1b0696474e927d504cd05ef4
 # Runs checks even for features we disabled.
 make_check=no
 

From 749df30055fcbdae12bdad23247bef55f9f9ee14 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 08/12] openimagedenoise: update to 1.4.1.

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index c73913b4e9d7..14055aff1c27 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,6 +1,6 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
-version=1.4.0
+version=1.4.1
 revision=1
 archs="x86_64*"
 wrksrc=oidn-${version}

From e30cd818f3f1d503a5efd5ec5bab1dc9c64794a5 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 09/12] openvdb: update to 8.1.0.

---
 common/shlibs                             |    2 +-
 srcpkgs/openvdb/patches/00-tbb-2021.patch | 1320 +++++++++++++++++++++
 srcpkgs/openvdb/template                  |   16 +-
 3 files changed, 1325 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/openvdb/patches/00-tbb-2021.patch

diff --git a/common/shlibs b/common/shlibs
index 6b7ca5fbc249..2a7acdb253a7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3883,7 +3883,7 @@ libjanet.so.1.16 janet-1.16.0_1
 libOpenImageDenoise.so.1 openimagedenoise-1.3.0_1
 libcbang0.so cbang-1.6.0_3
 libblosc.so.1 c-blosc-1.17.1_1
-libopenvdb.so.7.0 openvdb-7.0.0_1
+libopenvdb.so.8.1 openvdb-8.1.0_1
 libAlembic.so.1.7 alembic-1.7.13_1
 libmodsecurity.so.3 modsecurity-3.0.4_1
 libraven.so.0 budgie-desktop-10.5.1_1
diff --git a/srcpkgs/openvdb/patches/00-tbb-2021.patch b/srcpkgs/openvdb/patches/00-tbb-2021.patch
new file mode 100644
index 000000000000..271104af3df9
--- /dev/null
+++ b/srcpkgs/openvdb/patches/00-tbb-2021.patch
@@ -0,0 +1,1320 @@
+https://github.com/AcademySoftwareFoundation/openvdb/pull/1027
+Should be dropped after 8.1.1 release.
+
+diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake
+index d41436b1c..06de2b3f3 100644
+--- a/cmake/FindTBB.cmake
++++ b/cmake/FindTBB.cmake
+@@ -169,8 +169,22 @@ find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
+   PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
+ )
+ 
+-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" ""
+@@ -178,7 +192,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" ""
+@@ -192,6 +206,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
+ # ------------------------------------------------------------------------
+diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt
+index 88543df3a..929fe94d1 100644
+--- a/openvdb/openvdb/CMakeLists.txt
++++ b/openvdb/openvdb/CMakeLists.txt
+@@ -437,6 +437,10 @@ set(OPENVDB_LIBRARY_UTIL_INCLUDE_FILES
+   util/Util.h
+ )
+ 
++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} DESTINATION ${OPENVDB_INST
+ 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)
+diff --git a/openvdb/openvdb/cmd/openvdb_render.cc b/openvdb/openvdb/cmd/openvdb_render.cc
+index ee5b737c5..2c9831ba3 100644
+--- a/openvdb/openvdb/cmd/openvdb_render.cc
++++ b/openvdb/openvdb/cmd/openvdb_render.cc
+@@ -19,7 +19,14 @@
+ #include <OpenEXR/ImfHeader.h>
+ #include <OpenEXR/ImfOutputFile.h>
+ #include <OpenEXR/ImfPixelType.h>
+-#include <tbb/task_scheduler_init.h>
++
++// 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 <tbb/global_control.h>
+ #include <tbb/tick_count.h>
+ 
+ #include <algorithm>
+@@ -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<tbb::global_control> 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();
+ 
+diff --git a/openvdb/openvdb/io/Queue.cc b/openvdb/openvdb/io/Queue.cc
+index ef5d2961a..20ff1a0c1 100644
+--- a/openvdb/openvdb/io/Queue.cc
++++ b/openvdb/openvdb/io/Queue.cc
+@@ -5,20 +5,22 @@
+ /// @author Peter Cucka
+ 
+ #include "Queue.h"
+-
+ #include "File.h"
+ #include "Stream.h"
+-#include <openvdb/Exceptions.h>
+-#include <openvdb/util/logging.h>
++#include "openvdb/Exceptions.h"
++#include "openvdb/util/logging.h"
++
+ #include <tbb/concurrent_hash_map.h>
+-#include <tbb/task.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
+-#include <tbb/tick_count.h>
++#include <tbb/task_arena.h>
++
++#include <thread>
+ #include <algorithm> // for std::max()
+ #include <atomic>
+ #include <iostream>
+ #include <map>
+ #include <mutex>
++#include <chrono>
++
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -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
+ 
+ 
+ // 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
+         : 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
+             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<Queue::Id, Queue::Status>;
+ 
+-
+     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::milliseconds>(
++                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;
+ }
+ 
+diff --git a/openvdb/openvdb/math/Coord.h b/openvdb/openvdb/math/Coord.h
+index 504b5e9a4..2e9cfed5d 100644
+--- a/openvdb/openvdb/math/Coord.h
++++ b/openvdb/openvdb/math/Coord.h
+@@ -13,8 +13,7 @@
+ #include "Math.h"
+ #include "Vec3.h"
+ 
+-namespace tbb { class split; } // forward declaration
+-
++#include <tbb/blocked_range.h> // for tbb::split
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+diff --git a/openvdb/openvdb/points/PointSample.h b/openvdb/openvdb/points/PointSample.h
+index a122cc4fb..27ec3fb29 100644
+--- a/openvdb/openvdb/points/PointSample.h
++++ b/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 <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tools/Interpolation.h>
++#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 <sstream>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -299,7 +299,7 @@ class PointDataSampler
+             using TargetHandleT = AttributeWriteHandle<typename SamplerWrapperT::ValueType>;
+ 
+             if (util::wasInterrupted(interrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return;
+             }
+ 
+diff --git a/openvdb/openvdb/thread/Threading.h b/openvdb/openvdb/thread/Threading.h
+new file mode 100644
+index 000000000..0c3b356e3
+--- /dev/null
++++ b/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 <tbb/blocked_range.h>
++#include <tbb/task.h>
++#include <tbb/task_group.h>
++
++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
+diff --git a/openvdb/openvdb/tools/Composite.h b/openvdb/openvdb/tools/Composite.h
+index 6bc170bf7..88ff86f9f 100644
+--- a/openvdb/openvdb/tools/Composite.h
++++ b/openvdb/openvdb/tools/Composite.h
+@@ -24,7 +24,6 @@
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include <type_traits>
+ #include <functional>
+diff --git a/openvdb/openvdb/tools/Diagnostics.h b/openvdb/openvdb/tools/Diagnostics.h
+index 694d2155f..e5844e448 100644
+--- a/openvdb/openvdb/tools/Diagnostics.h
++++ b/openvdb/openvdb/tools/Diagnostics.h
+@@ -11,14 +11,17 @@
+ #ifndef OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ 
+-#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/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 <tbb/blocked_range.h>
+ #include <tbb/parallel_reduce.h>
++
+ #include <cmath> // for std::isnan(), std::isfinite()
+ #include <set>
+ #include <sstream>
+@@ -26,7 +29,6 @@
+ #include <type_traits>
+ #include <vector>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -1160,13 +1162,13 @@ InactiveVoxelValues<TreeType>::operator()(const tbb::blocked_range<size_t>& rang
+ {
+     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<typename TreeType>
+ inline void
+ InactiveTileValues<TreeType>::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();
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/tools/Filter.h b/openvdb/openvdb/tools/Filter.h
+index 408c75541..b70212520 100644
+--- a/openvdb/openvdb/tools/Filter.h
++++ b/openvdb/openvdb/tools/Filter.h
+@@ -14,21 +14,24 @@
+ #ifndef OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ 
+-#include <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
++#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 <tbb/parallel_for.h>
++#include <tbb/concurrent_vector.h>
++
+ #include <algorithm> // for std::max()
+ #include <functional>
+ #include <type_traits>
+-#include <tbb/concurrent_vector.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -833,7 +836,7 @@ inline bool
+ Filter<GridT, MaskT, InterruptT>::wasInterrupted()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return true;
+     }
+     return false;
+diff --git a/openvdb/openvdb/tools/GridOperators.h b/openvdb/openvdb/tools/GridOperators.h
+index 31305a1ab..78fafead9 100644
+--- a/openvdb/openvdb/tools/GridOperators.h
++++ b/openvdb/openvdb/tools/GridOperators.h
+@@ -9,14 +9,15 @@
+ #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/Grid.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
++#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 <tbb/parallel_for.h>
+ 
++#include <tbb/parallel_for.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -383,7 +384,9 @@ class GridOperator
+     /// 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) {
+diff --git a/openvdb/openvdb/tools/LevelSetMeasure.h b/openvdb/openvdb/tools/LevelSetMeasure.h
+index efe19074d..59969cdcf 100644
+--- a/openvdb/openvdb/tools/LevelSetMeasure.h
++++ b/openvdb/openvdb/tools/LevelSetMeasure.h
+@@ -8,18 +8,21 @@
+ #ifndef OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/math/Math.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/Grid.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/math/FiniteDifference.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/math/Stencils.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
+ #include <tbb/parallel_sort.h>
+ #include <tbb/parallel_invoke.h>
++
+ #include <type_traits>
+ 
+ namespace openvdb {
+@@ -329,7 +332,7 @@ inline bool
+ LevelSetMeasure<GridT, InterruptT>::checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/LevelSetTracker.h b/openvdb/openvdb/tools/LevelSetTracker.h
+index cbdc267e8..bfc8004e7 100644
+--- a/openvdb/openvdb/tools/LevelSetTracker.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/tree/LeafManager.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -383,7 +385,7 @@ LevelSetTracker<GridT, InterruptT>::
+ checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/MeshToVolume.h b/openvdb/openvdb/tools/MeshToVolume.h
+index 6643c8f05..de3406eda 100644
+--- a/openvdb/openvdb/tools/MeshToVolume.h
++++ b/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 <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/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 <tbb/parallel_reduce.h>
+ #include <tbb/partitioner.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm> // for std::sort()
+ #include <cmath> // 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<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+@@ -1989,7 +1990,7 @@ class VoxelizePolygons
+         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
+ 
+         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) {
+diff --git a/openvdb/openvdb/tools/Morphology.h b/openvdb/openvdb/tools/Morphology.h
+index 736982ef5..0a1e71009 100644
+--- a/openvdb/openvdb/tools/Morphology.h
++++ b/openvdb/openvdb/tools/Morphology.h
+@@ -24,7 +24,7 @@
+ #include "openvdb/tree/ValueAccessor.h"
+ #include "openvdb/tree/LeafManager.h"
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ 
+@@ -726,7 +726,7 @@ void Morphology<TreeType>::dilateVoxels(const size_t iter,
+         }
+ 
+         // @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
+diff --git a/openvdb/openvdb/tools/ParticlesToLevelSet.h b/openvdb/openvdb/tools/ParticlesToLevelSet.h
+index 739af2b69..f9c19911c 100644
+--- a/openvdb/openvdb/tools/ParticlesToLevelSet.h
++++ b/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 <tbb/parallel_reduce.h>
+-#include <tbb/blocked_range.h>
+-#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/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 <tbb/parallel_reduce.h>
++#include <tbb/blocked_range.h>
++
+ #include <functional>
+ #include <iostream>
+ #include <type_traits>
+@@ -738,7 +742,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         for (Coord c = lo; c.x() <= hi.x(); ++c.x()) {
+             //only check interrupter every 32'th scan in x
+             if (!(count++ & ((1<<5)-1)) && util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Real x2 = math::Pow2(c.x() - P[0]);
+@@ -804,7 +808,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         // Densely fill the remaining regions.
+         for (const auto& bbox: padding) {
+             if (util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Coord &bmin = bbox.min(), &bmax = bbox.max();
+diff --git a/openvdb/openvdb/tools/PointAdvect.h b/openvdb/openvdb/tools/PointAdvect.h
+index 12b1177ad..e487bfb3e 100644
+--- a/openvdb/openvdb/tools/PointAdvect.h
++++ b/openvdb/openvdb/tools/PointAdvect.h
+@@ -10,16 +10,19 @@
+ #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/openvdb.h>
+-#include <openvdb/math/Math.h>             // min
+-#include <openvdb/Types.h>                 // Vec3 types and version number
+-#include <openvdb/Grid.h>                  // grid
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/blocked_range.h>             // threading
+ #include <tbb/parallel_for.h>              // threading
+ #include <tbb/task.h>                      // for cancel
++
+ #include <vector>
+ 
+ 
+@@ -167,7 +170,7 @@ class PointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityFieldIntegrator  velField(*mVelGrid);
+@@ -307,7 +310,7 @@ class ConstrainedPointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityIntegratorType velField(*mVelGrid);
+diff --git a/openvdb/openvdb/tools/PointIndexGrid.h b/openvdb/openvdb/tools/PointIndexGrid.h
+index e9ebf96f7..b2e378a79 100644
+--- a/openvdb/openvdb/tools/PointIndexGrid.h
++++ b/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 <openvdb/version.h>
+@@ -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;
+         }
+ 
+diff --git a/openvdb/openvdb/tools/PointPartitioner.h b/openvdb/openvdb/tools/PointPartitioner.h
+index ccf50ab05..f7f6fc13d 100644
+--- a/openvdb/openvdb/tools/PointPartitioner.h
++++ b/openvdb/openvdb/tools/PointPartitioner.h
+@@ -23,7 +23,7 @@
+ 
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm>
+ #include <cmath> // for std::isfinite()
+@@ -764,7 +764,7 @@ inline void binAndSegment(
+     using IndexPairListMap = std::map<Coord, IndexPairListPtr>;
+     using IndexPairListMapPtr = std::shared_ptr<IndexPairListMap>;
+ 
+-    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;
+ 
+diff --git a/openvdb/openvdb/tools/PointsToMask.h b/openvdb/openvdb/tools/PointsToMask.h
+index 592ab7a15..8a276fb04 100644
+--- a/openvdb/openvdb/tools/PointsToMask.h
++++ b/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 <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/blocked_range.h>
+-#include <openvdb/openvdb.h> // for MaskGrid
+-#include <openvdb/Grid.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/util/NullInterrupter.h>
++
+ #include <vector>
+ 
+ 
+@@ -150,7 +154,7 @@ class PointsToMask
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeAdvect.h b/openvdb/openvdb/tools/VolumeAdvect.h
+index e7eec740e..f38eaa9c2 100644
+--- a/openvdb/openvdb/tools/VolumeAdvect.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/math/Math.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ 
+ 
+@@ -294,7 +297,7 @@ class VolumeAdvection
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeToMesh.h b/openvdb/openvdb/tools/VolumeToMesh.h
+index a834dd3b3..a446f806a 100644
+--- a/openvdb/openvdb/tools/VolumeToMesh.h
++++ b/openvdb/openvdb/tools/VolumeToMesh.h
+@@ -18,7 +18,7 @@
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <cmath> // for std::isfinite()
+ #include <map>
+@@ -388,7 +388,7 @@ inline void
+ fillArray(ValueType* array, const ValueType& val, const size_t length)
+ {
+     const auto grainSize = std::max<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+diff --git a/openvdb/openvdb/unittest/TestCoord.cc b/openvdb/openvdb/unittest/TestCoord.cc
+index be1c24ced..148690041 100644
+--- a/openvdb/openvdb/unittest/TestCoord.cc
++++ b/openvdb/openvdb/unittest/TestCoord.cc
+@@ -2,9 +2,9 @@
+ // SPDX-License-Identifier: MPL-2.0
+ 
+ #include <openvdb/Types.h>
++#include <openvdb/math/Coord.h>
+ 
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_stddef.h> // for tbb::split
+ 
+ #include <unordered_map>
+ #include <sstream>
+diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc
+index 8074166d2..053448f30 100644
+--- a/openvdb/openvdb/unittest/TestFile.cc
++++ b/openvdb/openvdb/unittest/TestFile.cc
+@@ -13,8 +13,11 @@
+ #include <openvdb/version.h>
+ #include <openvdb/openvdb.h>
+ #include "util.h" // for unittest_util::makeSphere()
++
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
++
++#include <thread>
++#include <chrono>
+ #include <algorithm> // for std::sort()
+ #include <cstdio> // for remove() and rename()
+ #include <fstream>
+@@ -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::seconds>(
++                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<io::Queue::Id> 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));
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc
+index 70e7df5f7..6b2204771 100644
+--- a/openvdb/openvdb/unittest/TestUtil.cc
++++ b/openvdb/openvdb/unittest/TestUtil.cc
+@@ -8,7 +8,6 @@
+ 
+ #include <gtest/gtest.h>
+ 
+-#include <tbb/task_scheduler_init.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/blocked_range.h>
+diff --git a/openvdb/openvdb/unittest/TestValueAccessor.cc b/openvdb/openvdb/unittest/TestValueAccessor.cc
+index fd2dd5d81..5c1cbb18b 100644
+--- a/openvdb/openvdb/unittest/TestValueAccessor.cc
++++ b/openvdb/openvdb/unittest/TestValueAccessor.cc
+@@ -6,6 +6,7 @@
+ 
+ #include <gtest/gtest.h>
+ #include <tbb/task.h>
++#include <tbb/task_group.h>
+ 
+ #include <type_traits>
+ 
+@@ -378,22 +379,21 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
+     //using AccessorT = openvdb::tree::ValueAccessor<Tree4Type>;
+ 
+     // 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
+ }
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+index 0e1b4d855..6d9bb528b 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+@@ -20,6 +20,7 @@
+ #include <openvdb/tools/GridTransformer.h>
+ #include <openvdb/tools/PointIndexGrid.h>
+ #include <openvdb/tools/Prune.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <CH/CH_Manager.h>
+ #include <CVEX/CVEX_Context.h>
+@@ -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;
+             }
+ 
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+index 757fdc8c6..dbee74b32 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+@@ -16,13 +16,11 @@
+ #include <openvdb_houdini/SOP_NodeVDB.h>
+ 
+ #include <openvdb/tools/Interpolation.h>  // for box sampler
++#include <openvdb/thread/Threading.h>
+ #include <openvdb/points/PointCount.h>
+ #include <openvdb/points/PointSample.h>
+ #include <openvdb/points/IndexFilter.h>   // for MultiGroupFilter
+ 
+-#include <tbb/tick_count.h>                 // for timing
+-#include <tbb/task.h>                       // for cancel
+-
+ #include <UT/UT_Interrupt.h>
+ #include <GA/GA_PageHandle.h>
+ #include <GA/GA_PageIterator.h>
+@@ -38,6 +36,7 @@
+ #include <stdexcept>
+ #include <string>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ 
+@@ -327,7 +326,7 @@ class PointSampler
+     {
+ 
+         if (mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            openvdb::thread::cancelGroupExecution();
+         }
+         const GridType& grid = UTvdbGridCast<GridType>(mGrid);
+         // task local grid accessor
+@@ -481,7 +480,7 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Context& context)
+         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_Context& context)
+             }
+         }
+ 
+-        // 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::milliseconds>(
++                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;
+         }
+ 
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+index 3d559f8cc..d63ed1591 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
++++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+@@ -47,11 +47,8 @@ struct NodeInfo {
+ 
+ typedef std::vector<NodeInfo> 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, const MTypeId& typeId,
+     node.type               = type;
+     node.classification     = classification;
+ 
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (!gNodes) {
+         OPENVDB_START_THREADSAFE_STATIC_WRITE
+@@ -85,7 +82,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, const MTypeId& typeId,
+ void
+ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+@@ -109,7 +106,7 @@ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ void
+ NodeRegistry::deregisterNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.h b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+index b58bd6f2c..6a04b1eaf 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBUtil.h
++++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+@@ -14,8 +14,7 @@
+ #include <openvdb/tree/LeafManager.h>
+ #include <openvdb/tools/VolumeToMesh.h>
+ #include <openvdb/util/Formats.h> // printBytes
+-
+-#include <tbb/tick_count.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <maya/M3dView.h>
+ #include <maya/MString.h>
+@@ -40,6 +39,7 @@
+ #include <string>
+ #include <type_traits>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ ////////////////////////////////////////
+@@ -116,11 +116,15 @@ insertFrameNumber(std::string& str, const MTime& time, int numberingScheme = 0);
+ 
+ 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::milliseconds>(
++            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<std::chrono::steady_clock> mStamp;
+ };
+ 
+ 
+diff --git a/pendingchanges/tbb2021.txt b/pendingchanges/tbb2021.txt
+new file mode 100644
+index 000000000..8109c2552
+--- /dev/null
++++ b/pendingchanges/tbb2021.txt
+@@ -0,0 +1,6 @@
++Improvements:
++  - Moved from the deprecated TBB task scheduler to TBB arenas. Various methods now respect the TBB arena state they were invoked from.
++  - Introduced a new thread/Threading.h header to consolidate calls to third-party threading methods.
++
++Build:
++  - Added support for TBB 2021.
diff --git a/srcpkgs/openvdb/template b/srcpkgs/openvdb/template
index 72fde5bc6375..d420a3ee5f5d 100644
--- a/srcpkgs/openvdb/template
+++ b/srcpkgs/openvdb/template
@@ -1,26 +1,18 @@
 # Template file for 'openvdb'
 pkgname=openvdb
-version=7.0.0
+version=8.1.0
 revision=1
 build_style=cmake
 configure_args="-DOPENVDB_BUILD_VDB_VIEW=1"
 hostmakedepends="pkg-config"
-makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel glfw-devel"
+makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel
+ glfw-devel jemalloc-devel"
 short_desc="Sparse volume data structure and tools"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MPL-2.0"
 homepage="https://openvdb.org"
 distfiles="https://github.com/AcademySoftwareFoundation/openvdb/archive/v${version}.tar.gz"
-checksum=97bc8ae35ef7ccbf49a4e25cb73e8c2eccae6b235bac86f2150707efcd1e910d
-
-if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
-	makedepends+=" libatomic-devel"
-fi
-
-post_patch() {
-	[ "$XBPS_TARGET_NO_ATOMIC8" ] || return 0
-	vsed -i 's,ZLIB::ZLIB,ZLIB::ZLIB atomic,' openvdb/CMakeLists.txt
-}
+checksum=3e09d47331429be7409a3a3c27fdd3c297f96d31d2153febe194e664a99d6183
 
 post_install() {
 	vlicense LICENSE

From 2e8bbc914059136d80d389577aed357a9af4672d Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 10/12] paraview: update to 5.9.1.

---
 srcpkgs/paraview/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/paraview/template b/srcpkgs/paraview/template
index 20a7f5589677..e6c3941ce90a 100644
--- a/srcpkgs/paraview/template
+++ b/srcpkgs/paraview/template
@@ -1,7 +1,7 @@
 # Template file for 'paraview'
 pkgname=paraview
-version=5.8.1
-revision=3
+version=5.9.1
+revision=1
 wrksrc=ParaView-v${version}
 build_style=cmake
 configure_args="-DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr

From 3e3eef017eebd9aa1f5627c0b4657b92e54cab9c Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 11/12] occt: revbump due to tbb update

---
 srcpkgs/occt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/occt/template b/srcpkgs/occt/template
index 9298edc76e08..006f89ebb8ce 100644
--- a/srcpkgs/occt/template
+++ b/srcpkgs/occt/template
@@ -2,7 +2,7 @@
 pkgname=occt
 reverts=7.5.0_1
 version=7.4.0p1
-revision=3
+revision=4
 _gittag="V${version//./_}"
 wrksrc=occt-${_gittag}
 build_style=cmake

From bf0394a76484af636bcd0525ca046e8f80242d1f Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 18:05:52 +0300
Subject: [PATCH 12/12] hwloc

---
 .../patches/00-get-area-memlocation.patch     | 63 ++++++++++++++++++-
 1 file changed, 61 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hwloc/patches/00-get-area-memlocation.patch b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
index e398a80e046d..da907f1aae9f 100644
--- a/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
+++ b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
@@ -1,12 +1,21 @@
 diff --git a/tests/hwloc/hwloc_get_area_memlocation.c b/tests/hwloc/hwloc_get_area_memlocation.c
-index 498dfae..999d95b 100644
+index 498dfae..8d77cf7 100644
 --- a/tests/hwloc/hwloc_get_area_memlocation.c
 +++ b/tests/hwloc/hwloc_get_area_memlocation.c
+@@ -8,7 +8,7 @@
+ #include <stdio.h>
+ #include <assert.h>
+ 
+-#define LEN 1048576
++#define LEN 1024
+ 
+ int main(void)
+ {
 @@ -34,11 +34,13 @@ int main(void)
    assert(buffer);
    printf("buffer %p length %d\n", buffer, LEN);
  
-+  fprintf(stderr, "Before memloation\nerr == %i, errno == %s\n", err, strerror(errno));
++  fprintf(stderr, "Before memlocation\nerr == %i, errno == %s\n", err, strerror(errno));
    err = hwloc_get_area_memlocation(topology, buffer, LEN, set, HWLOC_MEMBIND_BYNODESET);
    if (err < 0 && errno == ENOSYS) {
      fprintf(stderr, "hwloc_get_area_memlocation() failed with ENOSYS, aborting\n");
@@ -16,3 +25,53 @@ index 498dfae..999d95b 100644
    assert(!err);
    hwloc_bitmap_asprintf(&s, set);
    printf("address %p length %d allocated in nodeset %s\n", buffer, LEN, s);
+diff --git a/hwloc/topology-linux.c b/hwloc/topology-linux.c
+index 10e038e..c50933c 100644
+--- a/hwloc/topology-linux.c
++++ b/hwloc/topology-linux.c
+@@ -21,6 +21,7 @@
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <assert.h>
++#include <string.h>
+ #ifdef HAVE_DIRENT_H
+ #include <dirent.h>
+ #endif
+@@ -2039,8 +2040,10 @@ hwloc_linux_get_area_memlocation(hwloc_topology_t topology __hwloc_attribute_unu
+   addr = ((char*) addr) - offset;
+   len += offset;
+   count = (len + pagesize-1)/pagesize;
++  fprintf(stderr, "errno == %s\n", strerror(errno));
+   pages = malloc(count*sizeof(*pages));
+   status = malloc(count*sizeof(*status));
++  fprintf(stderr, "errno == %s\n", strerror(errno));
+   if (!pages || !status) {
+     ret = -1;
+     goto out_with_pages;
+@@ -2049,19 +2052,25 @@ hwloc_linux_get_area_memlocation(hwloc_topology_t topology __hwloc_attribute_unu
+   for(i=0; i<count; i++)
+     pages[i] = ((char*)addr) + i*pagesize;
+ 
++  fprintf(stderr, "errno == %s\n", strerror(errno));
+   ret = hwloc_move_pages(0, count, pages, NULL, status, 0);
++  fprintf(stderr, "errno == %s\n", strerror(errno));
+   if (ret  < 0)
+     goto out_with_pages;
+ 
+   hwloc_bitmap_zero(nodeset);
+   for(i=0; i<count; i++)
+-    if (status[i] >= 0)
++    if (status[i] >= 0) {
+       hwloc_bitmap_set(nodeset, status[i]);
++      fprintf(stderr, "i == %i, errno == %s\n", i, strerror(errno));
++	}
+   ret = 0; /* not really useful since move_pages never returns > 0 */
+ 
+  out_with_pages:
++  fprintf(stderr, "errno == %s\n", strerror(errno));
+   free(pages);
+   free(status);
++  fprintf(stderr, "errno == %s\n", strerror(errno));
+   return ret;
+ }
+ 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PR PATCH] [Updated] tbb: update to 2021.3.0
  2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
                   ` (5 preceding siblings ...)
  2021-07-24 15:32 ` Logarithmus
@ 2021-07-24 16:16 ` Logarithmus
  2021-07-24 16:41 ` Logarithmus
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Logarithmus @ 2021-07-24 16:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

There is an updated pull request by Logarithmus against master on the void-packages repository

https://github.com/Logarithmus/void-packages tbb-2021
https://github.com/void-linux/void-packages/pull/32166

tbb: update to 2021.3.0
Follow-up of https://github.com/void-linux/void-packages/pull/27746, @thypon & @olafmersmann might be interested.
**TODO** fix reverse dependencies:
- [ ] OpenSubdiv: update to 3.4.4.
- [ ] PrusaSlicer: update to 2.3.3.
- [ ] lender: update to 2.93.1.
- [ ] embree: update to 3.13.0.
- [ ] openimageio: update to 2.2.16.0.
- [ ] openimagedenoise: update to 1.4.1.
- [ ] openvdb: update to 8.1.0.
- [ ] paraview: update to 5.9.1.
- [ ] occt: revbump due to tbb update

#### Have the results of the proposed changes been tested?
- [x] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me


A patch file from https://github.com/void-linux/void-packages/pull/32166.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-tbb-2021-32166.patch --]
[-- Type: text/x-diff, Size: 92414 bytes --]

From 80e56eebd3e7bc6f7b9486f3a7c75dca5ad766fd Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 17 Jul 2021 23:57:52 +0300
Subject: [PATCH 01/12] hwloc: add libpciaccess-devel make dependency

---
 .../patches/00-get-area-memlocation.patch      | 18 ++++++++++++++++++
 srcpkgs/hwloc/template                         |  8 +++++---
 2 files changed, 23 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hwloc/patches/00-get-area-memlocation.patch

diff --git a/srcpkgs/hwloc/patches/00-get-area-memlocation.patch b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
new file mode 100644
index 000000000000..e398a80e046d
--- /dev/null
+++ b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
@@ -0,0 +1,18 @@
+diff --git a/tests/hwloc/hwloc_get_area_memlocation.c b/tests/hwloc/hwloc_get_area_memlocation.c
+index 498dfae..999d95b 100644
+--- a/tests/hwloc/hwloc_get_area_memlocation.c
++++ b/tests/hwloc/hwloc_get_area_memlocation.c
+@@ -34,11 +34,13 @@ int main(void)
+   assert(buffer);
+   printf("buffer %p length %d\n", buffer, LEN);
+ 
++  fprintf(stderr, "Before memloation\nerr == %i, errno == %s\n", err, strerror(errno));
+   err = hwloc_get_area_memlocation(topology, buffer, LEN, set, HWLOC_MEMBIND_BYNODESET);
+   if (err < 0 && errno == ENOSYS) {
+     fprintf(stderr, "hwloc_get_area_memlocation() failed with ENOSYS, aborting\n");
+     goto out_with_buffer;
+   }
++  fprintf(stderr, "After memlocation\nerr == %i, errno == %s\n", err, strerror(errno));
+   assert(!err);
+   hwloc_bitmap_asprintf(&s, set);
+   printf("address %p length %d allocated in nodeset %s\n", buffer, LEN, s);
diff --git a/srcpkgs/hwloc/template b/srcpkgs/hwloc/template
index 818db269cebb..6eec662d0d6e 100644
--- a/srcpkgs/hwloc/template
+++ b/srcpkgs/hwloc/template
@@ -1,10 +1,12 @@
 # Template file for 'hwloc'
 pkgname=hwloc
 version=2.5.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="cairo-devel ncurses-devel libxml2-devel eudev-libudev-devel"
+makedepends="cairo-devel ncurses-devel libxml2-devel libpciaccess-devel eudev-libudev-devel"
+checkdepends="tar"
+make_check_args="VERBOSE=1"
 short_desc="Portable abstraction of hierarchical hardware architectures"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
 license="BSD-3-Clause"
@@ -31,7 +33,7 @@ libhwloc_package() {
 
 libhwloc-devel_package() {
 	short_desc+=" - development files"
-	depends="libhwloc>=${version}_${revision}"
+	depends="${makedepends} libhwloc>=${version}_${revision}"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/share/man/man3

From 14ad1bfa40be1eda08bfe91cc01002ad33830459 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 02:50:26 +0300
Subject: [PATCH 02/12] tbb: update to 2021.3.0.

---
 common/shlibs                                |   6 +-
 srcpkgs/tbb/patches/00-hwloc-2.5.patch       | 367 +++++++++++++++++++
 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch |  52 +++
 srcpkgs/tbb/patches/hostname-usage.patch     |  11 -
 srcpkgs/tbb/patches/musl.patch               |   4 +-
 srcpkgs/tbb/template                         |  63 +---
 6 files changed, 433 insertions(+), 70 deletions(-)
 create mode 100644 srcpkgs/tbb/patches/00-hwloc-2.5.patch
 create mode 100644 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
 delete mode 100644 srcpkgs/tbb/patches/hostname-usage.patch

diff --git a/common/shlibs b/common/shlibs
index a7afbf2a56f7..6b7ca5fbc249 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2376,12 +2376,10 @@ libanthy-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthydic-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthyinput-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthygobject-1.0.so.5 ibus-anthy-1.5.6_1
-libtbbmalloc_proxy_debug.so.2 tbb-4.3_1
 libtbbmalloc_proxy.so.2 tbb-4.3_1
 libtbbmalloc.so.2 tbb-4.3_1
-libtbb_debug.so.2 tbb-4.3_1
-libtbb.so.2 tbb-4.3_1
-libtbbmalloc_debug.so.2 tbb-4.3_1
+libtbb.so.12 tbb-2021.3.0_1
+libtbbbind_2_5.so.3 tbb-2021.3.0_1
 libembree.so.2 embree-2.5.1_1
 libgtkimageview.so.0 gtkimageview-1.6.4_1
 libgoocanvas-2.0.so.9 goocanvas-2.0.4_1
diff --git a/srcpkgs/tbb/patches/00-hwloc-2.5.patch b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
new file mode 100644
index 000000000000..9c4c9285c71d
--- /dev/null
+++ b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
@@ -0,0 +1,367 @@
+Adjusted by Artur Sinila <freesoftware@logarithmus.dev>
+
+From e96dbf4b48e689ab810b0428d0858a6abc2c83bd Mon Sep 17 00:00:00 2001
+From: Ivan Kochin <iv.kochin@gmail.com>
+Date: Thu, 1 Jul 2021 15:07:39 +0300
+Subject: [PATCH] Upgrade from HWLOC 2.4 to HWLOC 2.5 (#448)
+
+* Upgrade from HWLOC 2.4 to HWLOC 2.5
+* Introduce tbbbind_2_5 library
+* Remove tbbbind_2_4 library
+* Use the HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING topology flag (introduces as a part of HWLOC 2.5) to restrict topology discovering to process binding
+* Fix testing on Linux
+* Apply review comments
+* Improve wording: variable -> substring
+* Use right tbbbind version for incompatible hwlocs test
+* Rework option semantic
+* Update README.md for CMake
+* Rework readme
+* Update cmake/README.md
+
+Signed-off-by: Kochin, Ivan <kochin.ivan@intel.com>
+
+Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
+---
+ CMakeLists.txt                         |  3 ++-
+ cmake/README.md                        | 11 +++++---
+ cmake/hwloc_detection.cmake            |  9 ++++---
+ src/tbb/governor.cpp                   |  4 +--
+ src/tbbbind/CMakeLists.txt             |  2 +-
+ src/tbbbind/tbb_bind.cpp               | 23 +++++++++++-----
+ test/CMakeLists.txt                    | 30 ++++++++++-----------
+ test/common/common_arena_constraints.h | 37 ++++++++++++++++++++++----
+ 8 files changed, 82 insertions(+), 37 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 34a23d400..301899aca 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -100,6 +100,7 @@ option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Win
+ option(TBB4PY_BUILD "Enable tbb4py build" OFF)
+ option(TBB_CPF "Enable preview features of the library" OFF)
+ option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
++option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
+ 
+ if (NOT DEFINED BUILD_SHARED_LIBS)
+     set(BUILD_SHARED_LIBS ON)
+@@ -195,7 +196,7 @@ else()
+         add_subdirectory(src/tbbmalloc)
+         add_subdirectory(src/tbbmalloc_proxy)
+         if (APPLE)
+-            message(STATUS "TBBBind build target is disabled due to unsupported environment")
++            message(STATUS "TBBBind build targets are disabled due to unsupported environment")
+         else()
+             add_subdirectory(src/tbbbind)
+         endif()
+diff --git a/cmake/README.md b/cmake/README.md
+index 36fc303f9..b58c2ff6a 100644
+--- a/cmake/README.md
++++ b/cmake/README.md
+@@ -13,6 +13,7 @@ TBB4PY_BUILD:BOOL - Enable  Intel(R) oneAPI Threading Building Blocks (oneTBB) P
+ TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
+ TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
+ TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
++TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)
+ ```
+ 
+ ## Configure, build and test
+@@ -42,9 +43,9 @@ Some useful options:
+ 
+ #### TBBBind library configuration
+ 
+-The TBBbind library has two versions: `tbbbind` and `tbbbind_2_0`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.x.
++The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0` and `tbbbind_2_5`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.1-2.4, `tbbbind_2_5` links with HWLOC 2.5 and later.
+ 
+-To enable the TBBBind library build or special tests that performed inside the HWLOC environment, please specify the following CMake variables:
++The search for a suitable version of the HWLOC library is enabled by default, but if you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
+ 
+  - `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux or path to `.lib` file on Windows.
+  - `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version includes directory.
+@@ -52,7 +53,11 @@ To enable the TBBBind library build or special tests that performed inside the H
+ Windows requires one additional variable for correct TBBBind library building:
+  - `CMAKE_HWLOC_<HWLOC_VER>_DLL_PATH` - path to the corresponding HWLOC version `.dll` file.
+ 
+-`HWLOC_VER` variable used above can be replaced with one of the two values: `1_11` for the `tbbbind` library configuration and `2` for the `tbbbind_2_0` library configuration.
++`HWLOC_VER` substring used above can be replaced with one of the three values: `1_11` for the `tbbbind` library configuration, `2` for the `tbbbind_2_0`, and `2_5` for the `tbbbind_2_5` library configuration.
++
++If you specify variables for several TBBBind versions, then building process for all of these versions will be performed during single build session.
++
++Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
+ 
+ ### Build
+ 
+diff --git a/cmake/hwloc_detection.cmake b/cmake/hwloc_detection.cmake
+index e1eeca5fa..de7f3c047 100644
+--- a/cmake/hwloc_detection.cmake
++++ b/cmake/hwloc_detection.cmake
+@@ -12,7 +12,7 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
+-list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_4)
++list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_5)
+ 
+ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
+     if (NOT WIN32)
+@@ -55,10 +56,10 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
+         if (HWLOC_FOUND)
+             if (HWLOC_VERSION VERSION_LESS 2)
+                 set(TBBBIND_LIBRARY_NAME tbbbind)
+-            elseif(HWLOC_VERSION VERSION_LESS 2.4)
++            elseif(HWLOC_VERSION VERSION_LESS 2.5)
+                 set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
+             else()
+-                set(TBBBIND_LIBRARY_NAME tbbbind_2_4)
++                set(TBBBIND_LIBRARY_NAME tbbbind_2_5)
+             endif()
+         endif()
+     endif()
+diff --git a/src/tbb/governor.cpp b/src/tbb/governor.cpp
+index bf4e402d1..b842e075f 100644
+--- a/src/tbb/governor.cpp
++++ b/src/tbb/governor.cpp
+@@ -362,7 +362,7 @@ static const unsigned LinkTableSize = sizeof(TbbBindLinkTable) / sizeof(dynamic_
+ 
+ #define TBBBIND_NAME LIBRARY_PREFIX "tbbbind" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #define TBBBIND_2_0_NAME LIBRARY_PREFIX "tbbbind_2_0" DEBUG_SUFFIX LIBRARY_EXTENSION
+-#define TBBBIND_2_4_NAME LIBRARY_PREFIX "tbbbind_2_4" DEBUG_SUFFIX LIBRARY_EXTENSION
++#define TBBBIND_2_5_NAME LIBRARY_PREFIX "tbbbind_2_5" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #endif /* _WIN32 || _WIN64 || __linux__ */
+ 
+ // Representation of system hardware topology information on the TBB side.
+@@ -389,7 +389,7 @@ const char* load_tbbbind_shared_object() {
+     GetNativeSystemInfo(&si);
+     if (si.dwNumberOfProcessors > 32) return nullptr;
+ #endif /* _WIN32 && !_WIN64 */
+-    for (const auto& tbbbind_version : {TBBBIND_2_4_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
++    for (const auto& tbbbind_version : {TBBBIND_2_5_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
+         if (dynamic_link(tbbbind_version, TbbBindLinkTable, LinkTableSize)) {
+             return tbbbind_version;
+         }
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index 029893751..e5cdbf8bb 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -99,7 +99,7 @@ if (NOT DEFINED HWLOC_TARGET_EXPLICITLY_DEFINED AND DEFINED HWLOC_LIBRARIES)
+ else()
+     tbbbind_build(tbbbind     HWLOC::hwloc_1_11)
+     tbbbind_build(tbbbind_2_0 HWLOC::hwloc_2   )
+-    tbbbind_build(tbbbind_2_4 HWLOC::hwloc_2_4 )
++    tbbbind_build(tbbbind_2_5 HWLOC::hwloc_2_5 )
+ endif()
+ 
+ 
+diff --git a/src/tbbbind/tbb_bind.cpp b/src/tbbbind/tbb_bind.cpp
+index 97be308c7..88c956acb 100644
+--- a/src/tbbbind/tbb_bind.cpp
++++ b/src/tbbbind/tbb_bind.cpp
+@@ -34,7 +34,8 @@
+ #pragma GCC diagnostic pop
+ #endif
+ 
+-#define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ 
+ // Most of hwloc calls returns negative exit code on error.
+ // This macro tracks error codes that are returned from the hwloc interfaces.
+@@ -85,6 +86,16 @@ class platform_topology {
+         // Parse topology
+         if ( hwloc_topology_init( &topology ) == 0 ) {
+             initialization_state = topology_allocated;
++#if __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++            if ( groups_num == 1 &&
++                 hwloc_topology_set_flags(topology,
++                     HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                     HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
++                 ) != 0
++            ) {
++                return;
++            }
++#endif
+             if ( hwloc_topology_load( topology ) == 0 ) {
+                 initialization_state = topology_loaded;
+             }
+@@ -135,7 +146,7 @@ class platform_topology {
+             numa_indexes_list.resize(numa_nodes_count);
+             hwloc_obj_t node_buffer;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 numa_indexes_list[counter] = static_cast<int>(node_buffer->logical_index);
+ 
+                 if ( numa_indexes_list[counter] > max_numa_index ) {
+@@ -150,7 +161,7 @@ class platform_topology {
+             numa_affinity_masks_list.resize(max_numa_index + 1);
+             int index = 0;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 index = static_cast<int>(node_buffer->logical_index);
+ 
+                 hwloc_cpuset_t& current_mask = numa_affinity_masks_list[index];
+@@ -168,7 +179,7 @@ class platform_topology {
+             core_types_indexes_list.push_back(-1);
+             return;
+         }
+-#if __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
++#if __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
+         __TBB_ASSERT(hwloc_get_api_version() >= 0x20400, "Hybrid CPUs support interfaces required HWLOC >= 2.4");
+         // Parsing the hybrid CPU topology
+         int core_types_number = hwloc_cpukinds_get_nr(topology, 0);
+@@ -196,9 +207,9 @@ class platform_topology {
+                 }
+             }
+         }
+-#else /*!__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#else /*!__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+         bool core_types_parsing_broken{true};
+-#endif /*__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#endif /*__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+ 
+         if (core_types_parsing_broken) {
+             for (auto& core_type_mask : core_types_affinity_masks_list) {
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index bdae9e2b1..c2b9d6dba 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -275,9 +275,9 @@ function(tbb_add_tbbbind_test)
+         FAIL_REGULAR_EXPRESSION "Status:.*FAILURE"
+     )
+ 
+-    if (TARGET HWLOC::hwloc_2_4 AND NOT HWLOC_2_4_TESTS_STATUS_SHOWN)
+-        message(STATUS "HWLOC 2.4 dependent tests were enabled.")
+-        set(HWLOC_2_4_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
++    if (TARGET HWLOC::hwloc_2_5 AND NOT HWLOC_2_5_TESTS_STATUS_SHOWN)
++        message(STATUS "HWLOC 2.5 dependent tests were enabled.")
++        set(HWLOC_2_5_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
+     endif()
+ 
+     if (TARGET HWLOC::hwloc_2 AND NOT HWLOC_2_TESTS_STATUS_SHOWN)
+@@ -291,22 +291,22 @@ function(tbb_add_tbbbind_test)
+     endif()
+ 
+     list(APPEND HWLOC_TEST_CASES
+-        hwloc_2_4
++        hwloc_2_5
+         hwloc_2
+         hwloc_1_11
+-        hwloc_2_4_hwloc_2
+-        hwloc_2_4_hwloc_1_11
++        hwloc_2_5_hwloc_2
++        hwloc_2_5_hwloc_1_11
+         hwloc_2_hwloc_1_11
+-        hwloc_2_4_hwloc_2_hwloc_1_11
++        hwloc_2_5_hwloc_2_hwloc_1_11
+     )
+ 
+-    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_4 "hwloc_2_4")
++    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_5 "hwloc_2_5")
+     list(APPEND HWLOC_TEST_CASE_1_VARS tbbbind_2   "hwloc_2")
+     list(APPEND HWLOC_TEST_CASE_2_VARS tbbbind     "hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2")
+-    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_4 "hwloc_2_4,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2")
++    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_5 "hwloc_2_5,hwloc_1_11")
+     list(APPEND HWLOC_TEST_CASE_5_VARS tbbbind_2   "hwloc_2,hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2,hwloc_1_11")
+ 
+     foreach(TEST_CASE ${HWLOC_TEST_CASES})
+         list(FIND HWLOC_TEST_CASES ${TEST_CASE} TEST_CASE_INDEX)
+@@ -331,7 +331,7 @@ endfunction()
+ # Copy libraries to test folder to make it visible during tests execution if external TBB is tested.
+ # TODO: check and update for multi-config generators.
+ if (TBB_FOUND)
+-    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_4)
++    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_5)
+     foreach(_component ${_tbb_test_components})
+         if (TARGET TBB::${_component})
+             get_property(${_component}_lib_file_location TARGET TBB::${_component} PROPERTY LOCATION)
+@@ -593,6 +593,6 @@ if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
+     tbb_add_test(SUBDIR tbbmalloc NAME test_malloc_new_handler DEPENDENCIES TBB::tbbmalloc_proxy)
+ endif()
+ 
+-unset(HWLOC_2_4_TESTS_STATUS_SHOWN)
++unset(HWLOC_2_5_TESTS_STATUS_SHOWN)
+ unset(HWLOC_2_TESTS_STATUS_SHOWN)
+ unset(HWLOC_1_11_TESTS_STATUS_SHOWN)
+diff --git a/test/common/common_arena_constraints.h b/test/common/common_arena_constraints.h
+index 2a0b1ea97..5efc71082 100644
+--- a/test/common/common_arena_constraints.h
++++ b/test/common/common_arena_constraints.h
+@@ -38,9 +38,26 @@
+ 
+ #if (_WIN32 || _WIN64) && __TBB_HWLOC_VALID_ENVIRONMENT
+ #include <windows.h>
+-int get_processors_groups_count() { return GetActiveProcessorGroupCount(); }
++int get_processors_group_count() {
++    SYSTEM_INFO si;
++    GetNativeSystemInfo(&si);
++    DWORD_PTR pam, sam, m = 1;
++    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
++    int nproc = 0;
++    for ( std::size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
++        if ( pam & m )
++            ++nproc;
++    }
++    // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present
++    if ( nproc == (int)si.dwNumberOfProcessors  ) {
++        // The process does not have restricting affinity mask and multiple processor groups are possible
++        return (int)GetActiveProcessorGroupCount();
++    } else {
++        return 1;
++    }
++}
+ #else
+-int get_processors_groups_count() { return 1; }
++int get_processors_group_count() { return 1; }
+ #endif
+ 
+ //TODO: Write a test that checks for memory leaks during dynamic link/unlink of TBBbind.
+@@ -69,6 +86,7 @@ int get_processors_groups_count() { return 1; }
+ #endif
+ 
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ // At this moment the hybrid CPUs HWLOC interfaces returns unexpected results on some Windows machines
+ // in the 32-bit arch mode.
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_VALID (!_WIN32 || _WIN64)
+@@ -153,9 +171,18 @@ class system_info {
+ 
+     system_info() {
+         hwloc_require_ex(hwloc_topology_init, &topology);
++#if __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++        if ( get_processors_group_count() == 1 ) {
++            REQUIRE(
++                hwloc_topology_set_flags(topology,
++                    HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                    HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING) == 0
++            );
++        }
++#endif
+         hwloc_require_ex(hwloc_topology_load, topology);
+ 
+-        if ( get_processors_groups_count() > 1 ) {
++        if ( get_processors_group_count() > 1 ) {
+             process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
+         } else {
+             process_cpuset = hwloc_bitmap_alloc();
+@@ -434,7 +461,7 @@ system_info::affinity_mask get_arena_affinity(tbb::task_arena& ta) {
+                 barrier.wait();
+                 tbb::spin_mutex::scoped_lock lock(affinity_mutex);
+                 system_info::affinity_mask thread_affinity = system_info::allocate_current_affinity_mask();
+-                if (get_processors_groups_count() == 1) {
++                if (get_processors_group_count() == 1) {
+                     REQUIRE_MESSAGE(hwloc_bitmap_isequal(thread_affinity, arena_affinity),
+                         "Threads have different masks on machine without several processors groups.");
+                 }
+@@ -532,7 +559,7 @@ constraints_container generate_constraints_variety() {
+         }
+ 
+         // Some constraints may cause unexpected behavior, which would be fixed later.
+-        if (get_processors_groups_count() > 1) {
++        if (get_processors_group_count() > 1) {
+             for(auto it = results.begin(); it != results.end(); ++it) {
+                 if (it->max_threads_per_core != tbb::task_arena::automatic
+                    && (it->numa_id == tbb::task_arena::automatic || tbb::info::numa_nodes().size() == 1)
diff --git a/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
new file mode 100644
index 000000000000..279ebc4397cd
--- /dev/null
+++ b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
@@ -0,0 +1,52 @@
+Based on https://github.com/oneapi-src/oneTBB/pull/498
+Tweaked a bit to work on `v2021.3.0`
+
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index e5cdbf8bb..a4033210a 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -37,6 +37,10 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+         ${HWLOC_INCLUDE_DIRS} # pkg-config defined
+     )
++	target_link_directories(${TBBBIND_NAME}
++		PRIVATE
++		${HWLOC_LIBRARY_DIRS} # pkg-config defined
++	)
+ 
+     target_compile_options(${TBBBIND_NAME}
+         PRIVATE
+@@ -69,7 +69,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     else()
+         target_link_libraries(${TBBBIND_NAME}
+@@ -76,7 +76,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     endif()
+ 
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index b768759d5..3eb8357e6 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -258,7 +258,12 @@ function(tbb_add_tbbbind_test)
+         )
+         set_property(
+             TARGET ${_tbbbind_test_NAME}
+-            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARY_DIRS} ${HWLOC_LIBRARIES}
++            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARIES}
++            APPEND
++        )
++        set_property(
++            TARGET ${_tbbbind_test_NAME}
++			PROPERTY LINK_DIRECTORIES ${HWLOC_LIBRARY_DIRS}
+             APPEND
+         )
+         set_property(
diff --git a/srcpkgs/tbb/patches/hostname-usage.patch b/srcpkgs/tbb/patches/hostname-usage.patch
deleted file mode 100644
index 4aefeff192b5..000000000000
--- a/srcpkgs/tbb/patches/hostname-usage.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/build/version_info_linux.sh
-+++ b/build/version_info_linux.sh
-@@ -20,7 +20,7 @@
- 
- # Script used to generate version info string
- echo "#define __TBB_VERSION_STRINGS(N) \\"
--echo '#N": BUILD_HOST'"\t\t"`hostname -s`" ("`uname -m`")"'" ENDL \'
-+echo '#N": BUILD_HOST'"\t\t"`hostname`" ("`uname -m`")"'" ENDL \'
- # find OS name in *-release and issue* files by filtering blank lines and lsb-release content out
- echo '#N": BUILD_OS'"\t\t"`lsb_release -sd 2>/dev/null | grep -ih '[a-z] ' - /etc/*release /etc/issue 2>/dev/null | head -1 | sed -e 's/["\\\\]//g'`'" ENDL \'
- echo '#N": BUILD_KERNEL'"\t"`uname -srv`'" ENDL \'
diff --git a/srcpkgs/tbb/patches/musl.patch b/srcpkgs/tbb/patches/musl.patch
index a8867eb53793..ec89c6a95fc6 100644
--- a/srcpkgs/tbb/patches/musl.patch
+++ b/srcpkgs/tbb/patches/musl.patch
@@ -1,5 +1,5 @@
---- a/src/tbbmalloc/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
-+++ b/src/tbbmalloc/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
+--- a/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
++++ b/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
 @@ -28,6 +28,7 @@
  // of aligned_alloc as required by new C++ standard, this makes it hard to
  // redefine aligned_alloc here. However, running on systems with new libc
diff --git a/srcpkgs/tbb/template b/srcpkgs/tbb/template
index aeef6ebdd061..47655829f744 100644
--- a/srcpkgs/tbb/template
+++ b/srcpkgs/tbb/template
@@ -1,76 +1,33 @@
 # Template file for 'tbb'
 pkgname=tbb
-version=2020.U3
+version=2021.3.0
 revision=1
-# version rewrite: 2017_U7 (upstream) => 2017.7 (xbps)
-_ver=${version/./_}
-wrksrc="oneTBB-${_ver}"
-build_style=gnu-makefile
-hostmakedepends="cmake"
+wrksrc="oneTBB-${version}"
+build_style=cmake
+makedepends="libhwloc-devel libgomp-devel"
 short_desc="Intel Threading Building Blocks"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
 license="Apache-2.0"
 homepage="https://www.threadingbuildingblocks.org"
-distfiles="https://github.com/oneapi-src/oneTBB/archive/${_ver}.tar.gz"
-checksum=2103cc6238c935664f87680618f6684d57501d4a2fa8ea8f6c97ad6ff7dc722a
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*)
-		make_build_args="arch=intel64"
-		;;
-	i686*)
-		make_build_args="arch=ia32"
-		;;
-	armv7l*)
-		make_build_args="arch=armv7"
-		;;
-	aarch64*)
-		make_build_args="arch=arm64"
-		;;
-	ppc64*)
-		make_build_args="arch=ppc64"
-		;;
-	ppc*)
-		make_build_args="arch=ppc32"
-		;;
-	*)
-		# make sure to fall back instead of letting host uname control it
-		make_build_args="arch=generic"
-		;;
-esac
-
-post_extract() {
-	sed -i 's|CPLUS = g..|CPLUS = $(CXX)|g' build/linux.gcc.inc
-	sed -i 's|CONLY = gcc|CONLY = $(CC)|g' build/linux.gcc.inc
+distfiles="https://github.com/oneapi-src/oneTBB/archive/v${version}.tar.gz"
+checksum=8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e
 
+pre_patch() {
 	# alternative might be:
 	# https://git.alpinelinux.org/cgit/aports/tree/testing/libtbb/glibc-struct-mallinfo.patch
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		vsed -e "s@#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__@@" \
-		  -i src/tbbmalloc/proxy.h
+		  -i src/tbbmalloc_proxy/proxy.h
 	fi
 }
 
-do_install() {
-	vmkdir usr/lib
-	vcopy build/linux_*/*.so* usr/lib
-	vmkdir usr/include/tbb
-	vcopy include/tbb/* usr/include/tbb
-
-	cmake \
-		-DINSTALL_DIR=$DESTDIR/usr/lib/cmake/TBB \
-		-DSYSTEM_NAME=Linux \
-		-DLIB_REL_PATH=../.. \
-		-DINC_REL_PATH=../../../include \
-		-P cmake/tbb_config_installer.cmake
-}
-
 tbb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
-		vmove "usr/lib/*.so"
 		vmove usr/lib/cmake
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.so
 	}
 }

From 58ac9ae5d54bd2e3523233976b54cefef4e7f6b7 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 03/12] OpenSubdiv: update to 3.4.4.

---
 srcpkgs/OpenSubdiv/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/OpenSubdiv/template b/srcpkgs/OpenSubdiv/template
index b7a5e16efbcf..dfbf29cc1a52 100644
--- a/srcpkgs/OpenSubdiv/template
+++ b/srcpkgs/OpenSubdiv/template
@@ -1,6 +1,6 @@
 # Template file for 'OpenSubdiv'
 pkgname=OpenSubdiv
-version=3.4.3
+version=3.4.4
 revision=1
 wrksrc="OpenSubdiv-${version//./_}"
 build_style=cmake
@@ -13,7 +13,7 @@ maintainer="John <me@johnnynator.dev>"
 license="Apache-2.0"
 homepage="http://graphics.pixar.com/opensubdiv/docs/intro.html"
 distfiles="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${version//./_}.tar.gz"
-checksum=7b22eb27d636ab0c1e03722c7a5a5bd4f11664ee65c9b48f341a6d0ce7f36745
+checksum=20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" OpenSubdiv"

From 0cce9a9c569c8ead61a5c61995fa4b3c87fe6100 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 04/12] PrusaSlicer: update to 2.3.3.

---
 srcpkgs/PrusaSlicer/patches/cross.patch | 11 -----------
 srcpkgs/PrusaSlicer/template            |  4 ++--
 2 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 srcpkgs/PrusaSlicer/patches/cross.patch

diff --git a/srcpkgs/PrusaSlicer/patches/cross.patch b/srcpkgs/PrusaSlicer/patches/cross.patch
deleted file mode 100644
index d64a450d9e9f..000000000000
--- a/srcpkgs/PrusaSlicer/patches/cross.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/avrdude/CMakeLists.txt	2020-06-04 09:19:26.017251215 +0200
-+++ b/src/avrdude/CMakeLists.txt	2020-06-04 09:19:36.468250771 +0200
-@@ -83,7 +83,7 @@ add_executable(avrdude-conf-gen conf-gen
- add_custom_command(
-     DEPENDS avrdude-conf-gen ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf
-     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
--    COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-+    COMMAND avrdude-conf-gen avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- 
diff --git a/srcpkgs/PrusaSlicer/template b/srcpkgs/PrusaSlicer/template
index dd0e76cb8017..a93832ac02e4 100644
--- a/srcpkgs/PrusaSlicer/template
+++ b/srcpkgs/PrusaSlicer/template
@@ -1,6 +1,6 @@
 # Template file for 'PrusaSlicer'
 pkgname=PrusaSlicer
-version=2.3.0
+version=2.3.3
 revision=1
 wrksrc="PrusaSlicer-version_${version}"
 build_style=cmake
@@ -16,7 +16,7 @@ maintainer="Jasper Chan <jasperchan515@gmail.com>"
 license="GPL-3.0-or-later"
 homepage="https://www.prusa3d.com/prusaslicer/"
 distfiles="https://github.com/prusa3d/Prusaslicer/archive/version_${version}.tar.gz"
-checksum=cd3bac5e29b5441fc4690f28cd7b1064e97dc00207bbdc88f7bd7832308d6ca5
+checksum=deda209505f740ac3d6f59cb2a960f4df908269ee09bd30cd4edb9fc472d29ac
 nocross="https://build.voidlinux.org/builders/armv7l_builder/builds/25230/steps/shell_3/logs/stdio"
 
 Slic3rPE_package() {

From 6e51deb8106170ac686ebfd2205f6d89524968ad Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 05/12] blender: update to 2.93.1.

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index af946c2b7999..8318317c82bf 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,6 +1,6 @@
 # Template file for 'blender'
 pkgname=blender
-version=2.93.0
+version=2.93.1
 revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"

From 9c32dd199aad6d41af4197a4cdedcb3d05b136fd Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 06/12] embree: update to 3.13.0.

---
 srcpkgs/embree/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/embree/template b/srcpkgs/embree/template
index 575b9bcb401c..b6f376d30efa 100644
--- a/srcpkgs/embree/template
+++ b/srcpkgs/embree/template
@@ -1,8 +1,8 @@
 # Template file for 'embree'
 pkgname=embree
-version=2.17.7
-revision=2
-archs="x86_64"
+version=3.13.0
+revision=1
+archs="x86_64*"
 build_style=cmake
 configure_args="-DTBB_ROOT=/usr -DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF"
 hostmakedepends="ispc"

From c7ee6b56ca53aee247edf115de88f3181b96c2bd Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 03:34:43 +0300
Subject: [PATCH 07/12] openimageio: update to 2.2.16.0.

---
 srcpkgs/openimageio/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index de8e1cd04409..3bfdd4e0ed1e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,11 +1,11 @@
 # Template file for 'openimageio'
 pkgname=openimageio
-version=2.2.15.1
+version=2.2.16.0
 revision=1
 wrksrc="oiio-Release-${version}"
 build_style=cmake
 configure_args="-DUSE_OPENGL=0 -DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=1
- -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0"
+ -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0 -DCMAKE_CXX_STANDARD=14"
 hostmakedepends="pkg-config git"
 makedepends="boost-devel giflib-devel libraw-devel libopenjpeg-devel libwebp-devel
  libjpeg-turbo-devel tiff-devel libpng-devel libopenexr-devel freetype-devel
@@ -17,7 +17,7 @@ license="BSD-3-Clause"
 homepage="https://sites.google.com/site/openimageio/home"
 changelog="https://raw.githubusercontent.com/OpenImageIO/oiio/release/CHANGES.md"
 distfiles="https://github.com/OpenImageIO/oiio/archive/Release-${version}.tar.gz"
-checksum=f222c6b51a40aabbc80ddf4055535be9af1ffa907452fa6d1ffa7674854aab17
+checksum=d1a59f32dbba3ba71ad2e62e107034d1c5287bca1b0696474e927d504cd05ef4
 # Runs checks even for features we disabled.
 make_check=no
 

From 749df30055fcbdae12bdad23247bef55f9f9ee14 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 08/12] openimagedenoise: update to 1.4.1.

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index c73913b4e9d7..14055aff1c27 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,6 +1,6 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
-version=1.4.0
+version=1.4.1
 revision=1
 archs="x86_64*"
 wrksrc=oidn-${version}

From e30cd818f3f1d503a5efd5ec5bab1dc9c64794a5 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 09/12] openvdb: update to 8.1.0.

---
 common/shlibs                             |    2 +-
 srcpkgs/openvdb/patches/00-tbb-2021.patch | 1320 +++++++++++++++++++++
 srcpkgs/openvdb/template                  |   16 +-
 3 files changed, 1325 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/openvdb/patches/00-tbb-2021.patch

diff --git a/common/shlibs b/common/shlibs
index 6b7ca5fbc249..2a7acdb253a7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3883,7 +3883,7 @@ libjanet.so.1.16 janet-1.16.0_1
 libOpenImageDenoise.so.1 openimagedenoise-1.3.0_1
 libcbang0.so cbang-1.6.0_3
 libblosc.so.1 c-blosc-1.17.1_1
-libopenvdb.so.7.0 openvdb-7.0.0_1
+libopenvdb.so.8.1 openvdb-8.1.0_1
 libAlembic.so.1.7 alembic-1.7.13_1
 libmodsecurity.so.3 modsecurity-3.0.4_1
 libraven.so.0 budgie-desktop-10.5.1_1
diff --git a/srcpkgs/openvdb/patches/00-tbb-2021.patch b/srcpkgs/openvdb/patches/00-tbb-2021.patch
new file mode 100644
index 000000000000..271104af3df9
--- /dev/null
+++ b/srcpkgs/openvdb/patches/00-tbb-2021.patch
@@ -0,0 +1,1320 @@
+https://github.com/AcademySoftwareFoundation/openvdb/pull/1027
+Should be dropped after 8.1.1 release.
+
+diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake
+index d41436b1c..06de2b3f3 100644
+--- a/cmake/FindTBB.cmake
++++ b/cmake/FindTBB.cmake
+@@ -169,8 +169,22 @@ find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
+   PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
+ )
+ 
+-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" ""
+@@ -178,7 +192,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" ""
+@@ -192,6 +206,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
+ # ------------------------------------------------------------------------
+diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt
+index 88543df3a..929fe94d1 100644
+--- a/openvdb/openvdb/CMakeLists.txt
++++ b/openvdb/openvdb/CMakeLists.txt
+@@ -437,6 +437,10 @@ set(OPENVDB_LIBRARY_UTIL_INCLUDE_FILES
+   util/Util.h
+ )
+ 
++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} DESTINATION ${OPENVDB_INST
+ 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)
+diff --git a/openvdb/openvdb/cmd/openvdb_render.cc b/openvdb/openvdb/cmd/openvdb_render.cc
+index ee5b737c5..2c9831ba3 100644
+--- a/openvdb/openvdb/cmd/openvdb_render.cc
++++ b/openvdb/openvdb/cmd/openvdb_render.cc
+@@ -19,7 +19,14 @@
+ #include <OpenEXR/ImfHeader.h>
+ #include <OpenEXR/ImfOutputFile.h>
+ #include <OpenEXR/ImfPixelType.h>
+-#include <tbb/task_scheduler_init.h>
++
++// 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 <tbb/global_control.h>
+ #include <tbb/tick_count.h>
+ 
+ #include <algorithm>
+@@ -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<tbb::global_control> 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();
+ 
+diff --git a/openvdb/openvdb/io/Queue.cc b/openvdb/openvdb/io/Queue.cc
+index ef5d2961a..20ff1a0c1 100644
+--- a/openvdb/openvdb/io/Queue.cc
++++ b/openvdb/openvdb/io/Queue.cc
+@@ -5,20 +5,22 @@
+ /// @author Peter Cucka
+ 
+ #include "Queue.h"
+-
+ #include "File.h"
+ #include "Stream.h"
+-#include <openvdb/Exceptions.h>
+-#include <openvdb/util/logging.h>
++#include "openvdb/Exceptions.h"
++#include "openvdb/util/logging.h"
++
+ #include <tbb/concurrent_hash_map.h>
+-#include <tbb/task.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
+-#include <tbb/tick_count.h>
++#include <tbb/task_arena.h>
++
++#include <thread>
+ #include <algorithm> // for std::max()
+ #include <atomic>
+ #include <iostream>
+ #include <map>
+ #include <mutex>
++#include <chrono>
++
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -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
+ 
+ 
+ // 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
+         : 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
+             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<Queue::Id, Queue::Status>;
+ 
+-
+     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::milliseconds>(
++                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;
+ }
+ 
+diff --git a/openvdb/openvdb/math/Coord.h b/openvdb/openvdb/math/Coord.h
+index 504b5e9a4..2e9cfed5d 100644
+--- a/openvdb/openvdb/math/Coord.h
++++ b/openvdb/openvdb/math/Coord.h
+@@ -13,8 +13,7 @@
+ #include "Math.h"
+ #include "Vec3.h"
+ 
+-namespace tbb { class split; } // forward declaration
+-
++#include <tbb/blocked_range.h> // for tbb::split
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+diff --git a/openvdb/openvdb/points/PointSample.h b/openvdb/openvdb/points/PointSample.h
+index a122cc4fb..27ec3fb29 100644
+--- a/openvdb/openvdb/points/PointSample.h
++++ b/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 <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tools/Interpolation.h>
++#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 <sstream>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -299,7 +299,7 @@ class PointDataSampler
+             using TargetHandleT = AttributeWriteHandle<typename SamplerWrapperT::ValueType>;
+ 
+             if (util::wasInterrupted(interrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return;
+             }
+ 
+diff --git a/openvdb/openvdb/thread/Threading.h b/openvdb/openvdb/thread/Threading.h
+new file mode 100644
+index 000000000..0c3b356e3
+--- /dev/null
++++ b/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 <tbb/blocked_range.h>
++#include <tbb/task.h>
++#include <tbb/task_group.h>
++
++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
+diff --git a/openvdb/openvdb/tools/Composite.h b/openvdb/openvdb/tools/Composite.h
+index 6bc170bf7..88ff86f9f 100644
+--- a/openvdb/openvdb/tools/Composite.h
++++ b/openvdb/openvdb/tools/Composite.h
+@@ -24,7 +24,6 @@
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include <type_traits>
+ #include <functional>
+diff --git a/openvdb/openvdb/tools/Diagnostics.h b/openvdb/openvdb/tools/Diagnostics.h
+index 694d2155f..e5844e448 100644
+--- a/openvdb/openvdb/tools/Diagnostics.h
++++ b/openvdb/openvdb/tools/Diagnostics.h
+@@ -11,14 +11,17 @@
+ #ifndef OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ 
+-#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/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 <tbb/blocked_range.h>
+ #include <tbb/parallel_reduce.h>
++
+ #include <cmath> // for std::isnan(), std::isfinite()
+ #include <set>
+ #include <sstream>
+@@ -26,7 +29,6 @@
+ #include <type_traits>
+ #include <vector>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -1160,13 +1162,13 @@ InactiveVoxelValues<TreeType>::operator()(const tbb::blocked_range<size_t>& rang
+ {
+     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<typename TreeType>
+ inline void
+ InactiveTileValues<TreeType>::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();
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/tools/Filter.h b/openvdb/openvdb/tools/Filter.h
+index 408c75541..b70212520 100644
+--- a/openvdb/openvdb/tools/Filter.h
++++ b/openvdb/openvdb/tools/Filter.h
+@@ -14,21 +14,24 @@
+ #ifndef OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ 
+-#include <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
++#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 <tbb/parallel_for.h>
++#include <tbb/concurrent_vector.h>
++
+ #include <algorithm> // for std::max()
+ #include <functional>
+ #include <type_traits>
+-#include <tbb/concurrent_vector.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -833,7 +836,7 @@ inline bool
+ Filter<GridT, MaskT, InterruptT>::wasInterrupted()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return true;
+     }
+     return false;
+diff --git a/openvdb/openvdb/tools/GridOperators.h b/openvdb/openvdb/tools/GridOperators.h
+index 31305a1ab..78fafead9 100644
+--- a/openvdb/openvdb/tools/GridOperators.h
++++ b/openvdb/openvdb/tools/GridOperators.h
+@@ -9,14 +9,15 @@
+ #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/Grid.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
++#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 <tbb/parallel_for.h>
+ 
++#include <tbb/parallel_for.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -383,7 +384,9 @@ class GridOperator
+     /// 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) {
+diff --git a/openvdb/openvdb/tools/LevelSetMeasure.h b/openvdb/openvdb/tools/LevelSetMeasure.h
+index efe19074d..59969cdcf 100644
+--- a/openvdb/openvdb/tools/LevelSetMeasure.h
++++ b/openvdb/openvdb/tools/LevelSetMeasure.h
+@@ -8,18 +8,21 @@
+ #ifndef OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/math/Math.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/Grid.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/math/FiniteDifference.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/math/Stencils.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
+ #include <tbb/parallel_sort.h>
+ #include <tbb/parallel_invoke.h>
++
+ #include <type_traits>
+ 
+ namespace openvdb {
+@@ -329,7 +332,7 @@ inline bool
+ LevelSetMeasure<GridT, InterruptT>::checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/LevelSetTracker.h b/openvdb/openvdb/tools/LevelSetTracker.h
+index cbdc267e8..bfc8004e7 100644
+--- a/openvdb/openvdb/tools/LevelSetTracker.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/tree/LeafManager.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -383,7 +385,7 @@ LevelSetTracker<GridT, InterruptT>::
+ checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/MeshToVolume.h b/openvdb/openvdb/tools/MeshToVolume.h
+index 6643c8f05..de3406eda 100644
+--- a/openvdb/openvdb/tools/MeshToVolume.h
++++ b/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 <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/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 <tbb/parallel_reduce.h>
+ #include <tbb/partitioner.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm> // for std::sort()
+ #include <cmath> // 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<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+@@ -1989,7 +1990,7 @@ class VoxelizePolygons
+         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
+ 
+         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) {
+diff --git a/openvdb/openvdb/tools/Morphology.h b/openvdb/openvdb/tools/Morphology.h
+index 736982ef5..0a1e71009 100644
+--- a/openvdb/openvdb/tools/Morphology.h
++++ b/openvdb/openvdb/tools/Morphology.h
+@@ -24,7 +24,7 @@
+ #include "openvdb/tree/ValueAccessor.h"
+ #include "openvdb/tree/LeafManager.h"
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ 
+@@ -726,7 +726,7 @@ void Morphology<TreeType>::dilateVoxels(const size_t iter,
+         }
+ 
+         // @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
+diff --git a/openvdb/openvdb/tools/ParticlesToLevelSet.h b/openvdb/openvdb/tools/ParticlesToLevelSet.h
+index 739af2b69..f9c19911c 100644
+--- a/openvdb/openvdb/tools/ParticlesToLevelSet.h
++++ b/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 <tbb/parallel_reduce.h>
+-#include <tbb/blocked_range.h>
+-#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/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 <tbb/parallel_reduce.h>
++#include <tbb/blocked_range.h>
++
+ #include <functional>
+ #include <iostream>
+ #include <type_traits>
+@@ -738,7 +742,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         for (Coord c = lo; c.x() <= hi.x(); ++c.x()) {
+             //only check interrupter every 32'th scan in x
+             if (!(count++ & ((1<<5)-1)) && util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Real x2 = math::Pow2(c.x() - P[0]);
+@@ -804,7 +808,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         // Densely fill the remaining regions.
+         for (const auto& bbox: padding) {
+             if (util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Coord &bmin = bbox.min(), &bmax = bbox.max();
+diff --git a/openvdb/openvdb/tools/PointAdvect.h b/openvdb/openvdb/tools/PointAdvect.h
+index 12b1177ad..e487bfb3e 100644
+--- a/openvdb/openvdb/tools/PointAdvect.h
++++ b/openvdb/openvdb/tools/PointAdvect.h
+@@ -10,16 +10,19 @@
+ #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/openvdb.h>
+-#include <openvdb/math/Math.h>             // min
+-#include <openvdb/Types.h>                 // Vec3 types and version number
+-#include <openvdb/Grid.h>                  // grid
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/blocked_range.h>             // threading
+ #include <tbb/parallel_for.h>              // threading
+ #include <tbb/task.h>                      // for cancel
++
+ #include <vector>
+ 
+ 
+@@ -167,7 +170,7 @@ class PointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityFieldIntegrator  velField(*mVelGrid);
+@@ -307,7 +310,7 @@ class ConstrainedPointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityIntegratorType velField(*mVelGrid);
+diff --git a/openvdb/openvdb/tools/PointIndexGrid.h b/openvdb/openvdb/tools/PointIndexGrid.h
+index e9ebf96f7..b2e378a79 100644
+--- a/openvdb/openvdb/tools/PointIndexGrid.h
++++ b/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 <openvdb/version.h>
+@@ -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;
+         }
+ 
+diff --git a/openvdb/openvdb/tools/PointPartitioner.h b/openvdb/openvdb/tools/PointPartitioner.h
+index ccf50ab05..f7f6fc13d 100644
+--- a/openvdb/openvdb/tools/PointPartitioner.h
++++ b/openvdb/openvdb/tools/PointPartitioner.h
+@@ -23,7 +23,7 @@
+ 
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm>
+ #include <cmath> // for std::isfinite()
+@@ -764,7 +764,7 @@ inline void binAndSegment(
+     using IndexPairListMap = std::map<Coord, IndexPairListPtr>;
+     using IndexPairListMapPtr = std::shared_ptr<IndexPairListMap>;
+ 
+-    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;
+ 
+diff --git a/openvdb/openvdb/tools/PointsToMask.h b/openvdb/openvdb/tools/PointsToMask.h
+index 592ab7a15..8a276fb04 100644
+--- a/openvdb/openvdb/tools/PointsToMask.h
++++ b/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 <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/blocked_range.h>
+-#include <openvdb/openvdb.h> // for MaskGrid
+-#include <openvdb/Grid.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/util/NullInterrupter.h>
++
+ #include <vector>
+ 
+ 
+@@ -150,7 +154,7 @@ class PointsToMask
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeAdvect.h b/openvdb/openvdb/tools/VolumeAdvect.h
+index e7eec740e..f38eaa9c2 100644
+--- a/openvdb/openvdb/tools/VolumeAdvect.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/math/Math.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ 
+ 
+@@ -294,7 +297,7 @@ class VolumeAdvection
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeToMesh.h b/openvdb/openvdb/tools/VolumeToMesh.h
+index a834dd3b3..a446f806a 100644
+--- a/openvdb/openvdb/tools/VolumeToMesh.h
++++ b/openvdb/openvdb/tools/VolumeToMesh.h
+@@ -18,7 +18,7 @@
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <cmath> // for std::isfinite()
+ #include <map>
+@@ -388,7 +388,7 @@ inline void
+ fillArray(ValueType* array, const ValueType& val, const size_t length)
+ {
+     const auto grainSize = std::max<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+diff --git a/openvdb/openvdb/unittest/TestCoord.cc b/openvdb/openvdb/unittest/TestCoord.cc
+index be1c24ced..148690041 100644
+--- a/openvdb/openvdb/unittest/TestCoord.cc
++++ b/openvdb/openvdb/unittest/TestCoord.cc
+@@ -2,9 +2,9 @@
+ // SPDX-License-Identifier: MPL-2.0
+ 
+ #include <openvdb/Types.h>
++#include <openvdb/math/Coord.h>
+ 
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_stddef.h> // for tbb::split
+ 
+ #include <unordered_map>
+ #include <sstream>
+diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc
+index 8074166d2..053448f30 100644
+--- a/openvdb/openvdb/unittest/TestFile.cc
++++ b/openvdb/openvdb/unittest/TestFile.cc
+@@ -13,8 +13,11 @@
+ #include <openvdb/version.h>
+ #include <openvdb/openvdb.h>
+ #include "util.h" // for unittest_util::makeSphere()
++
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
++
++#include <thread>
++#include <chrono>
+ #include <algorithm> // for std::sort()
+ #include <cstdio> // for remove() and rename()
+ #include <fstream>
+@@ -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::seconds>(
++                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<io::Queue::Id> 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));
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc
+index 70e7df5f7..6b2204771 100644
+--- a/openvdb/openvdb/unittest/TestUtil.cc
++++ b/openvdb/openvdb/unittest/TestUtil.cc
+@@ -8,7 +8,6 @@
+ 
+ #include <gtest/gtest.h>
+ 
+-#include <tbb/task_scheduler_init.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/blocked_range.h>
+diff --git a/openvdb/openvdb/unittest/TestValueAccessor.cc b/openvdb/openvdb/unittest/TestValueAccessor.cc
+index fd2dd5d81..5c1cbb18b 100644
+--- a/openvdb/openvdb/unittest/TestValueAccessor.cc
++++ b/openvdb/openvdb/unittest/TestValueAccessor.cc
+@@ -6,6 +6,7 @@
+ 
+ #include <gtest/gtest.h>
+ #include <tbb/task.h>
++#include <tbb/task_group.h>
+ 
+ #include <type_traits>
+ 
+@@ -378,22 +379,21 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
+     //using AccessorT = openvdb::tree::ValueAccessor<Tree4Type>;
+ 
+     // 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
+ }
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+index 0e1b4d855..6d9bb528b 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+@@ -20,6 +20,7 @@
+ #include <openvdb/tools/GridTransformer.h>
+ #include <openvdb/tools/PointIndexGrid.h>
+ #include <openvdb/tools/Prune.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <CH/CH_Manager.h>
+ #include <CVEX/CVEX_Context.h>
+@@ -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;
+             }
+ 
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+index 757fdc8c6..dbee74b32 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+@@ -16,13 +16,11 @@
+ #include <openvdb_houdini/SOP_NodeVDB.h>
+ 
+ #include <openvdb/tools/Interpolation.h>  // for box sampler
++#include <openvdb/thread/Threading.h>
+ #include <openvdb/points/PointCount.h>
+ #include <openvdb/points/PointSample.h>
+ #include <openvdb/points/IndexFilter.h>   // for MultiGroupFilter
+ 
+-#include <tbb/tick_count.h>                 // for timing
+-#include <tbb/task.h>                       // for cancel
+-
+ #include <UT/UT_Interrupt.h>
+ #include <GA/GA_PageHandle.h>
+ #include <GA/GA_PageIterator.h>
+@@ -38,6 +36,7 @@
+ #include <stdexcept>
+ #include <string>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ 
+@@ -327,7 +326,7 @@ class PointSampler
+     {
+ 
+         if (mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            openvdb::thread::cancelGroupExecution();
+         }
+         const GridType& grid = UTvdbGridCast<GridType>(mGrid);
+         // task local grid accessor
+@@ -481,7 +480,7 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Context& context)
+         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_Context& context)
+             }
+         }
+ 
+-        // 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::milliseconds>(
++                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;
+         }
+ 
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+index 3d559f8cc..d63ed1591 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
++++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+@@ -47,11 +47,8 @@ struct NodeInfo {
+ 
+ typedef std::vector<NodeInfo> 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, const MTypeId& typeId,
+     node.type               = type;
+     node.classification     = classification;
+ 
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (!gNodes) {
+         OPENVDB_START_THREADSAFE_STATIC_WRITE
+@@ -85,7 +82,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, const MTypeId& typeId,
+ void
+ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+@@ -109,7 +106,7 @@ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ void
+ NodeRegistry::deregisterNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.h b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+index b58bd6f2c..6a04b1eaf 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBUtil.h
++++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+@@ -14,8 +14,7 @@
+ #include <openvdb/tree/LeafManager.h>
+ #include <openvdb/tools/VolumeToMesh.h>
+ #include <openvdb/util/Formats.h> // printBytes
+-
+-#include <tbb/tick_count.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <maya/M3dView.h>
+ #include <maya/MString.h>
+@@ -40,6 +39,7 @@
+ #include <string>
+ #include <type_traits>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ ////////////////////////////////////////
+@@ -116,11 +116,15 @@ insertFrameNumber(std::string& str, const MTime& time, int numberingScheme = 0);
+ 
+ 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::milliseconds>(
++            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<std::chrono::steady_clock> mStamp;
+ };
+ 
+ 
+diff --git a/pendingchanges/tbb2021.txt b/pendingchanges/tbb2021.txt
+new file mode 100644
+index 000000000..8109c2552
+--- /dev/null
++++ b/pendingchanges/tbb2021.txt
+@@ -0,0 +1,6 @@
++Improvements:
++  - Moved from the deprecated TBB task scheduler to TBB arenas. Various methods now respect the TBB arena state they were invoked from.
++  - Introduced a new thread/Threading.h header to consolidate calls to third-party threading methods.
++
++Build:
++  - Added support for TBB 2021.
diff --git a/srcpkgs/openvdb/template b/srcpkgs/openvdb/template
index 72fde5bc6375..d420a3ee5f5d 100644
--- a/srcpkgs/openvdb/template
+++ b/srcpkgs/openvdb/template
@@ -1,26 +1,18 @@
 # Template file for 'openvdb'
 pkgname=openvdb
-version=7.0.0
+version=8.1.0
 revision=1
 build_style=cmake
 configure_args="-DOPENVDB_BUILD_VDB_VIEW=1"
 hostmakedepends="pkg-config"
-makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel glfw-devel"
+makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel
+ glfw-devel jemalloc-devel"
 short_desc="Sparse volume data structure and tools"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MPL-2.0"
 homepage="https://openvdb.org"
 distfiles="https://github.com/AcademySoftwareFoundation/openvdb/archive/v${version}.tar.gz"
-checksum=97bc8ae35ef7ccbf49a4e25cb73e8c2eccae6b235bac86f2150707efcd1e910d
-
-if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
-	makedepends+=" libatomic-devel"
-fi
-
-post_patch() {
-	[ "$XBPS_TARGET_NO_ATOMIC8" ] || return 0
-	vsed -i 's,ZLIB::ZLIB,ZLIB::ZLIB atomic,' openvdb/CMakeLists.txt
-}
+checksum=3e09d47331429be7409a3a3c27fdd3c297f96d31d2153febe194e664a99d6183
 
 post_install() {
 	vlicense LICENSE

From 2e8bbc914059136d80d389577aed357a9af4672d Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 10/12] paraview: update to 5.9.1.

---
 srcpkgs/paraview/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/paraview/template b/srcpkgs/paraview/template
index 20a7f5589677..e6c3941ce90a 100644
--- a/srcpkgs/paraview/template
+++ b/srcpkgs/paraview/template
@@ -1,7 +1,7 @@
 # Template file for 'paraview'
 pkgname=paraview
-version=5.8.1
-revision=3
+version=5.9.1
+revision=1
 wrksrc=ParaView-v${version}
 build_style=cmake
 configure_args="-DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr

From 3e3eef017eebd9aa1f5627c0b4657b92e54cab9c Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 11/12] occt: revbump due to tbb update

---
 srcpkgs/occt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/occt/template b/srcpkgs/occt/template
index 9298edc76e08..006f89ebb8ce 100644
--- a/srcpkgs/occt/template
+++ b/srcpkgs/occt/template
@@ -2,7 +2,7 @@
 pkgname=occt
 reverts=7.5.0_1
 version=7.4.0p1
-revision=3
+revision=4
 _gittag="V${version//./_}"
 wrksrc=occt-${_gittag}
 build_style=cmake

From 94b976d9c4e1ac0f795bde15a06b0bec2222be49 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 18:05:52 +0300
Subject: [PATCH 12/12] hwloc

---
 .../patches/00-get-area-memlocation.patch     | 71 ++++++++++++++++++-
 1 file changed, 69 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hwloc/patches/00-get-area-memlocation.patch b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
index e398a80e046d..b60af1bc2667 100644
--- a/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
+++ b/srcpkgs/hwloc/patches/00-get-area-memlocation.patch
@@ -1,12 +1,21 @@
 diff --git a/tests/hwloc/hwloc_get_area_memlocation.c b/tests/hwloc/hwloc_get_area_memlocation.c
-index 498dfae..999d95b 100644
+index 498dfae..8d77cf7 100644
 --- a/tests/hwloc/hwloc_get_area_memlocation.c
 +++ b/tests/hwloc/hwloc_get_area_memlocation.c
+@@ -8,7 +8,7 @@
+ #include <stdio.h>
+ #include <assert.h>
+ 
+-#define LEN 1048576
++#define LEN 1024
+ 
+ int main(void)
+ {
 @@ -34,11 +34,13 @@ int main(void)
    assert(buffer);
    printf("buffer %p length %d\n", buffer, LEN);
  
-+  fprintf(stderr, "Before memloation\nerr == %i, errno == %s\n", err, strerror(errno));
++  fprintf(stderr, "Before memlocation\nerr == %i, errno == %s\n", err, strerror(errno));
    err = hwloc_get_area_memlocation(topology, buffer, LEN, set, HWLOC_MEMBIND_BYNODESET);
    if (err < 0 && errno == ENOSYS) {
      fprintf(stderr, "hwloc_get_area_memlocation() failed with ENOSYS, aborting\n");
@@ -16,3 +25,61 @@ index 498dfae..999d95b 100644
    assert(!err);
    hwloc_bitmap_asprintf(&s, set);
    printf("address %p length %d allocated in nodeset %s\n", buffer, LEN, s);
+diff --git a/hwloc/topology-linux.c b/hwloc/topology-linux.c
+index 10e038e..c50933c 100644
+--- a/hwloc/topology-linux.c
++++ b/hwloc/topology-linux.c
+@@ -21,6 +21,7 @@
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <assert.h>
++#include <string.h>
+ #ifdef HAVE_DIRENT_H
+ #include <dirent.h>
+ #endif
+@@ -327,6 +328,7 @@ static __hwloc_inline long hwloc_move_pages(int pid __hwloc_attribute_unused,
+ 					    int flags __hwloc_attribute_unused)
+ {
+ #if (defined __NR_move_pages) && (defined HWLOC_HAVE_SYSCALL)
++  fprintf(stderr, "NR_MOVE_PAGES FOUND\n");
+   return syscall(__NR_move_pages, pid, count, pages, nodes, status, flags);
+ #else
+ #warning Couldn't find __NR_move_pages syscall number, getting memory location won't be supported
+@@ -2039,8 +2040,10 @@ hwloc_linux_get_area_memlocation(hwloc_topology_t topology __hwloc_attribute_unu
+   addr = ((char*) addr) - offset;
+   len += offset;
+   count = (len + pagesize-1)/pagesize;
++  fprintf(stderr, "errno == %s\n", strerror(errno));
+   pages = malloc(count*sizeof(*pages));
+   status = malloc(count*sizeof(*status));
++  fprintf(stderr, "errno == %s\n", strerror(errno));
+   if (!pages || !status) {
+     ret = -1;
+     goto out_with_pages;
+@@ -2049,19 +2052,25 @@ hwloc_linux_get_area_memlocation(hwloc_topology_t topology __hwloc_attribute_unu
+   for(i=0; i<count; i++)
+     pages[i] = ((char*)addr) + i*pagesize;
+ 
++  fprintf(stderr, "errno == %s\n", strerror(errno));
+   ret = hwloc_move_pages(0, count, pages, NULL, status, 0);
++  fprintf(stderr, "errno == %s\n", strerror(errno));
+   if (ret  < 0)
+     goto out_with_pages;
+ 
+   hwloc_bitmap_zero(nodeset);
+   for(i=0; i<count; i++)
+-    if (status[i] >= 0)
++    if (status[i] >= 0) {
+       hwloc_bitmap_set(nodeset, status[i]);
++      fprintf(stderr, "i == %i, errno == %s\n", i, strerror(errno));
++	}
+   ret = 0; /* not really useful since move_pages never returns > 0 */
+ 
+  out_with_pages:
++  fprintf(stderr, "errno == %s\n", strerror(errno));
+   free(pages);
+   free(status);
++  fprintf(stderr, "errno == %s\n", strerror(errno));
+   return ret;
+ }
+ 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PR PATCH] [Updated] tbb: update to 2021.3.0
  2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
                   ` (6 preceding siblings ...)
  2021-07-24 16:16 ` Logarithmus
@ 2021-07-24 16:41 ` Logarithmus
  2021-07-25 15:26 ` Logarithmus
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Logarithmus @ 2021-07-24 16:41 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

There is an updated pull request by Logarithmus against master on the void-packages repository

https://github.com/Logarithmus/void-packages tbb-2021
https://github.com/void-linux/void-packages/pull/32166

tbb: update to 2021.3.0
Follow-up of https://github.com/void-linux/void-packages/pull/27746, @thypon & @olafmersmann might be interested.
**TODO** fix reverse dependencies:
- [ ] OpenSubdiv: update to 3.4.4.
- [ ] PrusaSlicer: update to 2.3.3.
- [ ] lender: update to 2.93.1.
- [ ] embree: update to 3.13.0.
- [ ] openimageio: update to 2.2.16.0.
- [ ] openimagedenoise: update to 1.4.1.
- [ ] openvdb: update to 8.1.0.
- [ ] paraview: update to 5.9.1.
- [ ] occt: revbump due to tbb update

#### Have the results of the proposed changes been tested?
- [x] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me


A patch file from https://github.com/void-linux/void-packages/pull/32166.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-tbb-2021-32166.patch --]
[-- Type: text/x-diff, Size: 87645 bytes --]

From 0cf7569d38bf2e8a32e72b5ce7a8172fcf3a1257 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 17 Jul 2021 23:57:52 +0300
Subject: [PATCH 01/11] hwloc: add libpciaccess-devel make dependency

---
 srcpkgs/hwloc/template | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/hwloc/template b/srcpkgs/hwloc/template
index 818db269cebb..6c79a9513a1c 100644
--- a/srcpkgs/hwloc/template
+++ b/srcpkgs/hwloc/template
@@ -1,10 +1,12 @@
 # Template file for 'hwloc'
 pkgname=hwloc
 version=2.5.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="cairo-devel ncurses-devel libxml2-devel eudev-libudev-devel"
+makedepends="cairo-devel ncurses-devel libxml2-devel libpciaccess-devel eudev-libudev-devel"
+checkdepends="tar"
+make_check_args="VERBOSE=1"
 short_desc="Portable abstraction of hierarchical hardware architectures"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
 license="BSD-3-Clause"
@@ -16,6 +18,12 @@ case "$XBPS_TARGET_MACHINE" in
 	i686*|x86_64*|ppc64*) makedepends+=" libnuma-devel";;
 esac
 
+post_extract() {
+	# syscall 279 (move_pages) is unavailable inside Github Actions' Docker container,
+	# that's why we skip this test
+	rm tests/hwloc/hwloc_get_area_memlocation.c
+}
+
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc
 }
@@ -31,7 +39,7 @@ libhwloc_package() {
 
 libhwloc-devel_package() {
 	short_desc+=" - development files"
-	depends="libhwloc>=${version}_${revision}"
+	depends="${makedepends} libhwloc>=${version}_${revision}"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/share/man/man3

From b5ba49e49b1b1eb6d2cceb99d965658c59bb4402 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 02:50:26 +0300
Subject: [PATCH 02/11] tbb: update to 2021.3.0.

---
 common/shlibs                                |   6 +-
 srcpkgs/tbb/patches/00-hwloc-2.5.patch       | 367 +++++++++++++++++++
 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch |  52 +++
 srcpkgs/tbb/patches/hostname-usage.patch     |  11 -
 srcpkgs/tbb/patches/musl.patch               |   4 +-
 srcpkgs/tbb/template                         |  63 +---
 6 files changed, 433 insertions(+), 70 deletions(-)
 create mode 100644 srcpkgs/tbb/patches/00-hwloc-2.5.patch
 create mode 100644 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
 delete mode 100644 srcpkgs/tbb/patches/hostname-usage.patch

diff --git a/common/shlibs b/common/shlibs
index a7afbf2a56f7..6b7ca5fbc249 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2376,12 +2376,10 @@ libanthy-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthydic-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthyinput-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthygobject-1.0.so.5 ibus-anthy-1.5.6_1
-libtbbmalloc_proxy_debug.so.2 tbb-4.3_1
 libtbbmalloc_proxy.so.2 tbb-4.3_1
 libtbbmalloc.so.2 tbb-4.3_1
-libtbb_debug.so.2 tbb-4.3_1
-libtbb.so.2 tbb-4.3_1
-libtbbmalloc_debug.so.2 tbb-4.3_1
+libtbb.so.12 tbb-2021.3.0_1
+libtbbbind_2_5.so.3 tbb-2021.3.0_1
 libembree.so.2 embree-2.5.1_1
 libgtkimageview.so.0 gtkimageview-1.6.4_1
 libgoocanvas-2.0.so.9 goocanvas-2.0.4_1
diff --git a/srcpkgs/tbb/patches/00-hwloc-2.5.patch b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
new file mode 100644
index 000000000000..9c4c9285c71d
--- /dev/null
+++ b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
@@ -0,0 +1,367 @@
+Adjusted by Artur Sinila <freesoftware@logarithmus.dev>
+
+From e96dbf4b48e689ab810b0428d0858a6abc2c83bd Mon Sep 17 00:00:00 2001
+From: Ivan Kochin <iv.kochin@gmail.com>
+Date: Thu, 1 Jul 2021 15:07:39 +0300
+Subject: [PATCH] Upgrade from HWLOC 2.4 to HWLOC 2.5 (#448)
+
+* Upgrade from HWLOC 2.4 to HWLOC 2.5
+* Introduce tbbbind_2_5 library
+* Remove tbbbind_2_4 library
+* Use the HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING topology flag (introduces as a part of HWLOC 2.5) to restrict topology discovering to process binding
+* Fix testing on Linux
+* Apply review comments
+* Improve wording: variable -> substring
+* Use right tbbbind version for incompatible hwlocs test
+* Rework option semantic
+* Update README.md for CMake
+* Rework readme
+* Update cmake/README.md
+
+Signed-off-by: Kochin, Ivan <kochin.ivan@intel.com>
+
+Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
+---
+ CMakeLists.txt                         |  3 ++-
+ cmake/README.md                        | 11 +++++---
+ cmake/hwloc_detection.cmake            |  9 ++++---
+ src/tbb/governor.cpp                   |  4 +--
+ src/tbbbind/CMakeLists.txt             |  2 +-
+ src/tbbbind/tbb_bind.cpp               | 23 +++++++++++-----
+ test/CMakeLists.txt                    | 30 ++++++++++-----------
+ test/common/common_arena_constraints.h | 37 ++++++++++++++++++++++----
+ 8 files changed, 82 insertions(+), 37 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 34a23d400..301899aca 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -100,6 +100,7 @@ option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Win
+ option(TBB4PY_BUILD "Enable tbb4py build" OFF)
+ option(TBB_CPF "Enable preview features of the library" OFF)
+ option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
++option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
+ 
+ if (NOT DEFINED BUILD_SHARED_LIBS)
+     set(BUILD_SHARED_LIBS ON)
+@@ -195,7 +196,7 @@ else()
+         add_subdirectory(src/tbbmalloc)
+         add_subdirectory(src/tbbmalloc_proxy)
+         if (APPLE)
+-            message(STATUS "TBBBind build target is disabled due to unsupported environment")
++            message(STATUS "TBBBind build targets are disabled due to unsupported environment")
+         else()
+             add_subdirectory(src/tbbbind)
+         endif()
+diff --git a/cmake/README.md b/cmake/README.md
+index 36fc303f9..b58c2ff6a 100644
+--- a/cmake/README.md
++++ b/cmake/README.md
+@@ -13,6 +13,7 @@ TBB4PY_BUILD:BOOL - Enable  Intel(R) oneAPI Threading Building Blocks (oneTBB) P
+ TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
+ TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
+ TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
++TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)
+ ```
+ 
+ ## Configure, build and test
+@@ -42,9 +43,9 @@ Some useful options:
+ 
+ #### TBBBind library configuration
+ 
+-The TBBbind library has two versions: `tbbbind` and `tbbbind_2_0`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.x.
++The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0` and `tbbbind_2_5`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.1-2.4, `tbbbind_2_5` links with HWLOC 2.5 and later.
+ 
+-To enable the TBBBind library build or special tests that performed inside the HWLOC environment, please specify the following CMake variables:
++The search for a suitable version of the HWLOC library is enabled by default, but if you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
+ 
+  - `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux or path to `.lib` file on Windows.
+  - `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version includes directory.
+@@ -52,7 +53,11 @@ To enable the TBBBind library build or special tests that performed inside the H
+ Windows requires one additional variable for correct TBBBind library building:
+  - `CMAKE_HWLOC_<HWLOC_VER>_DLL_PATH` - path to the corresponding HWLOC version `.dll` file.
+ 
+-`HWLOC_VER` variable used above can be replaced with one of the two values: `1_11` for the `tbbbind` library configuration and `2` for the `tbbbind_2_0` library configuration.
++`HWLOC_VER` substring used above can be replaced with one of the three values: `1_11` for the `tbbbind` library configuration, `2` for the `tbbbind_2_0`, and `2_5` for the `tbbbind_2_5` library configuration.
++
++If you specify variables for several TBBBind versions, then building process for all of these versions will be performed during single build session.
++
++Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
+ 
+ ### Build
+ 
+diff --git a/cmake/hwloc_detection.cmake b/cmake/hwloc_detection.cmake
+index e1eeca5fa..de7f3c047 100644
+--- a/cmake/hwloc_detection.cmake
++++ b/cmake/hwloc_detection.cmake
+@@ -12,7 +12,7 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
+-list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_4)
++list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_5)
+ 
+ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
+     if (NOT WIN32)
+@@ -55,10 +56,10 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
+         if (HWLOC_FOUND)
+             if (HWLOC_VERSION VERSION_LESS 2)
+                 set(TBBBIND_LIBRARY_NAME tbbbind)
+-            elseif(HWLOC_VERSION VERSION_LESS 2.4)
++            elseif(HWLOC_VERSION VERSION_LESS 2.5)
+                 set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
+             else()
+-                set(TBBBIND_LIBRARY_NAME tbbbind_2_4)
++                set(TBBBIND_LIBRARY_NAME tbbbind_2_5)
+             endif()
+         endif()
+     endif()
+diff --git a/src/tbb/governor.cpp b/src/tbb/governor.cpp
+index bf4e402d1..b842e075f 100644
+--- a/src/tbb/governor.cpp
++++ b/src/tbb/governor.cpp
+@@ -362,7 +362,7 @@ static const unsigned LinkTableSize = sizeof(TbbBindLinkTable) / sizeof(dynamic_
+ 
+ #define TBBBIND_NAME LIBRARY_PREFIX "tbbbind" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #define TBBBIND_2_0_NAME LIBRARY_PREFIX "tbbbind_2_0" DEBUG_SUFFIX LIBRARY_EXTENSION
+-#define TBBBIND_2_4_NAME LIBRARY_PREFIX "tbbbind_2_4" DEBUG_SUFFIX LIBRARY_EXTENSION
++#define TBBBIND_2_5_NAME LIBRARY_PREFIX "tbbbind_2_5" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #endif /* _WIN32 || _WIN64 || __linux__ */
+ 
+ // Representation of system hardware topology information on the TBB side.
+@@ -389,7 +389,7 @@ const char* load_tbbbind_shared_object() {
+     GetNativeSystemInfo(&si);
+     if (si.dwNumberOfProcessors > 32) return nullptr;
+ #endif /* _WIN32 && !_WIN64 */
+-    for (const auto& tbbbind_version : {TBBBIND_2_4_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
++    for (const auto& tbbbind_version : {TBBBIND_2_5_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
+         if (dynamic_link(tbbbind_version, TbbBindLinkTable, LinkTableSize)) {
+             return tbbbind_version;
+         }
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index 029893751..e5cdbf8bb 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -99,7 +99,7 @@ if (NOT DEFINED HWLOC_TARGET_EXPLICITLY_DEFINED AND DEFINED HWLOC_LIBRARIES)
+ else()
+     tbbbind_build(tbbbind     HWLOC::hwloc_1_11)
+     tbbbind_build(tbbbind_2_0 HWLOC::hwloc_2   )
+-    tbbbind_build(tbbbind_2_4 HWLOC::hwloc_2_4 )
++    tbbbind_build(tbbbind_2_5 HWLOC::hwloc_2_5 )
+ endif()
+ 
+ 
+diff --git a/src/tbbbind/tbb_bind.cpp b/src/tbbbind/tbb_bind.cpp
+index 97be308c7..88c956acb 100644
+--- a/src/tbbbind/tbb_bind.cpp
++++ b/src/tbbbind/tbb_bind.cpp
+@@ -34,7 +34,8 @@
+ #pragma GCC diagnostic pop
+ #endif
+ 
+-#define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ 
+ // Most of hwloc calls returns negative exit code on error.
+ // This macro tracks error codes that are returned from the hwloc interfaces.
+@@ -85,6 +86,16 @@ class platform_topology {
+         // Parse topology
+         if ( hwloc_topology_init( &topology ) == 0 ) {
+             initialization_state = topology_allocated;
++#if __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++            if ( groups_num == 1 &&
++                 hwloc_topology_set_flags(topology,
++                     HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                     HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
++                 ) != 0
++            ) {
++                return;
++            }
++#endif
+             if ( hwloc_topology_load( topology ) == 0 ) {
+                 initialization_state = topology_loaded;
+             }
+@@ -135,7 +146,7 @@ class platform_topology {
+             numa_indexes_list.resize(numa_nodes_count);
+             hwloc_obj_t node_buffer;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 numa_indexes_list[counter] = static_cast<int>(node_buffer->logical_index);
+ 
+                 if ( numa_indexes_list[counter] > max_numa_index ) {
+@@ -150,7 +161,7 @@ class platform_topology {
+             numa_affinity_masks_list.resize(max_numa_index + 1);
+             int index = 0;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 index = static_cast<int>(node_buffer->logical_index);
+ 
+                 hwloc_cpuset_t& current_mask = numa_affinity_masks_list[index];
+@@ -168,7 +179,7 @@ class platform_topology {
+             core_types_indexes_list.push_back(-1);
+             return;
+         }
+-#if __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
++#if __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
+         __TBB_ASSERT(hwloc_get_api_version() >= 0x20400, "Hybrid CPUs support interfaces required HWLOC >= 2.4");
+         // Parsing the hybrid CPU topology
+         int core_types_number = hwloc_cpukinds_get_nr(topology, 0);
+@@ -196,9 +207,9 @@ class platform_topology {
+                 }
+             }
+         }
+-#else /*!__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#else /*!__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+         bool core_types_parsing_broken{true};
+-#endif /*__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#endif /*__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+ 
+         if (core_types_parsing_broken) {
+             for (auto& core_type_mask : core_types_affinity_masks_list) {
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index bdae9e2b1..c2b9d6dba 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -275,9 +275,9 @@ function(tbb_add_tbbbind_test)
+         FAIL_REGULAR_EXPRESSION "Status:.*FAILURE"
+     )
+ 
+-    if (TARGET HWLOC::hwloc_2_4 AND NOT HWLOC_2_4_TESTS_STATUS_SHOWN)
+-        message(STATUS "HWLOC 2.4 dependent tests were enabled.")
+-        set(HWLOC_2_4_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
++    if (TARGET HWLOC::hwloc_2_5 AND NOT HWLOC_2_5_TESTS_STATUS_SHOWN)
++        message(STATUS "HWLOC 2.5 dependent tests were enabled.")
++        set(HWLOC_2_5_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
+     endif()
+ 
+     if (TARGET HWLOC::hwloc_2 AND NOT HWLOC_2_TESTS_STATUS_SHOWN)
+@@ -291,22 +291,22 @@ function(tbb_add_tbbbind_test)
+     endif()
+ 
+     list(APPEND HWLOC_TEST_CASES
+-        hwloc_2_4
++        hwloc_2_5
+         hwloc_2
+         hwloc_1_11
+-        hwloc_2_4_hwloc_2
+-        hwloc_2_4_hwloc_1_11
++        hwloc_2_5_hwloc_2
++        hwloc_2_5_hwloc_1_11
+         hwloc_2_hwloc_1_11
+-        hwloc_2_4_hwloc_2_hwloc_1_11
++        hwloc_2_5_hwloc_2_hwloc_1_11
+     )
+ 
+-    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_4 "hwloc_2_4")
++    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_5 "hwloc_2_5")
+     list(APPEND HWLOC_TEST_CASE_1_VARS tbbbind_2   "hwloc_2")
+     list(APPEND HWLOC_TEST_CASE_2_VARS tbbbind     "hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2")
+-    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_4 "hwloc_2_4,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2")
++    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_5 "hwloc_2_5,hwloc_1_11")
+     list(APPEND HWLOC_TEST_CASE_5_VARS tbbbind_2   "hwloc_2,hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2,hwloc_1_11")
+ 
+     foreach(TEST_CASE ${HWLOC_TEST_CASES})
+         list(FIND HWLOC_TEST_CASES ${TEST_CASE} TEST_CASE_INDEX)
+@@ -331,7 +331,7 @@ endfunction()
+ # Copy libraries to test folder to make it visible during tests execution if external TBB is tested.
+ # TODO: check and update for multi-config generators.
+ if (TBB_FOUND)
+-    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_4)
++    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_5)
+     foreach(_component ${_tbb_test_components})
+         if (TARGET TBB::${_component})
+             get_property(${_component}_lib_file_location TARGET TBB::${_component} PROPERTY LOCATION)
+@@ -593,6 +593,6 @@ if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
+     tbb_add_test(SUBDIR tbbmalloc NAME test_malloc_new_handler DEPENDENCIES TBB::tbbmalloc_proxy)
+ endif()
+ 
+-unset(HWLOC_2_4_TESTS_STATUS_SHOWN)
++unset(HWLOC_2_5_TESTS_STATUS_SHOWN)
+ unset(HWLOC_2_TESTS_STATUS_SHOWN)
+ unset(HWLOC_1_11_TESTS_STATUS_SHOWN)
+diff --git a/test/common/common_arena_constraints.h b/test/common/common_arena_constraints.h
+index 2a0b1ea97..5efc71082 100644
+--- a/test/common/common_arena_constraints.h
++++ b/test/common/common_arena_constraints.h
+@@ -38,9 +38,26 @@
+ 
+ #if (_WIN32 || _WIN64) && __TBB_HWLOC_VALID_ENVIRONMENT
+ #include <windows.h>
+-int get_processors_groups_count() { return GetActiveProcessorGroupCount(); }
++int get_processors_group_count() {
++    SYSTEM_INFO si;
++    GetNativeSystemInfo(&si);
++    DWORD_PTR pam, sam, m = 1;
++    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
++    int nproc = 0;
++    for ( std::size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
++        if ( pam & m )
++            ++nproc;
++    }
++    // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present
++    if ( nproc == (int)si.dwNumberOfProcessors  ) {
++        // The process does not have restricting affinity mask and multiple processor groups are possible
++        return (int)GetActiveProcessorGroupCount();
++    } else {
++        return 1;
++    }
++}
+ #else
+-int get_processors_groups_count() { return 1; }
++int get_processors_group_count() { return 1; }
+ #endif
+ 
+ //TODO: Write a test that checks for memory leaks during dynamic link/unlink of TBBbind.
+@@ -69,6 +86,7 @@ int get_processors_groups_count() { return 1; }
+ #endif
+ 
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ // At this moment the hybrid CPUs HWLOC interfaces returns unexpected results on some Windows machines
+ // in the 32-bit arch mode.
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_VALID (!_WIN32 || _WIN64)
+@@ -153,9 +171,18 @@ class system_info {
+ 
+     system_info() {
+         hwloc_require_ex(hwloc_topology_init, &topology);
++#if __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++        if ( get_processors_group_count() == 1 ) {
++            REQUIRE(
++                hwloc_topology_set_flags(topology,
++                    HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                    HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING) == 0
++            );
++        }
++#endif
+         hwloc_require_ex(hwloc_topology_load, topology);
+ 
+-        if ( get_processors_groups_count() > 1 ) {
++        if ( get_processors_group_count() > 1 ) {
+             process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
+         } else {
+             process_cpuset = hwloc_bitmap_alloc();
+@@ -434,7 +461,7 @@ system_info::affinity_mask get_arena_affinity(tbb::task_arena& ta) {
+                 barrier.wait();
+                 tbb::spin_mutex::scoped_lock lock(affinity_mutex);
+                 system_info::affinity_mask thread_affinity = system_info::allocate_current_affinity_mask();
+-                if (get_processors_groups_count() == 1) {
++                if (get_processors_group_count() == 1) {
+                     REQUIRE_MESSAGE(hwloc_bitmap_isequal(thread_affinity, arena_affinity),
+                         "Threads have different masks on machine without several processors groups.");
+                 }
+@@ -532,7 +559,7 @@ constraints_container generate_constraints_variety() {
+         }
+ 
+         // Some constraints may cause unexpected behavior, which would be fixed later.
+-        if (get_processors_groups_count() > 1) {
++        if (get_processors_group_count() > 1) {
+             for(auto it = results.begin(); it != results.end(); ++it) {
+                 if (it->max_threads_per_core != tbb::task_arena::automatic
+                    && (it->numa_id == tbb::task_arena::automatic || tbb::info::numa_nodes().size() == 1)
diff --git a/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
new file mode 100644
index 000000000000..279ebc4397cd
--- /dev/null
+++ b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
@@ -0,0 +1,52 @@
+Based on https://github.com/oneapi-src/oneTBB/pull/498
+Tweaked a bit to work on `v2021.3.0`
+
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index e5cdbf8bb..a4033210a 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -37,6 +37,10 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+         ${HWLOC_INCLUDE_DIRS} # pkg-config defined
+     )
++	target_link_directories(${TBBBIND_NAME}
++		PRIVATE
++		${HWLOC_LIBRARY_DIRS} # pkg-config defined
++	)
+ 
+     target_compile_options(${TBBBIND_NAME}
+         PRIVATE
+@@ -69,7 +69,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     else()
+         target_link_libraries(${TBBBIND_NAME}
+@@ -76,7 +76,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     endif()
+ 
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index b768759d5..3eb8357e6 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -258,7 +258,12 @@ function(tbb_add_tbbbind_test)
+         )
+         set_property(
+             TARGET ${_tbbbind_test_NAME}
+-            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARY_DIRS} ${HWLOC_LIBRARIES}
++            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARIES}
++            APPEND
++        )
++        set_property(
++            TARGET ${_tbbbind_test_NAME}
++			PROPERTY LINK_DIRECTORIES ${HWLOC_LIBRARY_DIRS}
+             APPEND
+         )
+         set_property(
diff --git a/srcpkgs/tbb/patches/hostname-usage.patch b/srcpkgs/tbb/patches/hostname-usage.patch
deleted file mode 100644
index 4aefeff192b5..000000000000
--- a/srcpkgs/tbb/patches/hostname-usage.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/build/version_info_linux.sh
-+++ b/build/version_info_linux.sh
-@@ -20,7 +20,7 @@
- 
- # Script used to generate version info string
- echo "#define __TBB_VERSION_STRINGS(N) \\"
--echo '#N": BUILD_HOST'"\t\t"`hostname -s`" ("`uname -m`")"'" ENDL \'
-+echo '#N": BUILD_HOST'"\t\t"`hostname`" ("`uname -m`")"'" ENDL \'
- # find OS name in *-release and issue* files by filtering blank lines and lsb-release content out
- echo '#N": BUILD_OS'"\t\t"`lsb_release -sd 2>/dev/null | grep -ih '[a-z] ' - /etc/*release /etc/issue 2>/dev/null | head -1 | sed -e 's/["\\\\]//g'`'" ENDL \'
- echo '#N": BUILD_KERNEL'"\t"`uname -srv`'" ENDL \'
diff --git a/srcpkgs/tbb/patches/musl.patch b/srcpkgs/tbb/patches/musl.patch
index a8867eb53793..ec89c6a95fc6 100644
--- a/srcpkgs/tbb/patches/musl.patch
+++ b/srcpkgs/tbb/patches/musl.patch
@@ -1,5 +1,5 @@
---- a/src/tbbmalloc/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
-+++ b/src/tbbmalloc/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
+--- a/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
++++ b/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
 @@ -28,6 +28,7 @@
  // of aligned_alloc as required by new C++ standard, this makes it hard to
  // redefine aligned_alloc here. However, running on systems with new libc
diff --git a/srcpkgs/tbb/template b/srcpkgs/tbb/template
index aeef6ebdd061..47655829f744 100644
--- a/srcpkgs/tbb/template
+++ b/srcpkgs/tbb/template
@@ -1,76 +1,33 @@
 # Template file for 'tbb'
 pkgname=tbb
-version=2020.U3
+version=2021.3.0
 revision=1
-# version rewrite: 2017_U7 (upstream) => 2017.7 (xbps)
-_ver=${version/./_}
-wrksrc="oneTBB-${_ver}"
-build_style=gnu-makefile
-hostmakedepends="cmake"
+wrksrc="oneTBB-${version}"
+build_style=cmake
+makedepends="libhwloc-devel libgomp-devel"
 short_desc="Intel Threading Building Blocks"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
 license="Apache-2.0"
 homepage="https://www.threadingbuildingblocks.org"
-distfiles="https://github.com/oneapi-src/oneTBB/archive/${_ver}.tar.gz"
-checksum=2103cc6238c935664f87680618f6684d57501d4a2fa8ea8f6c97ad6ff7dc722a
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*)
-		make_build_args="arch=intel64"
-		;;
-	i686*)
-		make_build_args="arch=ia32"
-		;;
-	armv7l*)
-		make_build_args="arch=armv7"
-		;;
-	aarch64*)
-		make_build_args="arch=arm64"
-		;;
-	ppc64*)
-		make_build_args="arch=ppc64"
-		;;
-	ppc*)
-		make_build_args="arch=ppc32"
-		;;
-	*)
-		# make sure to fall back instead of letting host uname control it
-		make_build_args="arch=generic"
-		;;
-esac
-
-post_extract() {
-	sed -i 's|CPLUS = g..|CPLUS = $(CXX)|g' build/linux.gcc.inc
-	sed -i 's|CONLY = gcc|CONLY = $(CC)|g' build/linux.gcc.inc
+distfiles="https://github.com/oneapi-src/oneTBB/archive/v${version}.tar.gz"
+checksum=8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e
 
+pre_patch() {
 	# alternative might be:
 	# https://git.alpinelinux.org/cgit/aports/tree/testing/libtbb/glibc-struct-mallinfo.patch
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		vsed -e "s@#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__@@" \
-		  -i src/tbbmalloc/proxy.h
+		  -i src/tbbmalloc_proxy/proxy.h
 	fi
 }
 
-do_install() {
-	vmkdir usr/lib
-	vcopy build/linux_*/*.so* usr/lib
-	vmkdir usr/include/tbb
-	vcopy include/tbb/* usr/include/tbb
-
-	cmake \
-		-DINSTALL_DIR=$DESTDIR/usr/lib/cmake/TBB \
-		-DSYSTEM_NAME=Linux \
-		-DLIB_REL_PATH=../.. \
-		-DINC_REL_PATH=../../../include \
-		-P cmake/tbb_config_installer.cmake
-}
-
 tbb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
-		vmove "usr/lib/*.so"
 		vmove usr/lib/cmake
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.so
 	}
 }

From 3ccac789d51146ae3d507dc63c5817d4db37d000 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 03/11] OpenSubdiv: update to 3.4.4.

---
 srcpkgs/OpenSubdiv/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/OpenSubdiv/template b/srcpkgs/OpenSubdiv/template
index b7a5e16efbcf..dfbf29cc1a52 100644
--- a/srcpkgs/OpenSubdiv/template
+++ b/srcpkgs/OpenSubdiv/template
@@ -1,6 +1,6 @@
 # Template file for 'OpenSubdiv'
 pkgname=OpenSubdiv
-version=3.4.3
+version=3.4.4
 revision=1
 wrksrc="OpenSubdiv-${version//./_}"
 build_style=cmake
@@ -13,7 +13,7 @@ maintainer="John <me@johnnynator.dev>"
 license="Apache-2.0"
 homepage="http://graphics.pixar.com/opensubdiv/docs/intro.html"
 distfiles="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${version//./_}.tar.gz"
-checksum=7b22eb27d636ab0c1e03722c7a5a5bd4f11664ee65c9b48f341a6d0ce7f36745
+checksum=20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" OpenSubdiv"

From eea03043d52141292b79a6fb7182d83ee5755190 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 04/11] PrusaSlicer: update to 2.3.3.

---
 srcpkgs/PrusaSlicer/patches/cross.patch | 11 -----------
 srcpkgs/PrusaSlicer/template            |  4 ++--
 2 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 srcpkgs/PrusaSlicer/patches/cross.patch

diff --git a/srcpkgs/PrusaSlicer/patches/cross.patch b/srcpkgs/PrusaSlicer/patches/cross.patch
deleted file mode 100644
index d64a450d9e9f..000000000000
--- a/srcpkgs/PrusaSlicer/patches/cross.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/avrdude/CMakeLists.txt	2020-06-04 09:19:26.017251215 +0200
-+++ b/src/avrdude/CMakeLists.txt	2020-06-04 09:19:36.468250771 +0200
-@@ -83,7 +83,7 @@ add_executable(avrdude-conf-gen conf-gen
- add_custom_command(
-     DEPENDS avrdude-conf-gen ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf
-     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
--    COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-+    COMMAND avrdude-conf-gen avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- 
diff --git a/srcpkgs/PrusaSlicer/template b/srcpkgs/PrusaSlicer/template
index dd0e76cb8017..a93832ac02e4 100644
--- a/srcpkgs/PrusaSlicer/template
+++ b/srcpkgs/PrusaSlicer/template
@@ -1,6 +1,6 @@
 # Template file for 'PrusaSlicer'
 pkgname=PrusaSlicer
-version=2.3.0
+version=2.3.3
 revision=1
 wrksrc="PrusaSlicer-version_${version}"
 build_style=cmake
@@ -16,7 +16,7 @@ maintainer="Jasper Chan <jasperchan515@gmail.com>"
 license="GPL-3.0-or-later"
 homepage="https://www.prusa3d.com/prusaslicer/"
 distfiles="https://github.com/prusa3d/Prusaslicer/archive/version_${version}.tar.gz"
-checksum=cd3bac5e29b5441fc4690f28cd7b1064e97dc00207bbdc88f7bd7832308d6ca5
+checksum=deda209505f740ac3d6f59cb2a960f4df908269ee09bd30cd4edb9fc472d29ac
 nocross="https://build.voidlinux.org/builders/armv7l_builder/builds/25230/steps/shell_3/logs/stdio"
 
 Slic3rPE_package() {

From 8cd79fb82ddf28c9a8de8d6a64d6cc1a249b4583 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 05/11] blender: update to 2.93.1.

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index af946c2b7999..8318317c82bf 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,6 +1,6 @@
 # Template file for 'blender'
 pkgname=blender
-version=2.93.0
+version=2.93.1
 revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"

From f8e64eb432c687b7f182628af04afcc39850ad8d Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 06/11] embree: update to 3.13.0.

---
 srcpkgs/embree/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/embree/template b/srcpkgs/embree/template
index 575b9bcb401c..b6f376d30efa 100644
--- a/srcpkgs/embree/template
+++ b/srcpkgs/embree/template
@@ -1,8 +1,8 @@
 # Template file for 'embree'
 pkgname=embree
-version=2.17.7
-revision=2
-archs="x86_64"
+version=3.13.0
+revision=1
+archs="x86_64*"
 build_style=cmake
 configure_args="-DTBB_ROOT=/usr -DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF"
 hostmakedepends="ispc"

From 924c8c8ddfc94000cc52c43cd2cc285bafb53f44 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 03:34:43 +0300
Subject: [PATCH 07/11] openimageio: update to 2.2.16.0.

---
 srcpkgs/openimageio/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index de8e1cd04409..3bfdd4e0ed1e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,11 +1,11 @@
 # Template file for 'openimageio'
 pkgname=openimageio
-version=2.2.15.1
+version=2.2.16.0
 revision=1
 wrksrc="oiio-Release-${version}"
 build_style=cmake
 configure_args="-DUSE_OPENGL=0 -DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=1
- -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0"
+ -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0 -DCMAKE_CXX_STANDARD=14"
 hostmakedepends="pkg-config git"
 makedepends="boost-devel giflib-devel libraw-devel libopenjpeg-devel libwebp-devel
  libjpeg-turbo-devel tiff-devel libpng-devel libopenexr-devel freetype-devel
@@ -17,7 +17,7 @@ license="BSD-3-Clause"
 homepage="https://sites.google.com/site/openimageio/home"
 changelog="https://raw.githubusercontent.com/OpenImageIO/oiio/release/CHANGES.md"
 distfiles="https://github.com/OpenImageIO/oiio/archive/Release-${version}.tar.gz"
-checksum=f222c6b51a40aabbc80ddf4055535be9af1ffa907452fa6d1ffa7674854aab17
+checksum=d1a59f32dbba3ba71ad2e62e107034d1c5287bca1b0696474e927d504cd05ef4
 # Runs checks even for features we disabled.
 make_check=no
 

From ecb58375c9c9274a1be16371049dd51d1b0f34f4 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 08/11] openimagedenoise: update to 1.4.1.

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index c73913b4e9d7..14055aff1c27 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,6 +1,6 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
-version=1.4.0
+version=1.4.1
 revision=1
 archs="x86_64*"
 wrksrc=oidn-${version}

From 04ee4c149742fd6d56f9a62dd8d861bd61217085 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 09/11] openvdb: update to 8.1.0.

---
 common/shlibs                             |    2 +-
 srcpkgs/openvdb/patches/00-tbb-2021.patch | 1320 +++++++++++++++++++++
 srcpkgs/openvdb/template                  |   16 +-
 3 files changed, 1325 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/openvdb/patches/00-tbb-2021.patch

diff --git a/common/shlibs b/common/shlibs
index 6b7ca5fbc249..2a7acdb253a7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3883,7 +3883,7 @@ libjanet.so.1.16 janet-1.16.0_1
 libOpenImageDenoise.so.1 openimagedenoise-1.3.0_1
 libcbang0.so cbang-1.6.0_3
 libblosc.so.1 c-blosc-1.17.1_1
-libopenvdb.so.7.0 openvdb-7.0.0_1
+libopenvdb.so.8.1 openvdb-8.1.0_1
 libAlembic.so.1.7 alembic-1.7.13_1
 libmodsecurity.so.3 modsecurity-3.0.4_1
 libraven.so.0 budgie-desktop-10.5.1_1
diff --git a/srcpkgs/openvdb/patches/00-tbb-2021.patch b/srcpkgs/openvdb/patches/00-tbb-2021.patch
new file mode 100644
index 000000000000..271104af3df9
--- /dev/null
+++ b/srcpkgs/openvdb/patches/00-tbb-2021.patch
@@ -0,0 +1,1320 @@
+https://github.com/AcademySoftwareFoundation/openvdb/pull/1027
+Should be dropped after 8.1.1 release.
+
+diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake
+index d41436b1c..06de2b3f3 100644
+--- a/cmake/FindTBB.cmake
++++ b/cmake/FindTBB.cmake
+@@ -169,8 +169,22 @@ find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
+   PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
+ )
+ 
+-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" ""
+@@ -178,7 +192,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" ""
+@@ -192,6 +206,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
+ # ------------------------------------------------------------------------
+diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt
+index 88543df3a..929fe94d1 100644
+--- a/openvdb/openvdb/CMakeLists.txt
++++ b/openvdb/openvdb/CMakeLists.txt
+@@ -437,6 +437,10 @@ set(OPENVDB_LIBRARY_UTIL_INCLUDE_FILES
+   util/Util.h
+ )
+ 
++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} DESTINATION ${OPENVDB_INST
+ 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)
+diff --git a/openvdb/openvdb/cmd/openvdb_render.cc b/openvdb/openvdb/cmd/openvdb_render.cc
+index ee5b737c5..2c9831ba3 100644
+--- a/openvdb/openvdb/cmd/openvdb_render.cc
++++ b/openvdb/openvdb/cmd/openvdb_render.cc
+@@ -19,7 +19,14 @@
+ #include <OpenEXR/ImfHeader.h>
+ #include <OpenEXR/ImfOutputFile.h>
+ #include <OpenEXR/ImfPixelType.h>
+-#include <tbb/task_scheduler_init.h>
++
++// 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 <tbb/global_control.h>
+ #include <tbb/tick_count.h>
+ 
+ #include <algorithm>
+@@ -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<tbb::global_control> 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();
+ 
+diff --git a/openvdb/openvdb/io/Queue.cc b/openvdb/openvdb/io/Queue.cc
+index ef5d2961a..20ff1a0c1 100644
+--- a/openvdb/openvdb/io/Queue.cc
++++ b/openvdb/openvdb/io/Queue.cc
+@@ -5,20 +5,22 @@
+ /// @author Peter Cucka
+ 
+ #include "Queue.h"
+-
+ #include "File.h"
+ #include "Stream.h"
+-#include <openvdb/Exceptions.h>
+-#include <openvdb/util/logging.h>
++#include "openvdb/Exceptions.h"
++#include "openvdb/util/logging.h"
++
+ #include <tbb/concurrent_hash_map.h>
+-#include <tbb/task.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
+-#include <tbb/tick_count.h>
++#include <tbb/task_arena.h>
++
++#include <thread>
+ #include <algorithm> // for std::max()
+ #include <atomic>
+ #include <iostream>
+ #include <map>
+ #include <mutex>
++#include <chrono>
++
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -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
+ 
+ 
+ // 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
+         : 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
+             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<Queue::Id, Queue::Status>;
+ 
+-
+     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::milliseconds>(
++                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;
+ }
+ 
+diff --git a/openvdb/openvdb/math/Coord.h b/openvdb/openvdb/math/Coord.h
+index 504b5e9a4..2e9cfed5d 100644
+--- a/openvdb/openvdb/math/Coord.h
++++ b/openvdb/openvdb/math/Coord.h
+@@ -13,8 +13,7 @@
+ #include "Math.h"
+ #include "Vec3.h"
+ 
+-namespace tbb { class split; } // forward declaration
+-
++#include <tbb/blocked_range.h> // for tbb::split
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+diff --git a/openvdb/openvdb/points/PointSample.h b/openvdb/openvdb/points/PointSample.h
+index a122cc4fb..27ec3fb29 100644
+--- a/openvdb/openvdb/points/PointSample.h
++++ b/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 <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tools/Interpolation.h>
++#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 <sstream>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -299,7 +299,7 @@ class PointDataSampler
+             using TargetHandleT = AttributeWriteHandle<typename SamplerWrapperT::ValueType>;
+ 
+             if (util::wasInterrupted(interrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return;
+             }
+ 
+diff --git a/openvdb/openvdb/thread/Threading.h b/openvdb/openvdb/thread/Threading.h
+new file mode 100644
+index 000000000..0c3b356e3
+--- /dev/null
++++ b/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 <tbb/blocked_range.h>
++#include <tbb/task.h>
++#include <tbb/task_group.h>
++
++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
+diff --git a/openvdb/openvdb/tools/Composite.h b/openvdb/openvdb/tools/Composite.h
+index 6bc170bf7..88ff86f9f 100644
+--- a/openvdb/openvdb/tools/Composite.h
++++ b/openvdb/openvdb/tools/Composite.h
+@@ -24,7 +24,6 @@
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include <type_traits>
+ #include <functional>
+diff --git a/openvdb/openvdb/tools/Diagnostics.h b/openvdb/openvdb/tools/Diagnostics.h
+index 694d2155f..e5844e448 100644
+--- a/openvdb/openvdb/tools/Diagnostics.h
++++ b/openvdb/openvdb/tools/Diagnostics.h
+@@ -11,14 +11,17 @@
+ #ifndef OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ 
+-#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/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 <tbb/blocked_range.h>
+ #include <tbb/parallel_reduce.h>
++
+ #include <cmath> // for std::isnan(), std::isfinite()
+ #include <set>
+ #include <sstream>
+@@ -26,7 +29,6 @@
+ #include <type_traits>
+ #include <vector>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -1160,13 +1162,13 @@ InactiveVoxelValues<TreeType>::operator()(const tbb::blocked_range<size_t>& rang
+ {
+     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<typename TreeType>
+ inline void
+ InactiveTileValues<TreeType>::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();
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/tools/Filter.h b/openvdb/openvdb/tools/Filter.h
+index 408c75541..b70212520 100644
+--- a/openvdb/openvdb/tools/Filter.h
++++ b/openvdb/openvdb/tools/Filter.h
+@@ -14,21 +14,24 @@
+ #ifndef OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ 
+-#include <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
++#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 <tbb/parallel_for.h>
++#include <tbb/concurrent_vector.h>
++
+ #include <algorithm> // for std::max()
+ #include <functional>
+ #include <type_traits>
+-#include <tbb/concurrent_vector.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -833,7 +836,7 @@ inline bool
+ Filter<GridT, MaskT, InterruptT>::wasInterrupted()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return true;
+     }
+     return false;
+diff --git a/openvdb/openvdb/tools/GridOperators.h b/openvdb/openvdb/tools/GridOperators.h
+index 31305a1ab..78fafead9 100644
+--- a/openvdb/openvdb/tools/GridOperators.h
++++ b/openvdb/openvdb/tools/GridOperators.h
+@@ -9,14 +9,15 @@
+ #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/Grid.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
++#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 <tbb/parallel_for.h>
+ 
++#include <tbb/parallel_for.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -383,7 +384,9 @@ class GridOperator
+     /// 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) {
+diff --git a/openvdb/openvdb/tools/LevelSetMeasure.h b/openvdb/openvdb/tools/LevelSetMeasure.h
+index efe19074d..59969cdcf 100644
+--- a/openvdb/openvdb/tools/LevelSetMeasure.h
++++ b/openvdb/openvdb/tools/LevelSetMeasure.h
+@@ -8,18 +8,21 @@
+ #ifndef OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/math/Math.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/Grid.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/math/FiniteDifference.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/math/Stencils.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
+ #include <tbb/parallel_sort.h>
+ #include <tbb/parallel_invoke.h>
++
+ #include <type_traits>
+ 
+ namespace openvdb {
+@@ -329,7 +332,7 @@ inline bool
+ LevelSetMeasure<GridT, InterruptT>::checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/LevelSetTracker.h b/openvdb/openvdb/tools/LevelSetTracker.h
+index cbdc267e8..bfc8004e7 100644
+--- a/openvdb/openvdb/tools/LevelSetTracker.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/tree/LeafManager.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -383,7 +385,7 @@ LevelSetTracker<GridT, InterruptT>::
+ checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/MeshToVolume.h b/openvdb/openvdb/tools/MeshToVolume.h
+index 6643c8f05..de3406eda 100644
+--- a/openvdb/openvdb/tools/MeshToVolume.h
++++ b/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 <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/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 <tbb/parallel_reduce.h>
+ #include <tbb/partitioner.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm> // for std::sort()
+ #include <cmath> // 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<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+@@ -1989,7 +1990,7 @@ class VoxelizePolygons
+         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
+ 
+         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) {
+diff --git a/openvdb/openvdb/tools/Morphology.h b/openvdb/openvdb/tools/Morphology.h
+index 736982ef5..0a1e71009 100644
+--- a/openvdb/openvdb/tools/Morphology.h
++++ b/openvdb/openvdb/tools/Morphology.h
+@@ -24,7 +24,7 @@
+ #include "openvdb/tree/ValueAccessor.h"
+ #include "openvdb/tree/LeafManager.h"
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ 
+@@ -726,7 +726,7 @@ void Morphology<TreeType>::dilateVoxels(const size_t iter,
+         }
+ 
+         // @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
+diff --git a/openvdb/openvdb/tools/ParticlesToLevelSet.h b/openvdb/openvdb/tools/ParticlesToLevelSet.h
+index 739af2b69..f9c19911c 100644
+--- a/openvdb/openvdb/tools/ParticlesToLevelSet.h
++++ b/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 <tbb/parallel_reduce.h>
+-#include <tbb/blocked_range.h>
+-#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/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 <tbb/parallel_reduce.h>
++#include <tbb/blocked_range.h>
++
+ #include <functional>
+ #include <iostream>
+ #include <type_traits>
+@@ -738,7 +742,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         for (Coord c = lo; c.x() <= hi.x(); ++c.x()) {
+             //only check interrupter every 32'th scan in x
+             if (!(count++ & ((1<<5)-1)) && util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Real x2 = math::Pow2(c.x() - P[0]);
+@@ -804,7 +808,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         // Densely fill the remaining regions.
+         for (const auto& bbox: padding) {
+             if (util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Coord &bmin = bbox.min(), &bmax = bbox.max();
+diff --git a/openvdb/openvdb/tools/PointAdvect.h b/openvdb/openvdb/tools/PointAdvect.h
+index 12b1177ad..e487bfb3e 100644
+--- a/openvdb/openvdb/tools/PointAdvect.h
++++ b/openvdb/openvdb/tools/PointAdvect.h
+@@ -10,16 +10,19 @@
+ #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/openvdb.h>
+-#include <openvdb/math/Math.h>             // min
+-#include <openvdb/Types.h>                 // Vec3 types and version number
+-#include <openvdb/Grid.h>                  // grid
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/blocked_range.h>             // threading
+ #include <tbb/parallel_for.h>              // threading
+ #include <tbb/task.h>                      // for cancel
++
+ #include <vector>
+ 
+ 
+@@ -167,7 +170,7 @@ class PointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityFieldIntegrator  velField(*mVelGrid);
+@@ -307,7 +310,7 @@ class ConstrainedPointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityIntegratorType velField(*mVelGrid);
+diff --git a/openvdb/openvdb/tools/PointIndexGrid.h b/openvdb/openvdb/tools/PointIndexGrid.h
+index e9ebf96f7..b2e378a79 100644
+--- a/openvdb/openvdb/tools/PointIndexGrid.h
++++ b/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 <openvdb/version.h>
+@@ -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;
+         }
+ 
+diff --git a/openvdb/openvdb/tools/PointPartitioner.h b/openvdb/openvdb/tools/PointPartitioner.h
+index ccf50ab05..f7f6fc13d 100644
+--- a/openvdb/openvdb/tools/PointPartitioner.h
++++ b/openvdb/openvdb/tools/PointPartitioner.h
+@@ -23,7 +23,7 @@
+ 
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm>
+ #include <cmath> // for std::isfinite()
+@@ -764,7 +764,7 @@ inline void binAndSegment(
+     using IndexPairListMap = std::map<Coord, IndexPairListPtr>;
+     using IndexPairListMapPtr = std::shared_ptr<IndexPairListMap>;
+ 
+-    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;
+ 
+diff --git a/openvdb/openvdb/tools/PointsToMask.h b/openvdb/openvdb/tools/PointsToMask.h
+index 592ab7a15..8a276fb04 100644
+--- a/openvdb/openvdb/tools/PointsToMask.h
++++ b/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 <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/blocked_range.h>
+-#include <openvdb/openvdb.h> // for MaskGrid
+-#include <openvdb/Grid.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/util/NullInterrupter.h>
++
+ #include <vector>
+ 
+ 
+@@ -150,7 +154,7 @@ class PointsToMask
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeAdvect.h b/openvdb/openvdb/tools/VolumeAdvect.h
+index e7eec740e..f38eaa9c2 100644
+--- a/openvdb/openvdb/tools/VolumeAdvect.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/math/Math.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ 
+ 
+@@ -294,7 +297,7 @@ class VolumeAdvection
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeToMesh.h b/openvdb/openvdb/tools/VolumeToMesh.h
+index a834dd3b3..a446f806a 100644
+--- a/openvdb/openvdb/tools/VolumeToMesh.h
++++ b/openvdb/openvdb/tools/VolumeToMesh.h
+@@ -18,7 +18,7 @@
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <cmath> // for std::isfinite()
+ #include <map>
+@@ -388,7 +388,7 @@ inline void
+ fillArray(ValueType* array, const ValueType& val, const size_t length)
+ {
+     const auto grainSize = std::max<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+diff --git a/openvdb/openvdb/unittest/TestCoord.cc b/openvdb/openvdb/unittest/TestCoord.cc
+index be1c24ced..148690041 100644
+--- a/openvdb/openvdb/unittest/TestCoord.cc
++++ b/openvdb/openvdb/unittest/TestCoord.cc
+@@ -2,9 +2,9 @@
+ // SPDX-License-Identifier: MPL-2.0
+ 
+ #include <openvdb/Types.h>
++#include <openvdb/math/Coord.h>
+ 
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_stddef.h> // for tbb::split
+ 
+ #include <unordered_map>
+ #include <sstream>
+diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc
+index 8074166d2..053448f30 100644
+--- a/openvdb/openvdb/unittest/TestFile.cc
++++ b/openvdb/openvdb/unittest/TestFile.cc
+@@ -13,8 +13,11 @@
+ #include <openvdb/version.h>
+ #include <openvdb/openvdb.h>
+ #include "util.h" // for unittest_util::makeSphere()
++
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
++
++#include <thread>
++#include <chrono>
+ #include <algorithm> // for std::sort()
+ #include <cstdio> // for remove() and rename()
+ #include <fstream>
+@@ -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::seconds>(
++                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<io::Queue::Id> 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));
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc
+index 70e7df5f7..6b2204771 100644
+--- a/openvdb/openvdb/unittest/TestUtil.cc
++++ b/openvdb/openvdb/unittest/TestUtil.cc
+@@ -8,7 +8,6 @@
+ 
+ #include <gtest/gtest.h>
+ 
+-#include <tbb/task_scheduler_init.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/blocked_range.h>
+diff --git a/openvdb/openvdb/unittest/TestValueAccessor.cc b/openvdb/openvdb/unittest/TestValueAccessor.cc
+index fd2dd5d81..5c1cbb18b 100644
+--- a/openvdb/openvdb/unittest/TestValueAccessor.cc
++++ b/openvdb/openvdb/unittest/TestValueAccessor.cc
+@@ -6,6 +6,7 @@
+ 
+ #include <gtest/gtest.h>
+ #include <tbb/task.h>
++#include <tbb/task_group.h>
+ 
+ #include <type_traits>
+ 
+@@ -378,22 +379,21 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
+     //using AccessorT = openvdb::tree::ValueAccessor<Tree4Type>;
+ 
+     // 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
+ }
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+index 0e1b4d855..6d9bb528b 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+@@ -20,6 +20,7 @@
+ #include <openvdb/tools/GridTransformer.h>
+ #include <openvdb/tools/PointIndexGrid.h>
+ #include <openvdb/tools/Prune.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <CH/CH_Manager.h>
+ #include <CVEX/CVEX_Context.h>
+@@ -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;
+             }
+ 
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+index 757fdc8c6..dbee74b32 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+@@ -16,13 +16,11 @@
+ #include <openvdb_houdini/SOP_NodeVDB.h>
+ 
+ #include <openvdb/tools/Interpolation.h>  // for box sampler
++#include <openvdb/thread/Threading.h>
+ #include <openvdb/points/PointCount.h>
+ #include <openvdb/points/PointSample.h>
+ #include <openvdb/points/IndexFilter.h>   // for MultiGroupFilter
+ 
+-#include <tbb/tick_count.h>                 // for timing
+-#include <tbb/task.h>                       // for cancel
+-
+ #include <UT/UT_Interrupt.h>
+ #include <GA/GA_PageHandle.h>
+ #include <GA/GA_PageIterator.h>
+@@ -38,6 +36,7 @@
+ #include <stdexcept>
+ #include <string>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ 
+@@ -327,7 +326,7 @@ class PointSampler
+     {
+ 
+         if (mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            openvdb::thread::cancelGroupExecution();
+         }
+         const GridType& grid = UTvdbGridCast<GridType>(mGrid);
+         // task local grid accessor
+@@ -481,7 +480,7 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Context& context)
+         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_Context& context)
+             }
+         }
+ 
+-        // 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::milliseconds>(
++                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;
+         }
+ 
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+index 3d559f8cc..d63ed1591 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
++++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+@@ -47,11 +47,8 @@ struct NodeInfo {
+ 
+ typedef std::vector<NodeInfo> 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, const MTypeId& typeId,
+     node.type               = type;
+     node.classification     = classification;
+ 
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (!gNodes) {
+         OPENVDB_START_THREADSAFE_STATIC_WRITE
+@@ -85,7 +82,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, const MTypeId& typeId,
+ void
+ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+@@ -109,7 +106,7 @@ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ void
+ NodeRegistry::deregisterNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.h b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+index b58bd6f2c..6a04b1eaf 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBUtil.h
++++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+@@ -14,8 +14,7 @@
+ #include <openvdb/tree/LeafManager.h>
+ #include <openvdb/tools/VolumeToMesh.h>
+ #include <openvdb/util/Formats.h> // printBytes
+-
+-#include <tbb/tick_count.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <maya/M3dView.h>
+ #include <maya/MString.h>
+@@ -40,6 +39,7 @@
+ #include <string>
+ #include <type_traits>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ ////////////////////////////////////////
+@@ -116,11 +116,15 @@ insertFrameNumber(std::string& str, const MTime& time, int numberingScheme = 0);
+ 
+ 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::milliseconds>(
++            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<std::chrono::steady_clock> mStamp;
+ };
+ 
+ 
+diff --git a/pendingchanges/tbb2021.txt b/pendingchanges/tbb2021.txt
+new file mode 100644
+index 000000000..8109c2552
+--- /dev/null
++++ b/pendingchanges/tbb2021.txt
+@@ -0,0 +1,6 @@
++Improvements:
++  - Moved from the deprecated TBB task scheduler to TBB arenas. Various methods now respect the TBB arena state they were invoked from.
++  - Introduced a new thread/Threading.h header to consolidate calls to third-party threading methods.
++
++Build:
++  - Added support for TBB 2021.
diff --git a/srcpkgs/openvdb/template b/srcpkgs/openvdb/template
index 72fde5bc6375..d420a3ee5f5d 100644
--- a/srcpkgs/openvdb/template
+++ b/srcpkgs/openvdb/template
@@ -1,26 +1,18 @@
 # Template file for 'openvdb'
 pkgname=openvdb
-version=7.0.0
+version=8.1.0
 revision=1
 build_style=cmake
 configure_args="-DOPENVDB_BUILD_VDB_VIEW=1"
 hostmakedepends="pkg-config"
-makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel glfw-devel"
+makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel
+ glfw-devel jemalloc-devel"
 short_desc="Sparse volume data structure and tools"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MPL-2.0"
 homepage="https://openvdb.org"
 distfiles="https://github.com/AcademySoftwareFoundation/openvdb/archive/v${version}.tar.gz"
-checksum=97bc8ae35ef7ccbf49a4e25cb73e8c2eccae6b235bac86f2150707efcd1e910d
-
-if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
-	makedepends+=" libatomic-devel"
-fi
-
-post_patch() {
-	[ "$XBPS_TARGET_NO_ATOMIC8" ] || return 0
-	vsed -i 's,ZLIB::ZLIB,ZLIB::ZLIB atomic,' openvdb/CMakeLists.txt
-}
+checksum=3e09d47331429be7409a3a3c27fdd3c297f96d31d2153febe194e664a99d6183
 
 post_install() {
 	vlicense LICENSE

From 57544f96c25331257fd29e52e180a39490c87b64 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 10/11] paraview: update to 5.9.1.

---
 srcpkgs/paraview/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/paraview/template b/srcpkgs/paraview/template
index 20a7f5589677..e6c3941ce90a 100644
--- a/srcpkgs/paraview/template
+++ b/srcpkgs/paraview/template
@@ -1,7 +1,7 @@
 # Template file for 'paraview'
 pkgname=paraview
-version=5.8.1
-revision=3
+version=5.9.1
+revision=1
 wrksrc=ParaView-v${version}
 build_style=cmake
 configure_args="-DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr

From 15aa77a9208385109d2bee28b8cc256b11ed7210 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 11/11] occt: revbump due to tbb update

---
 srcpkgs/occt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/occt/template b/srcpkgs/occt/template
index 9298edc76e08..006f89ebb8ce 100644
--- a/srcpkgs/occt/template
+++ b/srcpkgs/occt/template
@@ -2,7 +2,7 @@
 pkgname=occt
 reverts=7.5.0_1
 version=7.4.0p1
-revision=3
+revision=4
 _gittag="V${version//./_}"
 wrksrc=occt-${_gittag}
 build_style=cmake

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PR PATCH] [Updated] tbb: update to 2021.3.0
  2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
                   ` (7 preceding siblings ...)
  2021-07-24 16:41 ` Logarithmus
@ 2021-07-25 15:26 ` Logarithmus
  2021-07-26  1:31 ` Logarithmus
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Logarithmus @ 2021-07-25 15:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

There is an updated pull request by Logarithmus against master on the void-packages repository

https://github.com/Logarithmus/void-packages tbb-2021
https://github.com/void-linux/void-packages/pull/32166

tbb: update to 2021.3.0
Follow-up of https://github.com/void-linux/void-packages/pull/27746, @thypon & @olafmersmann might be interested.
**TODO** fix reverse dependencies:
- [ ] OpenSubdiv: update to 3.4.4.
- [ ] PrusaSlicer: update to 2.3.3.
- [ ] lender: update to 2.93.1.
- [ ] embree: update to 3.13.0.
- [ ] openimageio: update to 2.2.16.0.
- [ ] openimagedenoise: update to 1.4.1.
- [ ] openvdb: update to 8.1.0.
- [ ] paraview: update to 5.9.1.
- [ ] occt: revbump due to tbb update

#### Have the results of the proposed changes been tested?
- [x] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me


A patch file from https://github.com/void-linux/void-packages/pull/32166.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-tbb-2021-32166.patch --]
[-- Type: text/x-diff, Size: 91962 bytes --]

From d4fe5764077988ae608ef6f9ea68fa535d13a1d0 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 17 Jul 2021 23:57:52 +0300
Subject: [PATCH 01/12] hwloc: add libpciaccess-devel make dependency

---
 srcpkgs/hwloc/template | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/hwloc/template b/srcpkgs/hwloc/template
index 818db269cebb..e482e7250d6d 100644
--- a/srcpkgs/hwloc/template
+++ b/srcpkgs/hwloc/template
@@ -1,10 +1,12 @@
 # Template file for 'hwloc'
 pkgname=hwloc
 version=2.5.0
-revision=1
+revision=2
 build_style=gnu-configure
-hostmakedepends="pkg-config"
-makedepends="cairo-devel ncurses-devel libxml2-devel eudev-libudev-devel"
+hostmakedepends="pkg-config automake libtool"
+makedepends="cairo-devel ncurses-devel libxml2-devel libpciaccess-devel eudev-libudev-devel"
+checkdepends="tar"
+make_check_args="VERBOSE=1"
 short_desc="Portable abstraction of hierarchical hardware architectures"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
 license="BSD-3-Clause"
@@ -16,6 +18,18 @@ case "$XBPS_TARGET_MACHINE" in
 	i686*|x86_64*|ppc64*) makedepends+=" libnuma-devel";;
 esac
 
+do_patch() {
+	# syscall 279 (move_pages) is unavailable inside Github Actions' Docker container,
+	# that's why we skip this test
+	#vsed -e "s/hwloc_get_area_memlocation.c\s//" -e "/hwloc_get_area_memlocation/d" \
+	#	-i tests/hwloc/Makefile.in -i tests/hwloc/Makefile.am
+	vsed -e "/hwloc_get_area_memlocation/d" -i tests/hwloc/Makefile.am
+}
+
+pre_configure() {
+	aclocal
+}
+
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc
 }
@@ -31,7 +45,7 @@ libhwloc_package() {
 
 libhwloc-devel_package() {
 	short_desc+=" - development files"
-	depends="libhwloc>=${version}_${revision}"
+	depends="${makedepends} libhwloc>=${version}_${revision}"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/share/man/man3

From e057276484ff6565992cde548454f4409f0f6495 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 02:50:26 +0300
Subject: [PATCH 02/12] tbb: update to 2021.3.0.

---
 common/shlibs                                |   6 +-
 srcpkgs/tbb/patches/00-hwloc-2.5.patch       | 367 +++++++++++++++++++
 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch |  52 +++
 srcpkgs/tbb/patches/hostname-usage.patch     |  11 -
 srcpkgs/tbb/patches/musl.patch               |   4 +-
 srcpkgs/tbb/template                         |  63 +---
 6 files changed, 433 insertions(+), 70 deletions(-)
 create mode 100644 srcpkgs/tbb/patches/00-hwloc-2.5.patch
 create mode 100644 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
 delete mode 100644 srcpkgs/tbb/patches/hostname-usage.patch

diff --git a/common/shlibs b/common/shlibs
index a7afbf2a56f7..6b7ca5fbc249 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2376,12 +2376,10 @@ libanthy-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthydic-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthyinput-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthygobject-1.0.so.5 ibus-anthy-1.5.6_1
-libtbbmalloc_proxy_debug.so.2 tbb-4.3_1
 libtbbmalloc_proxy.so.2 tbb-4.3_1
 libtbbmalloc.so.2 tbb-4.3_1
-libtbb_debug.so.2 tbb-4.3_1
-libtbb.so.2 tbb-4.3_1
-libtbbmalloc_debug.so.2 tbb-4.3_1
+libtbb.so.12 tbb-2021.3.0_1
+libtbbbind_2_5.so.3 tbb-2021.3.0_1
 libembree.so.2 embree-2.5.1_1
 libgtkimageview.so.0 gtkimageview-1.6.4_1
 libgoocanvas-2.0.so.9 goocanvas-2.0.4_1
diff --git a/srcpkgs/tbb/patches/00-hwloc-2.5.patch b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
new file mode 100644
index 000000000000..9c4c9285c71d
--- /dev/null
+++ b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
@@ -0,0 +1,367 @@
+Adjusted by Artur Sinila <freesoftware@logarithmus.dev>
+
+From e96dbf4b48e689ab810b0428d0858a6abc2c83bd Mon Sep 17 00:00:00 2001
+From: Ivan Kochin <iv.kochin@gmail.com>
+Date: Thu, 1 Jul 2021 15:07:39 +0300
+Subject: [PATCH] Upgrade from HWLOC 2.4 to HWLOC 2.5 (#448)
+
+* Upgrade from HWLOC 2.4 to HWLOC 2.5
+* Introduce tbbbind_2_5 library
+* Remove tbbbind_2_4 library
+* Use the HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING topology flag (introduces as a part of HWLOC 2.5) to restrict topology discovering to process binding
+* Fix testing on Linux
+* Apply review comments
+* Improve wording: variable -> substring
+* Use right tbbbind version for incompatible hwlocs test
+* Rework option semantic
+* Update README.md for CMake
+* Rework readme
+* Update cmake/README.md
+
+Signed-off-by: Kochin, Ivan <kochin.ivan@intel.com>
+
+Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
+---
+ CMakeLists.txt                         |  3 ++-
+ cmake/README.md                        | 11 +++++---
+ cmake/hwloc_detection.cmake            |  9 ++++---
+ src/tbb/governor.cpp                   |  4 +--
+ src/tbbbind/CMakeLists.txt             |  2 +-
+ src/tbbbind/tbb_bind.cpp               | 23 +++++++++++-----
+ test/CMakeLists.txt                    | 30 ++++++++++-----------
+ test/common/common_arena_constraints.h | 37 ++++++++++++++++++++++----
+ 8 files changed, 82 insertions(+), 37 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 34a23d400..301899aca 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -100,6 +100,7 @@ option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Win
+ option(TBB4PY_BUILD "Enable tbb4py build" OFF)
+ option(TBB_CPF "Enable preview features of the library" OFF)
+ option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
++option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
+ 
+ if (NOT DEFINED BUILD_SHARED_LIBS)
+     set(BUILD_SHARED_LIBS ON)
+@@ -195,7 +196,7 @@ else()
+         add_subdirectory(src/tbbmalloc)
+         add_subdirectory(src/tbbmalloc_proxy)
+         if (APPLE)
+-            message(STATUS "TBBBind build target is disabled due to unsupported environment")
++            message(STATUS "TBBBind build targets are disabled due to unsupported environment")
+         else()
+             add_subdirectory(src/tbbbind)
+         endif()
+diff --git a/cmake/README.md b/cmake/README.md
+index 36fc303f9..b58c2ff6a 100644
+--- a/cmake/README.md
++++ b/cmake/README.md
+@@ -13,6 +13,7 @@ TBB4PY_BUILD:BOOL - Enable  Intel(R) oneAPI Threading Building Blocks (oneTBB) P
+ TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
+ TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
+ TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
++TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)
+ ```
+ 
+ ## Configure, build and test
+@@ -42,9 +43,9 @@ Some useful options:
+ 
+ #### TBBBind library configuration
+ 
+-The TBBbind library has two versions: `tbbbind` and `tbbbind_2_0`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.x.
++The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0` and `tbbbind_2_5`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.1-2.4, `tbbbind_2_5` links with HWLOC 2.5 and later.
+ 
+-To enable the TBBBind library build or special tests that performed inside the HWLOC environment, please specify the following CMake variables:
++The search for a suitable version of the HWLOC library is enabled by default, but if you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
+ 
+  - `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux or path to `.lib` file on Windows.
+  - `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version includes directory.
+@@ -52,7 +53,11 @@ To enable the TBBBind library build or special tests that performed inside the H
+ Windows requires one additional variable for correct TBBBind library building:
+  - `CMAKE_HWLOC_<HWLOC_VER>_DLL_PATH` - path to the corresponding HWLOC version `.dll` file.
+ 
+-`HWLOC_VER` variable used above can be replaced with one of the two values: `1_11` for the `tbbbind` library configuration and `2` for the `tbbbind_2_0` library configuration.
++`HWLOC_VER` substring used above can be replaced with one of the three values: `1_11` for the `tbbbind` library configuration, `2` for the `tbbbind_2_0`, and `2_5` for the `tbbbind_2_5` library configuration.
++
++If you specify variables for several TBBBind versions, then building process for all of these versions will be performed during single build session.
++
++Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
+ 
+ ### Build
+ 
+diff --git a/cmake/hwloc_detection.cmake b/cmake/hwloc_detection.cmake
+index e1eeca5fa..de7f3c047 100644
+--- a/cmake/hwloc_detection.cmake
++++ b/cmake/hwloc_detection.cmake
+@@ -12,7 +12,7 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
+-list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_4)
++list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_5)
+ 
+ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
+     if (NOT WIN32)
+@@ -55,10 +56,10 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
+         if (HWLOC_FOUND)
+             if (HWLOC_VERSION VERSION_LESS 2)
+                 set(TBBBIND_LIBRARY_NAME tbbbind)
+-            elseif(HWLOC_VERSION VERSION_LESS 2.4)
++            elseif(HWLOC_VERSION VERSION_LESS 2.5)
+                 set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
+             else()
+-                set(TBBBIND_LIBRARY_NAME tbbbind_2_4)
++                set(TBBBIND_LIBRARY_NAME tbbbind_2_5)
+             endif()
+         endif()
+     endif()
+diff --git a/src/tbb/governor.cpp b/src/tbb/governor.cpp
+index bf4e402d1..b842e075f 100644
+--- a/src/tbb/governor.cpp
++++ b/src/tbb/governor.cpp
+@@ -362,7 +362,7 @@ static const unsigned LinkTableSize = sizeof(TbbBindLinkTable) / sizeof(dynamic_
+ 
+ #define TBBBIND_NAME LIBRARY_PREFIX "tbbbind" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #define TBBBIND_2_0_NAME LIBRARY_PREFIX "tbbbind_2_0" DEBUG_SUFFIX LIBRARY_EXTENSION
+-#define TBBBIND_2_4_NAME LIBRARY_PREFIX "tbbbind_2_4" DEBUG_SUFFIX LIBRARY_EXTENSION
++#define TBBBIND_2_5_NAME LIBRARY_PREFIX "tbbbind_2_5" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #endif /* _WIN32 || _WIN64 || __linux__ */
+ 
+ // Representation of system hardware topology information on the TBB side.
+@@ -389,7 +389,7 @@ const char* load_tbbbind_shared_object() {
+     GetNativeSystemInfo(&si);
+     if (si.dwNumberOfProcessors > 32) return nullptr;
+ #endif /* _WIN32 && !_WIN64 */
+-    for (const auto& tbbbind_version : {TBBBIND_2_4_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
++    for (const auto& tbbbind_version : {TBBBIND_2_5_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
+         if (dynamic_link(tbbbind_version, TbbBindLinkTable, LinkTableSize)) {
+             return tbbbind_version;
+         }
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index 029893751..e5cdbf8bb 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -99,7 +99,7 @@ if (NOT DEFINED HWLOC_TARGET_EXPLICITLY_DEFINED AND DEFINED HWLOC_LIBRARIES)
+ else()
+     tbbbind_build(tbbbind     HWLOC::hwloc_1_11)
+     tbbbind_build(tbbbind_2_0 HWLOC::hwloc_2   )
+-    tbbbind_build(tbbbind_2_4 HWLOC::hwloc_2_4 )
++    tbbbind_build(tbbbind_2_5 HWLOC::hwloc_2_5 )
+ endif()
+ 
+ 
+diff --git a/src/tbbbind/tbb_bind.cpp b/src/tbbbind/tbb_bind.cpp
+index 97be308c7..88c956acb 100644
+--- a/src/tbbbind/tbb_bind.cpp
++++ b/src/tbbbind/tbb_bind.cpp
+@@ -34,7 +34,8 @@
+ #pragma GCC diagnostic pop
+ #endif
+ 
+-#define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ 
+ // Most of hwloc calls returns negative exit code on error.
+ // This macro tracks error codes that are returned from the hwloc interfaces.
+@@ -85,6 +86,16 @@ class platform_topology {
+         // Parse topology
+         if ( hwloc_topology_init( &topology ) == 0 ) {
+             initialization_state = topology_allocated;
++#if __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++            if ( groups_num == 1 &&
++                 hwloc_topology_set_flags(topology,
++                     HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                     HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
++                 ) != 0
++            ) {
++                return;
++            }
++#endif
+             if ( hwloc_topology_load( topology ) == 0 ) {
+                 initialization_state = topology_loaded;
+             }
+@@ -135,7 +146,7 @@ class platform_topology {
+             numa_indexes_list.resize(numa_nodes_count);
+             hwloc_obj_t node_buffer;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 numa_indexes_list[counter] = static_cast<int>(node_buffer->logical_index);
+ 
+                 if ( numa_indexes_list[counter] > max_numa_index ) {
+@@ -150,7 +161,7 @@ class platform_topology {
+             numa_affinity_masks_list.resize(max_numa_index + 1);
+             int index = 0;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 index = static_cast<int>(node_buffer->logical_index);
+ 
+                 hwloc_cpuset_t& current_mask = numa_affinity_masks_list[index];
+@@ -168,7 +179,7 @@ class platform_topology {
+             core_types_indexes_list.push_back(-1);
+             return;
+         }
+-#if __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
++#if __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
+         __TBB_ASSERT(hwloc_get_api_version() >= 0x20400, "Hybrid CPUs support interfaces required HWLOC >= 2.4");
+         // Parsing the hybrid CPU topology
+         int core_types_number = hwloc_cpukinds_get_nr(topology, 0);
+@@ -196,9 +207,9 @@ class platform_topology {
+                 }
+             }
+         }
+-#else /*!__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#else /*!__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+         bool core_types_parsing_broken{true};
+-#endif /*__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#endif /*__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+ 
+         if (core_types_parsing_broken) {
+             for (auto& core_type_mask : core_types_affinity_masks_list) {
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index bdae9e2b1..c2b9d6dba 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -275,9 +275,9 @@ function(tbb_add_tbbbind_test)
+         FAIL_REGULAR_EXPRESSION "Status:.*FAILURE"
+     )
+ 
+-    if (TARGET HWLOC::hwloc_2_4 AND NOT HWLOC_2_4_TESTS_STATUS_SHOWN)
+-        message(STATUS "HWLOC 2.4 dependent tests were enabled.")
+-        set(HWLOC_2_4_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
++    if (TARGET HWLOC::hwloc_2_5 AND NOT HWLOC_2_5_TESTS_STATUS_SHOWN)
++        message(STATUS "HWLOC 2.5 dependent tests were enabled.")
++        set(HWLOC_2_5_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
+     endif()
+ 
+     if (TARGET HWLOC::hwloc_2 AND NOT HWLOC_2_TESTS_STATUS_SHOWN)
+@@ -291,22 +291,22 @@ function(tbb_add_tbbbind_test)
+     endif()
+ 
+     list(APPEND HWLOC_TEST_CASES
+-        hwloc_2_4
++        hwloc_2_5
+         hwloc_2
+         hwloc_1_11
+-        hwloc_2_4_hwloc_2
+-        hwloc_2_4_hwloc_1_11
++        hwloc_2_5_hwloc_2
++        hwloc_2_5_hwloc_1_11
+         hwloc_2_hwloc_1_11
+-        hwloc_2_4_hwloc_2_hwloc_1_11
++        hwloc_2_5_hwloc_2_hwloc_1_11
+     )
+ 
+-    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_4 "hwloc_2_4")
++    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_5 "hwloc_2_5")
+     list(APPEND HWLOC_TEST_CASE_1_VARS tbbbind_2   "hwloc_2")
+     list(APPEND HWLOC_TEST_CASE_2_VARS tbbbind     "hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2")
+-    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_4 "hwloc_2_4,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2")
++    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_5 "hwloc_2_5,hwloc_1_11")
+     list(APPEND HWLOC_TEST_CASE_5_VARS tbbbind_2   "hwloc_2,hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2,hwloc_1_11")
+ 
+     foreach(TEST_CASE ${HWLOC_TEST_CASES})
+         list(FIND HWLOC_TEST_CASES ${TEST_CASE} TEST_CASE_INDEX)
+@@ -331,7 +331,7 @@ endfunction()
+ # Copy libraries to test folder to make it visible during tests execution if external TBB is tested.
+ # TODO: check and update for multi-config generators.
+ if (TBB_FOUND)
+-    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_4)
++    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_5)
+     foreach(_component ${_tbb_test_components})
+         if (TARGET TBB::${_component})
+             get_property(${_component}_lib_file_location TARGET TBB::${_component} PROPERTY LOCATION)
+@@ -593,6 +593,6 @@ if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
+     tbb_add_test(SUBDIR tbbmalloc NAME test_malloc_new_handler DEPENDENCIES TBB::tbbmalloc_proxy)
+ endif()
+ 
+-unset(HWLOC_2_4_TESTS_STATUS_SHOWN)
++unset(HWLOC_2_5_TESTS_STATUS_SHOWN)
+ unset(HWLOC_2_TESTS_STATUS_SHOWN)
+ unset(HWLOC_1_11_TESTS_STATUS_SHOWN)
+diff --git a/test/common/common_arena_constraints.h b/test/common/common_arena_constraints.h
+index 2a0b1ea97..5efc71082 100644
+--- a/test/common/common_arena_constraints.h
++++ b/test/common/common_arena_constraints.h
+@@ -38,9 +38,26 @@
+ 
+ #if (_WIN32 || _WIN64) && __TBB_HWLOC_VALID_ENVIRONMENT
+ #include <windows.h>
+-int get_processors_groups_count() { return GetActiveProcessorGroupCount(); }
++int get_processors_group_count() {
++    SYSTEM_INFO si;
++    GetNativeSystemInfo(&si);
++    DWORD_PTR pam, sam, m = 1;
++    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
++    int nproc = 0;
++    for ( std::size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
++        if ( pam & m )
++            ++nproc;
++    }
++    // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present
++    if ( nproc == (int)si.dwNumberOfProcessors  ) {
++        // The process does not have restricting affinity mask and multiple processor groups are possible
++        return (int)GetActiveProcessorGroupCount();
++    } else {
++        return 1;
++    }
++}
+ #else
+-int get_processors_groups_count() { return 1; }
++int get_processors_group_count() { return 1; }
+ #endif
+ 
+ //TODO: Write a test that checks for memory leaks during dynamic link/unlink of TBBbind.
+@@ -69,6 +86,7 @@ int get_processors_groups_count() { return 1; }
+ #endif
+ 
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ // At this moment the hybrid CPUs HWLOC interfaces returns unexpected results on some Windows machines
+ // in the 32-bit arch mode.
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_VALID (!_WIN32 || _WIN64)
+@@ -153,9 +171,18 @@ class system_info {
+ 
+     system_info() {
+         hwloc_require_ex(hwloc_topology_init, &topology);
++#if __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++        if ( get_processors_group_count() == 1 ) {
++            REQUIRE(
++                hwloc_topology_set_flags(topology,
++                    HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                    HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING) == 0
++            );
++        }
++#endif
+         hwloc_require_ex(hwloc_topology_load, topology);
+ 
+-        if ( get_processors_groups_count() > 1 ) {
++        if ( get_processors_group_count() > 1 ) {
+             process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
+         } else {
+             process_cpuset = hwloc_bitmap_alloc();
+@@ -434,7 +461,7 @@ system_info::affinity_mask get_arena_affinity(tbb::task_arena& ta) {
+                 barrier.wait();
+                 tbb::spin_mutex::scoped_lock lock(affinity_mutex);
+                 system_info::affinity_mask thread_affinity = system_info::allocate_current_affinity_mask();
+-                if (get_processors_groups_count() == 1) {
++                if (get_processors_group_count() == 1) {
+                     REQUIRE_MESSAGE(hwloc_bitmap_isequal(thread_affinity, arena_affinity),
+                         "Threads have different masks on machine without several processors groups.");
+                 }
+@@ -532,7 +559,7 @@ constraints_container generate_constraints_variety() {
+         }
+ 
+         // Some constraints may cause unexpected behavior, which would be fixed later.
+-        if (get_processors_groups_count() > 1) {
++        if (get_processors_group_count() > 1) {
+             for(auto it = results.begin(); it != results.end(); ++it) {
+                 if (it->max_threads_per_core != tbb::task_arena::automatic
+                    && (it->numa_id == tbb::task_arena::automatic || tbb::info::numa_nodes().size() == 1)
diff --git a/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
new file mode 100644
index 000000000000..279ebc4397cd
--- /dev/null
+++ b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
@@ -0,0 +1,52 @@
+Based on https://github.com/oneapi-src/oneTBB/pull/498
+Tweaked a bit to work on `v2021.3.0`
+
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index e5cdbf8bb..a4033210a 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -37,6 +37,10 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+         ${HWLOC_INCLUDE_DIRS} # pkg-config defined
+     )
++	target_link_directories(${TBBBIND_NAME}
++		PRIVATE
++		${HWLOC_LIBRARY_DIRS} # pkg-config defined
++	)
+ 
+     target_compile_options(${TBBBIND_NAME}
+         PRIVATE
+@@ -69,7 +69,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     else()
+         target_link_libraries(${TBBBIND_NAME}
+@@ -76,7 +76,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     endif()
+ 
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index b768759d5..3eb8357e6 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -258,7 +258,12 @@ function(tbb_add_tbbbind_test)
+         )
+         set_property(
+             TARGET ${_tbbbind_test_NAME}
+-            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARY_DIRS} ${HWLOC_LIBRARIES}
++            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARIES}
++            APPEND
++        )
++        set_property(
++            TARGET ${_tbbbind_test_NAME}
++			PROPERTY LINK_DIRECTORIES ${HWLOC_LIBRARY_DIRS}
+             APPEND
+         )
+         set_property(
diff --git a/srcpkgs/tbb/patches/hostname-usage.patch b/srcpkgs/tbb/patches/hostname-usage.patch
deleted file mode 100644
index 4aefeff192b5..000000000000
--- a/srcpkgs/tbb/patches/hostname-usage.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/build/version_info_linux.sh
-+++ b/build/version_info_linux.sh
-@@ -20,7 +20,7 @@
- 
- # Script used to generate version info string
- echo "#define __TBB_VERSION_STRINGS(N) \\"
--echo '#N": BUILD_HOST'"\t\t"`hostname -s`" ("`uname -m`")"'" ENDL \'
-+echo '#N": BUILD_HOST'"\t\t"`hostname`" ("`uname -m`")"'" ENDL \'
- # find OS name in *-release and issue* files by filtering blank lines and lsb-release content out
- echo '#N": BUILD_OS'"\t\t"`lsb_release -sd 2>/dev/null | grep -ih '[a-z] ' - /etc/*release /etc/issue 2>/dev/null | head -1 | sed -e 's/["\\\\]//g'`'" ENDL \'
- echo '#N": BUILD_KERNEL'"\t"`uname -srv`'" ENDL \'
diff --git a/srcpkgs/tbb/patches/musl.patch b/srcpkgs/tbb/patches/musl.patch
index a8867eb53793..ec89c6a95fc6 100644
--- a/srcpkgs/tbb/patches/musl.patch
+++ b/srcpkgs/tbb/patches/musl.patch
@@ -1,5 +1,5 @@
---- a/src/tbbmalloc/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
-+++ b/src/tbbmalloc/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
+--- a/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
++++ b/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
 @@ -28,6 +28,7 @@
  // of aligned_alloc as required by new C++ standard, this makes it hard to
  // redefine aligned_alloc here. However, running on systems with new libc
diff --git a/srcpkgs/tbb/template b/srcpkgs/tbb/template
index aeef6ebdd061..47655829f744 100644
--- a/srcpkgs/tbb/template
+++ b/srcpkgs/tbb/template
@@ -1,76 +1,33 @@
 # Template file for 'tbb'
 pkgname=tbb
-version=2020.U3
+version=2021.3.0
 revision=1
-# version rewrite: 2017_U7 (upstream) => 2017.7 (xbps)
-_ver=${version/./_}
-wrksrc="oneTBB-${_ver}"
-build_style=gnu-makefile
-hostmakedepends="cmake"
+wrksrc="oneTBB-${version}"
+build_style=cmake
+makedepends="libhwloc-devel libgomp-devel"
 short_desc="Intel Threading Building Blocks"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
 license="Apache-2.0"
 homepage="https://www.threadingbuildingblocks.org"
-distfiles="https://github.com/oneapi-src/oneTBB/archive/${_ver}.tar.gz"
-checksum=2103cc6238c935664f87680618f6684d57501d4a2fa8ea8f6c97ad6ff7dc722a
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*)
-		make_build_args="arch=intel64"
-		;;
-	i686*)
-		make_build_args="arch=ia32"
-		;;
-	armv7l*)
-		make_build_args="arch=armv7"
-		;;
-	aarch64*)
-		make_build_args="arch=arm64"
-		;;
-	ppc64*)
-		make_build_args="arch=ppc64"
-		;;
-	ppc*)
-		make_build_args="arch=ppc32"
-		;;
-	*)
-		# make sure to fall back instead of letting host uname control it
-		make_build_args="arch=generic"
-		;;
-esac
-
-post_extract() {
-	sed -i 's|CPLUS = g..|CPLUS = $(CXX)|g' build/linux.gcc.inc
-	sed -i 's|CONLY = gcc|CONLY = $(CC)|g' build/linux.gcc.inc
+distfiles="https://github.com/oneapi-src/oneTBB/archive/v${version}.tar.gz"
+checksum=8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e
 
+pre_patch() {
 	# alternative might be:
 	# https://git.alpinelinux.org/cgit/aports/tree/testing/libtbb/glibc-struct-mallinfo.patch
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		vsed -e "s@#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__@@" \
-		  -i src/tbbmalloc/proxy.h
+		  -i src/tbbmalloc_proxy/proxy.h
 	fi
 }
 
-do_install() {
-	vmkdir usr/lib
-	vcopy build/linux_*/*.so* usr/lib
-	vmkdir usr/include/tbb
-	vcopy include/tbb/* usr/include/tbb
-
-	cmake \
-		-DINSTALL_DIR=$DESTDIR/usr/lib/cmake/TBB \
-		-DSYSTEM_NAME=Linux \
-		-DLIB_REL_PATH=../.. \
-		-DINC_REL_PATH=../../../include \
-		-P cmake/tbb_config_installer.cmake
-}
-
 tbb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
-		vmove "usr/lib/*.so"
 		vmove usr/lib/cmake
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.so
 	}
 }

From 64e644e15bf3e153566630d912aae8733b5a8f32 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 03/12] OpenSubdiv: update to 3.4.4.

---
 srcpkgs/OpenSubdiv/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/OpenSubdiv/template b/srcpkgs/OpenSubdiv/template
index b7a5e16efbcf..dfbf29cc1a52 100644
--- a/srcpkgs/OpenSubdiv/template
+++ b/srcpkgs/OpenSubdiv/template
@@ -1,6 +1,6 @@
 # Template file for 'OpenSubdiv'
 pkgname=OpenSubdiv
-version=3.4.3
+version=3.4.4
 revision=1
 wrksrc="OpenSubdiv-${version//./_}"
 build_style=cmake
@@ -13,7 +13,7 @@ maintainer="John <me@johnnynator.dev>"
 license="Apache-2.0"
 homepage="http://graphics.pixar.com/opensubdiv/docs/intro.html"
 distfiles="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${version//./_}.tar.gz"
-checksum=7b22eb27d636ab0c1e03722c7a5a5bd4f11664ee65c9b48f341a6d0ce7f36745
+checksum=20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" OpenSubdiv"

From 090dadbdb80d958b923850a2cb4b53822f0f5df0 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 04/12] PrusaSlicer: update to 2.3.3.

---
 srcpkgs/PrusaSlicer/patches/cross.patch | 11 -----------
 srcpkgs/PrusaSlicer/template            |  4 ++--
 2 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 srcpkgs/PrusaSlicer/patches/cross.patch

diff --git a/srcpkgs/PrusaSlicer/patches/cross.patch b/srcpkgs/PrusaSlicer/patches/cross.patch
deleted file mode 100644
index d64a450d9e9f..000000000000
--- a/srcpkgs/PrusaSlicer/patches/cross.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/avrdude/CMakeLists.txt	2020-06-04 09:19:26.017251215 +0200
-+++ b/src/avrdude/CMakeLists.txt	2020-06-04 09:19:36.468250771 +0200
-@@ -83,7 +83,7 @@ add_executable(avrdude-conf-gen conf-gen
- add_custom_command(
-     DEPENDS avrdude-conf-gen ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf
-     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
--    COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-+    COMMAND avrdude-conf-gen avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- 
diff --git a/srcpkgs/PrusaSlicer/template b/srcpkgs/PrusaSlicer/template
index dd0e76cb8017..a93832ac02e4 100644
--- a/srcpkgs/PrusaSlicer/template
+++ b/srcpkgs/PrusaSlicer/template
@@ -1,6 +1,6 @@
 # Template file for 'PrusaSlicer'
 pkgname=PrusaSlicer
-version=2.3.0
+version=2.3.3
 revision=1
 wrksrc="PrusaSlicer-version_${version}"
 build_style=cmake
@@ -16,7 +16,7 @@ maintainer="Jasper Chan <jasperchan515@gmail.com>"
 license="GPL-3.0-or-later"
 homepage="https://www.prusa3d.com/prusaslicer/"
 distfiles="https://github.com/prusa3d/Prusaslicer/archive/version_${version}.tar.gz"
-checksum=cd3bac5e29b5441fc4690f28cd7b1064e97dc00207bbdc88f7bd7832308d6ca5
+checksum=deda209505f740ac3d6f59cb2a960f4df908269ee09bd30cd4edb9fc472d29ac
 nocross="https://build.voidlinux.org/builders/armv7l_builder/builds/25230/steps/shell_3/logs/stdio"
 
 Slic3rPE_package() {

From 9ae3bae2c1b6729effcb1a663a86b00c63badfc8 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 05/12] blender: update to 2.93.1.

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index af946c2b7999..8318317c82bf 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,6 +1,6 @@
 # Template file for 'blender'
 pkgname=blender
-version=2.93.0
+version=2.93.1
 revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"

From 95d732bda8a01fb717b07e60195221ba9b1a6361 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 06/12] embree: update to 3.13.0.

---
 srcpkgs/embree/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/embree/template b/srcpkgs/embree/template
index 575b9bcb401c..b6f376d30efa 100644
--- a/srcpkgs/embree/template
+++ b/srcpkgs/embree/template
@@ -1,8 +1,8 @@
 # Template file for 'embree'
 pkgname=embree
-version=2.17.7
-revision=2
-archs="x86_64"
+version=3.13.0
+revision=1
+archs="x86_64*"
 build_style=cmake
 configure_args="-DTBB_ROOT=/usr -DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF"
 hostmakedepends="ispc"

From a1720fc3bfd2b9fcce31473d9acb86449781acf6 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 03:34:43 +0300
Subject: [PATCH 07/12] openimageio: update to 2.2.16.0.

---
 srcpkgs/openimageio/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index de8e1cd04409..3bfdd4e0ed1e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,11 +1,11 @@
 # Template file for 'openimageio'
 pkgname=openimageio
-version=2.2.15.1
+version=2.2.16.0
 revision=1
 wrksrc="oiio-Release-${version}"
 build_style=cmake
 configure_args="-DUSE_OPENGL=0 -DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=1
- -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0"
+ -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0 -DCMAKE_CXX_STANDARD=14"
 hostmakedepends="pkg-config git"
 makedepends="boost-devel giflib-devel libraw-devel libopenjpeg-devel libwebp-devel
  libjpeg-turbo-devel tiff-devel libpng-devel libopenexr-devel freetype-devel
@@ -17,7 +17,7 @@ license="BSD-3-Clause"
 homepage="https://sites.google.com/site/openimageio/home"
 changelog="https://raw.githubusercontent.com/OpenImageIO/oiio/release/CHANGES.md"
 distfiles="https://github.com/OpenImageIO/oiio/archive/Release-${version}.tar.gz"
-checksum=f222c6b51a40aabbc80ddf4055535be9af1ffa907452fa6d1ffa7674854aab17
+checksum=d1a59f32dbba3ba71ad2e62e107034d1c5287bca1b0696474e927d504cd05ef4
 # Runs checks even for features we disabled.
 make_check=no
 

From 650fcda8d7fe06500cd6be856c19617e498a1a96 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 08/12] openimagedenoise: update to 1.4.1.

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index c73913b4e9d7..14055aff1c27 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,6 +1,6 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
-version=1.4.0
+version=1.4.1
 revision=1
 archs="x86_64*"
 wrksrc=oidn-${version}

From 15ac32964d63c74f41353b8f9b4aa574af2159dc Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 09/12] openvdb: update to 8.1.0.

---
 common/shlibs                             |    2 +-
 srcpkgs/openvdb/patches/00-tbb-2021.patch | 1320 +++++++++++++++++++++
 srcpkgs/openvdb/template                  |   16 +-
 3 files changed, 1325 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/openvdb/patches/00-tbb-2021.patch

diff --git a/common/shlibs b/common/shlibs
index 6b7ca5fbc249..2a7acdb253a7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3883,7 +3883,7 @@ libjanet.so.1.16 janet-1.16.0_1
 libOpenImageDenoise.so.1 openimagedenoise-1.3.0_1
 libcbang0.so cbang-1.6.0_3
 libblosc.so.1 c-blosc-1.17.1_1
-libopenvdb.so.7.0 openvdb-7.0.0_1
+libopenvdb.so.8.1 openvdb-8.1.0_1
 libAlembic.so.1.7 alembic-1.7.13_1
 libmodsecurity.so.3 modsecurity-3.0.4_1
 libraven.so.0 budgie-desktop-10.5.1_1
diff --git a/srcpkgs/openvdb/patches/00-tbb-2021.patch b/srcpkgs/openvdb/patches/00-tbb-2021.patch
new file mode 100644
index 000000000000..271104af3df9
--- /dev/null
+++ b/srcpkgs/openvdb/patches/00-tbb-2021.patch
@@ -0,0 +1,1320 @@
+https://github.com/AcademySoftwareFoundation/openvdb/pull/1027
+Should be dropped after 8.1.1 release.
+
+diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake
+index d41436b1c..06de2b3f3 100644
+--- a/cmake/FindTBB.cmake
++++ b/cmake/FindTBB.cmake
+@@ -169,8 +169,22 @@ find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
+   PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
+ )
+ 
+-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" ""
+@@ -178,7 +192,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" ""
+@@ -192,6 +206,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
+ # ------------------------------------------------------------------------
+diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt
+index 88543df3a..929fe94d1 100644
+--- a/openvdb/openvdb/CMakeLists.txt
++++ b/openvdb/openvdb/CMakeLists.txt
+@@ -437,6 +437,10 @@ set(OPENVDB_LIBRARY_UTIL_INCLUDE_FILES
+   util/Util.h
+ )
+ 
++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} DESTINATION ${OPENVDB_INST
+ 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)
+diff --git a/openvdb/openvdb/cmd/openvdb_render.cc b/openvdb/openvdb/cmd/openvdb_render.cc
+index ee5b737c5..2c9831ba3 100644
+--- a/openvdb/openvdb/cmd/openvdb_render.cc
++++ b/openvdb/openvdb/cmd/openvdb_render.cc
+@@ -19,7 +19,14 @@
+ #include <OpenEXR/ImfHeader.h>
+ #include <OpenEXR/ImfOutputFile.h>
+ #include <OpenEXR/ImfPixelType.h>
+-#include <tbb/task_scheduler_init.h>
++
++// 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 <tbb/global_control.h>
+ #include <tbb/tick_count.h>
+ 
+ #include <algorithm>
+@@ -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<tbb::global_control> 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();
+ 
+diff --git a/openvdb/openvdb/io/Queue.cc b/openvdb/openvdb/io/Queue.cc
+index ef5d2961a..20ff1a0c1 100644
+--- a/openvdb/openvdb/io/Queue.cc
++++ b/openvdb/openvdb/io/Queue.cc
+@@ -5,20 +5,22 @@
+ /// @author Peter Cucka
+ 
+ #include "Queue.h"
+-
+ #include "File.h"
+ #include "Stream.h"
+-#include <openvdb/Exceptions.h>
+-#include <openvdb/util/logging.h>
++#include "openvdb/Exceptions.h"
++#include "openvdb/util/logging.h"
++
+ #include <tbb/concurrent_hash_map.h>
+-#include <tbb/task.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
+-#include <tbb/tick_count.h>
++#include <tbb/task_arena.h>
++
++#include <thread>
+ #include <algorithm> // for std::max()
+ #include <atomic>
+ #include <iostream>
+ #include <map>
+ #include <mutex>
++#include <chrono>
++
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -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
+ 
+ 
+ // 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
+         : 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
+             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<Queue::Id, Queue::Status>;
+ 
+-
+     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::milliseconds>(
++                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;
+ }
+ 
+diff --git a/openvdb/openvdb/math/Coord.h b/openvdb/openvdb/math/Coord.h
+index 504b5e9a4..2e9cfed5d 100644
+--- a/openvdb/openvdb/math/Coord.h
++++ b/openvdb/openvdb/math/Coord.h
+@@ -13,8 +13,7 @@
+ #include "Math.h"
+ #include "Vec3.h"
+ 
+-namespace tbb { class split; } // forward declaration
+-
++#include <tbb/blocked_range.h> // for tbb::split
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+diff --git a/openvdb/openvdb/points/PointSample.h b/openvdb/openvdb/points/PointSample.h
+index a122cc4fb..27ec3fb29 100644
+--- a/openvdb/openvdb/points/PointSample.h
++++ b/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 <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tools/Interpolation.h>
++#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 <sstream>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -299,7 +299,7 @@ class PointDataSampler
+             using TargetHandleT = AttributeWriteHandle<typename SamplerWrapperT::ValueType>;
+ 
+             if (util::wasInterrupted(interrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return;
+             }
+ 
+diff --git a/openvdb/openvdb/thread/Threading.h b/openvdb/openvdb/thread/Threading.h
+new file mode 100644
+index 000000000..0c3b356e3
+--- /dev/null
++++ b/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 <tbb/blocked_range.h>
++#include <tbb/task.h>
++#include <tbb/task_group.h>
++
++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
+diff --git a/openvdb/openvdb/tools/Composite.h b/openvdb/openvdb/tools/Composite.h
+index 6bc170bf7..88ff86f9f 100644
+--- a/openvdb/openvdb/tools/Composite.h
++++ b/openvdb/openvdb/tools/Composite.h
+@@ -24,7 +24,6 @@
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include <type_traits>
+ #include <functional>
+diff --git a/openvdb/openvdb/tools/Diagnostics.h b/openvdb/openvdb/tools/Diagnostics.h
+index 694d2155f..e5844e448 100644
+--- a/openvdb/openvdb/tools/Diagnostics.h
++++ b/openvdb/openvdb/tools/Diagnostics.h
+@@ -11,14 +11,17 @@
+ #ifndef OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ 
+-#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/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 <tbb/blocked_range.h>
+ #include <tbb/parallel_reduce.h>
++
+ #include <cmath> // for std::isnan(), std::isfinite()
+ #include <set>
+ #include <sstream>
+@@ -26,7 +29,6 @@
+ #include <type_traits>
+ #include <vector>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -1160,13 +1162,13 @@ InactiveVoxelValues<TreeType>::operator()(const tbb::blocked_range<size_t>& rang
+ {
+     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<typename TreeType>
+ inline void
+ InactiveTileValues<TreeType>::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();
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/tools/Filter.h b/openvdb/openvdb/tools/Filter.h
+index 408c75541..b70212520 100644
+--- a/openvdb/openvdb/tools/Filter.h
++++ b/openvdb/openvdb/tools/Filter.h
+@@ -14,21 +14,24 @@
+ #ifndef OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ 
+-#include <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
++#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 <tbb/parallel_for.h>
++#include <tbb/concurrent_vector.h>
++
+ #include <algorithm> // for std::max()
+ #include <functional>
+ #include <type_traits>
+-#include <tbb/concurrent_vector.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -833,7 +836,7 @@ inline bool
+ Filter<GridT, MaskT, InterruptT>::wasInterrupted()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return true;
+     }
+     return false;
+diff --git a/openvdb/openvdb/tools/GridOperators.h b/openvdb/openvdb/tools/GridOperators.h
+index 31305a1ab..78fafead9 100644
+--- a/openvdb/openvdb/tools/GridOperators.h
++++ b/openvdb/openvdb/tools/GridOperators.h
+@@ -9,14 +9,15 @@
+ #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/Grid.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
++#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 <tbb/parallel_for.h>
+ 
++#include <tbb/parallel_for.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -383,7 +384,9 @@ class GridOperator
+     /// 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) {
+diff --git a/openvdb/openvdb/tools/LevelSetMeasure.h b/openvdb/openvdb/tools/LevelSetMeasure.h
+index efe19074d..59969cdcf 100644
+--- a/openvdb/openvdb/tools/LevelSetMeasure.h
++++ b/openvdb/openvdb/tools/LevelSetMeasure.h
+@@ -8,18 +8,21 @@
+ #ifndef OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/math/Math.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/Grid.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/math/FiniteDifference.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/math/Stencils.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
+ #include <tbb/parallel_sort.h>
+ #include <tbb/parallel_invoke.h>
++
+ #include <type_traits>
+ 
+ namespace openvdb {
+@@ -329,7 +332,7 @@ inline bool
+ LevelSetMeasure<GridT, InterruptT>::checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/LevelSetTracker.h b/openvdb/openvdb/tools/LevelSetTracker.h
+index cbdc267e8..bfc8004e7 100644
+--- a/openvdb/openvdb/tools/LevelSetTracker.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/tree/LeafManager.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -383,7 +385,7 @@ LevelSetTracker<GridT, InterruptT>::
+ checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/MeshToVolume.h b/openvdb/openvdb/tools/MeshToVolume.h
+index 6643c8f05..de3406eda 100644
+--- a/openvdb/openvdb/tools/MeshToVolume.h
++++ b/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 <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/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 <tbb/parallel_reduce.h>
+ #include <tbb/partitioner.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm> // for std::sort()
+ #include <cmath> // 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<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+@@ -1989,7 +1990,7 @@ class VoxelizePolygons
+         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
+ 
+         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) {
+diff --git a/openvdb/openvdb/tools/Morphology.h b/openvdb/openvdb/tools/Morphology.h
+index 736982ef5..0a1e71009 100644
+--- a/openvdb/openvdb/tools/Morphology.h
++++ b/openvdb/openvdb/tools/Morphology.h
+@@ -24,7 +24,7 @@
+ #include "openvdb/tree/ValueAccessor.h"
+ #include "openvdb/tree/LeafManager.h"
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ 
+@@ -726,7 +726,7 @@ void Morphology<TreeType>::dilateVoxels(const size_t iter,
+         }
+ 
+         // @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
+diff --git a/openvdb/openvdb/tools/ParticlesToLevelSet.h b/openvdb/openvdb/tools/ParticlesToLevelSet.h
+index 739af2b69..f9c19911c 100644
+--- a/openvdb/openvdb/tools/ParticlesToLevelSet.h
++++ b/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 <tbb/parallel_reduce.h>
+-#include <tbb/blocked_range.h>
+-#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/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 <tbb/parallel_reduce.h>
++#include <tbb/blocked_range.h>
++
+ #include <functional>
+ #include <iostream>
+ #include <type_traits>
+@@ -738,7 +742,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         for (Coord c = lo; c.x() <= hi.x(); ++c.x()) {
+             //only check interrupter every 32'th scan in x
+             if (!(count++ & ((1<<5)-1)) && util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Real x2 = math::Pow2(c.x() - P[0]);
+@@ -804,7 +808,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         // Densely fill the remaining regions.
+         for (const auto& bbox: padding) {
+             if (util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Coord &bmin = bbox.min(), &bmax = bbox.max();
+diff --git a/openvdb/openvdb/tools/PointAdvect.h b/openvdb/openvdb/tools/PointAdvect.h
+index 12b1177ad..e487bfb3e 100644
+--- a/openvdb/openvdb/tools/PointAdvect.h
++++ b/openvdb/openvdb/tools/PointAdvect.h
+@@ -10,16 +10,19 @@
+ #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/openvdb.h>
+-#include <openvdb/math/Math.h>             // min
+-#include <openvdb/Types.h>                 // Vec3 types and version number
+-#include <openvdb/Grid.h>                  // grid
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/blocked_range.h>             // threading
+ #include <tbb/parallel_for.h>              // threading
+ #include <tbb/task.h>                      // for cancel
++
+ #include <vector>
+ 
+ 
+@@ -167,7 +170,7 @@ class PointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityFieldIntegrator  velField(*mVelGrid);
+@@ -307,7 +310,7 @@ class ConstrainedPointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityIntegratorType velField(*mVelGrid);
+diff --git a/openvdb/openvdb/tools/PointIndexGrid.h b/openvdb/openvdb/tools/PointIndexGrid.h
+index e9ebf96f7..b2e378a79 100644
+--- a/openvdb/openvdb/tools/PointIndexGrid.h
++++ b/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 <openvdb/version.h>
+@@ -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;
+         }
+ 
+diff --git a/openvdb/openvdb/tools/PointPartitioner.h b/openvdb/openvdb/tools/PointPartitioner.h
+index ccf50ab05..f7f6fc13d 100644
+--- a/openvdb/openvdb/tools/PointPartitioner.h
++++ b/openvdb/openvdb/tools/PointPartitioner.h
+@@ -23,7 +23,7 @@
+ 
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm>
+ #include <cmath> // for std::isfinite()
+@@ -764,7 +764,7 @@ inline void binAndSegment(
+     using IndexPairListMap = std::map<Coord, IndexPairListPtr>;
+     using IndexPairListMapPtr = std::shared_ptr<IndexPairListMap>;
+ 
+-    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;
+ 
+diff --git a/openvdb/openvdb/tools/PointsToMask.h b/openvdb/openvdb/tools/PointsToMask.h
+index 592ab7a15..8a276fb04 100644
+--- a/openvdb/openvdb/tools/PointsToMask.h
++++ b/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 <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/blocked_range.h>
+-#include <openvdb/openvdb.h> // for MaskGrid
+-#include <openvdb/Grid.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/util/NullInterrupter.h>
++
+ #include <vector>
+ 
+ 
+@@ -150,7 +154,7 @@ class PointsToMask
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeAdvect.h b/openvdb/openvdb/tools/VolumeAdvect.h
+index e7eec740e..f38eaa9c2 100644
+--- a/openvdb/openvdb/tools/VolumeAdvect.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/math/Math.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ 
+ 
+@@ -294,7 +297,7 @@ class VolumeAdvection
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeToMesh.h b/openvdb/openvdb/tools/VolumeToMesh.h
+index a834dd3b3..a446f806a 100644
+--- a/openvdb/openvdb/tools/VolumeToMesh.h
++++ b/openvdb/openvdb/tools/VolumeToMesh.h
+@@ -18,7 +18,7 @@
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <cmath> // for std::isfinite()
+ #include <map>
+@@ -388,7 +388,7 @@ inline void
+ fillArray(ValueType* array, const ValueType& val, const size_t length)
+ {
+     const auto grainSize = std::max<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+diff --git a/openvdb/openvdb/unittest/TestCoord.cc b/openvdb/openvdb/unittest/TestCoord.cc
+index be1c24ced..148690041 100644
+--- a/openvdb/openvdb/unittest/TestCoord.cc
++++ b/openvdb/openvdb/unittest/TestCoord.cc
+@@ -2,9 +2,9 @@
+ // SPDX-License-Identifier: MPL-2.0
+ 
+ #include <openvdb/Types.h>
++#include <openvdb/math/Coord.h>
+ 
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_stddef.h> // for tbb::split
+ 
+ #include <unordered_map>
+ #include <sstream>
+diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc
+index 8074166d2..053448f30 100644
+--- a/openvdb/openvdb/unittest/TestFile.cc
++++ b/openvdb/openvdb/unittest/TestFile.cc
+@@ -13,8 +13,11 @@
+ #include <openvdb/version.h>
+ #include <openvdb/openvdb.h>
+ #include "util.h" // for unittest_util::makeSphere()
++
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
++
++#include <thread>
++#include <chrono>
+ #include <algorithm> // for std::sort()
+ #include <cstdio> // for remove() and rename()
+ #include <fstream>
+@@ -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::seconds>(
++                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<io::Queue::Id> 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));
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc
+index 70e7df5f7..6b2204771 100644
+--- a/openvdb/openvdb/unittest/TestUtil.cc
++++ b/openvdb/openvdb/unittest/TestUtil.cc
+@@ -8,7 +8,6 @@
+ 
+ #include <gtest/gtest.h>
+ 
+-#include <tbb/task_scheduler_init.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/blocked_range.h>
+diff --git a/openvdb/openvdb/unittest/TestValueAccessor.cc b/openvdb/openvdb/unittest/TestValueAccessor.cc
+index fd2dd5d81..5c1cbb18b 100644
+--- a/openvdb/openvdb/unittest/TestValueAccessor.cc
++++ b/openvdb/openvdb/unittest/TestValueAccessor.cc
+@@ -6,6 +6,7 @@
+ 
+ #include <gtest/gtest.h>
+ #include <tbb/task.h>
++#include <tbb/task_group.h>
+ 
+ #include <type_traits>
+ 
+@@ -378,22 +379,21 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
+     //using AccessorT = openvdb::tree::ValueAccessor<Tree4Type>;
+ 
+     // 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
+ }
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+index 0e1b4d855..6d9bb528b 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+@@ -20,6 +20,7 @@
+ #include <openvdb/tools/GridTransformer.h>
+ #include <openvdb/tools/PointIndexGrid.h>
+ #include <openvdb/tools/Prune.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <CH/CH_Manager.h>
+ #include <CVEX/CVEX_Context.h>
+@@ -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;
+             }
+ 
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+index 757fdc8c6..dbee74b32 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+@@ -16,13 +16,11 @@
+ #include <openvdb_houdini/SOP_NodeVDB.h>
+ 
+ #include <openvdb/tools/Interpolation.h>  // for box sampler
++#include <openvdb/thread/Threading.h>
+ #include <openvdb/points/PointCount.h>
+ #include <openvdb/points/PointSample.h>
+ #include <openvdb/points/IndexFilter.h>   // for MultiGroupFilter
+ 
+-#include <tbb/tick_count.h>                 // for timing
+-#include <tbb/task.h>                       // for cancel
+-
+ #include <UT/UT_Interrupt.h>
+ #include <GA/GA_PageHandle.h>
+ #include <GA/GA_PageIterator.h>
+@@ -38,6 +36,7 @@
+ #include <stdexcept>
+ #include <string>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ 
+@@ -327,7 +326,7 @@ class PointSampler
+     {
+ 
+         if (mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            openvdb::thread::cancelGroupExecution();
+         }
+         const GridType& grid = UTvdbGridCast<GridType>(mGrid);
+         // task local grid accessor
+@@ -481,7 +480,7 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Context& context)
+         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_Context& context)
+             }
+         }
+ 
+-        // 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::milliseconds>(
++                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;
+         }
+ 
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+index 3d559f8cc..d63ed1591 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
++++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+@@ -47,11 +47,8 @@ struct NodeInfo {
+ 
+ typedef std::vector<NodeInfo> 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, const MTypeId& typeId,
+     node.type               = type;
+     node.classification     = classification;
+ 
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (!gNodes) {
+         OPENVDB_START_THREADSAFE_STATIC_WRITE
+@@ -85,7 +82,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, const MTypeId& typeId,
+ void
+ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+@@ -109,7 +106,7 @@ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ void
+ NodeRegistry::deregisterNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.h b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+index b58bd6f2c..6a04b1eaf 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBUtil.h
++++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+@@ -14,8 +14,7 @@
+ #include <openvdb/tree/LeafManager.h>
+ #include <openvdb/tools/VolumeToMesh.h>
+ #include <openvdb/util/Formats.h> // printBytes
+-
+-#include <tbb/tick_count.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <maya/M3dView.h>
+ #include <maya/MString.h>
+@@ -40,6 +39,7 @@
+ #include <string>
+ #include <type_traits>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ ////////////////////////////////////////
+@@ -116,11 +116,15 @@ insertFrameNumber(std::string& str, const MTime& time, int numberingScheme = 0);
+ 
+ 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::milliseconds>(
++            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<std::chrono::steady_clock> mStamp;
+ };
+ 
+ 
+diff --git a/pendingchanges/tbb2021.txt b/pendingchanges/tbb2021.txt
+new file mode 100644
+index 000000000..8109c2552
+--- /dev/null
++++ b/pendingchanges/tbb2021.txt
+@@ -0,0 +1,6 @@
++Improvements:
++  - Moved from the deprecated TBB task scheduler to TBB arenas. Various methods now respect the TBB arena state they were invoked from.
++  - Introduced a new thread/Threading.h header to consolidate calls to third-party threading methods.
++
++Build:
++  - Added support for TBB 2021.
diff --git a/srcpkgs/openvdb/template b/srcpkgs/openvdb/template
index 72fde5bc6375..d420a3ee5f5d 100644
--- a/srcpkgs/openvdb/template
+++ b/srcpkgs/openvdb/template
@@ -1,26 +1,18 @@
 # Template file for 'openvdb'
 pkgname=openvdb
-version=7.0.0
+version=8.1.0
 revision=1
 build_style=cmake
 configure_args="-DOPENVDB_BUILD_VDB_VIEW=1"
 hostmakedepends="pkg-config"
-makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel glfw-devel"
+makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel
+ glfw-devel jemalloc-devel"
 short_desc="Sparse volume data structure and tools"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MPL-2.0"
 homepage="https://openvdb.org"
 distfiles="https://github.com/AcademySoftwareFoundation/openvdb/archive/v${version}.tar.gz"
-checksum=97bc8ae35ef7ccbf49a4e25cb73e8c2eccae6b235bac86f2150707efcd1e910d
-
-if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
-	makedepends+=" libatomic-devel"
-fi
-
-post_patch() {
-	[ "$XBPS_TARGET_NO_ATOMIC8" ] || return 0
-	vsed -i 's,ZLIB::ZLIB,ZLIB::ZLIB atomic,' openvdb/CMakeLists.txt
-}
+checksum=3e09d47331429be7409a3a3c27fdd3c297f96d31d2153febe194e664a99d6183
 
 post_install() {
 	vlicense LICENSE

From e425988f85c012996a0f24b5bfa5982b090cdf83 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 10/12] paraview: update to 5.9.1.

---
 srcpkgs/paraview/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/paraview/template b/srcpkgs/paraview/template
index 20a7f5589677..e6c3941ce90a 100644
--- a/srcpkgs/paraview/template
+++ b/srcpkgs/paraview/template
@@ -1,7 +1,7 @@
 # Template file for 'paraview'
 pkgname=paraview
-version=5.8.1
-revision=3
+version=5.9.1
+revision=1
 wrksrc=ParaView-v${version}
 build_style=cmake
 configure_args="-DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr

From cf3a632eb93e4e6232af75316294332a0bc7d63d Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 11/12] occt: revbump due to tbb update

---
 srcpkgs/occt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/occt/template b/srcpkgs/occt/template
index 9298edc76e08..006f89ebb8ce 100644
--- a/srcpkgs/occt/template
+++ b/srcpkgs/occt/template
@@ -2,7 +2,7 @@
 pkgname=occt
 reverts=7.5.0_1
 version=7.4.0p1
-revision=3
+revision=4
 _gittag="V${version//./_}"
 wrksrc=occt-${_gittag}
 build_style=cmake

From aaa4c4a40701d1aa8ffcb044932353dd10a9378a Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 03:44:08 +0300
Subject: [PATCH 12/12] common/build-style/: enable running tests in parallel

---
 common/build-style/cmake.sh           | 6 +++++-
 common/build-style/configure.sh       | 6 +++++-
 common/build-style/gnu-configure.sh   | 6 +++++-
 common/build-style/gnu-makefile.sh    | 6 +++++-
 common/build-style/perl-module.sh     | 6 +++++-
 common/environment/setup/sourcepkg.sh | 3 ++-
 6 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/common/build-style/cmake.sh b/common/build-style/cmake.sh
index 401dabad31c8..c7ffd16fee21 100644
--- a/common/build-style/cmake.sh
+++ b/common/build-style/cmake.sh
@@ -113,7 +113,11 @@ do_check() {
 
 	: ${make_check_target:=test}
 
-	${make_cmd} ${make_check_args} ${make_check_target}
+	if [ -z "$disable_parallel_check" ]; then
+		${make_cmd} ${makejobs} ${make_check_args} ${make_check_target}
+	else
+		${make_cmd} ${make_check_args} ${make_check_target}
+	fi
 }
 
 do_install() {
diff --git a/common/build-style/configure.sh b/common/build-style/configure.sh
index 0963fc347934..b846a1a77572 100644
--- a/common/build-style/configure.sh
+++ b/common/build-style/configure.sh
@@ -29,7 +29,11 @@ do_check() {
 	: ${make_cmd:=make}
 	: ${make_check_target:=check}
 
-	${make_cmd} ${make_check_args} ${make_check_target}
+	if [ -z "$disable_parallel_check" ]; then
+		${make_cmd} ${makejobs} ${make_check_args} ${make_check_target}
+	else
+		${make_cmd} ${make_check_args} ${make_check_target}
+	fi
 }
 
 do_install() {
diff --git a/common/build-style/gnu-configure.sh b/common/build-style/gnu-configure.sh
index 8121136cd121..b09de442b05b 100644
--- a/common/build-style/gnu-configure.sh
+++ b/common/build-style/gnu-configure.sh
@@ -30,7 +30,11 @@ do_check() {
 	: ${make_cmd:=make}
 	: ${make_check_target:=check}
 
-	${make_cmd} ${make_check_args} ${make_check_target}
+	if [ -z "$disable_parallel_check" ]; then
+		${make_cmd} ${makejobs} ${make_check_args} ${make_check_target}
+	else
+		${make_cmd} ${make_check_args} ${make_check_target}
+	fi
 }
 
 do_install() {
diff --git a/common/build-style/gnu-makefile.sh b/common/build-style/gnu-makefile.sh
index d7ea148fc483..0f7afa7d3695 100644
--- a/common/build-style/gnu-makefile.sh
+++ b/common/build-style/gnu-makefile.sh
@@ -30,7 +30,11 @@ do_check() {
 	: ${make_cmd:=make}
 	: ${make_check_target:=check}
 
-	${make_cmd} ${make_check_args} ${make_check_target}
+	if [ -z "$disable_parallel_check" ]; then
+		${make_cmd} ${makejobs} ${make_check_args} ${make_check_target}
+	else
+		${make_cmd} ${make_check_args} ${make_check_target}
+	fi
 }
 
 do_install() {
diff --git a/common/build-style/perl-module.sh b/common/build-style/perl-module.sh
index b9a01b13cfa9..d47945b33d36 100644
--- a/common/build-style/perl-module.sh
+++ b/common/build-style/perl-module.sh
@@ -79,7 +79,11 @@ do_check() {
 	: ${make_cmd:=make}
 	: ${make_check_target:=test}
 
-	${make_cmd} ${make_check_args} ${make_check_target}
+	if [ -z "$disable_parallel_check" ]; then
+		${make_cmd} ${makejobs} ${make_check_args} ${make_check_target}
+	else
+		${make_cmd} ${make_check_args} ${make_check_target}
+	fi
 }
 
 do_install() {
diff --git a/common/environment/setup/sourcepkg.sh b/common/environment/setup/sourcepkg.sh
index bc06f745b78a..1fd541f1e715 100644
--- a/common/environment/setup/sourcepkg.sh
+++ b/common/environment/setup/sourcepkg.sh
@@ -13,7 +13,8 @@ unset -v cmake_builddir meson_builddir
 unset -v meson_crossfile
 unset -v gemspec
 unset -v go_import_path go_package go_mod_mode
-unset -v patch_args disable_parallel_build keep_libtool_archives make_use_env
+unset -v patch_args disable_parallel_build disable_parallel_check
+unset -v keep_libtool_archives make_use_env
 unset -v reverts subpackages makedepends hostmakedepends checkdepends depends restricted
 unset -v nopie build_options build_options_default bootstrap repository reverts
 unset -v CFLAGS CXXFLAGS FFLAGS CPPFLAGS LDFLAGS LD_LIBRARY_PATH

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PR PATCH] [Updated] tbb: update to 2021.3.0
  2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
                   ` (8 preceding siblings ...)
  2021-07-25 15:26 ` Logarithmus
@ 2021-07-26  1:31 ` Logarithmus
  2022-01-28  7:53 ` ericonr
  2022-01-28  7:53 ` [PR PATCH] [Closed]: " ericonr
  11 siblings, 0 replies; 13+ messages in thread
From: Logarithmus @ 2021-07-26  1:31 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

There is an updated pull request by Logarithmus against master on the void-packages repository

https://github.com/Logarithmus/void-packages tbb-2021
https://github.com/void-linux/void-packages/pull/32166

tbb: update to 2021.3.0
Follow-up of https://github.com/void-linux/void-packages/pull/27746, @thypon & @olafmersmann might be interested.
**TODO** fix reverse dependencies:
- [ ] OpenSubdiv: update to 3.4.4.
- [ ] PrusaSlicer: update to 2.3.3.
- [ ] lender: update to 2.93.1.
- [ ] embree: update to 3.13.0.
- [ ] openimageio: update to 2.2.16.0.
- [ ] openimagedenoise: update to 1.4.1.
- [ ] openvdb: update to 8.1.0.
- [ ] paraview: update to 5.9.1.
- [ ] occt: revbump due to tbb update

#### Have the results of the proposed changes been tested?
- [x] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me


A patch file from https://github.com/void-linux/void-packages/pull/32166.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-tbb-2021-32166.patch --]
[-- Type: text/x-diff, Size: 95408 bytes --]

From 51999c634a46d6797dc0092d849319223ec11646 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 17 Jul 2021 23:57:52 +0300
Subject: [PATCH 01/12] hwloc: add libpciaccess-devel make dependency

---
 srcpkgs/hwloc/template | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/hwloc/template b/srcpkgs/hwloc/template
index 818db269cebb..41747f99f5ab 100644
--- a/srcpkgs/hwloc/template
+++ b/srcpkgs/hwloc/template
@@ -1,10 +1,12 @@
 # Template file for 'hwloc'
 pkgname=hwloc
 version=2.5.0
-revision=1
+revision=2
 build_style=gnu-configure
-hostmakedepends="pkg-config"
-makedepends="cairo-devel ncurses-devel libxml2-devel eudev-libudev-devel"
+make_check_args="VERBOSE=1"
+hostmakedepends="pkg-config automake libtool"
+makedepends="cairo-devel ncurses-devel libxml2-devel libpciaccess-devel eudev-libudev-devel"
+checkdepends="tar"
 short_desc="Portable abstraction of hierarchical hardware architectures"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
 license="BSD-3-Clause"
@@ -16,6 +18,18 @@ case "$XBPS_TARGET_MACHINE" in
 	i686*|x86_64*|ppc64*) makedepends+=" libnuma-devel";;
 esac
 
+do_patch() {
+	# syscall 279 (move_pages) is unavailable inside Github Actions' Docker container,
+	# that's why we skip this test
+	#vsed -e "s/hwloc_get_area_memlocation.c\s//" -e "/hwloc_get_area_memlocation/d" \
+	#	-i tests/hwloc/Makefile.in -i tests/hwloc/Makefile.am
+	vsed -e "/hwloc_get_area_memlocation/d" -i tests/hwloc/Makefile.am
+}
+
+pre_configure() {
+	aclocal
+}
+
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc
 }
@@ -31,7 +45,7 @@ libhwloc_package() {
 
 libhwloc-devel_package() {
 	short_desc+=" - development files"
-	depends="libhwloc>=${version}_${revision}"
+	depends="${makedepends} libhwloc>=${version}_${revision}"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/share/man/man3

From 23b547d61a6f179008fca38a58eed6ed5d54c0d5 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 02:50:26 +0300
Subject: [PATCH 02/12] tbb: update to 2021.3.0.

---
 common/shlibs                                |   6 +-
 srcpkgs/tbb/patches/00-hwloc-2.5.patch       | 367 +++++++++++++++++++
 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch |  52 +++
 srcpkgs/tbb/patches/hostname-usage.patch     |  11 -
 srcpkgs/tbb/patches/musl.patch               |   4 +-
 srcpkgs/tbb/template                         |  63 +---
 6 files changed, 433 insertions(+), 70 deletions(-)
 create mode 100644 srcpkgs/tbb/patches/00-hwloc-2.5.patch
 create mode 100644 srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
 delete mode 100644 srcpkgs/tbb/patches/hostname-usage.patch

diff --git a/common/shlibs b/common/shlibs
index 14c9e6a84e2c..a9b7e1a146c1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2376,12 +2376,10 @@ libanthy-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthydic-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthyinput-unicode.so.0 libanthy-unicode-1.0.0.20201109_1
 libanthygobject-1.0.so.5 ibus-anthy-1.5.6_1
-libtbbmalloc_proxy_debug.so.2 tbb-4.3_1
 libtbbmalloc_proxy.so.2 tbb-4.3_1
 libtbbmalloc.so.2 tbb-4.3_1
-libtbb_debug.so.2 tbb-4.3_1
-libtbb.so.2 tbb-4.3_1
-libtbbmalloc_debug.so.2 tbb-4.3_1
+libtbb.so.12 tbb-2021.3.0_1
+libtbbbind_2_5.so.3 tbb-2021.3.0_1
 libembree.so.2 embree-2.5.1_1
 libgtkimageview.so.0 gtkimageview-1.6.4_1
 libgoocanvas-2.0.so.9 goocanvas-2.0.4_1
diff --git a/srcpkgs/tbb/patches/00-hwloc-2.5.patch b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
new file mode 100644
index 000000000000..9c4c9285c71d
--- /dev/null
+++ b/srcpkgs/tbb/patches/00-hwloc-2.5.patch
@@ -0,0 +1,367 @@
+Adjusted by Artur Sinila <freesoftware@logarithmus.dev>
+
+From e96dbf4b48e689ab810b0428d0858a6abc2c83bd Mon Sep 17 00:00:00 2001
+From: Ivan Kochin <iv.kochin@gmail.com>
+Date: Thu, 1 Jul 2021 15:07:39 +0300
+Subject: [PATCH] Upgrade from HWLOC 2.4 to HWLOC 2.5 (#448)
+
+* Upgrade from HWLOC 2.4 to HWLOC 2.5
+* Introduce tbbbind_2_5 library
+* Remove tbbbind_2_4 library
+* Use the HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING topology flag (introduces as a part of HWLOC 2.5) to restrict topology discovering to process binding
+* Fix testing on Linux
+* Apply review comments
+* Improve wording: variable -> substring
+* Use right tbbbind version for incompatible hwlocs test
+* Rework option semantic
+* Update README.md for CMake
+* Rework readme
+* Update cmake/README.md
+
+Signed-off-by: Kochin, Ivan <kochin.ivan@intel.com>
+
+Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
+---
+ CMakeLists.txt                         |  3 ++-
+ cmake/README.md                        | 11 +++++---
+ cmake/hwloc_detection.cmake            |  9 ++++---
+ src/tbb/governor.cpp                   |  4 +--
+ src/tbbbind/CMakeLists.txt             |  2 +-
+ src/tbbbind/tbb_bind.cpp               | 23 +++++++++++-----
+ test/CMakeLists.txt                    | 30 ++++++++++-----------
+ test/common/common_arena_constraints.h | 37 ++++++++++++++++++++++----
+ 8 files changed, 82 insertions(+), 37 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 34a23d400..301899aca 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -100,6 +100,7 @@ option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Win
+ option(TBB4PY_BUILD "Enable tbb4py build" OFF)
+ option(TBB_CPF "Enable preview features of the library" OFF)
+ option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
++option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
+ 
+ if (NOT DEFINED BUILD_SHARED_LIBS)
+     set(BUILD_SHARED_LIBS ON)
+@@ -195,7 +196,7 @@ else()
+         add_subdirectory(src/tbbmalloc)
+         add_subdirectory(src/tbbmalloc_proxy)
+         if (APPLE)
+-            message(STATUS "TBBBind build target is disabled due to unsupported environment")
++            message(STATUS "TBBBind build targets are disabled due to unsupported environment")
+         else()
+             add_subdirectory(src/tbbbind)
+         endif()
+diff --git a/cmake/README.md b/cmake/README.md
+index 36fc303f9..b58c2ff6a 100644
+--- a/cmake/README.md
++++ b/cmake/README.md
+@@ -13,6 +13,7 @@ TBB4PY_BUILD:BOOL - Enable  Intel(R) oneAPI Threading Building Blocks (oneTBB) P
+ TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
+ TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
+ TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
++TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)
+ ```
+ 
+ ## Configure, build and test
+@@ -42,9 +43,9 @@ Some useful options:
+ 
+ #### TBBBind library configuration
+ 
+-The TBBbind library has two versions: `tbbbind` and `tbbbind_2_0`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.x.
++The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0` and `tbbbind_2_5`. Each of these versions is linked with corresponding HWLOC library version: `tbbbind` links with HWLOC 1.11.x , `tbbbind_2_0` links with HWLOC 2.1-2.4, `tbbbind_2_5` links with HWLOC 2.5 and later.
+ 
+-To enable the TBBBind library build or special tests that performed inside the HWLOC environment, please specify the following CMake variables:
++The search for a suitable version of the HWLOC library is enabled by default, but if you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
+ 
+  - `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux or path to `.lib` file on Windows.
+  - `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version includes directory.
+@@ -52,7 +53,11 @@ To enable the TBBBind library build or special tests that performed inside the H
+ Windows requires one additional variable for correct TBBBind library building:
+  - `CMAKE_HWLOC_<HWLOC_VER>_DLL_PATH` - path to the corresponding HWLOC version `.dll` file.
+ 
+-`HWLOC_VER` variable used above can be replaced with one of the two values: `1_11` for the `tbbbind` library configuration and `2` for the `tbbbind_2_0` library configuration.
++`HWLOC_VER` substring used above can be replaced with one of the three values: `1_11` for the `tbbbind` library configuration, `2` for the `tbbbind_2_0`, and `2_5` for the `tbbbind_2_5` library configuration.
++
++If you specify variables for several TBBBind versions, then building process for all of these versions will be performed during single build session.
++
++Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
+ 
+ ### Build
+ 
+diff --git a/cmake/hwloc_detection.cmake b/cmake/hwloc_detection.cmake
+index e1eeca5fa..de7f3c047 100644
+--- a/cmake/hwloc_detection.cmake
++++ b/cmake/hwloc_detection.cmake
+@@ -12,7 +12,7 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
+-list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_4)
++list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_5)
+ 
+ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
+     if (NOT WIN32)
+@@ -55,10 +56,10 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
+         if (HWLOC_FOUND)
+             if (HWLOC_VERSION VERSION_LESS 2)
+                 set(TBBBIND_LIBRARY_NAME tbbbind)
+-            elseif(HWLOC_VERSION VERSION_LESS 2.4)
++            elseif(HWLOC_VERSION VERSION_LESS 2.5)
+                 set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
+             else()
+-                set(TBBBIND_LIBRARY_NAME tbbbind_2_4)
++                set(TBBBIND_LIBRARY_NAME tbbbind_2_5)
+             endif()
+         endif()
+     endif()
+diff --git a/src/tbb/governor.cpp b/src/tbb/governor.cpp
+index bf4e402d1..b842e075f 100644
+--- a/src/tbb/governor.cpp
++++ b/src/tbb/governor.cpp
+@@ -362,7 +362,7 @@ static const unsigned LinkTableSize = sizeof(TbbBindLinkTable) / sizeof(dynamic_
+ 
+ #define TBBBIND_NAME LIBRARY_PREFIX "tbbbind" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #define TBBBIND_2_0_NAME LIBRARY_PREFIX "tbbbind_2_0" DEBUG_SUFFIX LIBRARY_EXTENSION
+-#define TBBBIND_2_4_NAME LIBRARY_PREFIX "tbbbind_2_4" DEBUG_SUFFIX LIBRARY_EXTENSION
++#define TBBBIND_2_5_NAME LIBRARY_PREFIX "tbbbind_2_5" DEBUG_SUFFIX LIBRARY_EXTENSION
+ #endif /* _WIN32 || _WIN64 || __linux__ */
+ 
+ // Representation of system hardware topology information on the TBB side.
+@@ -389,7 +389,7 @@ const char* load_tbbbind_shared_object() {
+     GetNativeSystemInfo(&si);
+     if (si.dwNumberOfProcessors > 32) return nullptr;
+ #endif /* _WIN32 && !_WIN64 */
+-    for (const auto& tbbbind_version : {TBBBIND_2_4_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
++    for (const auto& tbbbind_version : {TBBBIND_2_5_NAME, TBBBIND_2_0_NAME, TBBBIND_NAME}) {
+         if (dynamic_link(tbbbind_version, TbbBindLinkTable, LinkTableSize)) {
+             return tbbbind_version;
+         }
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index 029893751..e5cdbf8bb 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -99,7 +99,7 @@ if (NOT DEFINED HWLOC_TARGET_EXPLICITLY_DEFINED AND DEFINED HWLOC_LIBRARIES)
+ else()
+     tbbbind_build(tbbbind     HWLOC::hwloc_1_11)
+     tbbbind_build(tbbbind_2_0 HWLOC::hwloc_2   )
+-    tbbbind_build(tbbbind_2_4 HWLOC::hwloc_2_4 )
++    tbbbind_build(tbbbind_2_5 HWLOC::hwloc_2_5 )
+ endif()
+ 
+ 
+diff --git a/src/tbbbind/tbb_bind.cpp b/src/tbbbind/tbb_bind.cpp
+index 97be308c7..88c956acb 100644
+--- a/src/tbbbind/tbb_bind.cpp
++++ b/src/tbbbind/tbb_bind.cpp
+@@ -34,7 +34,8 @@
+ #pragma GCC diagnostic pop
+ #endif
+ 
+-#define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ 
+ // Most of hwloc calls returns negative exit code on error.
+ // This macro tracks error codes that are returned from the hwloc interfaces.
+@@ -85,6 +86,16 @@ class platform_topology {
+         // Parse topology
+         if ( hwloc_topology_init( &topology ) == 0 ) {
+             initialization_state = topology_allocated;
++#if __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++            if ( groups_num == 1 &&
++                 hwloc_topology_set_flags(topology,
++                     HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                     HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
++                 ) != 0
++            ) {
++                return;
++            }
++#endif
+             if ( hwloc_topology_load( topology ) == 0 ) {
+                 initialization_state = topology_loaded;
+             }
+@@ -135,7 +146,7 @@ class platform_topology {
+             numa_indexes_list.resize(numa_nodes_count);
+             hwloc_obj_t node_buffer;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 numa_indexes_list[counter] = static_cast<int>(node_buffer->logical_index);
+ 
+                 if ( numa_indexes_list[counter] > max_numa_index ) {
+@@ -150,7 +161,7 @@ class platform_topology {
+             numa_affinity_masks_list.resize(max_numa_index + 1);
+             int index = 0;
+             hwloc_bitmap_foreach_begin(i, process_node_affinity_mask) {
+-                node_buffer = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, i);
++                node_buffer = hwloc_get_numanode_obj_by_os_index(topology, i);
+                 index = static_cast<int>(node_buffer->logical_index);
+ 
+                 hwloc_cpuset_t& current_mask = numa_affinity_masks_list[index];
+@@ -168,7 +179,7 @@ class platform_topology {
+             core_types_indexes_list.push_back(-1);
+             return;
+         }
+-#if __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
++#if __TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT
+         __TBB_ASSERT(hwloc_get_api_version() >= 0x20400, "Hybrid CPUs support interfaces required HWLOC >= 2.4");
+         // Parsing the hybrid CPU topology
+         int core_types_number = hwloc_cpukinds_get_nr(topology, 0);
+@@ -196,9 +207,9 @@ class platform_topology {
+                 }
+             }
+         }
+-#else /*!__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#else /*!__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+         bool core_types_parsing_broken{true};
+-#endif /*__HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
++#endif /*__TBBBIND_HWLOC_HYBRID_CPUS_INTERFACES_PRESENT*/
+ 
+         if (core_types_parsing_broken) {
+             for (auto& core_type_mask : core_types_affinity_masks_list) {
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index bdae9e2b1..c2b9d6dba 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -275,9 +275,9 @@ function(tbb_add_tbbbind_test)
+         FAIL_REGULAR_EXPRESSION "Status:.*FAILURE"
+     )
+ 
+-    if (TARGET HWLOC::hwloc_2_4 AND NOT HWLOC_2_4_TESTS_STATUS_SHOWN)
+-        message(STATUS "HWLOC 2.4 dependent tests were enabled.")
+-        set(HWLOC_2_4_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
++    if (TARGET HWLOC::hwloc_2_5 AND NOT HWLOC_2_5_TESTS_STATUS_SHOWN)
++        message(STATUS "HWLOC 2.5 dependent tests were enabled.")
++        set(HWLOC_2_5_TESTS_STATUS_SHOWN TRUE PARENT_SCOPE)
+     endif()
+ 
+     if (TARGET HWLOC::hwloc_2 AND NOT HWLOC_2_TESTS_STATUS_SHOWN)
+@@ -291,22 +291,22 @@ function(tbb_add_tbbbind_test)
+     endif()
+ 
+     list(APPEND HWLOC_TEST_CASES
+-        hwloc_2_4
++        hwloc_2_5
+         hwloc_2
+         hwloc_1_11
+-        hwloc_2_4_hwloc_2
+-        hwloc_2_4_hwloc_1_11
++        hwloc_2_5_hwloc_2
++        hwloc_2_5_hwloc_1_11
+         hwloc_2_hwloc_1_11
+-        hwloc_2_4_hwloc_2_hwloc_1_11
++        hwloc_2_5_hwloc_2_hwloc_1_11
+     )
+ 
+-    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_4 "hwloc_2_4")
++    list(APPEND HWLOC_TEST_CASE_0_VARS tbbbind_2_5 "hwloc_2_5")
+     list(APPEND HWLOC_TEST_CASE_1_VARS tbbbind_2   "hwloc_2")
+     list(APPEND HWLOC_TEST_CASE_2_VARS tbbbind     "hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2")
+-    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_4 "hwloc_2_4,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_3_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2")
++    list(APPEND HWLOC_TEST_CASE_4_VARS tbbbind_2_5 "hwloc_2_5,hwloc_1_11")
+     list(APPEND HWLOC_TEST_CASE_5_VARS tbbbind_2   "hwloc_2,hwloc_1_11")
+-    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_4 "hwloc_2_4,hwloc_2,hwloc_1_11")
++    list(APPEND HWLOC_TEST_CASE_6_VARS tbbbind_2_5 "hwloc_2_5,hwloc_2,hwloc_1_11")
+ 
+     foreach(TEST_CASE ${HWLOC_TEST_CASES})
+         list(FIND HWLOC_TEST_CASES ${TEST_CASE} TEST_CASE_INDEX)
+@@ -331,7 +331,7 @@ endfunction()
+ # Copy libraries to test folder to make it visible during tests execution if external TBB is tested.
+ # TODO: check and update for multi-config generators.
+ if (TBB_FOUND)
+-    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_4)
++    list(APPEND _tbb_test_components tbb tbbmalloc tbbmalloc_proxy tbbbind tbbbind_2_0 tbbbind_2_5)
+     foreach(_component ${_tbb_test_components})
+         if (TARGET TBB::${_component})
+             get_property(${_component}_lib_file_location TARGET TBB::${_component} PROPERTY LOCATION)
+@@ -593,6 +593,6 @@ if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
+     tbb_add_test(SUBDIR tbbmalloc NAME test_malloc_new_handler DEPENDENCIES TBB::tbbmalloc_proxy)
+ endif()
+ 
+-unset(HWLOC_2_4_TESTS_STATUS_SHOWN)
++unset(HWLOC_2_5_TESTS_STATUS_SHOWN)
+ unset(HWLOC_2_TESTS_STATUS_SHOWN)
+ unset(HWLOC_1_11_TESTS_STATUS_SHOWN)
+diff --git a/test/common/common_arena_constraints.h b/test/common/common_arena_constraints.h
+index 2a0b1ea97..5efc71082 100644
+--- a/test/common/common_arena_constraints.h
++++ b/test/common/common_arena_constraints.h
+@@ -38,9 +38,26 @@
+ 
+ #if (_WIN32 || _WIN64) && __TBB_HWLOC_VALID_ENVIRONMENT
+ #include <windows.h>
+-int get_processors_groups_count() { return GetActiveProcessorGroupCount(); }
++int get_processors_group_count() {
++    SYSTEM_INFO si;
++    GetNativeSystemInfo(&si);
++    DWORD_PTR pam, sam, m = 1;
++    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
++    int nproc = 0;
++    for ( std::size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
++        if ( pam & m )
++            ++nproc;
++    }
++    // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present
++    if ( nproc == (int)si.dwNumberOfProcessors  ) {
++        // The process does not have restricting affinity mask and multiple processor groups are possible
++        return (int)GetActiveProcessorGroupCount();
++    } else {
++        return 1;
++    }
++}
+ #else
+-int get_processors_groups_count() { return 1; }
++int get_processors_group_count() { return 1; }
+ #endif
+ 
+ //TODO: Write a test that checks for memory leaks during dynamic link/unlink of TBBbind.
+@@ -69,6 +86,7 @@ int get_processors_groups_count() { return 1; }
+ #endif
+ 
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT (HWLOC_API_VERSION >= 0x20400)
++#define __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT (HWLOC_API_VERSION >= 0x20500)
+ // At this moment the hybrid CPUs HWLOC interfaces returns unexpected results on some Windows machines
+ // in the 32-bit arch mode.
+ #define __HWLOC_HYBRID_CPUS_INTERFACES_VALID (!_WIN32 || _WIN64)
+@@ -153,9 +171,18 @@ class system_info {
+ 
+     system_info() {
+         hwloc_require_ex(hwloc_topology_init, &topology);
++#if __HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
++        if ( get_processors_group_count() == 1 ) {
++            REQUIRE(
++                hwloc_topology_set_flags(topology,
++                    HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
++                    HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING) == 0
++            );
++        }
++#endif
+         hwloc_require_ex(hwloc_topology_load, topology);
+ 
+-        if ( get_processors_groups_count() > 1 ) {
++        if ( get_processors_group_count() > 1 ) {
+             process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
+         } else {
+             process_cpuset = hwloc_bitmap_alloc();
+@@ -434,7 +461,7 @@ system_info::affinity_mask get_arena_affinity(tbb::task_arena& ta) {
+                 barrier.wait();
+                 tbb::spin_mutex::scoped_lock lock(affinity_mutex);
+                 system_info::affinity_mask thread_affinity = system_info::allocate_current_affinity_mask();
+-                if (get_processors_groups_count() == 1) {
++                if (get_processors_group_count() == 1) {
+                     REQUIRE_MESSAGE(hwloc_bitmap_isequal(thread_affinity, arena_affinity),
+                         "Threads have different masks on machine without several processors groups.");
+                 }
+@@ -532,7 +559,7 @@ constraints_container generate_constraints_variety() {
+         }
+ 
+         // Some constraints may cause unexpected behavior, which would be fixed later.
+-        if (get_processors_groups_count() > 1) {
++        if (get_processors_group_count() > 1) {
+             for(auto it = results.begin(); it != results.end(); ++it) {
+                 if (it->max_threads_per_core != tbb::task_arena::automatic
+                    && (it->numa_id == tbb::task_arena::automatic || tbb::info::numa_nodes().size() == 1)
diff --git a/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
new file mode 100644
index 000000000000..279ebc4397cd
--- /dev/null
+++ b/srcpkgs/tbb/patches/01-hwloc-pkgconfig.patch
@@ -0,0 +1,52 @@
+Based on https://github.com/oneapi-src/oneTBB/pull/498
+Tweaked a bit to work on `v2021.3.0`
+
+diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt
+index e5cdbf8bb..a4033210a 100644
+--- a/src/tbbbind/CMakeLists.txt
++++ b/src/tbbbind/CMakeLists.txt
+@@ -37,6 +37,10 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+         ${HWLOC_INCLUDE_DIRS} # pkg-config defined
+     )
++	target_link_directories(${TBBBIND_NAME}
++		PRIVATE
++		${HWLOC_LIBRARY_DIRS} # pkg-config defined
++	)
+ 
+     target_compile_options(${TBBBIND_NAME}
+         PRIVATE
+@@ -69,7 +69,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     else()
+         target_link_libraries(${TBBBIND_NAME}
+@@ -76,7 +76,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET)
+             PRIVATE
+             ${TBB_LIB_LINK_FLAGS}
+             ${TBB_COMMON_LINK_FLAGS}
+-            ${HWLOC_LIBRARY_DIRS} # pkg-config defined
+         )
+     endif()
+ 
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index b768759d5..3eb8357e6 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -258,7 +258,12 @@ function(tbb_add_tbbbind_test)
+         )
+         set_property(
+             TARGET ${_tbbbind_test_NAME}
+-            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARY_DIRS} ${HWLOC_LIBRARIES}
++            PROPERTY LINK_LIBRARIES ${HWLOC_LIBRARIES}
++            APPEND
++        )
++        set_property(
++            TARGET ${_tbbbind_test_NAME}
++			PROPERTY LINK_DIRECTORIES ${HWLOC_LIBRARY_DIRS}
+             APPEND
+         )
+         set_property(
diff --git a/srcpkgs/tbb/patches/hostname-usage.patch b/srcpkgs/tbb/patches/hostname-usage.patch
deleted file mode 100644
index 4aefeff192b5..000000000000
--- a/srcpkgs/tbb/patches/hostname-usage.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/build/version_info_linux.sh
-+++ b/build/version_info_linux.sh
-@@ -20,7 +20,7 @@
- 
- # Script used to generate version info string
- echo "#define __TBB_VERSION_STRINGS(N) \\"
--echo '#N": BUILD_HOST'"\t\t"`hostname -s`" ("`uname -m`")"'" ENDL \'
-+echo '#N": BUILD_HOST'"\t\t"`hostname`" ("`uname -m`")"'" ENDL \'
- # find OS name in *-release and issue* files by filtering blank lines and lsb-release content out
- echo '#N": BUILD_OS'"\t\t"`lsb_release -sd 2>/dev/null | grep -ih '[a-z] ' - /etc/*release /etc/issue 2>/dev/null | head -1 | sed -e 's/["\\\\]//g'`'" ENDL \'
- echo '#N": BUILD_KERNEL'"\t"`uname -srv`'" ENDL \'
diff --git a/srcpkgs/tbb/patches/musl.patch b/srcpkgs/tbb/patches/musl.patch
index a8867eb53793..ec89c6a95fc6 100644
--- a/srcpkgs/tbb/patches/musl.patch
+++ b/srcpkgs/tbb/patches/musl.patch
@@ -1,5 +1,5 @@
---- a/src/tbbmalloc/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
-+++ b/src/tbbmalloc/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
+--- a/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:05:31.311723013 +0200
++++ b/src/tbbmalloc_proxy/proxy.cpp	2018-10-17 14:06:32.972726194 +0200
 @@ -28,6 +28,7 @@
  // of aligned_alloc as required by new C++ standard, this makes it hard to
  // redefine aligned_alloc here. However, running on systems with new libc
diff --git a/srcpkgs/tbb/template b/srcpkgs/tbb/template
index aeef6ebdd061..47655829f744 100644
--- a/srcpkgs/tbb/template
+++ b/srcpkgs/tbb/template
@@ -1,76 +1,33 @@
 # Template file for 'tbb'
 pkgname=tbb
-version=2020.U3
+version=2021.3.0
 revision=1
-# version rewrite: 2017_U7 (upstream) => 2017.7 (xbps)
-_ver=${version/./_}
-wrksrc="oneTBB-${_ver}"
-build_style=gnu-makefile
-hostmakedepends="cmake"
+wrksrc="oneTBB-${version}"
+build_style=cmake
+makedepends="libhwloc-devel libgomp-devel"
 short_desc="Intel Threading Building Blocks"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
 license="Apache-2.0"
 homepage="https://www.threadingbuildingblocks.org"
-distfiles="https://github.com/oneapi-src/oneTBB/archive/${_ver}.tar.gz"
-checksum=2103cc6238c935664f87680618f6684d57501d4a2fa8ea8f6c97ad6ff7dc722a
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*)
-		make_build_args="arch=intel64"
-		;;
-	i686*)
-		make_build_args="arch=ia32"
-		;;
-	armv7l*)
-		make_build_args="arch=armv7"
-		;;
-	aarch64*)
-		make_build_args="arch=arm64"
-		;;
-	ppc64*)
-		make_build_args="arch=ppc64"
-		;;
-	ppc*)
-		make_build_args="arch=ppc32"
-		;;
-	*)
-		# make sure to fall back instead of letting host uname control it
-		make_build_args="arch=generic"
-		;;
-esac
-
-post_extract() {
-	sed -i 's|CPLUS = g..|CPLUS = $(CXX)|g' build/linux.gcc.inc
-	sed -i 's|CONLY = gcc|CONLY = $(CC)|g' build/linux.gcc.inc
+distfiles="https://github.com/oneapi-src/oneTBB/archive/v${version}.tar.gz"
+checksum=8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e
 
+pre_patch() {
 	# alternative might be:
 	# https://git.alpinelinux.org/cgit/aports/tree/testing/libtbb/glibc-struct-mallinfo.patch
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		vsed -e "s@#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__@@" \
-		  -i src/tbbmalloc/proxy.h
+		  -i src/tbbmalloc_proxy/proxy.h
 	fi
 }
 
-do_install() {
-	vmkdir usr/lib
-	vcopy build/linux_*/*.so* usr/lib
-	vmkdir usr/include/tbb
-	vcopy include/tbb/* usr/include/tbb
-
-	cmake \
-		-DINSTALL_DIR=$DESTDIR/usr/lib/cmake/TBB \
-		-DSYSTEM_NAME=Linux \
-		-DLIB_REL_PATH=../.. \
-		-DINC_REL_PATH=../../../include \
-		-P cmake/tbb_config_installer.cmake
-}
-
 tbb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
-		vmove "usr/lib/*.so"
 		vmove usr/lib/cmake
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.so
 	}
 }

From 14ee649b010ed4a2f0f2640ffb83091048697adc Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 03/12] OpenSubdiv: update to 3.4.4.

---
 common/shlibs                                |  4 +--
 srcpkgs/OpenSubdiv-doc                       |  1 +
 srcpkgs/OpenSubdiv-tools                     |  1 +
 srcpkgs/OpenSubdiv/patches/00-tbb-2021.patch | 29 ++++++++++++++++++++
 srcpkgs/OpenSubdiv/template                  | 29 ++++++++++++++++----
 5 files changed, 57 insertions(+), 7 deletions(-)
 create mode 120000 srcpkgs/OpenSubdiv-doc
 create mode 120000 srcpkgs/OpenSubdiv-tools
 create mode 100644 srcpkgs/OpenSubdiv/patches/00-tbb-2021.patch

diff --git a/common/shlibs b/common/shlibs
index a9b7e1a146c1..6860088fc0d1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3868,8 +3868,8 @@ librdkafka++.so.1 librdkafka-1.4.4_3
 libco.so.0 libco-20_1
 libraft.so.0 raft-0.9.16_1
 libmdnsd.so.1 libmdnsd-0.9_1
-libosdGPU.so.3.4.3 OpenSubdiv-3.4.3_1
-libosdCPU.so.3.4.3 OpenSubdiv-3.4.3_1
+libosdGPU.so.3.4.4 OpenSubdiv-3.4.4_1
+libosdCPU.so.3.4.4 OpenSubdiv-3.4.4_1
 libdino.so.0 dino-0.1.0_1
 libxmpp-vala.so.0 dino-0.1.0_1
 libqlite.so.0 dino-0.1.0_1
diff --git a/srcpkgs/OpenSubdiv-doc b/srcpkgs/OpenSubdiv-doc
new file mode 120000
index 000000000000..3b6ad59f809a
--- /dev/null
+++ b/srcpkgs/OpenSubdiv-doc
@@ -0,0 +1 @@
+OpenSubdiv
\ No newline at end of file
diff --git a/srcpkgs/OpenSubdiv-tools b/srcpkgs/OpenSubdiv-tools
new file mode 120000
index 000000000000..3b6ad59f809a
--- /dev/null
+++ b/srcpkgs/OpenSubdiv-tools
@@ -0,0 +1 @@
+OpenSubdiv
\ No newline at end of file
diff --git a/srcpkgs/OpenSubdiv/patches/00-tbb-2021.patch b/srcpkgs/OpenSubdiv/patches/00-tbb-2021.patch
new file mode 100644
index 000000000000..5a812c84b211
--- /dev/null
+++ b/srcpkgs/OpenSubdiv/patches/00-tbb-2021.patch
@@ -0,0 +1,29 @@
+diff --git a/opensubdiv/osd/tbbEvaluator.cpp b/opensubdiv/osd/tbbEvaluator.cpp
+index c98db9f..8dec0e1 100644
+--- a/opensubdiv/osd/tbbEvaluator.cpp
++++ b/opensubdiv/osd/tbbEvaluator.cpp
+@@ -25,7 +25,7 @@
+ #include "../osd/tbbEvaluator.h"
+ #include "../osd/tbbKernel.h"
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/global_control.h>
+ 
+ namespace OpenSubdiv {
+ namespace OPENSUBDIV_VERSION {
+@@ -215,10 +215,11 @@ TbbEvaluator::Synchronize(void *) {
+ /* static */
+ void
+ TbbEvaluator::SetNumThreads(int numThreads) {
+-    if (numThreads == -1) {
+-        tbb::task_scheduler_init init;
+-    } else {
+-        tbb::task_scheduler_init init(numThreads);
++    if (numThreads != -1) {
++		tbb::global_control tbb_global_control(
++			tbb::global_control::max_allowed_parallelism,
++			numThreads
++		);
+     }
+ }
+ 
diff --git a/srcpkgs/OpenSubdiv/template b/srcpkgs/OpenSubdiv/template
index b7a5e16efbcf..549b353c391d 100644
--- a/srcpkgs/OpenSubdiv/template
+++ b/srcpkgs/OpenSubdiv/template
@@ -1,25 +1,44 @@
 # Template file for 'OpenSubdiv'
 pkgname=OpenSubdiv
-version=3.4.3
+version=3.4.4
 revision=1
 wrksrc="OpenSubdiv-${version//./_}"
 build_style=cmake
-configure_args="-DOpenGL_GL_PREFERENCE=GLVND"
-# TODO: CUDA/OpenCL support
+# TODO: CUDA support
+# NO_GLTESTS: skip tests which require X11 & $DISPLAY environment variable
+configure_args="-DNO_GLTESTS=1 -DNO_CUDA=1"
+hostmakedepends="doxygen"
 makedepends="libXrandr-devel libXinerama-devel libXcursor-devel zlib-devel
- libgomp-devel glfw-devel glew-devel tbb-devel"
+ libgomp-devel glfw-devel glew-devel tbb-devel ptex-devel opencl-headers ocl-icd-devel"
 short_desc="Open-Source subdivision surface library"
 maintainer="John <me@johnnynator.dev>"
 license="Apache-2.0"
 homepage="http://graphics.pixar.com/opensubdiv/docs/intro.html"
 distfiles="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${version//./_}.tar.gz"
-checksum=7b22eb27d636ab0c1e03722c7a5a5bd4f11664ee65c9b48f341a6d0ce7f36745
+checksum=20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" OpenSubdiv"
 	configure_args+=" -DSTRINGIFY_LOCATION=/usr/bin/stringify"
 fi
 
+OpenSubdiv-tools_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - tools"
+	pkg_install() {
+		vmove usr/bin
+	}
+}
+
+OpenSubdiv-doc_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - documentation"
+	nostrip=yes
+	pkg_install() {
+		vmove usr/share/doc
+	}
+}
+
 OpenSubdiv-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}"
 	short_desc+=" - development files"

From 3b6cf9639eee12a35082c7db263f9b6a3a2bfdb2 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:38 +0300
Subject: [PATCH 04/12] PrusaSlicer: update to 2.3.3.

---
 srcpkgs/PrusaSlicer/patches/cross.patch | 11 -----------
 srcpkgs/PrusaSlicer/template            |  4 ++--
 2 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 srcpkgs/PrusaSlicer/patches/cross.patch

diff --git a/srcpkgs/PrusaSlicer/patches/cross.patch b/srcpkgs/PrusaSlicer/patches/cross.patch
deleted file mode 100644
index d64a450d9e9f..000000000000
--- a/srcpkgs/PrusaSlicer/patches/cross.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/avrdude/CMakeLists.txt	2020-06-04 09:19:26.017251215 +0200
-+++ b/src/avrdude/CMakeLists.txt	2020-06-04 09:19:36.468250771 +0200
-@@ -83,7 +83,7 @@ add_executable(avrdude-conf-gen conf-gen
- add_custom_command(
-     DEPENDS avrdude-conf-gen ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf
-     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
--    COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-+    COMMAND avrdude-conf-gen avrdude-slic3r.conf avrdude_slic3r_conf ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
-     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- 
diff --git a/srcpkgs/PrusaSlicer/template b/srcpkgs/PrusaSlicer/template
index dd0e76cb8017..a93832ac02e4 100644
--- a/srcpkgs/PrusaSlicer/template
+++ b/srcpkgs/PrusaSlicer/template
@@ -1,6 +1,6 @@
 # Template file for 'PrusaSlicer'
 pkgname=PrusaSlicer
-version=2.3.0
+version=2.3.3
 revision=1
 wrksrc="PrusaSlicer-version_${version}"
 build_style=cmake
@@ -16,7 +16,7 @@ maintainer="Jasper Chan <jasperchan515@gmail.com>"
 license="GPL-3.0-or-later"
 homepage="https://www.prusa3d.com/prusaslicer/"
 distfiles="https://github.com/prusa3d/Prusaslicer/archive/version_${version}.tar.gz"
-checksum=cd3bac5e29b5441fc4690f28cd7b1064e97dc00207bbdc88f7bd7832308d6ca5
+checksum=deda209505f740ac3d6f59cb2a960f4df908269ee09bd30cd4edb9fc472d29ac
 nocross="https://build.voidlinux.org/builders/armv7l_builder/builds/25230/steps/shell_3/logs/stdio"
 
 Slic3rPE_package() {

From 1b6b65d3d681d18b8392561da187c8a07d425c57 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 05/12] blender: update to 2.93.1.

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index af946c2b7999..8318317c82bf 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,6 +1,6 @@
 # Template file for 'blender'
 pkgname=blender
-version=2.93.0
+version=2.93.1
 revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"

From d5d85a0c3b2a397161fce2f41f8bcb2a14a13a43 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 06/12] embree: update to 3.13.0.

---
 srcpkgs/embree/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/embree/template b/srcpkgs/embree/template
index 575b9bcb401c..b6f376d30efa 100644
--- a/srcpkgs/embree/template
+++ b/srcpkgs/embree/template
@@ -1,8 +1,8 @@
 # Template file for 'embree'
 pkgname=embree
-version=2.17.7
-revision=2
-archs="x86_64"
+version=3.13.0
+revision=1
+archs="x86_64*"
 build_style=cmake
 configure_args="-DTBB_ROOT=/usr -DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF"
 hostmakedepends="ispc"

From 75d0e3e13353a33bf78c62474ddc6cb2018be504 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sat, 24 Jul 2021 03:34:43 +0300
Subject: [PATCH 07/12] openimageio: update to 2.2.16.0.

---
 srcpkgs/openimageio/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index de8e1cd04409..3bfdd4e0ed1e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,11 +1,11 @@
 # Template file for 'openimageio'
 pkgname=openimageio
-version=2.2.15.1
+version=2.2.16.0
 revision=1
 wrksrc="oiio-Release-${version}"
 build_style=cmake
 configure_args="-DUSE_OPENGL=0 -DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=1
- -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0"
+ -DSTOP_ON_WARNING=0 -DUSE_STD_REGEX_EXITCODE=0 -DCMAKE_CXX_STANDARD=14"
 hostmakedepends="pkg-config git"
 makedepends="boost-devel giflib-devel libraw-devel libopenjpeg-devel libwebp-devel
  libjpeg-turbo-devel tiff-devel libpng-devel libopenexr-devel freetype-devel
@@ -17,7 +17,7 @@ license="BSD-3-Clause"
 homepage="https://sites.google.com/site/openimageio/home"
 changelog="https://raw.githubusercontent.com/OpenImageIO/oiio/release/CHANGES.md"
 distfiles="https://github.com/OpenImageIO/oiio/archive/Release-${version}.tar.gz"
-checksum=f222c6b51a40aabbc80ddf4055535be9af1ffa907452fa6d1ffa7674854aab17
+checksum=d1a59f32dbba3ba71ad2e62e107034d1c5287bca1b0696474e927d504cd05ef4
 # Runs checks even for features we disabled.
 make_check=no
 

From 4a0c1d1246c59cd250314d8afd90b096e2d424f8 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 08/12] openimagedenoise: update to 1.4.1.

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index c73913b4e9d7..14055aff1c27 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,6 +1,6 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
-version=1.4.0
+version=1.4.1
 revision=1
 archs="x86_64*"
 wrksrc=oidn-${version}

From ec2f6b22ea4b77f3d7e54640dedb0e92680c0c67 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 09/12] openvdb: update to 8.1.0.

---
 common/shlibs                             |    2 +-
 srcpkgs/openvdb/patches/00-tbb-2021.patch | 1320 +++++++++++++++++++++
 srcpkgs/openvdb/template                  |   16 +-
 3 files changed, 1325 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/openvdb/patches/00-tbb-2021.patch

diff --git a/common/shlibs b/common/shlibs
index 6860088fc0d1..29f191b645f5 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3883,7 +3883,7 @@ libjanet.so.1.16 janet-1.16.0_1
 libOpenImageDenoise.so.1 openimagedenoise-1.3.0_1
 libcbang0.so cbang-1.6.0_3
 libblosc.so.1 c-blosc-1.17.1_1
-libopenvdb.so.7.0 openvdb-7.0.0_1
+libopenvdb.so.8.1 openvdb-8.1.0_1
 libAlembic.so.1.7 alembic-1.7.13_1
 libmodsecurity.so.3 modsecurity-3.0.4_1
 libraven.so.0 budgie-desktop-10.5.1_1
diff --git a/srcpkgs/openvdb/patches/00-tbb-2021.patch b/srcpkgs/openvdb/patches/00-tbb-2021.patch
new file mode 100644
index 000000000000..271104af3df9
--- /dev/null
+++ b/srcpkgs/openvdb/patches/00-tbb-2021.patch
@@ -0,0 +1,1320 @@
+https://github.com/AcademySoftwareFoundation/openvdb/pull/1027
+Should be dropped after 8.1.1 release.
+
+diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake
+index d41436b1c..06de2b3f3 100644
+--- a/cmake/FindTBB.cmake
++++ b/cmake/FindTBB.cmake
+@@ -169,8 +169,22 @@ find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
+   PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR} include
+ )
+ 
+-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" ""
+@@ -178,7 +192,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" ""
+@@ -192,6 +206,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
+ # ------------------------------------------------------------------------
+diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt
+index 88543df3a..929fe94d1 100644
+--- a/openvdb/openvdb/CMakeLists.txt
++++ b/openvdb/openvdb/CMakeLists.txt
+@@ -437,6 +437,10 @@ set(OPENVDB_LIBRARY_UTIL_INCLUDE_FILES
+   util/Util.h
+ )
+ 
++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} DESTINATION ${OPENVDB_INST
+ 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)
+diff --git a/openvdb/openvdb/cmd/openvdb_render.cc b/openvdb/openvdb/cmd/openvdb_render.cc
+index ee5b737c5..2c9831ba3 100644
+--- a/openvdb/openvdb/cmd/openvdb_render.cc
++++ b/openvdb/openvdb/cmd/openvdb_render.cc
+@@ -19,7 +19,14 @@
+ #include <OpenEXR/ImfHeader.h>
+ #include <OpenEXR/ImfOutputFile.h>
+ #include <OpenEXR/ImfPixelType.h>
+-#include <tbb/task_scheduler_init.h>
++
++// 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 <tbb/global_control.h>
+ #include <tbb/tick_count.h>
+ 
+ #include <algorithm>
+@@ -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<tbb::global_control> 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();
+ 
+diff --git a/openvdb/openvdb/io/Queue.cc b/openvdb/openvdb/io/Queue.cc
+index ef5d2961a..20ff1a0c1 100644
+--- a/openvdb/openvdb/io/Queue.cc
++++ b/openvdb/openvdb/io/Queue.cc
+@@ -5,20 +5,22 @@
+ /// @author Peter Cucka
+ 
+ #include "Queue.h"
+-
+ #include "File.h"
+ #include "Stream.h"
+-#include <openvdb/Exceptions.h>
+-#include <openvdb/util/logging.h>
++#include "openvdb/Exceptions.h"
++#include "openvdb/util/logging.h"
++
+ #include <tbb/concurrent_hash_map.h>
+-#include <tbb/task.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
+-#include <tbb/tick_count.h>
++#include <tbb/task_arena.h>
++
++#include <thread>
+ #include <algorithm> // for std::max()
+ #include <atomic>
+ #include <iostream>
+ #include <map>
+ #include <mutex>
++#include <chrono>
++
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -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
+ 
+ 
+ // 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
+         : 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
+             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<Queue::Id, Queue::Status>;
+ 
+-
+     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::milliseconds>(
++                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;
+ }
+ 
+diff --git a/openvdb/openvdb/math/Coord.h b/openvdb/openvdb/math/Coord.h
+index 504b5e9a4..2e9cfed5d 100644
+--- a/openvdb/openvdb/math/Coord.h
++++ b/openvdb/openvdb/math/Coord.h
+@@ -13,8 +13,7 @@
+ #include "Math.h"
+ #include "Vec3.h"
+ 
+-namespace tbb { class split; } // forward declaration
+-
++#include <tbb/blocked_range.h> // for tbb::split
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+diff --git a/openvdb/openvdb/points/PointSample.h b/openvdb/openvdb/points/PointSample.h
+index a122cc4fb..27ec3fb29 100644
+--- a/openvdb/openvdb/points/PointSample.h
++++ b/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 <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tools/Interpolation.h>
++#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 <sstream>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -299,7 +299,7 @@ class PointDataSampler
+             using TargetHandleT = AttributeWriteHandle<typename SamplerWrapperT::ValueType>;
+ 
+             if (util::wasInterrupted(interrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return;
+             }
+ 
+diff --git a/openvdb/openvdb/thread/Threading.h b/openvdb/openvdb/thread/Threading.h
+new file mode 100644
+index 000000000..0c3b356e3
+--- /dev/null
++++ b/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 <tbb/blocked_range.h>
++#include <tbb/task.h>
++#include <tbb/task_group.h>
++
++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
+diff --git a/openvdb/openvdb/tools/Composite.h b/openvdb/openvdb/tools/Composite.h
+index 6bc170bf7..88ff86f9f 100644
+--- a/openvdb/openvdb/tools/Composite.h
++++ b/openvdb/openvdb/tools/Composite.h
+@@ -24,7 +24,6 @@
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include <type_traits>
+ #include <functional>
+diff --git a/openvdb/openvdb/tools/Diagnostics.h b/openvdb/openvdb/tools/Diagnostics.h
+index 694d2155f..e5844e448 100644
+--- a/openvdb/openvdb/tools/Diagnostics.h
++++ b/openvdb/openvdb/tools/Diagnostics.h
+@@ -11,14 +11,17 @@
+ #ifndef OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_DIAGNOSTICS_HAS_BEEN_INCLUDED
+ 
+-#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/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 <tbb/blocked_range.h>
+ #include <tbb/parallel_reduce.h>
++
+ #include <cmath> // for std::isnan(), std::isfinite()
+ #include <set>
+ #include <sstream>
+@@ -26,7 +29,6 @@
+ #include <type_traits>
+ #include <vector>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -1160,13 +1162,13 @@ InactiveVoxelValues<TreeType>::operator()(const tbb::blocked_range<size_t>& rang
+ {
+     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<typename TreeType>
+ inline void
+ InactiveTileValues<TreeType>::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();
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/tools/Filter.h b/openvdb/openvdb/tools/Filter.h
+index 408c75541..b70212520 100644
+--- a/openvdb/openvdb/tools/Filter.h
++++ b/openvdb/openvdb/tools/Filter.h
+@@ -14,21 +14,24 @@
+ #ifndef OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_FILTER_HAS_BEEN_INCLUDED
+ 
+-#include <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
++#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 <tbb/parallel_for.h>
++#include <tbb/concurrent_vector.h>
++
+ #include <algorithm> // for std::max()
+ #include <functional>
+ #include <type_traits>
+-#include <tbb/concurrent_vector.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -833,7 +836,7 @@ inline bool
+ Filter<GridT, MaskT, InterruptT>::wasInterrupted()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return true;
+     }
+     return false;
+diff --git a/openvdb/openvdb/tools/GridOperators.h b/openvdb/openvdb/tools/GridOperators.h
+index 31305a1ab..78fafead9 100644
+--- a/openvdb/openvdb/tools/GridOperators.h
++++ b/openvdb/openvdb/tools/GridOperators.h
+@@ -9,14 +9,15 @@
+ #ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/Grid.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
++#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 <tbb/parallel_for.h>
+ 
++#include <tbb/parallel_for.h>
+ 
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+@@ -383,7 +384,9 @@ class GridOperator
+     /// 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) {
+diff --git a/openvdb/openvdb/tools/LevelSetMeasure.h b/openvdb/openvdb/tools/LevelSetMeasure.h
+index efe19074d..59969cdcf 100644
+--- a/openvdb/openvdb/tools/LevelSetMeasure.h
++++ b/openvdb/openvdb/tools/LevelSetMeasure.h
+@@ -8,18 +8,21 @@
+ #ifndef OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_LEVELSETMEASURE_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/math/Math.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/Grid.h>
+-#include <openvdb/tree/LeafManager.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/math/FiniteDifference.h>
+-#include <openvdb/math/Operators.h>
+-#include <openvdb/math/Stencils.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
+ #include <tbb/parallel_sort.h>
+ #include <tbb/parallel_invoke.h>
++
+ #include <type_traits>
+ 
+ namespace openvdb {
+@@ -329,7 +332,7 @@ inline bool
+ LevelSetMeasure<GridT, InterruptT>::checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/LevelSetTracker.h b/openvdb/openvdb/tools/LevelSetTracker.h
+index cbdc267e8..bfc8004e7 100644
+--- a/openvdb/openvdb/tools/LevelSetTracker.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.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/Grid.h>
+-#include <openvdb/util/NullInterrupter.h>
+-#include <openvdb/tree/ValueAccessor.h>
+-#include <openvdb/tree/LeafManager.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ #include <type_traits>
+ 
+-
+ namespace openvdb {
+ OPENVDB_USE_VERSION_NAMESPACE
+ namespace OPENVDB_VERSION_NAME {
+@@ -383,7 +385,7 @@ LevelSetTracker<GridT, InterruptT>::
+ checkInterrupter()
+ {
+     if (util::wasInterrupted(mInterrupter)) {
+-        tbb::task::self().cancel_group_execution();
++        thread::cancelGroupExecution();
+         return false;
+     }
+     return true;
+diff --git a/openvdb/openvdb/tools/MeshToVolume.h b/openvdb/openvdb/tools/MeshToVolume.h
+index 6643c8f05..de3406eda 100644
+--- a/openvdb/openvdb/tools/MeshToVolume.h
++++ b/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 <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/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 <tbb/parallel_reduce.h>
+ #include <tbb/partitioner.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm> // for std::sort()
+ #include <cmath> // 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<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+@@ -1989,7 +1990,7 @@ class VoxelizePolygons
+         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
+ 
+         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) {
+diff --git a/openvdb/openvdb/tools/Morphology.h b/openvdb/openvdb/tools/Morphology.h
+index 736982ef5..0a1e71009 100644
+--- a/openvdb/openvdb/tools/Morphology.h
++++ b/openvdb/openvdb/tools/Morphology.h
+@@ -24,7 +24,7 @@
+ #include "openvdb/tree/ValueAccessor.h"
+ #include "openvdb/tree/LeafManager.h"
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ 
+@@ -726,7 +726,7 @@ void Morphology<TreeType>::dilateVoxels(const size_t iter,
+         }
+ 
+         // @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
+diff --git a/openvdb/openvdb/tools/ParticlesToLevelSet.h b/openvdb/openvdb/tools/ParticlesToLevelSet.h
+index 739af2b69..f9c19911c 100644
+--- a/openvdb/openvdb/tools/ParticlesToLevelSet.h
++++ b/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 <tbb/parallel_reduce.h>
+-#include <tbb/blocked_range.h>
+-#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/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 <tbb/parallel_reduce.h>
++#include <tbb/blocked_range.h>
++
+ #include <functional>
+ #include <iostream>
+ #include <type_traits>
+@@ -738,7 +742,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         for (Coord c = lo; c.x() <= hi.x(); ++c.x()) {
+             //only check interrupter every 32'th scan in x
+             if (!(count++ & ((1<<5)-1)) && util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Real x2 = math::Pow2(c.x() - P[0]);
+@@ -804,7 +808,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
+         // Densely fill the remaining regions.
+         for (const auto& bbox: padding) {
+             if (util::wasInterrupted(mParent.mInterrupter)) {
+-                tbb::task::self().cancel_group_execution();
++                thread::cancelGroupExecution();
+                 return false;
+             }
+             const Coord &bmin = bbox.min(), &bmax = bbox.max();
+diff --git a/openvdb/openvdb/tools/PointAdvect.h b/openvdb/openvdb/tools/PointAdvect.h
+index 12b1177ad..e487bfb3e 100644
+--- a/openvdb/openvdb/tools/PointAdvect.h
++++ b/openvdb/openvdb/tools/PointAdvect.h
+@@ -10,16 +10,19 @@
+ #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
+ 
+-#include <openvdb/openvdb.h>
+-#include <openvdb/math/Math.h>             // min
+-#include <openvdb/Types.h>                 // Vec3 types and version number
+-#include <openvdb/Grid.h>                  // grid
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/blocked_range.h>             // threading
+ #include <tbb/parallel_for.h>              // threading
+ #include <tbb/task.h>                      // for cancel
++
+ #include <vector>
+ 
+ 
+@@ -167,7 +170,7 @@ class PointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityFieldIntegrator  velField(*mVelGrid);
+@@ -307,7 +310,7 @@ class ConstrainedPointAdvect
+     void operator() (const tbb::blocked_range<size_t> &range) const
+     {
+         if (mInterrupter && mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+         }
+ 
+         VelocityIntegratorType velField(*mVelGrid);
+diff --git a/openvdb/openvdb/tools/PointIndexGrid.h b/openvdb/openvdb/tools/PointIndexGrid.h
+index e9ebf96f7..b2e378a79 100644
+--- a/openvdb/openvdb/tools/PointIndexGrid.h
++++ b/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 <openvdb/version.h>
+@@ -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;
+         }
+ 
+diff --git a/openvdb/openvdb/tools/PointPartitioner.h b/openvdb/openvdb/tools/PointPartitioner.h
+index ccf50ab05..f7f6fc13d 100644
+--- a/openvdb/openvdb/tools/PointPartitioner.h
++++ b/openvdb/openvdb/tools/PointPartitioner.h
+@@ -23,7 +23,7 @@
+ 
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <algorithm>
+ #include <cmath> // for std::isfinite()
+@@ -764,7 +764,7 @@ inline void binAndSegment(
+     using IndexPairListMap = std::map<Coord, IndexPairListPtr>;
+     using IndexPairListMapPtr = std::shared_ptr<IndexPairListMap>;
+ 
+-    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;
+ 
+diff --git a/openvdb/openvdb/tools/PointsToMask.h b/openvdb/openvdb/tools/PointsToMask.h
+index 592ab7a15..8a276fb04 100644
+--- a/openvdb/openvdb/tools/PointsToMask.h
++++ b/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 <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ #include <tbb/blocked_range.h>
+-#include <openvdb/openvdb.h> // for MaskGrid
+-#include <openvdb/Grid.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/util/NullInterrupter.h>
++
+ #include <vector>
+ 
+ 
+@@ -150,7 +154,7 @@ class PointsToMask
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeAdvect.h b/openvdb/openvdb/tools/VolumeAdvect.h
+index e7eec740e..f38eaa9c2 100644
+--- a/openvdb/openvdb/tools/VolumeAdvect.h
++++ b/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 <tbb/parallel_for.h>
+-#include <openvdb/Types.h>
+-#include <openvdb/math/Math.h>
+-#include <openvdb/util/NullInterrupter.h>
++#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 <tbb/parallel_for.h>
++
+ #include <functional>
+ 
+ 
+@@ -294,7 +297,7 @@ class VolumeAdvection
+     bool interrupt() const
+     {
+         if (mInterrupter && util::wasInterrupted(mInterrupter)) {
+-            tbb::task::self().cancel_group_execution();
++            thread::cancelGroupExecution();
+             return true;
+         }
+         return false;
+diff --git a/openvdb/openvdb/tools/VolumeToMesh.h b/openvdb/openvdb/tools/VolumeToMesh.h
+index a834dd3b3..a446f806a 100644
+--- a/openvdb/openvdb/tools/VolumeToMesh.h
++++ b/openvdb/openvdb/tools/VolumeToMesh.h
+@@ -18,7 +18,7 @@
+ #include <tbb/blocked_range.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/task_arena.h>
+ 
+ #include <cmath> // for std::isfinite()
+ #include <map>
+@@ -388,7 +388,7 @@ inline void
+ fillArray(ValueType* array, const ValueType& val, const size_t length)
+ {
+     const auto grainSize = std::max<size_t>(
+-        length / tbb::task_scheduler_init::default_num_threads(), 1024);
++        length / tbb::this_task_arena::max_concurrency(), 1024);
+     const tbb::blocked_range<size_t> range(0, length, grainSize);
+     tbb::parallel_for(range, FillArray<ValueType>(array, val), tbb::simple_partitioner());
+ }
+diff --git a/openvdb/openvdb/unittest/TestCoord.cc b/openvdb/openvdb/unittest/TestCoord.cc
+index be1c24ced..148690041 100644
+--- a/openvdb/openvdb/unittest/TestCoord.cc
++++ b/openvdb/openvdb/unittest/TestCoord.cc
+@@ -2,9 +2,9 @@
+ // SPDX-License-Identifier: MPL-2.0
+ 
+ #include <openvdb/Types.h>
++#include <openvdb/math/Coord.h>
+ 
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_stddef.h> // for tbb::split
+ 
+ #include <unordered_map>
+ #include <sstream>
+diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc
+index 8074166d2..053448f30 100644
+--- a/openvdb/openvdb/unittest/TestFile.cc
++++ b/openvdb/openvdb/unittest/TestFile.cc
+@@ -13,8 +13,11 @@
+ #include <openvdb/version.h>
+ #include <openvdb/openvdb.h>
+ #include "util.h" // for unittest_util::makeSphere()
++
+ #include <gtest/gtest.h>
+-#include <tbb/tbb_thread.h> // for tbb::this_tbb_thread::sleep()
++
++#include <thread>
++#include <chrono>
+ #include <algorithm> // for std::sort()
+ #include <cstdio> // for remove() and rename()
+ #include <fstream>
+@@ -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::seconds>(
++                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<io::Queue::Id> 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));
+         }
+     }
+ }
+diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc
+index 70e7df5f7..6b2204771 100644
+--- a/openvdb/openvdb/unittest/TestUtil.cc
++++ b/openvdb/openvdb/unittest/TestUtil.cc
+@@ -8,7 +8,6 @@
+ 
+ #include <gtest/gtest.h>
+ 
+-#include <tbb/task_scheduler_init.h>
+ #include <tbb/enumerable_thread_specific.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/blocked_range.h>
+diff --git a/openvdb/openvdb/unittest/TestValueAccessor.cc b/openvdb/openvdb/unittest/TestValueAccessor.cc
+index fd2dd5d81..5c1cbb18b 100644
+--- a/openvdb/openvdb/unittest/TestValueAccessor.cc
++++ b/openvdb/openvdb/unittest/TestValueAccessor.cc
+@@ -6,6 +6,7 @@
+ 
+ #include <gtest/gtest.h>
+ #include <tbb/task.h>
++#include <tbb/task_group.h>
+ 
+ #include <type_traits>
+ 
+@@ -378,22 +379,21 @@ TEST_F(TestValueAccessor, testMultithreadedAccessor)
+     //using AccessorT = openvdb::tree::ValueAccessor<Tree4Type>;
+ 
+     // 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
+ }
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+index 0e1b4d855..6d9bb528b 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc
+@@ -20,6 +20,7 @@
+ #include <openvdb/tools/GridTransformer.h>
+ #include <openvdb/tools/PointIndexGrid.h>
+ #include <openvdb/tools/Prune.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <CH/CH_Manager.h>
+ #include <CVEX/CVEX_Context.h>
+@@ -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;
+             }
+ 
+diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+index 757fdc8c6..dbee74b32 100644
+--- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
++++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc
+@@ -16,13 +16,11 @@
+ #include <openvdb_houdini/SOP_NodeVDB.h>
+ 
+ #include <openvdb/tools/Interpolation.h>  // for box sampler
++#include <openvdb/thread/Threading.h>
+ #include <openvdb/points/PointCount.h>
+ #include <openvdb/points/PointSample.h>
+ #include <openvdb/points/IndexFilter.h>   // for MultiGroupFilter
+ 
+-#include <tbb/tick_count.h>                 // for timing
+-#include <tbb/task.h>                       // for cancel
+-
+ #include <UT/UT_Interrupt.h>
+ #include <GA/GA_PageHandle.h>
+ #include <GA/GA_PageIterator.h>
+@@ -38,6 +36,7 @@
+ #include <stdexcept>
+ #include <string>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ 
+@@ -327,7 +326,7 @@ class PointSampler
+     {
+ 
+         if (mInterrupter->wasInterrupted()) {
+-            tbb::task::self().cancel_group_execution();
++            openvdb::thread::cancelGroupExecution();
+         }
+         const GridType& grid = UTvdbGridCast<GridType>(mGrid);
+         // task local grid accessor
+@@ -481,7 +480,7 @@ SOP_OpenVDB_Sample_Points::Cache::cookVDBSop(OP_Context& context)
+         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_Context& context)
+             }
+         }
+ 
+-        // 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::milliseconds>(
++                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;
+         }
+ 
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+index 3d559f8cc..d63ed1591 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
++++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc
+@@ -47,11 +47,8 @@ struct NodeInfo {
+ 
+ typedef std::vector<NodeInfo> 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, const MTypeId& typeId,
+     node.type               = type;
+     node.classification     = classification;
+ 
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (!gNodes) {
+         OPENVDB_START_THREADSAFE_STATIC_WRITE
+@@ -85,7 +82,7 @@ NodeRegistry::NodeRegistry(const MString& typeName, const MTypeId& typeId,
+ void
+ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+@@ -109,7 +106,7 @@ NodeRegistry::registerNodes(MFnPlugin& plugin, MStatus& status)
+ void
+ NodeRegistry::deregisterNodes(MFnPlugin& plugin, MStatus& status)
+ {
+-    Lock lock(sRegistryMutex);
++    std::lock_guard<std::mutex> lock(sRegistryMutex);
+ 
+     if (gNodes) {
+         for (size_t n = 0, N = gNodes->size(); n < N; ++n) {
+diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.h b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+index b58bd6f2c..6a04b1eaf 100644
+--- a/openvdb_maya/openvdb_maya/OpenVDBUtil.h
++++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.h
+@@ -14,8 +14,7 @@
+ #include <openvdb/tree/LeafManager.h>
+ #include <openvdb/tools/VolumeToMesh.h>
+ #include <openvdb/util/Formats.h> // printBytes
+-
+-#include <tbb/tick_count.h>
++#include <openvdb/thread/Threading.h>
+ 
+ #include <maya/M3dView.h>
+ #include <maya/MString.h>
+@@ -40,6 +39,7 @@
+ #include <string>
+ #include <type_traits>
+ #include <vector>
++#include <chrono>
+ 
+ 
+ ////////////////////////////////////////
+@@ -116,11 +116,15 @@ insertFrameNumber(std::string& str, const MTime& time, int numberingScheme = 0);
+ 
+ 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::milliseconds>(
++            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<std::chrono::steady_clock> mStamp;
+ };
+ 
+ 
+diff --git a/pendingchanges/tbb2021.txt b/pendingchanges/tbb2021.txt
+new file mode 100644
+index 000000000..8109c2552
+--- /dev/null
++++ b/pendingchanges/tbb2021.txt
+@@ -0,0 +1,6 @@
++Improvements:
++  - Moved from the deprecated TBB task scheduler to TBB arenas. Various methods now respect the TBB arena state they were invoked from.
++  - Introduced a new thread/Threading.h header to consolidate calls to third-party threading methods.
++
++Build:
++  - Added support for TBB 2021.
diff --git a/srcpkgs/openvdb/template b/srcpkgs/openvdb/template
index 72fde5bc6375..d420a3ee5f5d 100644
--- a/srcpkgs/openvdb/template
+++ b/srcpkgs/openvdb/template
@@ -1,26 +1,18 @@
 # Template file for 'openvdb'
 pkgname=openvdb
-version=7.0.0
+version=8.1.0
 revision=1
 build_style=cmake
 configure_args="-DOPENVDB_BUILD_VDB_VIEW=1"
 hostmakedepends="pkg-config"
-makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel glfw-devel"
+makedepends="boost-devel tbb-devel ilmbase-devel libopenexr-devel c-blosc-devel
+ glfw-devel jemalloc-devel"
 short_desc="Sparse volume data structure and tools"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MPL-2.0"
 homepage="https://openvdb.org"
 distfiles="https://github.com/AcademySoftwareFoundation/openvdb/archive/v${version}.tar.gz"
-checksum=97bc8ae35ef7ccbf49a4e25cb73e8c2eccae6b235bac86f2150707efcd1e910d
-
-if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
-	makedepends+=" libatomic-devel"
-fi
-
-post_patch() {
-	[ "$XBPS_TARGET_NO_ATOMIC8" ] || return 0
-	vsed -i 's,ZLIB::ZLIB,ZLIB::ZLIB atomic,' openvdb/CMakeLists.txt
-}
+checksum=3e09d47331429be7409a3a3c27fdd3c297f96d31d2153febe194e664a99d6183
 
 post_install() {
 	vlicense LICENSE

From 60f5da5d6b7d7453cd1b05e8e0ce96efac0d0485 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:40 +0300
Subject: [PATCH 10/12] paraview: update to 5.9.1.

---
 srcpkgs/paraview/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/paraview/template b/srcpkgs/paraview/template
index 20a7f5589677..e6c3941ce90a 100644
--- a/srcpkgs/paraview/template
+++ b/srcpkgs/paraview/template
@@ -1,7 +1,7 @@
 # Template file for 'paraview'
 pkgname=paraview
-version=5.8.1
-revision=3
+version=5.9.1
+revision=1
 wrksrc=ParaView-v${version}
 build_style=cmake
 configure_args="-DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr

From 5f15e1ebabebcc3e5cbdbbe3383eb46f27e46f09 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Sun, 18 Jul 2021 18:29:39 +0300
Subject: [PATCH 11/12] occt: revbump due to tbb update

---
 srcpkgs/occt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/occt/template b/srcpkgs/occt/template
index 9298edc76e08..006f89ebb8ce 100644
--- a/srcpkgs/occt/template
+++ b/srcpkgs/occt/template
@@ -2,7 +2,7 @@
 pkgname=occt
 reverts=7.5.0_1
 version=7.4.0p1
-revision=3
+revision=4
 _gittag="V${version//./_}"
 wrksrc=occt-${_gittag}
 build_style=cmake

From 6585bfd54ff081c0cdaca8824ca1ea54609efa21 Mon Sep 17 00:00:00 2001
From: Artur Sinila <freesoftware@logarithmus.dev>
Date: Mon, 5 Jul 2021 03:44:08 +0300
Subject: [PATCH 12/12] common/build-style/: enable running tests in parallel

---
 common/build-style/cmake.sh           | 6 +++++-
 common/build-style/configure.sh       | 6 +++++-
 common/build-style/gnu-configure.sh   | 6 +++++-
 common/build-style/gnu-makefile.sh    | 6 +++++-
 common/build-style/perl-module.sh     | 6 +++++-
 common/environment/setup/sourcepkg.sh | 3 ++-
 6 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/common/build-style/cmake.sh b/common/build-style/cmake.sh
index 401dabad31c8..c7ffd16fee21 100644
--- a/common/build-style/cmake.sh
+++ b/common/build-style/cmake.sh
@@ -113,7 +113,11 @@ do_check() {
 
 	: ${make_check_target:=test}
 
-	${make_cmd} ${make_check_args} ${make_check_target}
+	if [ -z "$disable_parallel_check" ]; then
+		${make_cmd} ${makejobs} ${make_check_args} ${make_check_target}
+	else
+		${make_cmd} ${make_check_args} ${make_check_target}
+	fi
 }
 
 do_install() {
diff --git a/common/build-style/configure.sh b/common/build-style/configure.sh
index 0963fc347934..b846a1a77572 100644
--- a/common/build-style/configure.sh
+++ b/common/build-style/configure.sh
@@ -29,7 +29,11 @@ do_check() {
 	: ${make_cmd:=make}
 	: ${make_check_target:=check}
 
-	${make_cmd} ${make_check_args} ${make_check_target}
+	if [ -z "$disable_parallel_check" ]; then
+		${make_cmd} ${makejobs} ${make_check_args} ${make_check_target}
+	else
+		${make_cmd} ${make_check_args} ${make_check_target}
+	fi
 }
 
 do_install() {
diff --git a/common/build-style/gnu-configure.sh b/common/build-style/gnu-configure.sh
index 8121136cd121..b09de442b05b 100644
--- a/common/build-style/gnu-configure.sh
+++ b/common/build-style/gnu-configure.sh
@@ -30,7 +30,11 @@ do_check() {
 	: ${make_cmd:=make}
 	: ${make_check_target:=check}
 
-	${make_cmd} ${make_check_args} ${make_check_target}
+	if [ -z "$disable_parallel_check" ]; then
+		${make_cmd} ${makejobs} ${make_check_args} ${make_check_target}
+	else
+		${make_cmd} ${make_check_args} ${make_check_target}
+	fi
 }
 
 do_install() {
diff --git a/common/build-style/gnu-makefile.sh b/common/build-style/gnu-makefile.sh
index d7ea148fc483..0f7afa7d3695 100644
--- a/common/build-style/gnu-makefile.sh
+++ b/common/build-style/gnu-makefile.sh
@@ -30,7 +30,11 @@ do_check() {
 	: ${make_cmd:=make}
 	: ${make_check_target:=check}
 
-	${make_cmd} ${make_check_args} ${make_check_target}
+	if [ -z "$disable_parallel_check" ]; then
+		${make_cmd} ${makejobs} ${make_check_args} ${make_check_target}
+	else
+		${make_cmd} ${make_check_args} ${make_check_target}
+	fi
 }
 
 do_install() {
diff --git a/common/build-style/perl-module.sh b/common/build-style/perl-module.sh
index b9a01b13cfa9..d47945b33d36 100644
--- a/common/build-style/perl-module.sh
+++ b/common/build-style/perl-module.sh
@@ -79,7 +79,11 @@ do_check() {
 	: ${make_cmd:=make}
 	: ${make_check_target:=test}
 
-	${make_cmd} ${make_check_args} ${make_check_target}
+	if [ -z "$disable_parallel_check" ]; then
+		${make_cmd} ${makejobs} ${make_check_args} ${make_check_target}
+	else
+		${make_cmd} ${make_check_args} ${make_check_target}
+	fi
 }
 
 do_install() {
diff --git a/common/environment/setup/sourcepkg.sh b/common/environment/setup/sourcepkg.sh
index bc06f745b78a..1fd541f1e715 100644
--- a/common/environment/setup/sourcepkg.sh
+++ b/common/environment/setup/sourcepkg.sh
@@ -13,7 +13,8 @@ unset -v cmake_builddir meson_builddir
 unset -v meson_crossfile
 unset -v gemspec
 unset -v go_import_path go_package go_mod_mode
-unset -v patch_args disable_parallel_build keep_libtool_archives make_use_env
+unset -v patch_args disable_parallel_build disable_parallel_check
+unset -v keep_libtool_archives make_use_env
 unset -v reverts subpackages makedepends hostmakedepends checkdepends depends restricted
 unset -v nopie build_options build_options_default bootstrap repository reverts
 unset -v CFLAGS CXXFLAGS FFLAGS CPPFLAGS LDFLAGS LD_LIBRARY_PATH

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tbb: update to 2021.3.0
  2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
                   ` (9 preceding siblings ...)
  2021-07-26  1:31 ` Logarithmus
@ 2022-01-28  7:53 ` ericonr
  2022-01-28  7:53 ` [PR PATCH] [Closed]: " ericonr
  11 siblings, 0 replies; 13+ messages in thread
From: ericonr @ 2022-01-28  7:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]

New comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/32166#issuecomment-1023968859

Comment:
d5123dd31980758c2a5700d480555e35798edfcd and friends

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PR PATCH] [Closed]: tbb: update to 2021.3.0
  2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
                   ` (10 preceding siblings ...)
  2022-01-28  7:53 ` ericonr
@ 2022-01-28  7:53 ` ericonr
  11 siblings, 0 replies; 13+ messages in thread
From: ericonr @ 2022-01-28  7:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 808 bytes --]

There's a closed pull request on the void-packages repository

tbb: update to 2021.3.0
https://github.com/void-linux/void-packages/pull/32166

Description:
Follow-up of https://github.com/void-linux/void-packages/pull/27746, @thypon & @olafmersmann might be interested.
**TODO** fix reverse dependencies:
- [ ] OpenSubdiv: update to 3.4.4.
- [ ] PrusaSlicer: update to 2.3.3.
- [ ] lender: update to 2.93.1.
- [ ] embree: update to 3.13.0.
- [ ] openimageio: update to 2.2.16.0.
- [ ] openimagedenoise: update to 1.4.1.
- [ ] openvdb: update to 8.1.0.
- [ ] paraview: update to 5.9.1.
- [ ] occt: revbump due to tbb update

#### Have the results of the proposed changes been tested?
- [x] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-01-28  7:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-24 10:00 [PR PATCH] tbb: update to 2021.3.0 Logarithmus
2021-07-24 10:20 ` [PR PATCH] [Updated] " Logarithmus
2021-07-24 11:13 ` Logarithmus
2021-07-24 11:36 ` Logarithmus
2021-07-24 12:32 ` Logarithmus
2021-07-24 15:06 ` Logarithmus
2021-07-24 15:32 ` Logarithmus
2021-07-24 16:16 ` Logarithmus
2021-07-24 16:41 ` Logarithmus
2021-07-25 15:26 ` Logarithmus
2021-07-26  1:31 ` Logarithmus
2022-01-28  7:53 ` ericonr
2022-01-28  7:53 ` [PR PATCH] [Closed]: " ericonr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).