From 20897dd3e1a68ccf0f4a015040f47f83d5f5d905 Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 24 Feb 2000 13:01:56 +0000 Subject: [PATCH] Update to auto-detection of the number of CPUs in a system. git-svn-id: https://svn.dealii.org/trunk@2490 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/sparse_matrix.templates.h | 15 +++++++-------- deal.II/lac/include/lac/sparse_vanka.h | 12 ++++++++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h index c9e7d1a7ef..170e4bad33 100644 --- a/deal.II/lac/include/lac/sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix.templates.h @@ -27,8 +27,7 @@ # include # include - -# define NTHREADS 4 +# include #endif @@ -214,9 +213,9 @@ SparseMatrix::vmult (Vector& dst, const Vector& // in MT mode: start new threads only // if the matrix is sufficiently large. // the limit is mostly artificial - if (n_rows/NTHREADS > 2000) + if (n_rows/multithread_info.n_default_threads > 2000) { - const unsigned int n_threads = NTHREADS; + const unsigned int n_threads = multithread_info.n_default_threads; ThreadManager thread_manager; @@ -380,9 +379,9 @@ SparseMatrix::matrix_norm (const Vector& v) const // if in MT mode and size sufficiently // large: do it in parallel; the limit // is mostly artificial - if (n_rows/NTHREADS > 2000) + if (n_rows/multithread_info.n_default_threads > 2000) { - const unsigned int n_threads = NTHREADS; + const unsigned int n_threads = multithread_info.n_default_threads; ThreadManager thread_manager; @@ -530,9 +529,9 @@ SparseMatrix::residual (Vector &dst, // if in MT mode and size sufficiently // large: do it in parallel; the limit // is mostly artificial - if (n_rows/NTHREADS > 2000) + if (n_rows/multithread_info.n_default_threads > 2000) { - const unsigned int n_threads = NTHREADS; + const unsigned int n_threads = multithread_info.n_default_threads; ThreadManager thread_manager; diff --git a/deal.II/lac/include/lac/sparse_vanka.h b/deal.II/lac/include/lac/sparse_vanka.h index 328d2b43e0..bef2d29292 100644 --- a/deal.II/lac/include/lac/sparse_vanka.h +++ b/deal.II/lac/include/lac/sparse_vanka.h @@ -18,6 +18,7 @@ #include +#include #include #include @@ -165,12 +166,15 @@ class SparseVanka * building the inverses of the * diagonal blocks. This * parameter is ignored if not in - * multithreaded mode. + * multithreaded mode. By + * default, this variable is set + * to the value of + * #multithread_info.n_default_threads#. */ SparseVanka(const SparseMatrix &M, const vector &selected, const bool conserve_memory = false, - const unsigned int n_threads = 1); + const unsigned int n_threads = multithread_info.n_default_threads); /** * Destructor. @@ -268,7 +272,7 @@ class SparseVanka * Number of threads to be used * when building the * inverses. Only relevant in - * multithread mode. + * multithreaded mode. */ const unsigned int n_threads; @@ -491,7 +495,7 @@ class SparseBlockVanka : public SparseVanka const unsigned int n_blocks, const BlockingStrategy blocking_strategy, const bool conserve_memory = false, - const unsigned int n_threads = 1); + const unsigned int n_threads = multithread_info.n_default_threads); /** * Apply the preconditioner. -- 2.39.5