mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #4709 from blattms/omp-allow-oversubscribe
OpenMP: allow oversubscribing to prevent only 1 thread on some hardware
This commit is contained in:
commit
81bda54c67
@ -378,13 +378,24 @@ 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;
|
||||
|
||||
// We are not limiting this to the number of processes
|
||||
// reported by OpenMP as on some hardware (and some OpenMPI
|
||||
// versions) this will be 1 when run with mpirun
|
||||
omp_set_num_threads(threads);
|
||||
}
|
||||
#endif
|
||||
|
||||
using ThreadManager = GetPropType<TypeTag, Properties::ThreadManager>;
|
||||
ThreadManager::init();
|
||||
ThreadManager::init(false);
|
||||
}
|
||||
|
||||
void mergeParallelLogFiles()
|
||||
|
@ -670,15 +670,17 @@ private:
|
||||
// This function is called before the parallel OpenMP stuff gets initialized.
|
||||
// That initialization happends after the deck is read and we want this message.
|
||||
// Hence we duplicate the code of setupParallelism to get the number of threads.
|
||||
if (std::getenv("OMP_NUM_THREADS"))
|
||||
if (std::getenv("OMP_NUM_THREADS")) {
|
||||
threads = omp_get_max_threads();
|
||||
else
|
||||
threads = std::min(2, omp_get_max_threads());
|
||||
}
|
||||
else {
|
||||
threads = 2;
|
||||
|
||||
const int input_threads = EWOMS_GET_PARAM(TypeTag, int, ThreadsPerProcess);
|
||||
const int input_threads = EWOMS_GET_PARAM(TypeTag, int, ThreadsPerProcess);
|
||||
|
||||
if (input_threads > 0)
|
||||
threads = std::min(input_threads, omp_get_max_threads());
|
||||
if (input_threads > 0)
|
||||
threads = input_threads;
|
||||
}
|
||||
#endif
|
||||
|
||||
return threads;
|
||||
|
Loading…
Reference in New Issue
Block a user