From d139f2c726c915bc201753986381a81b2894eb9a Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Tue, 17 Feb 2015 03:05:04 +0100 Subject: [PATCH] Fix issues with multithreading off --- include/deal.II/base/work_stream.h | 10 +++++----- source/base/mpi.cc | 6 +++--- source/base/multithread_info.cc | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/deal.II/base/work_stream.h b/include/deal.II/base/work_stream.h index 0d831eadca..6d2b5bdc38 100644 --- a/include/deal.II/base/work_stream.h +++ b/include/deal.II/base/work_stream.h @@ -960,7 +960,7 @@ namespace WorkStream Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, - const unsigned int queue_length = 2*multithread_info.n_threads(), + const unsigned int queue_length = 2*MultithreadInfo::n_threads(), const unsigned int chunk_size = 8); @@ -1010,7 +1010,7 @@ namespace WorkStream Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, - const unsigned int queue_length = 2*multithread_info.n_threads(), + const unsigned int queue_length = 2*MultithreadInfo::n_threads(), const unsigned int chunk_size = 8) { Assert (queue_length > 0, @@ -1029,7 +1029,7 @@ namespace WorkStream // we want to use TBB if we have support and if it is not disabled at // runtime: #ifdef DEAL_II_WITH_THREADS - if (multithread_info.n_threads()==1) + if (MultithreadInfo::n_threads()==1) #endif { // need to copy the sample since it is marked const @@ -1135,7 +1135,7 @@ namespace WorkStream // we want to use TBB if we have support and if it is not disabled at // runtime: #ifdef DEAL_II_WITH_THREADS - if (multithread_info.n_threads()==1) + if (MultithreadInfo::n_threads()==1) #endif { // need to copy the sample since it is marked const @@ -1236,7 +1236,7 @@ namespace WorkStream void (MainClass::*copier) (const CopyData &), const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, - const unsigned int queue_length = 2*multithread_info.n_threads(), + const unsigned int queue_length = 2*MultithreadInfo::n_threads(), const unsigned int chunk_size = 8) { // forward to the other function diff --git a/source/base/mpi.cc b/source/base/mpi.cc index 473b590168..5641b4dc87 100644 --- a/source/base/mpi.cc +++ b/source/base/mpi.cc @@ -437,16 +437,16 @@ namespace Utilities // if the number would be zero, round up to one since every // process needs to have at least one thread const unsigned int n_threads - = std::max(MultithreadInfo::n_cpus / n_local_processes + = std::max(MultithreadInfo::n_cores() / n_local_processes + - (nth_process_on_host <= MultithreadInfo::n_cpus % n_local_processes + (nth_process_on_host <= MultithreadInfo::n_cores() % n_local_processes ? 1 : 0), 1U); #else - const unsigned int n_threads = MultithreadInfo::n_cpus; + const unsigned int n_threads = MultithreadInfo::n_cores(); #endif // finally set this number of threads diff --git a/source/base/multithread_info.cc b/source/base/multithread_info.cc index 333aecb683..453dee100e 100644 --- a/source/base/multithread_info.cc +++ b/source/base/multithread_info.cc @@ -173,6 +173,11 @@ unsigned int MultithreadInfo::get_n_cpus() return 1; } +unsigned int MultithreadInfo::n_cores() +{ + return 1; +} + unsigned int MultithreadInfo::n_threads() { return 1; -- 2.39.5