]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix compiling with THREADS=ON 7246/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Fri, 28 Sep 2018 01:47:55 +0000 (03:47 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Fri, 28 Sep 2018 02:03:49 +0000 (04:03 +0200)
29 files changed:
include/deal.II/base/timer.h
include/deal.II/fe/fe_tools.templates.h
include/deal.II/lac/block_matrix_base.h
include/deal.II/lac/la_parallel_vector.templates.h
include/deal.II/lac/precondition.h
include/deal.II/lac/swappable_vector.templates.h
include/deal.II/lac/tensor_product_matrix.h
include/deal.II/lac/vector_memory.templates.h
include/deal.II/matrix_free/dof_info.templates.h
source/base/flow_function.cc
source/base/function_cspline.cc
source/base/function_parser.cc
source/base/index_set.cc
source/base/logstream.cc
source/base/polynomial.cc
source/base/polynomials_abf.cc
source/base/polynomials_bdm.cc
source/base/polynomials_raviart_thomas.cc
source/base/polynomials_rt_bubbles.cc
source/base/timer.cc
source/fe/fe_dgq.cc
source/fe/fe_nedelec.cc
source/fe/fe_poly_tensor.cc
source/fe/fe_q_base.cc
source/fe/fe_system.cc
source/fe/mapping_fe_field.cc
source/fe/mapping_q_eulerian.cc
source/lac/lapack_full_matrix.cc
source/lac/scalapack.cc

index 1acb5750d246ad5d196e17c021cde1a4e79a4441..1fad47765fea02ca885ea7cce93fee33a6f5f2f9 100644 (file)
@@ -910,7 +910,9 @@ private:
    * A lock that makes sure that this class gives reasonable results even when
    * used with several threads.
    */
+#ifdef DEAL_II_WITH_THREADS
   Threads::Mutex mutex;
+#endif
 };
 
 
index c741bc0c245c36e98688607c082b0c3a0eb4e24d..9721e875194794f0966a993a76f388c61ce07f18 100644 (file)
@@ -1281,7 +1281,9 @@ namespace FETools
       // they're in an anonymous namespace) in order to make icc happy
       // (which otherwise reports a multiply defined symbol when linking
       // libraries for more than one space dimension together
+#ifdef DEAL_II_WITH_THREADS
       static Threads::Mutex fe_name_map_lock;
+#endif
 
       // This is the map used by FETools::get_fe_by_name and
       // FETools::add_fe_name. It is only accessed by functions in this
@@ -2404,13 +2406,15 @@ namespace FETools
       "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"));
     if (name_end < name.size())
       name.erase(name_end);
-    // first make sure that no other
-    // thread intercepts the
-    // operation of this function;
-    // for this, acquire the lock
-    // until we quit this function
+      // first make sure that no other
+      // thread intercepts the
+      // operation of this function;
+      // for this, acquire the lock
+      // until we quit this function
+#ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(
       internal::FEToolsAddFENameHelper::fe_name_map_lock);
