10 #ifndef vtk_m_cont_tbb_internal_RuntimeDeviceConfigurationTBB_h
11 #define vtk_m_cont_tbb_internal_RuntimeDeviceConfigurationTBB_h
17 #if TBB_VERSION_MAJOR >= 2020
18 #define TBB_PREVIEW_GLOBAL_CONTROL
19 #include <tbb/global_control.h>
20 #include <tbb/task_arena.h>
36 class RuntimeDeviceConfiguration<
vtkm::cont::DeviceAdapterTagTBB>
37 :
public vtkm::cont::internal::RuntimeDeviceConfigurationBase
41 RuntimeDeviceConfiguration<vtkm::cont::DeviceAdapterTagTBB>()
43 #if TBB_VERSION_MAJOR >= 2020
44 HardwareMaxThreads(::tbb::task_arena{}.max_concurrency())
47 HardwareMaxThreads(::tbb::task_scheduler_init::default_num_threads())
50 CurrentNumThreads(this->HardwareMaxThreads)
61 this->CurrentNumThreads = value > 0 ? value : this->HardwareMaxThreads;
62 #if TBB_VERSION_MAJOR >= 2020
63 GlobalControl.reset(new ::tbb::global_control(::tbb::global_control::max_allowed_parallelism,
64 this->CurrentNumThreads));
66 TaskSchedulerInit.reset(
67 new ::tbb::task_scheduler_init(
static_cast<int>(this->CurrentNumThreads)));
69 return RuntimeDeviceConfigReturnCode::SUCCESS;
74 #if TBB_VERSION_MAJOR >= 2020
75 value = ::tbb::global_control::active_value(::tbb::global_control::max_allowed_parallelism);
77 value = this->CurrentNumThreads;
79 return RuntimeDeviceConfigReturnCode::SUCCESS;
82 VTKM_CONT RuntimeDeviceConfigReturnCode GetMaxThreads(
vtkm::Id& value)
const final
84 value = this->HardwareMaxThreads;
85 return RuntimeDeviceConfigReturnCode::SUCCESS;
89 #if TBB_VERSION_MAJOR >= 2020
90 std::unique_ptr<::tbb::global_control> GlobalControl;
92 std::unique_ptr<::tbb::task_scheduler_init> TaskSchedulerInit;
101 #endif //vtk_m_cont_tbb_internal_RuntimeDeviceConfigurationTBB_h