]> https://gitweb.dealii.org/ - dealii.git/commitdiff
On Mac OS X, all symbols referenced in a shared lib must be available. Since we use...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 1 Sep 2009 19:00:53 +0000 (19:00 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 1 Sep 2009 19:00:53 +0000 (19:00 +0000)
git-svn-id: https://svn.dealii.org/trunk@19362 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/parallel.h
deal.II/base/source/parallel.cc [new file with mode: 0644]
deal.II/lac/include/lac/sparse_matrix.h
deal.II/lac/include/lac/vector.h
deal.II/lac/source/sparse_matrix.cc
deal.II/lac/source/vector.cc

index 17e6329e15772e8cbee4f869089ad92e0336329e..b5f496ee0e2b012c806118e970c49b4b8aa6e2e1 100644 (file)
@@ -102,7 +102,7 @@ namespace parallel
                    :
                    iterators (i)
     {}
-        
+
 
     template <typename Iterators>
     inline
@@ -195,7 +195,7 @@ namespace parallel
       std::advance (std_cxx1x::get<2>(t), n);
       std::advance (std_cxx1x::get<3>(t), n);
     }
-    
+
 
 
                                     /**
@@ -220,7 +220,7 @@ namespace parallel
       ++std_cxx1x::get<1>(t);
       ++std_cxx1x::get<2>(t);
     }
-    
+
                                     /**
                                      * Advance a tuple of iterators by 1.
                                      */
@@ -234,7 +234,7 @@ namespace parallel
       ++std_cxx1x::get<2>(t);
       ++std_cxx1x::get<3>(t);
     }
-    
+
 
 
                                     /**
@@ -281,7 +281,7 @@ namespace parallel
       return (std_cxx1x::get<0>(a.iterators) !=
              std_cxx1x::get<0>(b.iterators));
     }
-    
+
 
                                     /**
                                      * Convert a function object of type F
@@ -309,7 +309,7 @@ namespace parallel
                 p != range.end(); ++p)
              apply (f, p.iterators);
          }
-       
+
       private:
                                         /**
                                          * The stored function object.
@@ -376,7 +376,7 @@ namespace parallel
       return Body<F>(f);
     }
   }
-  
+
                                   /**
                                    * An algorithm that performs the action
                                    * <code>*out++ = predicate(*in++)</code>
@@ -695,9 +695,9 @@ namespace parallel
   }
 
 
-  
+
   namespace internal
-  {  
+  {
 #if DEAL_II_USE_MT == 1
                                     /**
                                      * A class that conforms to the Body
@@ -757,7 +757,7 @@ namespace parallel
                        neutral_element (r.neutral_element),
                        reductor (r.reductor)
          {}
-       
+
                                         /**
                                          * Join operation: merge the results
                                          * from computations on different
@@ -767,7 +767,7 @@ namespace parallel
          {
            result = reductor(result, r.result);
          }
-       
+
                                         /**
                                          * Execute the given function on the
                                          * specified range.
@@ -785,7 +785,7 @@ namespace parallel
                                          * every sub-range.
                                          */
        const Function f;
-       
+
                                         /**
                                          * The neutral element with respect
                                          * to the reduction operation. This
@@ -803,9 +803,9 @@ namespace parallel
                                          */
        const std_cxx1x::function<ResultType (ResultType, ResultType)> reductor;
     };
-#endif  
+#endif
   }
-  
+
 
                                   /**
                                    * This function works a lot like the
@@ -908,10 +908,56 @@ namespace parallel
     return reductor.result;
 #endif
   }
-  
+
 }
 
 
+namespace internal
+{
+  namespace Vector
+  {
+                                    /**
+                                     * If we do computations on vectors in
+                                     * parallel (say, we add two vectors to
+                                     * get a third, and we do the loop over
+                                     * all elements in parallel), then this
+                                     * variable determines the minimum number
+                                     * of elements for which it is profitable
+                                     * to split a range of elements any
+                                     * further to distribute to different
+                                     * threads.
+                                     *
+                                     * This variable is available as
+                                     * a global writable variable in
+                                     * order to allow the testsuite
+                                     * to also test the parallel
+                                     * case. By default, it is set to
+                                     * several thousand elements,
+                                     * which is a case that the
+                                     * testsuite would not normally
+                                     * encounter. As a consequence,
+                                     * in the testsuite we set it to
+                                     * one -- a value that's hugely
+                                     * unprofitable but definitely
+                                     * tests parallel operations.
+                                     */
+    extern unsigned int minimum_parallel_grain_size;
+  }
+
+
+  namespace SparseMatrix
+  {
+                                    /**
+                                     * Like
+                                     * internal::Vector::minimum_parallel_grain_size,
+                                     * but now denoting the number of rows of
+                                     * a matrix that should be worked on as a
+                                     * minimum.
+                                     */
+    extern unsigned int minimum_parallel_grain_size;
+  }
+}
+
 DEAL_II_NAMESPACE_CLOSE
 
 #endif
