diff --git a/vtkm/cont/internal/ParallelRadixSort.h b/vtkm/cont/internal/ParallelRadixSort.h index 7604aacd7..cca8f6b72 100644 --- a/vtkm/cont/internal/ParallelRadixSort.h +++ b/vtkm/cont/internal/ParallelRadixSort.h @@ -485,7 +485,7 @@ struct RunTask } template - void operator()(ThreaderData tData = nullptr) + void operator()(ThreaderData tData = nullptr) const { size_t num_nodes_at_current_height = (size_t)pow(2, (double)binary_tree_height_); if (num_threads_ <= num_nodes_at_current_height) diff --git a/vtkm/cont/tbb/internal/ParallelSortTBB.cxx b/vtkm/cont/tbb/internal/ParallelSortTBB.cxx index 9243017e6..d99406954 100644 --- a/vtkm/cont/tbb/internal/ParallelSortTBB.cxx +++ b/vtkm/cont/tbb/internal/ParallelSortTBB.cxx @@ -53,7 +53,7 @@ // correct settings so that we don't clobber any existing function #include -#include +#include #include #if defined(VTKM_MSVC) @@ -71,6 +71,7 @@ namespace sort const size_t MAX_CORES = std::thread::hardware_concurrency(); +#if TBB_VERSION_MAJOR < 2020 // Simple TBB task wrapper around a generic functor. template struct TaskWrapper : public ::tbb::task @@ -94,7 +95,7 @@ struct RadixThreaderTBB size_t GetAvailableCores() const { return MAX_CORES; } template - void RunParentTask(TaskType task) + void RunParentTask(TaskType task) const { using Task = TaskWrapper; Task& root = *new (::tbb::task::allocate_root()) Task(task); @@ -102,7 +103,7 @@ struct RadixThreaderTBB } template - void RunChildTasks(TaskWrapper* wrapper, TaskType left, TaskType right) + void RunChildTasks(TaskWrapper* wrapper, TaskType left, TaskType right) const { using Task = TaskWrapper; ::tbb::empty_task& p = *new (wrapper->allocate_continuation())::tbb::empty_task(); @@ -115,6 +116,34 @@ struct RadixThreaderTBB } }; +#else // TBB_VERSION_MAJOR >= 2020 + +// In TBB version 2020, the task class was deprecated. Instead, we use the simpler task_group. + +struct RadixThreaderTBB +{ + std::shared_ptr<::tbb::task_group> TaskGroup = + std::shared_ptr<::tbb::task_group>(new ::tbb::task_group); + + size_t GetAvailableCores() const { return MAX_CORES; } + + template + void RunParentTask(TaskType task) const + { + this->TaskGroup->run_and_wait(task); + // All tasks should be complete at this point. + } + + template + void RunChildTasks(void*, TaskType left, TaskType right) const + { + this->TaskGroup->run(left); + this->TaskGroup->run(right); + } +}; + +#endif + VTKM_INSTANTIATE_RADIX_SORT_FOR_THREADER(RadixThreaderTBB) } }