changed: ThreadsPerProcess parameter moved to Opm::Parameters namespace

This commit is contained in:
Arne Morten Kvarving
2024-06-28 12:17:13 +02:00
parent ddb984c24e
commit afa62ee428
6 changed files with 43 additions and 28 deletions

View File

@@ -176,15 +176,6 @@ struct NewtonMaxIterations<TypeTag, TTag::FlowExpTypeTag> {
static constexpr int value = 8; static constexpr int value = 8;
}; };
// if openMP is available, set the default the number of threads per process for the main
// simulation to 2 (instead of grabbing everything that is available).
#if _OPENMP
template<class TypeTag>
struct ThreadsPerProcess<TypeTag, TTag::FlowExpTypeTag> {
static constexpr int value = 2;
};
#endif
// By default, flowexp accepts the result of the time integration unconditionally if the // By default, flowexp accepts the result of the time integration unconditionally if the
// smallest time step size is reached. // smallest time step size is reached.
template<class TypeTag> template<class TypeTag>
@@ -198,6 +189,18 @@ struct LinearSolverBackend<TypeTag, TTag::FlowExpTypeTag> {
} // namespace Opm::Properties } // namespace Opm::Properties
namespace Opm::Parameters {
// if openMP is available, set the default the number of threads per process for the main
// simulation to 2 (instead of grabbing everything that is available).
#if _OPENMP
template<class TypeTag>
struct ThreadsPerProcess<TypeTag, Properties::TTag::FlowExpTypeTag>
{ static constexpr int value = 2; };
#endif
} // namespace Opm::Parameters
namespace Opm { namespace Opm {
template <class TypeTag> template <class TypeTag>
class FlowExpProblem : public FlowProblem<TypeTag> //, public FvBaseProblem<TypeTag> class FlowExpProblem : public FlowProblem<TypeTag> //, public FvBaseProblem<TypeTag>

View File

@@ -54,12 +54,6 @@ struct Problem<TypeTag, TTag::FlowExpProblemBlackOil>
using type = FlowExpProblem<TypeTag>; using type = FlowExpProblem<TypeTag>;
}; };
template<class TypeTag>
struct ThreadsPerProcess<TypeTag, TTag::FlowExpProblemBlackOil>
{
static constexpr int value = 1;
};
template<class TypeTag> template<class TypeTag>
struct ContinueOnConvergenceError<TypeTag, TTag::FlowExpProblemBlackOil> struct ContinueOnConvergenceError<TypeTag, TTag::FlowExpProblemBlackOil>
{ {
@@ -117,6 +111,14 @@ struct Simulator<TypeTag, TTag::FlowExpProblemBlackOil>
} }
namespace Opm::Parameters {
template<class TypeTag>
struct ThreadsPerProcess<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
{ static constexpr int value = 1; };
} // namespace Opm::Parameters
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
using TypeTag = Opm::Properties::TTag::FlowExpProblemBlackOil; using TypeTag = Opm::Properties::TTag::FlowExpProblemBlackOil;

View File

@@ -20,6 +20,7 @@
#ifndef OPM_BLACKOILMODELPARAMETERS_HEADER_INCLUDED #ifndef OPM_BLACKOILMODELPARAMETERS_HEADER_INCLUDED
#define OPM_BLACKOILMODELPARAMETERS_HEADER_INCLUDED #define OPM_BLACKOILMODELPARAMETERS_HEADER_INCLUDED
#include <opm/models/discretization/common/fvbaseparameters.hh>
#include <opm/models/discretization/common/fvbaseproperties.hh> #include <opm/models/discretization/common/fvbaseproperties.hh>
#include <opm/models/utils/basicproperties.hh> #include <opm/models/utils/basicproperties.hh>
@@ -467,15 +468,21 @@ template<class TypeTag>
struct LocalDomainsOrderingMeasure<TypeTag, TTag::FlowModelParameters> { struct LocalDomainsOrderingMeasure<TypeTag, TTag::FlowModelParameters> {
static constexpr auto value = "maxpressure"; static constexpr auto value = "maxpressure";
}; };
} // namespace Opm::Properties
namespace Opm::Parameters {
// if openMP is available, determine the number threads per process automatically. // if openMP is available, determine the number threads per process automatically.
#if _OPENMP #if _OPENMP
template<class TypeTag> template<class TypeTag>
struct ThreadsPerProcess<TypeTag, TTag::FlowModelParameters> { struct ThreadsPerProcess<TypeTag, Properties::TTag::FlowModelParameters>
{
static constexpr int value = -1; static constexpr int value = -1;
}; };
#endif #endif
} // namespace Opm::Properties } // namespace Opm::Parameters
namespace Opm namespace Opm
{ {

View File

@@ -388,7 +388,7 @@ namespace Opm {
if (!getenv("OMP_NUM_THREADS")) if (!getenv("OMP_NUM_THREADS"))
{ {
int threads = 2; int threads = 2;
const int requested_threads = Parameters::get<TypeTag, Properties::ThreadsPerProcess>(); const int requested_threads = Parameters::get<TypeTag, Parameters::ThreadsPerProcess>();
if (requested_threads > 0) if (requested_threads > 0)
threads = requested_threads; threads = requested_threads;

View File

@@ -719,7 +719,7 @@ private:
else { else {
threads = 2; threads = 2;
const int input_threads = Parameters::get<TypeTag, Properties::ThreadsPerProcess>(); const int input_threads = Parameters::get<TypeTag, Parameters::ThreadsPerProcess>();
if (input_threads > 0) if (input_threads > 0)
threads = input_threads; threads = input_threads;

View File

@@ -126,15 +126,6 @@ struct NewtonMaxIterations<TypeTag, TTag::TestTypeTag> {
static constexpr int value = 8; static constexpr int value = 8;
}; };
// if openMP is available, set the default the number of threads per process for the main
// simulation to 2 (instead of grabbing everything that is available).
#if _OPENMP
template<class TypeTag>
struct ThreadsPerProcess<TypeTag, TTag::TestTypeTag> {
static constexpr int value = 2;
};
#endif
// By default, ebos accepts the result of the time integration unconditionally if the // By default, ebos accepts the result of the time integration unconditionally if the
// smallest time step size is reached. // smallest time step size is reached.
template<class TypeTag> template<class TypeTag>
@@ -144,4 +135,16 @@ struct ContinueOnConvergenceError<TypeTag, TTag::TestTypeTag> {
} // namespace Opm::Properties } // namespace Opm::Properties
namespace Opm::Parameters {
// if openMP is available, set the default the number of threads per process for the main
// simulation to 2 (instead of grabbing everything that is available).
#if _OPENMP
template<class TypeTag>
struct ThreadsPerProcess<TypeTag, Properties::TTag::TestTypeTag>
{ static constexpr int value = 2; };
#endif
} // namespace Opm::Parameters
#endif // OPM_TEST_TYPETAG_HPP #endif // OPM_TEST_TYPETAG_HPP