diff --git a/deal.II/base/source/parallel.cc b/deal.II/base/source/parallel.cc
new file mode 100644 (file)
index 0000000..f13a519
--- /dev/null
@@ -0,0 +1,57 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2009 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+
+#include <base/parallel.h>
+
+
+DEAL_II_NAMESPACE_OPEN
+
+namespace internal
+{
+  namespace Vector
+  {
+                                    // set minimum grain size. this value is
+                                    // roughly in accordance with the curve
+                                    // in the TBB book (fig 3.2) that shows
+                                    // run time as a function of grain size
+                                    // -- there, values from 200 upward are
+                                    // so that the scheduling overhead
+                                    // amortizes well (for very large values
+                                    // in that example, the grain size is too
+                                    // large to split the work load into
+                                    // enough chunks and the problem becomes
+                                    // badly balanced)
+    unsigned int minimum_parallel_grain_size = 1000;
+  }
+
+
+  namespace SparseMatrix
+  {
+                                    // set this value to 1/5 of the value of
+                                    // the minimum grain size of
+                                    // vectors. this rests on the fact that
+                                    // we have to do a lot more work per row
+                                    // of a matrix than per element of a
+                                    // vector. it could possibly be reduced
+                                    // even further but that doesn't appear
+                                    // worth it any more for anything but
+                                    // very small matrices that we don't care
+                                    // that much about anyway.
+    unsigned int minimum_parallel_grain_size = 200;
+  }
+}
+
+
+
+
+DEAL_II_NAMESPACE_CLOSE
index 94a1ab8dcc21da85a418e763011424f63ca881b2..5a818e8a18869238c9e717b9b68e193d3b332582 100644 (file)
@@ -32,27 +32,13 @@ template <typename Matrix> class BlockMatrixBase;
  *@{
  */
 
-namespace internal
-{
-  namespace SparseMatrix
-  {
-                                    /**
-                                     * Like
-                                     * internal::Vector::minimum_parallel_grain_size,
-                                     * but now denoting the number of rows of
-                                     * a matrix that should be worked on as a
-                                     * minimum.
-                                     */
-    extern unsigned int minimum_parallel_grain_size;
-  }
-}
 
 namespace SparseMatrixIterators
 {
                                   // forward declaration
   template <typename number, bool Constness>
   class Iterator;
-  
+
                                   /**
                                    * General template for sparse matrix
                                    * accessors. The first template argument
@@ -78,12 +64,12 @@ namespace SparseMatrixIterators
                                        * Value of this matrix entry.
                                        */
       number value() const;
-   
+
                                       /**
                                        * Value of this matrix entry.
                                        */
       number& value();
-   
+
                                       /**
                                        * Return a reference to the matrix
                                        * into which this accessor
@@ -93,9 +79,9 @@ namespace SparseMatrixIterators
                                        */
       const SparseMatrix<number>& get_matrix () const;
   };
-  
-  
-  
+
+
+
                                   /**
                                    * Accessor class for constant matrices,
                                    * used in the const_iterators. This
@@ -116,32 +102,32 @@ namespace SparseMatrixIterators
                                        * used here.
                                        */
       typedef const SparseMatrix<number> MatrixType;
-      
+
                                       /**
                                        * Constructor.
                                        */
       Accessor (MatrixType         *matrix,
                const unsigned int  row,
                const unsigned int  index);
-      
+
                                       /**
                                        * Constructor. Construct the end
                                        * accessor for the given matrix.
                                        */
       Accessor (MatrixType         *matrix);
-      
+
                                       /**
                                        * Copy constructor to get from a
                                        * non-const accessor to a const
                                        * accessor.
                                        */
       Accessor (const SparseMatrixIterators::Accessor<number,false> &a);
-      
+
                                       /**
                                        * Value of this matrix entry.
                                        */
       number value() const;
-      
+
                                       /**
                                        * Return a reference to the matrix
                                        * into which this accessor
@@ -150,27 +136,27 @@ namespace SparseMatrixIterators
                                        * reference.
                                        */
       MatrixType & get_matrix () const;
-      
+
     private:
                                       /**
                                        * Pointer to the matrix we use.
                                        */
       MatrixType *matrix;
-      
+
                                       /**
                                        * Make the advance function of the
                                        * base class available.
                                        */
       using SparsityPatternIterators::Accessor::advance;
-      
+
                                       /**
                                        * Make iterator class a friend.
                                        */
       template <typename, bool>
       friend class Iterator;
   };
-  
-  
+
+
                                   /**
                                    * Accessor class for non-constant
                                    * matrices, used in the iterators. This
@@ -228,7 +214,7 @@ namespace SparseMatrixIterators
                                        * The testcase oliver_01 checks that
                                        * this actually works as intended.
                                        */
-      class Reference 
+      class Reference
       {
        public:
                                           /**
@@ -256,28 +242,28 @@ namespace SparseMatrixIterators
                                            * matrix we presently point to.
                                            */
          const Reference & operator += (const number n) const;
-            
+
                                           /**
                                            * Subtract @p n from the element
                                            * of the matrix we presently
                                            * point to.
                                            */
          const Reference & operator -= (const number n) const;
-            
+
                                           /**
                                            * Multiply the element of the
                                            * matrix we presently point to
                                            * by @p n.
                                            */
          const Reference & operator *= (const number n) const;
-            
+
                                           /**
                                            * Divide the element of the
                                            * matrix we presently point to
                                            * by @p n.
                                            */
          const Reference & operator /= (const number n) const;
-            
+
        private:
                                           /**
                                            * Pointer to the accessor that
@@ -301,7 +287,7 @@ namespace SparseMatrixIterators
       Accessor (MatrixType         *matrix,
                const unsigned int  row,
                const unsigned int  index);
-        
+
                                       /**
                                        * Constructor. Construct the end
                                        * accessor for the given matrix.
@@ -314,7 +300,7 @@ namespace SparseMatrixIterators
                                        * reference.
                                        */
       Reference value() const;
-        
+
                                       /**
                                        * Return a reference to the matrix
                                        * into which this accessor
@@ -341,7 +327,7 @@ namespace SparseMatrixIterators
                                        */
       template <typename, bool>
       friend class Iterator;
-       
+
                                       /**
                                        * Make the inner reference class a
                                        * friend if the compiler has a bug
@@ -351,7 +337,7 @@ namespace SparseMatrixIterators
       friend class Reference;
 #endif
   };
-    
+
 
 
                                   /**
@@ -385,7 +371,7 @@ namespace SparseMatrixIterators
                                        * Constructor. Create an iterator
                                        * into the matrix @p matrix for the
                                        * given row and the index within it.
-                                       */ 
+                                       */
       Iterator (MatrixType        *matrix,
                const unsigned int row,
                const unsigned int index);
@@ -395,14 +381,14 @@ namespace SparseMatrixIterators
                                        * iterator for the given matrix.
                                        */
       Iterator (MatrixType *matrix);
-        
+
                                       /**
                                        * Conversion constructor to get from
                                        * a non-const iterator to a const
                                        * iterator.
                                        */
       Iterator (const SparseMatrixIterators::Iterator<number,false> &i);
-        
+
                                       /**
                                        * Prefix increment.
                                        */
@@ -455,7 +441,7 @@ namespace SparseMatrixIterators
                                        * the other way round.
                                        */
       bool operator > (const Iterator &) const;
-        
+
     private:
                                       /**
                                        * Store an object of the
@@ -463,7 +449,7 @@ namespace SparseMatrixIterators
                                        */
       Accessor<number,Constness> accessor;
   };
