flow: default to 2 threads if OpenMP is available

I still think it is better to specify `--threads-per-process`
explicitly, but this patch is better than the current machinery...
This commit is contained in:
Andreas Lauser 2018-08-31 12:32:41 +02:00
parent c4c461b389
commit 05dfe43fd2
2 changed files with 12 additions and 0 deletions

View File

@ -78,6 +78,11 @@ SET_SCALAR_PROP(FlowModelParameters, MaxPressureChangeMsWells, 2.0 *1e5);
SET_BOOL_PROP(FlowModelParameters, UseInnerIterationsMsWells, true);
SET_INT_PROP(FlowModelParameters, MaxInnerIterMsWells, 10);
// if openMP is available, determine the number threads per process automatically.
#if _OPENMP
SET_INT_PROP(FlowModelParameters, ThreadsPerProcess, -1);
#endif
END_PROPERTIES
namespace Opm

View File

@ -255,6 +255,13 @@ namespace Opm
mpi_rank_ = 0;
mpi_size_ = 1;
#endif
#if _OPENMP
// if openMP is available, default to 2 threads per process.
if (!getenv("OMP_NUM_THREADS"))
omp_set_num_threads(std::min(2, omp_get_num_procs()));
#endif
typedef typename GET_PROP_TYPE(TypeTag, ThreadManager) ThreadManager;
ThreadManager::init();
}