10 #ifndef vtk_m_cont_openmp_internal_RuntimeDeviceConfigurationOpenMP_h
11 #define vtk_m_cont_openmp_internal_RuntimeDeviceConfigurationOpenMP_h
30 class RuntimeDeviceConfiguration<
vtkm::cont::DeviceAdapterTagOpenMP>
31 :
public vtkm::cont::internal::RuntimeDeviceConfigurationBase
34 RuntimeDeviceConfiguration<vtkm::cont::DeviceAdapterTagOpenMP>()
35 : HardwareMaxThreads(InitializeHardwareMaxThreads())
36 , CurrentNumThreads(this->HardwareMaxThreads)
45 VTKM_CONT virtual RuntimeDeviceConfigReturnCode SetThreads(
const vtkm::Id& value)
override final
47 if (omp_in_parallel())
50 return RuntimeDeviceConfigReturnCode::NOT_APPLIED;
54 if (value > this->HardwareMaxThreads)
57 "OpenMP: You may be oversubscribing your CPU cores: "
58 <<
"process threads available: " << this->HardwareMaxThreads
59 <<
", requested threads: " << value);
61 this->CurrentNumThreads = value;
62 omp_set_num_threads(this->CurrentNumThreads);
66 this->CurrentNumThreads = this->HardwareMaxThreads;
67 omp_set_num_threads(this->CurrentNumThreads);
69 return RuntimeDeviceConfigReturnCode::SUCCESS;
72 VTKM_CONT virtual RuntimeDeviceConfigReturnCode GetThreads(
vtkm::Id& value)
const override final
74 value = this->CurrentNumThreads;
75 return RuntimeDeviceConfigReturnCode::SUCCESS;
78 VTKM_CONT virtual RuntimeDeviceConfigReturnCode GetMaxThreads(
79 vtkm::Id& value)
const override final
81 value = this->HardwareMaxThreads;
82 return RuntimeDeviceConfigReturnCode::SUCCESS;
90 if (omp_in_parallel())
92 count = omp_get_num_threads();
112 #endif //vtk_m_cont_openmp_internal_RuntimeDeviceConfigurationOpenMP_h