-    
+
 }
 
 
@@ -514,7 +500,7 @@ class SparseMatrix : public virtual Subscriptor
                                      * norms.
                                      */
     typedef typename numbers::NumberTraits<number>::real_type real_type;
-    
+
                                      /**
                                       * Typedef of an STL conforming iterator
                                       * class walking over all the nonzero
@@ -558,7 +544,7 @@ class SparseMatrix : public virtual Subscriptor
                                           */
         static const bool zero_addition_can_be_elided = true;
     };
-    
+
 /**
  * @name Constructors and initalization.
  */
@@ -636,7 +622,7 @@ class SparseMatrix : public virtual Subscriptor
                                      */
     SparseMatrix (const SparsityPattern &sparsity,
                  const IdentityMatrix  &id);
-    
+
                                     /**
                                      * Destructor. Free all memory, but do not
                                      * release the memory of the sparsity
@@ -644,7 +630,7 @@ class SparseMatrix : public virtual Subscriptor
                                      */
     virtual ~SparseMatrix ();
 
-                                    /** 
+                                    /**
                                      * Copy operator. Since copying
                                      * entire sparse matrices is a
                                      * very expensive operation, we
@@ -679,7 +665,7 @@ class SparseMatrix : public virtual Subscriptor
                                      */
     SparseMatrix<number> &
     operator= (const IdentityMatrix  &id);
-    
+
                                      /**
                                       * This operator assigns a scalar to
                                       * a matrix. Since this does usually
@@ -733,7 +719,7 @@ class SparseMatrix : public virtual Subscriptor
                                      * previously tied to.
                                      */
     virtual void clear ();
-//@}    
+//@}
 /**
  * @name Information on the matrix
  */
@@ -754,7 +740,7 @@ class SparseMatrix : public virtual Subscriptor
                                      * $m \times n$.
                                      */
     unsigned int m () const;
-    
+
                                     /**
                                      * Return the dimension of the
                                      * range space.  To remember: the
@@ -790,7 +776,7 @@ class SparseMatrix : public virtual Subscriptor
                                      * value is greater than threshold).
                                      */
     unsigned int n_actually_nonzero_elements (const double threshold = 0.) const;
-    
+
                                     /**
                                      * Return a (constant) reference
                                      * to the underlying sparsity
@@ -812,7 +798,7 @@ class SparseMatrix : public virtual Subscriptor
                                      * MemoryConsumption.
                                      */
     unsigned int memory_consumption () const;
-    
+
 //@}
 /**
  * @name Modifying entries
@@ -1034,13 +1020,13 @@ class SparseMatrix : public virtual Subscriptor
                                      * fixed factor.
                                      */
     SparseMatrix & operator *= (const number factor);
-    
+
                                     /**
                                      * Divide the entire matrix by a
                                      * fixed factor.
                                      */
     SparseMatrix & operator /= (const number factor);
-    
+
                                     /**
                                      * Symmetrize the matrix by
                                      * forming the mean value between
@@ -1067,7 +1053,7 @@ class SparseMatrix : public virtual Subscriptor
                                      * SparsityPattern::symmetrize().
                                      */
     void symmetrize ();
-    
+
                                     /**
                                      * Copy the given matrix to this
                                      * one.  The operation throws an
@@ -1134,7 +1120,7 @@ class SparseMatrix : public virtual Subscriptor
                                      */
     template <typename ForwardIterator>
     void copy_from (const ForwardIterator begin,
-                   const ForwardIterator end);    
+                   const ForwardIterator end);
 
                                     /**
                                      * Copy the nonzero entries of a
@@ -1148,7 +1134,7 @@ class SparseMatrix : public virtual Subscriptor
                                      */
     template <typename somenumber>
     void copy_from (const FullMatrix<somenumber> &matrix);
-    
+
                                     /**
                                      * Add <tt>matrix</tt> scaled by
                                      * <tt>factor</tt> to this matrix,
@@ -1168,14 +1154,14 @@ class SparseMatrix : public virtual Subscriptor
                                      */
     template <typename somenumber>
     void add (const number factor,
-             const SparseMatrix<somenumber> &matrix);    
-    
+             const SparseMatrix<somenumber> &matrix);
+
 //@}
 /**
  * @name Entry Access
  */
 //@{
-    
+
                                     /**
                                      * Return the value of the entry
                                      * (<i>i,j</i>).  This may be an
@@ -1272,7 +1258,7 @@ class SparseMatrix : public virtual Subscriptor
                                      */
     number raw_entry (const unsigned int row,
                      const unsigned int index) const;
