Make 2 threads default and fix -1 for automatic

This commit is contained in:
Michal Tóth 2025-01-15 12:09:03 +01:00
parent 5ba8e87f55
commit c3489c5e62
3 changed files with 13 additions and 7 deletions

View File

@ -125,7 +125,13 @@ struct MinTimeStepSize { static constexpr Scalar value = 0.0; };
struct OutputDir { static constexpr auto value = ""; };
//! \brief Number of threads per process.
struct ThreadsPerProcess { static constexpr int value = 1; };
struct ThreadsPerProcess {
#if _OPENMP
static constexpr int value = 2;
#else
static constexpr int value = 1;
#endif // _OPENMP
};
} // namespace Opm::Parameters

View File

@ -261,9 +261,9 @@ void BlackoilModelParameters<Scalar>::registerParameters()
Parameters::Hide<Parameters::DebugEmitCellPartition>();
// if openMP is available, determine the number threads per process automatically.
// if openMP is available, use two threads per mpi rank by default
#if _OPENMP
Parameters::SetDefault<Parameters::ThreadsPerProcess>(-1);
Parameters::SetDefault<Parameters::ThreadsPerProcess>(2);
#endif
}

View File

@ -310,10 +310,10 @@ namespace Opm {
}
}
// 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);
// Requesting -1 thread will let OMP automatically deduce the number
if (requested_threads != -1) {
omp_set_num_threads(threads);
}
#endif
using TM = GetPropType<TypeTag, Properties::ThreadManager>;