+#endif
 
     Assert(
       internal::FEToolsAddFENameHelper::fe_name_map[dim][spacedim].find(name) ==
@@ -2566,8 +2570,10 @@ namespace FETools
           {
             // Make sure no other thread
             // is just adding an element
+#ifdef DEAL_II_WITH_THREADS
             std::lock_guard<std::mutex> lock(
               internal::FEToolsAddFENameHelper::fe_name_map_lock);
+#endif
             AssertThrow(fe_name_map.find(name_part) != fe_name_map.end(),
                         FETools::ExcInvalidFEName(name));
 
index 13c9b4a335cf688e6f7f33e5ea80d69c8da85bd2..955d43d69c9dc3173f55fb1b75939331a6ebb75d 100644 (file)
@@ -1724,7 +1724,9 @@ BlockMatrixBase<MatrixType>::set(const size_type  row,
 
   // lock access to the temporary data structure to
   // allow multiple threads to call this function concurrently
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(temporary_data.mutex);
+#  endif
 
   // Resize scratch arrays
   if (temporary_data.column_indices.size() < this->n_block_cols())
@@ -1980,8 +1982,10 @@ BlockMatrixBase<MatrixType>::add(const size_type  row,
       return;
     }
 
-  // Lock scratch arrays, then resize them
+    // Lock scratch arrays, then resize them
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(temporary_data.mutex);
+#  endif
 
   if (temporary_data.column_indices.size() < this->n_block_cols())
     {
index f008b8ce53e3cab666b3899d0047bb534f9d8d3e..7a63627e51c5323d7a23e4d657a5cdb150adb057 100644 (file)
@@ -875,7 +875,9 @@ namespace LinearAlgebra
 
 #ifdef DEAL_II_WITH_MPI
       // make this function thread safe
+#  ifdef DEAL_II_WITH_THREADS
       std::lock_guard<std::mutex> lock(mutex);
+#  endif
 
       // allocate import_data in case it is not set up yet
       if (import_data == nullptr && partitioner->n_import_indices() > 0)
@@ -928,7 +930,9 @@ namespace LinearAlgebra
       // compress_requests.size() == 0
 
       // make this function thread safe
+#  ifdef DEAL_II_WITH_THREADS
       std::lock_guard<std::mutex> lock(mutex);
+#  endif
 
       Assert(partitioner->n_import_indices() == 0 || import_data != nullptr,
              ExcNotInitialized());
@@ -974,8 +978,10 @@ namespace LinearAlgebra
           partitioner->n_import_indices() == 0)
         return;
 
-      // make this function thread safe
+        // make this function thread safe
+#  ifdef DEAL_II_WITH_THREADS
       std::lock_guard<std::mutex> lock(mutex);
+#  endif
 
       // allocate import_data in case it is not set up yet
       if (import_data == nullptr && partitioner->n_import_indices() > 0)
@@ -1033,7 +1039,9 @@ namespace LinearAlgebra
       if (update_ghost_values_requests.size() > 0)
         {
           // make this function thread safe
+#  ifdef DEAL_II_WITH_THREADS
           std::lock_guard<std::mutex> lock(mutex);
+#  endif
 
           partitioner->export_to_ghosted_array_finish(
             ArrayView<Number>(data.values.get() + partitioner->local_size(),
index 45bdb20c1353fb2c8f0121c6e09250e0d745a344..595f2aa3054b035cb28cc6f3b13c6dc996a48eab 100644 (file)
@@ -2308,7 +2308,9 @@ PreconditionChebyshev<MatrixType, VectorType, PreconditionerType>::vmult(
   VectorType &      dst,
   const VectorType &src) const
 {
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#  endif
   if (eigenvalues_are_initialized == false)
     estimate_eigenvalues(src);
 
@@ -2334,7 +2336,9 @@ PreconditionChebyshev<MatrixType, VectorType, PreconditionerType>::Tvmult(
   VectorType &      dst,
   const VectorType &src) const
 {
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#  endif
   if (eigenvalues_are_initialized == false)
     estimate_eigenvalues(src);
 
@@ -2360,7 +2364,9 @@ PreconditionChebyshev<MatrixType, VectorType, PreconditionerType>::step(
   VectorType &      dst,
   const VectorType &src) const
 {
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#  endif
   if (eigenvalues_are_initialized == false)
     estimate_eigenvalues(src);
 
@@ -2387,7 +2393,9 @@ PreconditionChebyshev<MatrixType, VectorType, PreconditionerType>::Tstep(
   VectorType &      dst,
   const VectorType &src) const
 {
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#  endif
   if (eigenvalues_are_initialized == false)
     estimate_eigenvalues(src);
 
index 54963f8920f59fc6ca782ee29027c0c93daa0278..64b98682d24c63925f6224e33d1501260d5ccc87 100644 (file)
@@ -75,10 +75,12 @@ SwappableVector<number>::operator=(const SwappableVector<number> &v)
   if (filename != "")
     kill_file();
 
-  // if in MT mode, block all other
-  // operations. if not in MT mode,
-  // this is a no-op
+    // if in MT mode, block all other
+    // operations. if not in MT mode,
+    // this is a no-op
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(this->lock);
+#endif
 
   Vector<number>::operator=(v);
   data_is_preloaded       = false;
@@ -107,7 +109,9 @@ SwappableVector<number>::swap_out(const std::string &name)
   // if in MT mode, block all other
   // operations. if not in MT mode,
   // this is a no-op
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(this->lock);
+#endif
 
   //  check that we have not called
   //  @p alert without the respective
@@ -131,7 +135,9 @@ SwappableVector<number>::reload()
   // possibly existing @p alert
   // calls. if not in MT mode, this
   // is a no-op
+#ifdef DEAL_II_WITH_THREADS
   lock.lock();
+#endif
 
   // if data was already preloaded,
   // then there is no more need to
@@ -147,10 +153,12 @@ SwappableVector<number>::reload()
       // needed
       data_is_preloaded = false;
 
-      // release lock. the lock is
-      // also released in the other
-      // branch of the if-clause
+// release lock. the lock is
+// also released in the other
+// branch of the if-clause
+#ifdef DEAL_II_WITH_THREADS
       lock.unlock();
+#endif
     }
 }
 
@@ -225,7 +233,9 @@ SwappableVector<number>::kill_file()
   // (there should be none, but who
   // knows). if not in MT mode,
   // this is a no-op
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(this->lock);
+#endif
 
   // this is too bad: someone
   // requested the vector in advance,
index 53fcb039f15e3212af85f599da3fc2142e6d1d2a..6d86f64dbd51b31a051124c865848adb02ee756e 100644 (file)
@@ -477,8 +477,10 @@ TensorProductMatrixSymmetricSumBase<dim, Number, size>::vmult(
 {
   AssertDimension(dst_view.size(), this->m());
   AssertDimension(src_view.size(), this->n());
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(this->mutex);
-  const unsigned int          n =
+#  endif
+  const unsigned int n =
     Utilities::fixed_power<dim>(size > 0 ? size : eigenvalues[0].size());
   tmp_array.resize_fast(n * 2);
   constexpr int kernel_size = size > 0 ? size : 0;
@@ -545,8 +547,10 @@ TensorProductMatrixSymmetricSumBase<dim, Number, size>::apply_inverse(
 {
   AssertDimension(dst_view.size(), this->n());
   AssertDimension(src_view.size(), this->m());
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(this->mutex);
-  const unsigned int          n = size > 0 ? size : eigenvalues[0].size();
+#  endif
+  const unsigned int n = size > 0 ? size : eigenvalues[0].size();
   tmp_array.resize_fast(Utilities::fixed_power<dim>(n));
   constexpr int kernel_size = size > 0 ? size : 0;
   internal::EvaluatorTensorProduct<internal::evaluate_general,
index 20412b74805905a560dec84bc99ac1ebf0e37607..e111d568cd126406840c4025d22cbdb409a58a32 100644 (file)
@@ -81,7 +81,9 @@ inline GrowingVectorMemory<VectorType>::GrowingVectorMemory(
   , current_alloc(0)
   , log_statistics(log_statistics)
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
   pool.initialize(initial_size);
 }
 
@@ -106,7 +108,9 @@ template <typename VectorType>
 inline VectorType *
 GrowingVectorMemory<VectorType>::alloc()
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
 
   ++total_alloc;
   ++current_alloc;
@@ -136,7 +140,9 @@ template <typename VectorType>
 inline void
 GrowingVectorMemory<VectorType>::free(const VectorType *const v)
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
 
   for (typename std::vector<entry_type>::iterator i = pool.data->begin();
        i != pool.data->end();
@@ -158,7 +164,9 @@ template <typename VectorType>
 inline void
 GrowingVectorMemory<VectorType>::release_unused_memory()
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
 
   if (pool.data != nullptr)
     pool.data->clear();
@@ -170,7 +178,9 @@ template <typename VectorType>
 inline std::size_t
 GrowingVectorMemory<VectorType>::memory_consumption() const
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
 
   std::size_t                                            result = sizeof(*this);
   const typename std::vector<entry_type>::const_iterator end = pool.data->end();
index a3400b2b506a01db4bf42de0ba140dce3bc52b1b..349aade88653ba5d54a4016c61b82359af3d02df 100644 (file)
@@ -1286,11 +1286,15 @@ namespace internal
       static constexpr unsigned int bucket_size_threading = 256;
 
       void
-      compute_row_lengths(const unsigned int           begin,
-                          const unsigned int           end,
-                          const DoFInfo &              dof_info,
+      compute_row_lengths(const unsigned int begin,
+                          const unsigned int end,
+                          const DoFInfo &    dof_info,
+#ifdef DEAL_II_WITH_THREADS
                           std::vector<Threads::Mutex> &mutexes,
-                          std::vector<unsigned int> &  row_lengths)
+#else
+                          std::vector<Threads::Mutex> &,
+#endif
+                          std::vector<unsigned int> &row_lengths)
       {
         std::vector<unsigned int> scratch;
         const unsigned int n_components = dof_info.start_components.back();
@@ -1313,8 +1317,11 @@ namespace internal
                 // that are within the range of one lock at once
                 const unsigned int next_bucket =
                   (*it / bucket_size_threading + 1) * bucket_size_threading;
+#ifdef DEAL_II_WITH_THREADS
                 std::lock_guard<std::mutex> lock(
                   mutexes[*it / bucket_size_threading]);
+#endif
+
                 for (; it != end_unique && *it < next_bucket; ++it)
                   {
                     AssertIndexRange(*it, row_lengths.size());
@@ -1329,8 +1336,12 @@ namespace internal
                              const unsigned int               end,
                              const DoFInfo &                  dof_info,
                              const std::vector<unsigned int> &row_lengths,
-                             std::vector<Threads::Mutex> &    mutexes,
-                             dealii::SparsityPattern &        connectivity_dof)
+#ifdef DEAL_II_WITH_THREADS
+                             std::vector<Threads::Mutex> &mutexes,
+#else
+                             std::vector<Threads::Mutex> &,
+#endif
+                             dealii::SparsityPattern &connectivity_dof)
       {
         std::vector<unsigned int> scratch;
         const unsigned int n_components = dof_info.start_components.back();
@@ -1351,8 +1362,10 @@ namespace internal
               {
                 const unsigned int next_bucket =
                   (*it / bucket_size_threading + 1) * bucket_size_threading;
+#ifdef DEAL_II_WITH_THREADS
                 std::lock_guard<std::mutex> lock(
                   mutexes[*it / bucket_size_threading]);
+#endif
                 for (; it != end_unique && *it < next_bucket; ++it)
                   if (row_lengths[*it] > 0)
                     connectivity_dof.add(*it, block);
index 8dae6dc072a8039c632e50998775a9f136bd0a0d..8bf63deeefd2f6e0634ece9d96dfac59d876ae29 100644 (file)
@@ -57,7 +57,9 @@ namespace Functions
 
     // guard access to the aux_*
     // variables in multithread mode
+#ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(mutex);
+#endif
 
     for (unsigned int d = 0; d < dim + 1; ++d)
       aux_values[d].resize(n_points);
@@ -87,7 +89,9 @@ namespace Functions
 
     // guard access to the aux_*
     // variables in multithread mode
+#ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(mutex);
+#endif
 
     for (unsigned int d = 0; d < dim + 1; ++d)
       aux_values[d].resize(n_points);
@@ -110,7 +114,9 @@ namespace Functions
 
     // guard access to the aux_*
     // variables in multithread mode
+#ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(mutex);
+#endif
 
     for (unsigned int d = 0; d < dim + 1; ++d)
       aux_values[d].resize(n_points);
@@ -132,7 +138,9 @@ namespace Functions
 
     // guard access to the aux_*
     // variables in multithread mode
+#ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(mutex);
+#endif
 
     for (unsigned int d = 0; d < dim + 1; ++d)
       aux_gradients[d].resize(n_points);
@@ -160,7 +168,9 @@ namespace Functions
 
     // guard access to the aux_*
     // variables in multithread mode
+#ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(mutex);
+#endif
 
     for (unsigned int d = 0; d < dim + 1; ++d)
       aux_values[d].resize(n_points);
index cdc9972c4942514f319cc93be2099f377c75d164..46c83e8b82e5accef72304a7180490473173e981 100644 (file)
@@ -73,7 +73,9 @@ namespace Functions
     // GSL functions may modify gsl_interp_accel *acc object (last argument).
     // This can only work in multithreaded applications if we lock the data
     // structures via a mutex.
+#  ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(acc_mutex);
+#  endif
 
     const double x = p[0];
     Assert(x >= interpolation_points.front() &&
@@ -94,7 +96,9 @@ namespace Functions
     // GSL functions may modify gsl_interp_accel *acc object (last argument).
     // This can only work in multithreaded applications if we lock the data
     // structures via a mutex.
+#  ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(acc_mutex);
+#  endif
 
     const double x = p[0];
     Assert(x >= interpolation_points.front() &&
@@ -118,7 +122,9 @@ namespace Functions
     // GSL functions may modify gsl_interp_accel *acc object (last argument).
     // This can only work in multithreaded applications if we lock the data
     // structures via a mutex.
+#  ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(acc_mutex);
+#  endif
 
     const double x = p[0];
     Assert(x >= interpolation_points.front() &&
index 769c681851adb60cd2adad0491c7c0a709f6dbdd..3d27017dd0e2b851727ec9876343cfdd011ac376 100644 (file)
@@ -241,8 +241,10 @@ namespace internal
   double
   mu_rand_seed(double seed)
   {
+#  ifdef DEAL_II_WITH_THREADS
     static Threads::Mutex       rand_mutex;
     std::lock_guard<std::mutex> lock(rand_mutex);
+#  endif
 
     static boost::random::uniform_real_distribution<> uniform_distribution(0,
                                                                            1);
@@ -261,8 +263,10 @@ namespace internal
   double
   mu_rand()
   {
-    static Threads::Mutex                             rand_mutex;
-    std::lock_guard<std::mutex>                       lock(rand_mutex);
+#  ifdef DEAL_II_WITH_THREADS
+    static Threads::Mutex       rand_mutex;
+    std::lock_guard<std::mutex> lock(rand_mutex);
+#  endif
     static boost::random::uniform_real_distribution<> uniform_distribution(0,
                                                                            1);
     static boost::random::mt19937                     rng(
index 5a491e5f7aa60dff4ef971755ffaeb5bcbdda8cd..7b69d4f06e3977ea486fa0e155766021403d9dec 100644 (file)
@@ -129,7 +129,9 @@ IndexSet::do_compress() const
   // via a mutex, so that users can call 'const' functions from threads
   // in parallel (and these 'const' functions can then call compress()
   // which itself calls the current function)
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(compress_mutex);
+#endif
 
   // see if any of the contiguous ranges can be merged. do not use
   // std::vector::erase in-place as it is quadratic in the number of
index c1c97a33798ca7324794d12384ab219e501ff84a..976c99064f9005bc0365430c437983bd144de7b9 100644 (file)
@@ -27,8 +27,10 @@ DEAL_II_NAMESPACE_OPEN
 
 namespace
 {
+#ifdef DEAL_II_WITH_THREADS
   Threads::Mutex log_lock;
   Threads::Mutex write_lock;
+#endif
 } // namespace
 
 
@@ -191,7 +193,9 @@ LogStream::operator<<(std::ostream &(*p)(std::ostream &))
 
   if (query_streambuf.flushed())
     {
+#ifdef DEAL_II_WITH_THREADS
       std::lock_guard<std::mutex> lock(write_lock);
+#endif
 
       // Print the line head in case of a previous newline:
       if (at_newline)
@@ -218,7 +222,9 @@ LogStream::attach(std::ostream &                o,
                   const bool                    print_job_id,
                   const std::ios_base::fmtflags flags)
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(log_lock);
+#endif
   file = &o;
   o.setf(flags);
   if (print_job_id)
@@ -229,7 +235,9 @@ LogStream::attach(std::ostream &                o,
 void
 LogStream::detach()
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(log_lock);
+#endif
   file = nullptr;
 }
 
@@ -347,9 +355,11 @@ LogStream::width(const std::streamsize wide)
 unsigned int
 LogStream::depth_console(const unsigned int n)
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(log_lock);
-  const unsigned int          h = std_depth;
-  std_depth                     = n;
+#endif
+  const unsigned int h = std_depth;
+  std_depth            = n;
   return h;
 }
 
@@ -358,9 +368,11 @@ LogStream::depth_console(const unsigned int n)
 unsigned int
 LogStream::depth_file(const unsigned int n)
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(log_lock);
-  const unsigned int          h = file_depth;
-  file_depth                    = n;
+#endif
+  const unsigned int h = file_depth;
+  file_depth           = n;
   return h;
 }
 
@@ -369,9 +381,11 @@ LogStream::depth_file(const unsigned int n)
 bool
 LogStream::log_thread_id(const bool flag)
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(log_lock);
-  const bool                  h = print_thread_id;
-  print_thread_id               = flag;
+#endif
+  const bool h    = print_thread_id;
+  print_thread_id = flag;
   return h;
 }
 
index 141d55dd6c14a534617a553026b90c4d1448a2e3..2bc3f1d25adb3cbfd5785531f1a2008d6999eaf0 100644 (file)
@@ -38,8 +38,10 @@ DEAL_II_NAMESPACE_OPEN
 // more fine-grained solution
 namespace
 {
+#ifdef DEAL_II_WITH_THREADS
   Threads::Mutex coefficients_lock;
-}
+#endif
+} // namespace
 
 
 
@@ -1006,7 +1008,9 @@ namespace Polynomials
     // of this function
     // for this, acquire the lock
     // until we quit this function
+#ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(coefficients_lock);
+#endif
 
     // The first 2 coefficients
     // are hard-coded
@@ -1066,9 +1070,13 @@ namespace Polynomials
           }
         else if (k == 2)
           {
+#ifdef DEAL_II_WITH_THREADS
             coefficients_lock.unlock();
+#endif
             compute_coefficients(1);
+#ifdef DEAL_II_WITH_THREADS
             coefficients_lock.lock();
+#endif
 
             std::vector<double> c2(3);
 
@@ -1091,9 +1099,13 @@ namespace Polynomials
             // allow the called
             // function to acquire it
             // itself
+#ifdef DEAL_II_WITH_THREADS
             coefficients_lock.unlock();
+#endif
             compute_coefficients(k - 1);
+#ifdef DEAL_II_WITH_THREADS
             coefficients_lock.lock();
+#endif
 
             std::vector<double> ck(k + 1);
 
@@ -1140,7 +1152,9 @@ namespace Polynomials
     // then get a pointer to the array
     // of coefficients. do that in a MT
     // safe way
+#ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(coefficients_lock);
+#endif
     return *recursive_coefficients[k];
   }
 
index b8ca149a93f0c3f4056f217f9dd0aece411c9733..bf698b1ea49fd055641d4410761067de65a1d399 100644 (file)
@@ -86,7 +86,9 @@ PolynomialsABF<dim>::compute(
   // using a mutex to make sure they
   // are not used by multiple threads
   // at once
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
 
   p_values.resize((values.size() == 0) ? 0 : n_sub);
   p_grads.resize((grads.size() == 0) ? 0 : n_sub);
index 51491c0a0b4e3a86183f4f6d567aa938e8b4055d..860b8536586b72215d0f832fdaff07c35756856a 100644 (file)
@@ -85,7 +85,9 @@ PolynomialsBDM<dim>::compute(
   // are not used by multiple threads
   // at once
   {
+#ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(mutex);
+#endif
 
     p_values.resize((values.size() == 0) ? 0 : n_sub);
     p_grads.resize((grads.size() == 0) ? 0 : n_sub);
index 8bf74e98817e4d30026fda9b631eff3bfe922c46..9505832a048e5bb1be2bb06ef6b5b4b7191fa19e 100644 (file)
@@ -80,21 +80,23 @@ PolynomialsRaviartThomas<dim>::compute(
   Assert(fourth_derivatives.size() == n_pols || fourth_derivatives.size() == 0,
          ExcDimensionMismatch(fourth_derivatives.size(), n_pols));
 
-  // have a few scratch
-  // arrays. because we don't want to
-  // re-allocate them every time this
-  // function is called, we make them
-  // static. however, in return we
-  // have to ensure that the calls to
-  // the use of these variables is
-  // locked with a mutex. if the
-  // mutex is removed, several tests
-  // (notably
-  // deal.II/create_mass_matrix_05)
-  // will start to produce random
-  // results in multithread mode
+// have a few scratch
+// arrays. because we don't want to
+// re-allocate them every time this
+// function is called, we make them
+// static. however, in return we
+// have to ensure that the calls to
+// the use of these variables is
+// locked with a mutex. if the
+// mutex is removed, several tests
+// (notably
+// deal.II/create_mass_matrix_05)
+// will start to produce random
+// results in multithread mode
+#ifdef DEAL_II_WITH_THREADS
   static Threads::Mutex       mutex;
   std::lock_guard<std::mutex> lock(mutex);
+#endif
 
   static std::vector<double>         p_values;
   static std::vector<Tensor<1, dim>> p_grads;
index 117d244723462c7738e2a9d7a50b17cc9b8c49ac..8cc0447c6ff640056115e9e43937e2be532dca0a 100644 (file)
@@ -73,8 +73,10 @@ PolynomialsRT_Bubbles<dim>::compute(
   // using a mutex to make sure they are not used by multiple threads
   // at once
   {
+#ifdef DEAL_II_WITH_THREADS
     static Threads::Mutex       mutex;
     std::lock_guard<std::mutex> lock(mutex);
+#endif
 
     static std::vector<Tensor<1, dim>> p_values;
     static std::vector<Tensor<2, dim>> p_grads;
index e2a1fba761ffbff27fb9f8f07f2384673a996354..433bcb132c1e05008d582946f36cd1aa6ad60aea 100644 (file)
@@ -412,7 +412,9 @@ TimerOutput::~TimerOutput()
 void
 TimerOutput::enter_subsection(const std::string &section_name)
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
 
   Assert(section_name.empty() == false, ExcMessage("Section string is empty."));
 
@@ -457,7 +459,9 @@ TimerOutput::leave_subsection(const std::string &section_name)
   Assert(!active_sections.empty(),
          ExcMessage("Cannot exit any section because none has been entered!"));
 
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
 
   if (section_name != "")
     {
@@ -873,7 +877,9 @@ TimerOutput::enable_output()
 void
 TimerOutput::reset()
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
   sections.clear();
   active_sections.clear();
   timer_all.restart();
index 439fb5d7b5a783aa3c7de0f1bdbfa736b7e0056b..a923c88fbf6ee683531c25f6a20539401e9d1f55 100644 (file)
@@ -408,7 +408,9 @@ FE_DGQ<dim, spacedim>::get_prolongation_matrix(
   // initialization upon first request
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
+#ifdef DEAL_II_WITH_THREADS
       std::lock_guard<std::mutex> lock(this->mutex);
+#endif
 
       // if matrix got updated while waiting for the lock
       if (this->prolongation[refinement_case - 1][child].n() ==
@@ -488,7 +490,9 @@ FE_DGQ<dim, spacedim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
+#ifdef DEAL_II_WITH_THREADS
       std::lock_guard<std::mutex> lock(this->mutex);
+#endif
 
       // if matrix got updated while waiting for the lock...
       if (this->restriction[refinement_case - 1][child].n() ==
index 51f5fe7515b7f0484f2117821d73c78218fffa51..367cd35799962886e63e93424fd570444da1e34c 100644 (file)
@@ -2985,7 +2985,9 @@ FE_Nedelec<dim>::get_prolongation_matrix(
   // initialization upon first request
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
+#ifdef DEAL_II_WITH_THREADS
       std::lock_guard<std::mutex> lock(this->mutex);
+#endif
 
       // if matrix got updated while waiting for the lock
       if (this->prolongation[refinement_case - 1][child].n() ==
@@ -3047,7 +3049,9 @@ FE_Nedelec<dim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
+#ifdef DEAL_II_WITH_THREADS
       std::lock_guard<std::mutex> lock(this->mutex);
+#endif
 
       // if matrix got updated while waiting for the lock...
       if (this->restriction[refinement_case - 1][child].n() ==
index 2dc68bc749b933fb966a3400e0926f47b5df838f..f68b05c36c431eba509a2fa9f5c1ca9280c5a7ea 100644 (file)
@@ -201,7 +201,9 @@ FE_PolyTensor<PolynomialType, dim, spacedim>::shape_value_component(
   Assert(i < this->dofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell));
   Assert(component < dim, ExcIndexRange(component, 0, dim));
 
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(cache_mutex);
+#endif
 
   if (cached_point != p || cached_values.size() == 0)
     {
@@ -247,7 +249,9 @@ FE_PolyTensor<PolynomialType, dim, spacedim>::shape_grad_component(
   Assert(i < this->dofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell));
   Assert(component < dim, ExcIndexRange(component, 0, dim));
 
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(cache_mutex);
+#endif
 
   if (cached_point != p || cached_grads.size() == 0)
     {
@@ -294,7 +298,9 @@ FE_PolyTensor<PolynomialType, dim, spacedim>::shape_grad_grad_component(
   Assert(i < this->dofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell));
   Assert(component < dim, ExcIndexRange(component, 0, dim));
 
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(cache_mutex);
+#endif
 
   if (cached_point != p || cached_grad_grads.size() == 0)
     {
index fd4f429c2293f5f9beb6006e1c53567e456a54d4..09a7b01f1f9eb8278f8a305ddcf65f843a7a43a9 100644 (file)
@@ -1232,7 +1232,9 @@ FE_Q_Base<PolynomialType, dim, spacedim>::get_prolongation_matrix(
   // initialization upon first request
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
+#ifdef DEAL_II_WITH_THREADS
       std::lock_guard<std::mutex> lock(this->mutex);
+#endif
 
       // if matrix got updated while waiting for the lock
       if (this->prolongation[refinement_case - 1][child].n() ==
@@ -1434,7 +1436,9 @@ FE_Q_Base<PolynomialType, dim, spacedim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
+#ifdef DEAL_II_WITH_THREADS
       std::lock_guard<std::mutex> lock(this->mutex);
+#endif
 
       // if matrix got updated while waiting for the lock...
       if (this->restriction[refinement_case - 1][child].n() ==
index 89f88c634fa55463f410f1f920554d02e8c29e38..a10d8c14b010f6a3e8383bc115369a648ff46312 100644 (file)
@@ -718,7 +718,9 @@ FESystem<dim, spacedim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
+#ifdef DEAL_II_WITH_THREADS
       std::lock_guard<std::mutex> lock(this->mutex);
+#endif
 
       // check if updated while waiting for lock
       if (this->restriction[refinement_case - 1][child].n() ==
@@ -815,7 +817,9 @@ FESystem<dim, spacedim>::get_prolongation_matrix(
   // restriction matrix
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
+#ifdef DEAL_II_WITH_THREADS
       std::lock_guard<std::mutex> lock(this->mutex);
+#endif
 
       if (this->prolongation[refinement_case - 1][child].n() ==
           this->dofs_per_cell)
index 5289c9d1e7ce1bc0a17758f10a57fb3bfea5be35..879388ff8d7ab2c0fc179b8db0c5c6ca61ad4743 100644 (file)
@@ -321,7 +321,9 @@ MappingFEField<dim, spacedim, VectorType, DoFHandlerType>::get_vertices(
       euler_dof_handler->get_fe().n_components()));
 
   {
+#ifdef DEAL_II_WITH_THREADS
     std::lock_guard<std::mutex> lock(fe_values_mutex);
+#endif
     fe_values.reinit(dof_cell);
     fe_values.get_function_values(*euler_vector, values);
   }
index e4bd088f83cc364baf0c53bf14825b0c28e7db28..530c0c84320be77f4e5f6944543f0ab189815aab 100644 (file)
@@ -221,7 +221,9 @@ MappingQEulerian<dim, VectorType, spacedim>::MappingQEulerianGeneric::
   // fill shift vector for each support point using an fe_values object. make
   // sure that the fe_values variable isn't used simultaneously from different
   // threads
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(fe_values_mutex);
+#endif
   fe_values.reinit(dof_cell);
   if (mg_vector)
     {
index e075424f7975f6b562f4bff2f6d8503dfaee485e..40393811b469288a2181cf500f735419fbee04c8 100644 (file)
@@ -670,7 +670,9 @@ LAPACKFullMatrix<number>::vmult(Vector<number> &      w,
         }
       case svd:
         {
+#ifdef DEAL_II_WITH_THREADS
           std::lock_guard<std::mutex> lock(mutex);
+#endif
           AssertDimension(v.size(), this->n());
           AssertDimension(w.size(), this->m());
           // Compute V^T v
@@ -705,7 +707,9 @@ LAPACKFullMatrix<number>::vmult(Vector<number> &      w,
         }
       case inverse_svd:
         {
+#ifdef DEAL_II_WITH_THREADS
           std::lock_guard<std::mutex> lock(mutex);
+#endif
           AssertDimension(w.size(), this->n());
           AssertDimension(v.size(), this->m());
           // Compute U^T v
@@ -805,7 +809,9 @@ LAPACKFullMatrix<number>::Tvmult(Vector<number> &      w,
         }
       case svd:
         {
+#ifdef DEAL_II_WITH_THREADS
           std::lock_guard<std::mutex> lock(mutex);
+#endif
           AssertDimension(w.size(), this->n());
           AssertDimension(v.size(), this->m());
 
@@ -841,7 +847,9 @@ LAPACKFullMatrix<number>::Tvmult(Vector<number> &      w,
         }
       case inverse_svd:
         {
+#ifdef DEAL_II_WITH_THREADS
           std::lock_guard<std::mutex> lock(mutex);
+#endif
           AssertDimension(v.size(), this->n());
           AssertDimension(w.size(), this->m());
 
@@ -996,7 +1004,9 @@ LAPACKFullMatrix<number>::Tmmult(LAPACKFullMatrix<number> &      C,
   // https://stackoverflow.com/questions/3548069/multiplying-three-matrices-in-blas-with-the-middle-one-being-diagonal
   // http://mathforum.org/kb/message.jspa?messageID=3546564
 
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
   // First, get V*B into "work" array
   work.resize(kk * nn);
   // following http://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=2&t=768#p2577
@@ -1369,7 +1379,9 @@ template <typename number>
 number
 LAPACKFullMatrix<number>::norm(const char type) const
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
 
   Assert(state == LAPACKSupport::matrix ||
            state == LAPACKSupport::inverse_matrix,
@@ -1447,7 +1459,9 @@ template <typename number>
 number
 LAPACKFullMatrix<number>::reciprocal_condition_number(const number a_norm) const
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
   Assert(state == cholesky, ExcState(state));
   number rcond = 0.;
 
@@ -1480,7 +1494,9 @@ template <typename number>
 number
 LAPACKFullMatrix<number>::reciprocal_condition_number() const
 {
+#ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#endif
   Assert(property == upper_triangular || property == lower_triangular,
          ExcProperty(property));
   number rcond = 0.;
index 8067646a20bef2bf9254932b7612ff8ebd25845f..57c96e37e6d6b8f158c1f51529d032db767bd782 100644 (file)
@@ -1388,7 +1388,9 @@ ScaLAPACKMatrix<NumberType>::eigenpairs_symmetric(
   Assert(property == LAPACKSupport::symmetric,
          ExcMessage("Matrix has to be symmetric for this operation."));
 
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#  endif
 
   const bool use_values = (std::isnan(eigenvalue_limits.first) ||
                            std::isnan(eigenvalue_limits.second)) ?
@@ -1719,7 +1721,9 @@ ScaLAPACKMatrix<NumberType>::eigenpairs_symmetric_MRRR(
   Assert(property == LAPACKSupport::symmetric,
          ExcMessage("Matrix has to be symmetric for this operation."));
 
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#  endif
 
   const bool use_values = (std::isnan(eigenvalue_limits.first) ||
                            std::isnan(eigenvalue_limits.second)) ?
@@ -1956,7 +1960,9 @@ ScaLAPACKMatrix<NumberType>::compute_SVD(ScaLAPACKMatrix<NumberType> *U,
              ExcDimensionMismatch(grid->blacs_context,
                                   VT->grid->blacs_context));
     }
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#  endif
 
   std::vector<NumberType> sv(std::min(n_rows, n_columns));
 
@@ -2071,7 +2077,9 @@ ScaLAPACKMatrix<NumberType>::least_squares(ScaLAPACKMatrix<NumberType> &B,
          ExcMessage(
            "Use identical block-cyclic distribution for matrices A and B"));
 
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
+#  endif
 
   if (grid->mpi_process_is_active)
     {
@@ -2223,8 +2231,10 @@ ScaLAPACKMatrix<NumberType>::reciprocal_condition_number(
   Assert(state == LAPACKSupport::cholesky,
          ExcMessage(
            "Matrix has to be in Cholesky state before calling this function."));
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
-  NumberType                  rcond = 0.;
+#  endif
+  NumberType rcond = 0.;
 
   if (grid->mpi_process_is_active)
     {
@@ -2326,8 +2336,10 @@ ScaLAPACKMatrix<NumberType>::norm_general(const char type) const
   Assert(state == LAPACKSupport::matrix ||
            state == LAPACKSupport::inverse_matrix,
          ExcMessage("norms can be called in matrix state only."));
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
-  NumberType                  res = 0.;
+#  endif
+  NumberType res = 0.;
 
   if (grid->mpi_process_is_active)
     {
@@ -2387,8 +2399,10 @@ ScaLAPACKMatrix<NumberType>::norm_symmetric(const char type) const
          ExcMessage("norms can be called in matrix state only."));
   Assert(property == LAPACKSupport::symmetric,
          ExcMessage("Matrix has to be symmetric for this operation."));
+#  ifdef DEAL_II_WITH_THREADS
   std::lock_guard<std::mutex> lock(mutex);
-  NumberType                  res = 0.;
+#  endif
+  NumberType res = 0.;
 
   if (grid->mpi_process_is_active)
     {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.