-    
+
                                     /**
                                      * @internal @deprecated Use iterator or
                                      * const_iterator instead!
@@ -1330,14 +1316,14 @@ class SparseMatrix : public virtual Subscriptor
                                      * with BlockVector objects, you should
                                      * consider using a BlockSparseMatrix as
                                      * well.
-                                     * 
+                                     *
                                       * Source and destination must
                                       * not be the same vector.
                                      */
     template <class OutVector, class InVector>
     void vmult (OutVector& dst,
                const InVector& src) const;
-    
+
                                     /**
                                      * Matrix-vector multiplication:
                                      * let <i>dst = M<sup>T</sup>*src</i> with
@@ -1358,14 +1344,14 @@ class SparseMatrix : public virtual Subscriptor
                                      * with BlockVector objects, you should
                                      * consider using a BlockSparseMatrix as
                                      * well.
-                                     * 
+                                     *
                                       * Source and destination must
                                       * not be the same vector.
                                      */
     template <class OutVector, class InVector>
     void Tvmult (OutVector& dst,
                 const InVector& src) const;
-  
+
                                     /**
                                      * Adding Matrix-vector
                                      * multiplication. Add
@@ -1385,14 +1371,14 @@ class SparseMatrix : public virtual Subscriptor
                                      * with BlockVector objects, you should
                                      * consider using a BlockSparseMatrix as
                                      * well.
-                                     * 
+                                     *
                                       * Source and destination must
                                       * not be the same vector.
                                      */
     template <class OutVector, class InVector>
     void vmult_add (OutVector& dst,
                    const InVector& src) const;
-    
+
                                     /**
                                      * Adding Matrix-vector
                                      * multiplication. Add
@@ -1415,14 +1401,14 @@ class SparseMatrix : public virtual Subscriptor
                                      * with BlockVector objects, you should
                                      * consider using a BlockSparseMatrix as
                                      * well.
-                                     * 
+                                     *
                                       * Source and destination must
                                       * not be the same vector.
                                      */
     template <class OutVector, class InVector>
     void Tvmult_add (OutVector& dst,
                     const InVector& src) const;
-  
+
                                     /**
                                      * Return the square of the norm
                                      * of the vector $v$ with respect
@@ -1460,7 +1446,7 @@ class SparseMatrix : public virtual Subscriptor
     template <typename somenumber>
     somenumber matrix_scalar_product (const Vector<somenumber> &u,
                                      const Vector<somenumber> &v) const;
-    
+
                                     /**
                                      * Compute the residual of an
                                      * equation <i>Mx=b</i>, where
@@ -1519,7 +1505,7 @@ class SparseMatrix : public virtual Subscriptor
                const SparseMatrix<numberB> &B,
                const Vector<numberV>       &V = Vector<numberV>(),
                const bool                   rebuild_sparsity_pattern = true) const;
-    
+
                                     /**
                                      * Perform the matrix-matrix
                                      * multiplication with the transpose of
@@ -1560,13 +1546,13 @@ class SparseMatrix : public virtual Subscriptor
                 const SparseMatrix<numberB> &B,
                 const Vector<numberV>       &V = Vector<numberV>(),
                 const bool                   rebuild_sparsity_pattern = true) const;
-    
+
 //@}
 /**
  * @name Matrix norms
  */
 //@{
-    
+
                                     /**
                                      * Return the $l_1$-norm of the matrix,
                                      * that is $|M|_1=\max_{\mathrm{all\
@@ -1608,7 +1594,7 @@ class SparseMatrix : public virtual Subscriptor
  * @name Preconditioning methods
  */
 //@{
-    
+
                                     /**
                                      * Apply the Jacobi
                                      * preconditioner, which
@@ -1649,7 +1635,7 @@ class SparseMatrix : public virtual Subscriptor
     void precondition_SOR (Vector<somenumber>       &dst,
                           const Vector<somenumber> &src,
                           const number              om = 1.) const;
-    
+
                                     /**
                                      * Apply transpose SOR
                                      * preconditioning matrix to
@@ -1659,7 +1645,7 @@ class SparseMatrix : public virtual Subscriptor
     void precondition_TSOR (Vector<somenumber>       &dst,
                            const Vector<somenumber> &src,
                            const number              om = 1.) const;
-    
+
                                     /**
                                      * Perform SSOR preconditioning
                                      * in-place.  Apply the
@@ -1818,7 +1804,7 @@ class SparseMatrix : public virtual Subscriptor
                                      * non-constant matrices.
                                      */
     iterator end ();
-    
+
                                     /**
                                      * STL-like iterator with the first entry
                                      * of row <tt>r</tt>. This is the version
@@ -1847,7 +1833,7 @@ class SparseMatrix : public virtual Subscriptor
                                      * iterator for the last row of a matrix.
                                      */
     const_iterator end (const unsigned int r) const;
-    
+
                                     /**
                                      * STL-like iterator with the first entry
                                      * of row <tt>r</tt>. This is the version
@@ -1951,7 +1937,7 @@ class SparseMatrix : public virtual Subscriptor
                                      */
     void print_pattern(std::ostream& out,
                       const double threshold = 0.) const;
-    
+
                                     /**
                                      * Write the data of this object
                                      * en bloc to a file. This is
@@ -2073,7 +2059,7 @@ class SparseMatrix : public virtual Subscriptor
                                       * requires such an operation.
                                       */
     void prepare_set();
-    
+
   private:
                                     /**
                                      * Pointer to the sparsity
@@ -2118,12 +2104,12 @@ class SparseMatrix : public virtual Subscriptor
     template <typename somenumber> friend class SparseMatrix;
     template <typename somenumber> friend class SparseLUDecomposition;
     template <typename> friend class SparseILU;
-    
+
                                       /**
                                        * To allow it calling private
                                         * prepare_add() and
                                         * prepare_set().
-                                       */  
+                                       */
     template <typename> friend class BlockMatrixBase;
 };
 
