16 #include <deal.II/base/multithread_info.h> 17 #include <deal.II/base/utilities.h> 19 #ifdef DEAL_II_HAVE_UNISTD_H 23 #if (defined(__MACH__) && defined(__APPLE__)) || defined(__FreeBSD__) 24 # include <sys/types.h> 25 # include <sys/sysctl.h> 30 #ifdef DEAL_II_WITH_THREADS 31 # include <deal.II/base/thread_management.h> 32 # include <tbb/task_scheduler_init.h> 35 DEAL_II_NAMESPACE_OPEN
37 #ifdef DEAL_II_WITH_THREADS 47 # if defined(__linux__) || defined(__sun__) || defined(__osf__) || defined(_AIX) 51 return sysconf(_SC_NPROCESSORS_ONLN);
54 # elif (defined(__MACH__) && defined(__APPLE__)) || defined(__FreeBSD__) 67 sysctl(mib, 2, &
n_cpus, &len, NULL, 0);
115 const char *penv = getenv (
"DEAL_II_NUM_THREADS");
126 ExcMessage (std::string(
"When specifying the <DEAL_II_NUM_THREADS> environment " 127 "variable, it needs to be something that can be interpreted " 128 "as an integer. The text you have in the environment " 129 "variable is <") + penv +
">"));
133 ExcMessage (
"When specifying the <DEAL_II_NUM_THREADS> environment " 134 "variable, it needs to be a positive number."));
145 n_max_threads = tbb::task_scheduler_init::default_num_threads();
148 static tbb::task_scheduler_init dummy (tbb::task_scheduler_init::deferred);
149 if (dummy.is_active())
162 #else // not in MT mode 204 static bool done =
false;
231 DEAL_II_NAMESPACE_CLOSE
static const unsigned int invalid_unsigned_int
static const unsigned int n_cpus
static unsigned int n_cores()
#define AssertThrow(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
static void initialize_multithreading()
static bool is_running_single_threaded()
static unsigned int n_max_threads
static std::size_t memory_consumption()
static void set_thread_limit(const unsigned int max_threads=numbers::invalid_unsigned_int)
int string_to_int(const std::string &s)
static unsigned int n_threads()
static ::ExceptionBase & ExcInternalError()
static unsigned int get_n_cpus()