Merge pull request #1562 from andlaus/threading_fixes

flow: default to 2 threads if OpenMP is available
This commit is contained in:
Arne Morten Kvarving 2018-09-11 12:37:13 +02:00 committed by GitHub
commit af863c82a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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();
}