From 9e61562fe6deb806031acf1cb7cbef4a54e0840c Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 27 May 2020 10:58:48 -0500 Subject: [PATCH] Do not let TBB override the number of threads used --- source/base/multithread_info.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/base/multithread_info.cc b/source/base/multithread_info.cc index 1484bafaeb..6da31b9853 100644 --- a/source/base/multithread_info.cc +++ b/source/base/multithread_info.cc @@ -81,20 +81,18 @@ MultithreadInfo::set_thread_limit(const unsigned int max_threads) } } -#ifdef DEAL_II_WITH_TBB - // Without restrictions from the user query TBB for the recommended number - // of threads: + // If we have not set the number of allowed threads yet, just default to + // the number of available cores if (n_max_threads == numbers::invalid_unsigned_int) - n_max_threads = tbb::task_scheduler_init::default_num_threads(); + n_max_threads = n_cores(); +#ifdef DEAL_II_WITH_TBB // Initialize the scheduler and destroy the old one before doing so static tbb::task_scheduler_init dummy(tbb::task_scheduler_init::deferred); if (dummy.is_active()) dummy.terminate(); dummy.initialize(n_max_threads); #endif - if (n_max_threads == numbers::invalid_unsigned_int) - n_max_threads = n_cores(); } -- 2.39.5