18 #ifndef viskores_cont_openmp_internal_RuntimeDeviceConfigurationOpenMP_h
19 #define viskores_cont_openmp_internal_RuntimeDeviceConfigurationOpenMP_h
38 class RuntimeDeviceConfiguration<
viskores::cont::DeviceAdapterTagOpenMP>
39 :
public viskores::cont::internal::RuntimeDeviceConfigurationBase
42 RuntimeDeviceConfiguration<viskores::cont::DeviceAdapterTagOpenMP>()
43 : HardwareMaxThreads(InitializeHardwareMaxThreads())
44 , CurrentNumThreads(this->HardwareMaxThreads)
53 VISKORES_CONT virtual RuntimeDeviceConfigReturnCode SetThreads(
56 if (omp_in_parallel())
59 "OpenMP SetThreads: Error, currently in parallel");
60 return RuntimeDeviceConfigReturnCode::NOT_APPLIED;
64 if (value > this->HardwareMaxThreads)
67 "OpenMP: You may be oversubscribing your CPU cores: "
68 <<
"process threads available: " << this->HardwareMaxThreads
69 <<
", requested threads: " << value);
71 this->CurrentNumThreads = value;
72 omp_set_num_threads(this->CurrentNumThreads);
76 this->CurrentNumThreads = this->HardwareMaxThreads;
77 omp_set_num_threads(this->CurrentNumThreads);
79 return RuntimeDeviceConfigReturnCode::SUCCESS;
82 VISKORES_CONT virtual RuntimeDeviceConfigReturnCode GetThreads(
85 value = this->CurrentNumThreads;
86 return RuntimeDeviceConfigReturnCode::SUCCESS;
89 VISKORES_CONT virtual RuntimeDeviceConfigReturnCode GetMaxThreads(
92 value = this->HardwareMaxThreads;
93 return RuntimeDeviceConfigReturnCode::SUCCESS;
101 if (omp_in_parallel())
103 count = omp_get_num_threads();
123 #endif //viskores_cont_openmp_internal_RuntimeDeviceConfigurationOpenMP_h