@@ -2153,9 +2139,9 @@ unsigned int SparseMatrix<number>::n () const
 
 
                                        // Inline the set() and add()
-                                       // functions, since they will be 
+                                       // functions, since they will be
                                         // called frequently.
-template <typename number>  
+template <typename number>
 inline
 void
 SparseMatrix<number>::set (const unsigned int i,
@@ -2185,8 +2171,8 @@ SparseMatrix<number>::set (const unsigned int i,
 
 
 
-template <typename number>  
-template <typename number2>  
+template <typename number>
+template <typename number2>
 inline
 void
 SparseMatrix<number>::set (const std::vector<unsigned int> &indices,
@@ -2204,8 +2190,8 @@ SparseMatrix<number>::set (const std::vector<unsigned int> &indices,
 
 
 
-template <typename number>  
-template <typename number2>  
+template <typename number>
+template <typename number2>
 inline
 void
 SparseMatrix<number>::set (const std::vector<unsigned int> &row_indices,
@@ -2225,8 +2211,8 @@ SparseMatrix<number>::set (const std::vector<unsigned int> &row_indices,
 
 
 
-template <typename number>  
-template <typename number2>  
+template <typename number>
+template <typename number2>
 inline
 void
 SparseMatrix<number>::set (const unsigned int               row,
@@ -2243,7 +2229,7 @@ SparseMatrix<number>::set (const unsigned int               row,
 
 
 
-template <typename number>  
+template <typename number>
 inline
 void
 SparseMatrix<number>::add (const unsigned int i,
@@ -2276,8 +2262,8 @@ SparseMatrix<number>::add (const unsigned int i,
 
 
 
-template <typename number>  
-template <typename number2>  
+template <typename number>
+template <typename number2>
 inline
 void
 SparseMatrix<number>::add (const std::vector<unsigned int> &indices,
@@ -2295,8 +2281,8 @@ SparseMatrix<number>::add (const std::vector<unsigned int> &indices,
 
 
 
-template <typename number>  
-template <typename number2>  
+template <typename number>
+template <typename number2>
 inline
 void
 SparseMatrix<number>::add (const std::vector<unsigned int> &row_indices,
@@ -2316,8 +2302,8 @@ SparseMatrix<number>::add (const std::vector<unsigned int> &row_indices,
 
 
 
-template <typename number>  
-template <typename number2>  
+template <typename number>
+template <typename number2>
 inline
 void
 SparseMatrix<number>::add (const unsigned int               row,
@@ -2411,7 +2397,7 @@ number SparseMatrix<number>::diag_element (const unsigned int i) const
   Assert (cols != 0, ExcNotInitialized());
   Assert (cols->optimize_diagonal(),  ExcNotQuadratic());
   Assert (i<m(), ExcInvalidIndex1(i));
-  
+
                                   // Use that the first element in each
                                   // row of a quadratic matrix is the main
                                   // diagonal
@@ -2427,7 +2413,7 @@ number & SparseMatrix<number>::diag_element (const unsigned int i)
   Assert (cols != 0, ExcNotInitialized());
   Assert (cols->optimize_diagonal(),  ExcNotQuadratic());
   Assert (i<m(), ExcInvalidIndex1(i));
-  
+
                                   // Use that the first element in each
                                   // row of a quadratic matrix is the main
                                   // diagonal
@@ -2458,7 +2444,7 @@ number SparseMatrix<number>::global_entry (const unsigned int j) const
   Assert (cols != 0, ExcNotInitialized());
   Assert (j < cols->n_nonzero_elements(),
          ExcIndexRange (j, 0, cols->n_nonzero_elements()));
-  
+
   return val[j];
 }
 
@@ -2528,7 +2514,7 @@ namespace SparseMatrixIterators
                  SparsityPatternIterators::Accessor (&matrix->get_sparsity_pattern()),
                  matrix (matrix)
   {}
-    
+
 
 
   template <typename number>
@@ -2539,7 +2525,7 @@ namespace SparseMatrixIterators
                  SparsityPatternIterators::Accessor (a),
                  matrix (&a.get_matrix())
   {}
-    
+
 
 
   template <typename number>
@@ -2551,7 +2537,7 @@ namespace SparseMatrixIterators
   }
 
 
-    
+
   template <typename number>
   inline
   typename Accessor<number, true>::MatrixType &
@@ -2561,7 +2547,7 @@ namespace SparseMatrixIterators
   }
 
 
-    
+
   template <typename number>
   inline
   Accessor<number, false>::Reference::
@@ -2570,9 +2556,9 @@ namespace SparseMatrixIterators
                  :
                  accessor (accessor)
   {}
-    
 
-    
+
+
   template <typename number>
   inline
   Accessor<number, false>::Reference::operator number() const
@@ -2580,9 +2566,9 @@ namespace SparseMatrixIterators
     return accessor->matrix->raw_entry(accessor->a_row,
                                       accessor->a_index);
   }
-    
 
-    
+
+
   template <typename number>
   inline
   const typename Accessor<number, false>::Reference &
@@ -2592,9 +2578,9 @@ namespace SparseMatrixIterators
     accessor->matrix->set (accessor->row(), accessor->column(), n);
     return *this;
   }
-    
 
-    
+
+
   template <typename number>
   inline
   const typename Accessor<number, false>::Reference &
@@ -2605,9 +2591,9 @@ namespace SparseMatrixIterators
                           static_cast<number>(*this) + n);
     return *this;
   }
-    
 
-    
+
+
   template <typename number>
   inline
   const typename Accessor<number, false>::Reference &
@@ -2631,9 +2617,9 @@ namespace SparseMatrixIterators
                           static_cast<number>(*this)*n);
     return *this;
   }
-    
 
-    
+
+
   template <typename number>
   inline
   const typename Accessor<number, false>::Reference &
@@ -2644,9 +2630,9 @@ namespace SparseMatrixIterators
                           static_cast<number>(*this)/n);
     return *this;
   }
-    
 
-    
+
+
   template <typename number>
   inline
   Accessor<number,false>::
@@ -2669,7 +2655,7 @@ namespace SparseMatrixIterators
                  SparsityPatternIterators::Accessor (&matrix->get_sparsity_pattern()),
                  matrix (matrix)
   {}
-    
+
 
 
   template <typename number>
@@ -2682,7 +2668,7 @@ namespace SparseMatrixIterators
 
 
 
-          
+
   template <typename number>
   inline
   typename Accessor<number, false>::MatrixType &
@@ -2692,7 +2678,7 @@ namespace SparseMatrixIterators
   }
 
 
-    
+
   template <typename number, bool Constness>
   inline
   Iterator<number, Constness>::
@@ -2722,8 +2708,8 @@ namespace SparseMatrixIterators
                  :
                  accessor(*i)
   {}
-    
-    
+
+
 
   template <typename number, bool Constness>
   inline
@@ -2792,7 +2778,7 @@ namespace SparseMatrixIterators
   {
     Assert (&accessor.get_matrix() == &other.accessor.get_matrix(),
            ExcInternalError());
-      
+
     return (accessor < other.accessor);
   }
 
@@ -2805,7 +2791,7 @@ namespace SparseMatrixIterators
   {
     return (other < *this);
   }
-    
+
 }
 
 
index 7c9abe9647783f8070746db688de2e4bcda6634e..ad1ad3e760ef31c67d5b83f339b087f067eb4319 100644 (file)
@@ -53,32 +53,6 @@ template <typename> class BlockVector;
 
 template <typename> class VectorView;
 
-namespace internal
-{
-  namespace Vector
-  {
-                                    /**
-                                     * If we do computations on vectors in
-                                     * parallel (say, we add two vectors to
-                                     * get a third, and we do the loop over
-                                     * all elements in parallel), then this
-                                     * variable determines the minimum number
-                                     * of elements for which it is profitable
-                                     * to split a range of elements any
-                                     * further to distribute to different
-                                     * threads.
-                                     *
-                                     * This variable is available as a global
-                                     * writable variable in order to allow
-                                     * the testsuite to also test the
-                                     * parallel case. By default, it is set
-                                     * to several thousand elements, which is
-                                     * a case that the testsuite would not
-                                     * normally encounter.
-                                     */
-    extern unsigned int minimum_parallel_grain_size;
-  }
-}
 
 
 
@@ -103,7 +77,7 @@ namespace internal
  * @<std::complex@<long double@>@></tt>; others can be generated in
  * application programs (see the section on @ref Instantiations in the
  * manual).
- * 
+ *
  * @author Guido Kanschat, Franz-Theo Suttmeier, Wolfgang Bangerth
  */
 template <typename Number>
@@ -147,9 +121,9 @@ class Vector : public Subscriptor
     typedef typename numbers::NumberTraits<Number>::real_type real_type;
 
   public:
-    
+
                                     /**
-                                     * @name 1: Basic Object-handling 
+                                     * @name 1: Basic Object-handling
                                      */
                                     //@{
                                     /**
@@ -157,7 +131,7 @@ class Vector : public Subscriptor
                                      *  dimension zero.
                                      */
     Vector ();
-    
+
                                     /**
                                      * Copy-constructor. Sets the dimension
                                       * to that of the given vector, and
@@ -170,7 +144,7 @@ class Vector : public Subscriptor
     Vector (const Vector<Number> &v);
 
 
-#ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG    
+#ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG
                                     /**
                                      * Copy constructor taking a vector of
                                      * another data type. This will fail if
@@ -195,7 +169,7 @@ class Vector : public Subscriptor
     explicit
     Vector (const Vector<OtherNumber> &v);
 #endif
-    
+
 #ifdef DEAL_II_USE_PETSC
                                      /**
                                       * Another copy constructor: copy the
@@ -260,7 +234,7 @@ class Vector : public Subscriptor
                                       */
     Vector (const TrilinosWrappers::Vector &v);
 #endif
-    
+
                                     /**
                                      * Constructor. Set dimension to
                                      * @p n and initialize all
@@ -290,7 +264,7 @@ class Vector : public Subscriptor
     template <typename InputIterator>
     Vector (const InputIterator first,
             const InputIterator last);
-    
+
                                     /**
                                      * Destructor, deallocates
                                      * memory. Made virtual to allow
@@ -303,7 +277,7 @@ class Vector : public Subscriptor
                                       * This function does nothing but is
                                       * there for compatibility with the
                                       * @p PETScWrappers::Vector class.
-                                      * 
+                                      *
                                       * For the PETSc vector wrapper class,
                                       * thios function compresses the
                                       * underlying representation of the PETSc
@@ -344,10 +318,10 @@ class Vector : public Subscriptor
                                      * order to allow for derived
                                      * classes to handle memory
                                      * separately.
-                                     */ 
+                                     */
     virtual void reinit (const unsigned int N,
                         const bool         fast=false);
-    
+
                                     /**
                                      * Change the dimension to that of the
                                      * vector @p V. The same applies as for
@@ -388,9 +362,9 @@ class Vector : public Subscriptor
                                      * order to allow for derived
                                      * classes to handle memory
                                      * separately.
-                                     */ 
+                                     */
     virtual void swap (Vector<Number> &v);
-    
+
                                     /**
                                       * Set all components of the vector to
                                       * the given number @p s. Simply pass
@@ -411,13 +385,13 @@ class Vector : public Subscriptor
                                       * be disallowed in the future.
                                      */
     Vector<Number> & operator = (const Number s);
-    
+
                                     /**
                                      * Copy the given vector. Resize the
                                      * present vector if necessary.
                                      */
     Vector<Number> & operator= (const Vector<Number> &c);
-    
+
                                     /**
                                      * Copy the given vector. Resize the
                                      * present vector if necessary.
@@ -431,7 +405,7 @@ class Vector : public Subscriptor
                                       * vector.
                                       */
     Vector<Number> & operator= (const BlockVector<Number> &v);
-    
+
 #ifdef DEAL_II_USE_PETSC
                                      /**
                                       * Another copy operator: copy the
@@ -515,7 +489,7 @@ class Vector : public Subscriptor
                                       */
     template <typename Number2>
     bool operator == (const Vector<Number2> &v) const;
-    
+
                                      /**
                                       * Test for inequality. This function
                                       * assumes that the present vector and
@@ -526,7 +500,7 @@ class Vector : public Subscriptor
                                       */
     template <typename Number2>
     bool operator != (const Vector<Number2> &v) const;
-    
+
                                     /**
                                      * Return the scalar product of
                                      * two vectors.  The return type
@@ -614,7 +588,7 @@ class Vector : public Subscriptor
                                      * thrown.
                                       */
     bool is_non_negative () const;
-    
+
                                     /**
                                      * Make the @p Vector class a bit like
                                      * the <tt>vector<></tt> class of the C++
@@ -640,7 +614,7 @@ class Vector : public Subscriptor
                                      * Return a constant iterator pointing to
                                      * the element past the end of the array.
                                      */
-    const_iterator end () const;  
+    const_iterator end () const;
                                     //@}
 
 
@@ -653,7 +627,7 @@ class Vector : public Subscriptor
                                      * component.
                                      */
     Number operator() (const unsigned int i) const;
-    
+
                                     /**
                                      * Access the @p ith component
                                      * as a writeable reference.
@@ -666,7 +640,7 @@ class Vector : public Subscriptor
                                      * @name 3: Modification of vectors
                                      */
                                     //@{
-    
+
                                     /**
                                      * Add the given vector to the present
                                      * one.
@@ -685,26 +659,26 @@ class Vector : public Subscriptor
                                      * scalar and not a vector.
                                      */
     void add (const Number s);
-    
+
                                     /**
                                      * Simple vector addition, equal to the
                                      * <tt>operator +=</tt>.
                                      */
     void add (const Vector<Number> &V);
-    
+
                                     /**
                                      * Simple addition of a multiple of a
                                      * vector, i.e. <tt>*this += a*V</tt>.
                                      */
     void add (const Number a, const Vector<Number> &V);
-    
+
                                     /**
                                      * Multiple addition of scaled vectors,
                                      * i.e. <tt>*this += a*V+b*W</tt>.
                                      */
     void add (const Number a, const Vector<Number> &V,
              const Number b, const Vector<Number> &W);
-    
+
                                     /**
                                      * Scaling and simple vector addition,
                                      * i.e.
@@ -712,7 +686,7 @@ class Vector : public Subscriptor
                                      */
     void sadd (const Number          s,
                const Vector<Number> &V);
-    
+
                                     /**
                                      * Scaling and simple addition, i.e.
                                      * <tt>*this = s*(*this)+a*V</tt>.
@@ -720,7 +694,7 @@ class Vector : public Subscriptor
     void sadd (const Number          s,
                const Number          a,
                const Vector<Number> &V);
-    
+
                                     /**
                                      * Scaling and multiple addition.
                                      */
@@ -729,7 +703,7 @@ class Vector : public Subscriptor
               const Vector<Number> &V,
                const Number          b,
                const Vector<Number> &W);
-    
+
                                     /**
                                      * Scaling and multiple addition.
                                      * <tt>*this = s*(*this)+a*V + b*W + c*X</tt>.
@@ -738,10 +712,10 @@ class Vector : public Subscriptor
                const Number          a,
               const Vector<Number> &V,
                const Number          b,
-               const Vector<Number> &W, 
+               const Vector<Number> &W,
               const Number          c,
                const Vector<Number> &X);
-    
+
                                     /**
                                      * Scale each element of the
                                      * vector by the given factor.
@@ -754,7 +728,7 @@ class Vector : public Subscriptor
                                      */
     void scale (const Number factor);
 
-    
+
                                     /**
                                      * Scale each element of the
                                      * vector by a constant
@@ -768,7 +742,7 @@ class Vector : public Subscriptor
                                      * given value.
                                      */
     Vector<Number> & operator /= (const Number factor);
-    
+
                                     /**
                                      * Scale each element of this
                                      * vector by the corresponding
@@ -779,7 +753,7 @@ class Vector : public Subscriptor
                                      * diagonal scaling matrix.
                                      */
     void scale (const Vector<Number> &scaling_factors);
-    
+
                                     /**
                                      * Scale each element of this
                                      * vector by the corresponding
@@ -802,13 +776,13 @@ class Vector : public Subscriptor
                                      */
     template <typename Number2>
     void equ (const Number a, const Vector<Number2>& u);
-    
+
                                     /**
                                      * Assignment <tt>*this = a*u + b*v</tt>.
                                      */
     void equ (const Number a, const Vector<Number>& u,
              const Number b, const Vector<Number>& v);
-    
+
                                     /**
                                      * Assignment <tt>*this = a*u + b*v + b*w</tt>.
                                      */
@@ -1019,14 +993,14 @@ template <typename Number>
 inline
 void Vector<Number>::reinit (const unsigned int n, const bool fast)
 {
-  if (n==0) 
+  if (n==0)
     {
       if (val) delete[] val;
       val = 0;
       max_vec_size = vec_size = 0;
       return;
     };
-  
+
   if (n>max_vec_size)
     {
       if (val) delete[] val;
@@ -1045,13 +1019,13 @@ template <typename Number>
 inline
 Vector<Number> & Vector<Number>::operator = (const Number s)
 {
-  Assert (numbers::is_finite(s), 
+  Assert (numbers::is_finite(s),
           ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
-  
+
   if (s != Number())
     Assert (vec_size!=0, ExcEmptyObject());
   if (vec_size!=0)
-    parallel::apply_to_subranges (begin(), end(), 
+    parallel::apply_to_subranges (begin(), end(),
                                  std_cxx1x::bind(&std::fill<Number*,Number>,
                                                  _1, _2, s),
                                  internal::Vector::minimum_parallel_grain_size);
@@ -1071,8 +1045,8 @@ unsigned int Vector<Number>::size () const
 
 template <typename Number>
 inline
-typename Vector<Number>::iterator 
-Vector<Number>::begin () 
+typename Vector<Number>::iterator
+Vector<Number>::begin ()
 {
   return &val[0];
 }
@@ -1081,8 +1055,8 @@ Vector<Number>::begin ()
 
 template <typename Number>
 inline
-typename Vector<Number>::const_iterator 
-Vector<Number>::begin () const 
+typename Vector<Number>::const_iterator
+Vector<Number>::begin () const
 {
   return &val[0];
 }
@@ -1092,7 +1066,7 @@ Vector<Number>::begin () const
 template <typename Number>
 inline
 typename Vector<Number>::iterator
-Vector<Number>::end () 
+Vector<Number>::end ()
 {
   return &val[vec_size];
 }
@@ -1134,7 +1108,7 @@ inline
 Vector<Number> & Vector<Number>::operator *= (const Number factor)
 {
 
-  Assert (numbers::is_finite(factor), 
+  Assert (numbers::is_finite(factor),
           ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
 
   scale (factor);
@@ -1148,7 +1122,7 @@ inline
 Vector<Number> &
 Vector<Number>::operator /= (const Number factor)
 {
-  Assert (numbers::is_finite(factor), 
+  Assert (numbers::is_finite(factor),
           ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
   Assert (factor != Number(0.), ExcZero() );
 
@@ -1163,7 +1137,7 @@ inline
 void
 Vector<Number>::scale (const Number factor)
 {
-  Assert (numbers::is_finite(factor), 
+  Assert (numbers::is_finite(factor),
           ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
 
   Assert (vec_size!=0, ExcEmptyObject());
@@ -1183,7 +1157,7 @@ void
 Vector<Number>::add (const Number a,
                     const Vector<Number>& v)
 {
-  Assert (numbers::is_finite(a), 
+  Assert (numbers::is_finite(a),
           ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
 
   Assert (vec_size!=0, ExcEmptyObject());
@@ -1206,9 +1180,9 @@ Vector<Number>::sadd (const Number x,
                      const Number a,
                      const Vector<Number>& v)
 {
-  Assert (numbers::is_finite(x), 
+  Assert (numbers::is_finite(x),
           ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
-  Assert (numbers::is_finite(a), 
+  Assert (numbers::is_finite(a),
           ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
 
   Assert (vec_size!=0, ExcEmptyObject());
index 0a703781c385e663227bbf6418f407eb441537d3..cdd677efe3fc13ff8c9d075b19513db207126145 100644 (file)
 
 DEAL_II_NAMESPACE_OPEN
 
-namespace internal
-{
-  namespace SparseMatrix
-  {
-                                    // set this value to 1/5 of the value of
-                                    // the minimum grain size of
-                                    // vectors. this rests on the fact that
-                                    // we have to do a lot more work per row
-                                    // of a matrix than per element of a
-                                    // vector. it could possibly be reduced
-                                    // even further but that doesn't appear
-                                    // worth it any more for anything but
-                                    // very small matrices that we don't care
-                                    // that much about anyway.
-    unsigned int minimum_parallel_grain_size = 200;
-  }
-}
-
-
 #include "sparse_matrix.inst"
 
 DEAL_II_NAMESPACE_CLOSE
index 7a41a6c4268fd366dbd4547768a9c54df8916ed9..39607ff73ab920dd587876524b6f22ce2297fa73 100644 (file)
 
 DEAL_II_NAMESPACE_OPEN
 
-
-namespace internal
-{
-  namespace Vector
-  {
-                                    // set minimum grain size. this value is
-                                    // roughly in accordance with the curve
-                                    // in the TBB book (fig 3.2) that shows
-                                    // run time as a function of grain size
-                                    // -- there, values from 200 upward are
-                                    // so that the scheduling overhead
-                                    // amortizes well (for very large values
-                                    // in that example, the grain size is too
-                                    // large to split the work load into
-                                    // enough chunks and the problem becomes
-                                    // badly balanced)
-    unsigned int minimum_parallel_grain_size = 1000;
-  }
-}
-
-
 #include "vector.inst"
 
 // do a few functions that currently don't fit the scheme because they have
@@ -47,7 +26,7 @@ namespace internal
 #define TEMPL_COPY_CONSTRUCTOR(S1,S2)                  \
   template Vector<S1>::Vector (const Vector<S2> &)
 
-#ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG    
+#ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG
 TEMPL_COPY_CONSTRUCTOR(double,float);
 TEMPL_COPY_CONSTRUCTOR(float,double);
 
@@ -78,7 +57,7 @@ TEMPL_COPY_CONSTRUCTOR(std::complex<float>,std::complex<long double>);
   Vector<S1>::DEAL_II_MEMBER_OP_TEMPLATE_INST \
   operator=<S2>(const Vector<S2>&);                  \
   template void Vector<S1>::scale (const Vector<S2>&); \
-  template void Vector<S1>::equ (const S1, const Vector<S2>&)    
+  template void Vector<S1>::equ (const S1, const Vector<S2>&)
 
 TEMPL_OP_EQ(double,float);
 TEMPL_OP_EQ(float,double);

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.