mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
[bugfix] Honor command line --threads-per-process
While we reported that we used the number of threads that were passed on the command line, we never really used it for OpenMP but always sticked to two unless environment variable OMP_NUM_THREADS was set. Note that because the ThreadManager in opm-models would always use the command line option and hence the linearizer would use that number of threads. Please note that the only use of OpenMP in opm-common (volume calculation in EclipseGrid) is not effected by this as it happens before we set the number of OpenMP threads.
This commit is contained in:
parent
6afda71480
commit
ae1f319c10
@ -378,13 +378,21 @@ void handleExtraConvergenceOutput(SimulatorReport& report,
|
||||
mpi_size_ = comm.size();
|
||||
|
||||
#if _OPENMP
|
||||
// if openMP is available, default to 2 threads per process.
|
||||
// if openMP is available, default to 2 threads per process unless
|
||||
// OMP_NUM_THREADS is set or command line --threads-per-process used
|
||||
if (!getenv("OMP_NUM_THREADS"))
|
||||
omp_set_num_threads(std::min(2, omp_get_num_procs()));
|
||||
{
|
||||
int threads = 2;
|
||||
const int requested_threads = EWOMS_GET_PARAM(TypeTag, int, ThreadsPerProcess);
|
||||
if (requested_threads > 0)
|
||||
threads = requested_threads;
|
||||
|
||||
omp_set_num_threads(std::min(threads, omp_get_num_procs()));
|
||||
}
|
||||
#endif
|
||||
|
||||
using ThreadManager = GetPropType<TypeTag, Properties::ThreadManager>;
|
||||
ThreadManager::init();
|
||||
ThreadManager::init(false);
|
||||
}
|
||||
|
||||
void mergeParallelLogFiles()
|
||||
|
Loading…
Reference in New Issue
Block a user