27 #ifndef EWOMS_THREAD_MANAGER_HH
28 #define EWOMS_THREAD_MANAGER_HH
38 #include <opm/common/ErrorMacros.hpp>
39 #include <opm/common/Exceptions.hpp>
41 #include <dune/common/version.hh>
44 namespace Properties {
51 template <
class TypeTag>
56 #if defined(_OPENMP) || DOXYGEN
70 "The maximum number of threads to be instantiated per process "
71 "('-1' means 'automatic')");
80 if (numThreads_ != 1 && numThreads_ != -1)
81 OPM_THROW(std::invalid_argument,
82 "OpenMP is not available. The only valid values for "
83 "threads-per-process is 1 and -1 but it is " << numThreads_ <<
"!");
85 #elif !defined NDEBUG && defined DUNE_INTERFACECHECK
87 OPM_THROW(std::invalid_argument,
88 "You explicitly enabled Barton-Nackman interface checking in Dune. "
89 "The Dune implementation of this is currently incompatible with "
90 "thread parallelism!");
95 OPM_THROW(std::invalid_argument,
96 "Zero threads per process are not possible: It must be at least 1, "
97 "(or -1 for 'automatic')!");
104 omp_set_num_threads(numThreads_);
106 numThreads_ = omp_get_max_threads();
114 {
return static_cast<unsigned>(numThreads_); }
122 return static_cast<unsigned>(omp_get_thread_num());
129 static int numThreads_;
132 template <
class TypeTag>
133 int ThreadManager<TypeTag>::numThreads_ = 1;
This file implements various objects which provide mutual exclusion capabilities for multi-threaded a...
Simplifies multi-threaded capabilities.
Definition: threadmanager.hh:52
static unsigned threadId()
Return the index of the current OpenMP thread.
Definition: threadmanager.hh:119
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:68
This file provides the infrastructure to retrieve run-time parameters.
static unsigned maxThreads()
Return the maximum number of threads of the current process.
Definition: threadmanager.hh:113
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:99
Provides the magic behind the eWoms property system.
#define NEW_PROP_TAG(PTagName)
Define a property tag.
Definition: propertysystem.hh:247
static void registerParameters()
Register all run-time parameters of the thread manager.
Definition: threadmanager.hh:67