]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Rest of change from #if to #ifdef
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 11 Sep 2012 17:02:01 +0000 (17:02 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 11 Sep 2012 17:02:01 +0000 (17:02 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@26292 0785d39b-7218-0410-832d-ea1e28bc413d

16 files changed:
deal.II/CMakeLists.txt
deal.II/include/deal.II/base/config.h.in
deal.II/include/deal.II/base/parallel.h
deal.II/include/deal.II/base/thread_local_storage.h
deal.II/include/deal.II/base/thread_management.h
deal.II/include/deal.II/base/work_stream.h
deal.II/include/deal.II/lac/sparse_vanka.templates.h
deal.II/include/deal.II/lac/swappable_vector.templates.h
deal.II/include/deal.II/matrix_free/mapping_info.templates.h
deal.II/include/deal.II/matrix_free/matrix_free.h
deal.II/include/deal.II/matrix_free/matrix_free.templates.h
deal.II/include/deal.II/numerics/vector_tools.templates.h
deal.II/source/base/boost_threads.cc
deal.II/source/base/multithread_info.cc
deal.II/source/base/subscriptor.cc
deal.II/source/numerics/time_dependent.cc

index 30230879bee6c91614c337ac755ad0ec4913fb90..32d210bc8bc945f9b7ac44ad37ca12acd65a5541 100644 (file)
@@ -162,6 +162,8 @@ ENDIF()
 # Platform checks:
 #
 
+INCLUDE(check_for_compiler_features)
+
 INCLUDE(check_for_cxx_features)
 
 INCLUDE(check_for_compiler_bugs)
index ea46530a2d43158d5b5d0b21b0bfcc40ced476fd..7854256881cce4df9f402fb30a6c2f3e66df2a78 100644 (file)
  * volatile. We do this here in a very old-fashioned C-style, but still
  * convenient way.
  */
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 #  define DEAL_VOLATILE volatile
 #else
 #  define DEAL_VOLATILE
index d4f46a59aa1596ba5e3e9f1049477a000c243f2c..363462bf42456b5ed0161d1dde1d925d9ab2af2d 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <cstddef>
 
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 #  include <tbb/parallel_for.h>
 #  include <tbb/parallel_reduce.h>
 #  include <tbb/partitioner.h>
@@ -340,7 +340,7 @@ namespace parallel
 
   namespace internal
   {
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
                                      /**
                                       * Take a range argument and call the
                                       * given function with its begin and end.
@@ -546,7 +546,7 @@ namespace parallel
 
   namespace internal
   {
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
                                      /**
                                       * A class that conforms to the Body
                                       * requirements of the TBB
@@ -813,7 +813,7 @@ namespace internal
 namespace parallel
 {
 
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 
   namespace internal
   {
@@ -851,7 +851,7 @@ namespace parallel
                                       const std::size_t end,
                                       const std::size_t minimum_parallel_grain_size) const
   {
-#if DEAL_II_USE_MT == 0
+#ifndef DEAL_II_USE_MT
                                      // make sure we don't get compiler
                                      // warnings about unused arguments
     (void) minimum_parallel_grain_size;
index 210b90c80d61ea46c84369d838034ec311ecd237..75f5e69a277bf89e843cf1cdd696d6fc607adcbd 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <deal.II/base/config.h>
 
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 #  include <tbb/enumerable_thread_specific.h>
 #endif
 
@@ -121,7 +121,7 @@ namespace Threads
     ThreadLocalStorage<T> & operator = (const T &t);
 
   private:
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
     /**
      * The data element we store. If we support threads, then this
      * object will be of a type that provides a separate object
@@ -163,7 +163,7 @@ namespace Threads
   T &
   ThreadLocalStorage<T>::get ()
   {
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
     return data.local();
 #else
     return data;
index e16b39078f52e2be1b3982427aeb074dbeab1516..c0a0eb4473ba758f8835e0011b44b18acf9dd902 100644 (file)
@@ -21,7 +21,7 @@
 #include <deal.II/base/std_cxx1x/shared_ptr.h>
 #include <deal.II/base/std_cxx1x/bind.h>
 
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 #  include <deal.II/base/std_cxx1x/thread.h>
 #  include <deal.II/base/std_cxx1x/mutex.h>
 #  include <deal.II/base/std_cxx1x/condition_variable.h>
@@ -33,8 +33,8 @@
 #include <utility>
 
 
-#if DEAL_II_USE_MT
-#  if defined(DEAL_II_USE_MT_POSIX)
+#ifdef DEAL_II_USE_MT
+#  ifdef DEAL_II_USE_MT_POSIX
 #    include <pthread.h>
 #  endif
 #  include <tbb/task.h>
@@ -273,7 +273,7 @@ namespace Threads
   };
 
 
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 
                                    /**
                                     * Class implementing a
@@ -1229,7 +1229,7 @@ namespace Threads
 
   namespace internal
   {
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 
                                      /**
                                       * A class that represents threads. For
@@ -3735,7 +3735,7 @@ namespace Threads
 
   namespace internal
   {
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 
     template <typename> struct TaskDescriptor;
 
index f70eb9afd4156244893dad5c96d303f5a81f7e55..c1af07325cb75a0aa8154ba9fa3cde2d28db751c 100644 (file)
@@ -19,7 +19,7 @@
 #include <deal.II/base/std_cxx1x/function.h>
 #include <deal.II/base/std_cxx1x/bind.h>
 
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 #  include <deal.II/base/thread_management.h>
 #  include <tbb/pipeline.h>
 #endif
@@ -125,7 +125,7 @@ DEAL_II_NAMESPACE_OPEN
 namespace WorkStream
 {
 
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 
 
   namespace internal
@@ -527,7 +527,7 @@ namespace WorkStream
     if (!(begin != end))
       return;
 
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
                                      // create the three stages of the
                                      // pipeline
     internal::IteratorRangeToItemStream<Iterator,ScratchData,CopyData>
index 38e8c133fcba91f99141f7a865dbe61989c8a463..cde7ca6b9ac0b9d3b5b28612e42503e0679fc793 100644 (file)
@@ -62,66 +62,65 @@ template <typename number>
 void
 SparseVanka<number>::compute_inverses ()
 {
-  if (!DEAL_II_USE_MT)
-    compute_inverses (0, matrix->m());
-  else
-    {
-      const unsigned int n_inverses = std::count (selected.begin(),
-                                                  selected.end(),
-                                                  true);
-
-      const unsigned int n_inverses_per_thread = std::max(n_inverses / n_threads,
-                                                          1U);
-
-                                       // set up start and end index
-                                       // for each of the
-                                       // threads. note that we have
-                                       // to work somewhat to get this
-                                       // appropriate, since the
-                                       // indices for which inverses
-                                       // have to be computed may not
-                                       // be evenly distributed in the
-                                       // vector. as an extreme
-                                       // example consider numbering
-                                       // of DoFs by component, then
-                                       // all indices for which we
-                                       // have to do work will be
-                                       // consecutive, with other
-                                       // consecutive regions where we
-                                       // do not have to do something
-      std::vector<std::pair<unsigned int, unsigned int> > blocking (n_threads);
+#ifndef DEAL_II_USE_MT
+  compute_inverses (0, matrix->m());
+#else
+  const unsigned int n_inverses = std::count (selected.begin(),
+                                              selected.end(),
+                                              true);
 
-      unsigned int c       = 0;
-      unsigned int thread  = 0;
-      blocking[0].first = 0;
+  const unsigned int n_inverses_per_thread = std::max(n_inverses / n_threads,
+                                                      1U);
+
+                                   // set up start and end index
+                                   // for each of the
+                                   // threads. note that we have
+                                   // to work somewhat to get this
+                                   // appropriate, since the
+                                   // indices for which inverses
+                                   // have to be computed may not
+                                   // be evenly distributed in the
+                                   // vector. as an extreme
+                                   // example consider numbering
+                                   // of DoFs by component, then
+                                   // all indices for which we
+                                   // have to do work will be
+                                   // consecutive, with other
+                                   // consecutive regions where we
+                                   // do not have to do something
+  std::vector<std::pair<unsigned int, unsigned int> > blocking (n_threads);
 
-      for (unsigned int i=0; (i<matrix->m()) && (thread+1<n_threads); ++i)
+  unsigned int c       = 0;
+  unsigned int thread  = 0;
+  blocking[0].first = 0;
+
+  for (unsigned int i=0; (i<matrix->m()) && (thread+1<n_threads); ++i)
+    {
+      if (selected[i] == true)
+        ++c;
+      if (c == n_inverses_per_thread)
         {
-          if (selected[i] == true)
-            ++c;
-          if (c == n_inverses_per_thread)
-            {
-              blocking[thread].second  = i;
-              blocking[thread+1].first = i;
-              ++thread;
+          blocking[thread].second  = i;
+          blocking[thread+1].first = i;
+          ++thread;
 
-              c = 0;
-            };
+          c = 0;
         };
-      blocking[n_threads-1].second = matrix->m();
-
-      typedef void (SparseVanka<number>::*FunPtr)(const unsigned int,
-                                                  const unsigned int);
-      const FunPtr fun_ptr = &SparseVanka<number>::compute_inverses;
-
-                                       // Now spawn the threads
-      Threads::ThreadGroup<> threads;
-      for (unsigned int i=0; i<n_threads; ++i)
-        threads += Threads::new_thread (fun_ptr, *this,
-                                        blocking[i].first,
-                                        blocking[i].second);
-      threads.join_all ();
     };
+  blocking[n_threads-1].second = matrix->m();
+
+  typedef void (SparseVanka<number>::*FunPtr)(const unsigned int,
+                                              const unsigned int);
+  const FunPtr fun_ptr = &SparseVanka<number>::compute_inverses;
+
+                                   // Now spawn the threads
+  Threads::ThreadGroup<> threads;
+  for (unsigned int i=0; i<n_threads; ++i)
+    threads += Threads::new_thread (fun_ptr, *this,
+                                    blocking[i].first,
+                                    blocking[i].second);
+  threads.join_all ();
+#endif
 }
 
 
@@ -581,38 +580,37 @@ void SparseBlockVanka<number>::vmult (Vector<number2>       &dst,
   else
                                      // otherwise: blocking requested
     {
-      if (DEAL_II_USE_MT)
-        {
-                                           // spawn threads. since
-                                           // some compilers have
-                                           // trouble finding out
-                                           // which 'encapsulate'
-                                           // function to take of all
-                                           // those possible ones if
-                                           // we simply drop in the
-                                           // address of an overloaded
-                                           // template member
-                                           // function, make it
-                                           // simpler for the compiler
-                                           // by giving it the correct
-                                           // type right away:
-          typedef void (SparseVanka<number>::*mem_fun_p)
-            (Vector<number2> &,
-             const Vector<number2> &,
-             const std::vector<bool> * const) const;
-          const mem_fun_p comp
-            = &SparseVanka<number>::template apply_preconditioner<number2>;
-          Threads::ThreadGroup<> threads;
-          for (unsigned int block=0; block<n_blocks; ++block)
-            threads += Threads::new_thread (comp,
-                                            *static_cast<const SparseVanka<number>*>(this),
-                                            dst, src,&dof_masks[block]);
-          threads.join_all ();
-        }
-      else
+#ifdef DEAL_II_USE_MT
+                                         // spawn threads. since
+                                         // some compilers have
+                                         // trouble finding out
+                                         // which 'encapsulate'
+                                         // function to take of all
+                                         // those possible ones if
+                                         // we simply drop in the
+                                         // address of an overloaded
+                                         // template member
+                                         // function, make it
+                                         // simpler for the compiler
+                                         // by giving it the correct
+                                         // type right away:
+        typedef void (SparseVanka<number>::*mem_fun_p)
+          (Vector<number2> &,
+           const Vector<number2> &,
+           const std::vector<bool> * const) const;
+        const mem_fun_p comp
+          = &SparseVanka<number>::template apply_preconditioner<number2>;
+        Threads::ThreadGroup<> threads;
+        for (unsigned int block=0; block<n_blocks; ++block)
+          threads += Threads::new_thread (comp,
+                                          *static_cast<const SparseVanka<number>*>(this),
+                                          dst, src,&dof_masks[block]);
+        threads.join_all ();
+#else
         for (unsigned int block=0; block<n_blocks; ++block)
           this->apply_preconditioner (dst, src,
                                       &dof_masks[block]);
+#endif
     }
 }
 
index cb56dec44b98893936b310eae7f12c29b9881ead..c6252665e7fd22ee9f01da4624e414ac6e5b91ef 100644 (file)
@@ -145,10 +145,11 @@ void SwappableVector<number>::reload ()
 template <typename number>
 void SwappableVector<number>::alert ()
 {
+#ifndef DEAL_II_USE_MT
                                    // note: this function does nothing
                                    // in non-MT mode
-  if (!DEAL_II_USE_MT)
     return;
+#else
 
                                    // synchronise with possible other
                                    // invocations of this function and
@@ -170,6 +171,7 @@ void SwappableVector<number>::alert ()
     Threads::new_thread (&SwappableVector<number>::reload_vector, *this, true);
                                    // note that reload_vector also
                                    // releases the lock
+#endif
 }
 
 
@@ -184,16 +186,16 @@ void SwappableVector<number>::reload_vector (const bool set_flag)
   this->block_read (tmp_in);
   tmp_in.close ();
 
+#ifdef DEAL_II_USE_MT
                                    // release the lock that was
                                    // acquired by the calling
                                    // functions
-  if (DEAL_II_USE_MT)
-    {
-                                       // set the flag if so required
-      if (set_flag)
-        data_is_preloaded = true;
-      lock.release ();
-    };
+
+                                   // set the flag if so required
+  if (set_flag)
+    data_is_preloaded = true;
+  lock.release ();
+#endif
 }
 
 
index 9d1626f45a9e08af1301172e24433ece5a51d064..227e9f8d1adf46331798942f1baa05ab57b549d9 100644 (file)
@@ -947,7 +947,7 @@ namespace MatrixFreeFunctions
                                 // global communication, so we can
                                 // disable the check here only if no
                                 // processor has any such data
-#if DEAL_II_COMPILER_SUPPORTS_MPI
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
     unsigned int general_size_glob = 0, general_size_loc = jacobians.size();
     MPI_Allreduce (&general_size_loc, &general_size_glob, 1, MPI_UNSIGNED,
                    MPI_MAX, size_info.communicator);
@@ -966,7 +966,7 @@ namespace MatrixFreeFunctions
            MemoryConsumption::memory_consumption (jacobians_grad_upper));
       }
 
-#if DEAL_II_COMPILER_SUPPORTS_MPI
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
     unsigned int quad_size_glob = 0, quad_size_loc = quadrature_points.size();
     MPI_Allreduce (&quad_size_loc, &quad_size_glob, 1, MPI_UNSIGNED,
                    MPI_MAX, size_info.communicator);
index b9e75d51179aee00734be63c824fb00a490d7da3..e60a9cabd80b7a978ea8c1a1cc9211abed12040f 100644 (file)
@@ -33,7 +33,7 @@
 #include <deal.II/matrix_free/dof_info.h>
 #include <deal.II/matrix_free/mapping_info.h>
 
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 #include <tbb/task.h>
 #include <tbb/task_scheduler_init.h>
 #include <tbb/parallel_for.h>
@@ -2101,7 +2101,7 @@ namespace internal
   }
 
 
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 
   // This defines the TBB data structures that
   // are needed to schedule the
@@ -2353,7 +2353,7 @@ namespace internal
     VectorStruct &dst;
   };
 
-#endif // #if DEAL_II_USE_MT
+#endif // DEAL_II_USE_MT
 
 } // end of namespace internal
 
@@ -2372,7 +2372,7 @@ MatrixFree<dim, Number>::cell_loop
  OutVector       &dst,
  const InVector  &src) const
 {
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 
                                 // Use multithreading if so requested and if
                                 // there is enough work to do in parallel (the
index 77a4f0759297e0383e568f531fa2897c7b9c23a5..ad562dcaea3b2777b41ef6eda2c6566ec4217aef 100644 (file)
@@ -73,7 +73,7 @@ namespace internal
   void assert_communicator_equality (const dealii::Triangulation<dim>&tria,
                                      const MPI_Comm                  &comm_mf)
   {
-#if DEAL_II_COMPILER_SUPPORTS_MPI
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
     const parallel::distributed::Triangulation<dim>* dist_tria =
       dynamic_cast<const parallel::distributed::Triangulation<dim>*>(&tria);
     if (dist_tria != 0)
@@ -139,7 +139,7 @@ internal_reinit(const Mapping<dim>                         &mapping,
                                 // initialize the basic multithreading
                                 // information that needs to be passed to the
                                 // DoFInfo structure
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
       if (additional_data.tasks_parallel_scheme != AdditionalData::none)
         {
           task_info.use_multithreading = true;
@@ -242,7 +242,7 @@ internal_reinit(const Mapping<dim>                            &mapping,
                                 // initialize the basic multithreading
                                 // information that needs to be passed to the
                                 // DoFInfo structure
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
       if (additional_data.tasks_parallel_scheme != AdditionalData::none)
         {
           task_info.use_multithreading = true;
@@ -984,7 +984,7 @@ namespace internal
                                 // try to balance the number of cells before
                                 // and after the boundary part on each
                                 // processor. probably not worth it!
-#if DEAL_II_COMPILER_SUPPORTS_MPI
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
     MPI_Allreduce (&n_boundary_cells, &n_max_boundary_cells, 1, MPI_UNSIGNED,
                    MPI_MAX, size_info.communicator);
 #endif
index bea6de958ed0df221069784d7d7ea7e7127ac9be..d30b1c824fa45f5397528dfab745e8c279ac0558 100644 (file)
@@ -5661,7 +5661,7 @@ namespace VectorTools
             }
         }
 
-#if DEAL_II_USE_P4EST
+#ifdef DEAL_II_USE_P4EST
                                      // if this was a distributed
                                      // DoFHandler, we need to do the
                                      // reduction over the entire domain
index 7c14d74918a92a3d71b08a7158789c2fcd617857..05dde5a01d7bc3a088d80dea68d3d4ae5742055e 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <deal.II/base/config.h>
 
-#if DEAL_II_USE_MT && !defined(DEAL_II_CAN_USE_CXX1X) && !defined(DEAL_II_USE_EXTERNAL_BOOST)
+#if defined(DEAL_II_USE_MT) && !defined(DEAL_II_CAN_USE_CXX1X) && !defined(DEAL_II_USE_EXTERNAL_BOOST)
 
 // if the C++ compiler doesn't completely support the C++1x standard (and
 // consequently we can't use std::thread, std::mutex, etc), then include all
@@ -21,8 +21,8 @@
 // build BOOST itself only to get at this small part of it. it also ensures
 // that we use the correct compiler and flags
 
-#  define BOOST_THREAD_BUILD_LIB 1
-#  define DBOOST_ALL_NO_LIB 1
+#  define BOOST_THREAD_BUILD_LIB
+#  define DBOOST_ALL_NO_LIB
 
 #  ifdef DEAL_II_USE_MT_POSIX
 #    define BOOST_THREAD_POSIX
index 421f4a447456ea5a19bb9e899980a4f1d51fded7..99457283380e0530ba040a8f61f868cb2d65e166 100644 (file)
@@ -36,7 +36,7 @@
 DEAL_II_NAMESPACE_OPEN
 
 
-#if DEAL_II_USE_MT
+#ifdef DEAL_II_USE_MT
 
 /* Detecting how many processors a given machine has is something that
    varies greatly between operating systems. For a few operating
index ec6f3534abd0795fa3bd459db87897aa205a1d2b..0d98ee6f8a597d11a07b06d63aa69c73c07878e4 100644 (file)
@@ -147,7 +147,7 @@ void Subscriptor::do_subscribe (const char* id) const
   Threads::ThreadMutex::ScopedLock lock (subscription_lock);
   ++counter;
 
-#if DEAL_USE_MT == 0
+#ifndef DEAL_II_USE_MT
   const char* const name = (id != 0) ? id : unknown_subscriber;
 
   map_iterator it = counter_map.find(name);
@@ -174,7 +174,7 @@ void Subscriptor::do_unsubscribe (const char* id) const
   Threads::ThreadMutex::ScopedLock lock (subscription_lock);
   --counter;
 
-#if DEAL_USE_MT == 0
+#ifndef DEAL_II_USE_MT
   map_iterator it = counter_map.find(name);
   Assert (it != counter_map.end(), ExcNoSubscriber(object_info->name(), name));
   Assert (it->second > 0, ExcNoSubscriber(object_info->name(), name));
@@ -193,7 +193,7 @@ unsigned int Subscriptor::n_subscriptions () const
 
 void Subscriptor::list_subscribers () const
 {
-#if DEAL_USE_MT == 0
+#ifndef DEAL_II_USE_MT
   for (map_iterator it = counter_map.begin();
   it != counter_map.end(); ++it)
     deallog << it->second << '/'
index c5d1355cc491117118f33cd70dc3d13564ae26a4..24ad0d22ee432884b80dcb1d2f339b22df26fa2b 100644 (file)
@@ -206,7 +206,8 @@ void TimeDependent::start_sweep (const unsigned int s)
 
 void TimeDependent::end_sweep (const unsigned int n_threads)
 {
-  if (DEAL_II_USE_MT && (n_threads > 1))
+#ifdef DEAL_II_USE_MT
+  if (n_threads > 1)
     {
       const unsigned int stride = timesteps.size() / n_threads;
       Threads::ThreadGroup<> threads;
@@ -220,8 +221,13 @@ void TimeDependent::end_sweep (const unsigned int n_threads)
       threads.join_all();
     }
   else
+    {
                                      // now do the work
     end_sweep (0, timesteps.size());
+    }
+#else
+    end_sweep (0, timesteps.size());
+#endif
 }
 
 

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.