From: Wolfgang Bangerth Date: Tue, 1 Sep 2009 19:00:53 +0000 (+0000) Subject: On Mac OS X, all symbols referenced in a shared lib must be available. Since we use... X-Git-Tag: v8.0.0~7206 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=449319de71edda5a2ba0d3c0bfcaa0196a1d6a87;p=dealii.git On Mac OS X, all symbols referenced in a shared lib must be available. Since we use Vector in a number of places, this means that we also have to have available everything that Vector uses, in particular the symbol internal::Vector::minimum_parallel_grain_size. Move this variable to base into parallel.{h,cc} to make the OS X linker happy. While there, also move internal::SparseMatrix::minimum_parallel_grain_size. git-svn-id: https://svn.dealii.org/trunk@19362 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/parallel.h b/deal.II/base/include/base/parallel.h index 17e6329e15..b5f496ee0e 100644 --- a/deal.II/base/include/base/parallel.h +++ b/deal.II/base/include/base/parallel.h @@ -102,7 +102,7 @@ namespace parallel : iterators (i) {} - + template 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); } } - + /** * An algorithm that performs the action * *out++ = predicate(*in++) @@ -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 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 index 0000000000..f13a5192fc --- /dev/null +++ b/deal.II/base/source/parallel.cc @@ -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 + + +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 diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index 94a1ab8dcc..5a818e8a18 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -32,27 +32,13 @@ template 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 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& 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 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 &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 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 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 &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 accessor; }; - + } @@ -514,7 +500,7 @@ class SparseMatrix : public virtual Subscriptor * norms. */ typedef typename numbers::NumberTraits::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 & 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 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 void copy_from (const FullMatrix &matrix); - + /** * Add matrix scaled by * factor to this matrix, @@ -1168,14 +1154,14 @@ class SparseMatrix : public virtual Subscriptor */ template void add (const number factor, - const SparseMatrix &matrix); - + const SparseMatrix &matrix); + //@} /** * @name Entry Access */ //@{ - + /** * Return the value of the entry * (i,j). 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 void vmult (OutVector& dst, const InVector& src) const; - + /** * Matrix-vector multiplication: * let dst = MT*src 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 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 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 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 somenumber matrix_scalar_product (const Vector &u, const Vector &v) const; - + /** * Compute the residual of an * equation Mx=b, where @@ -1519,7 +1505,7 @@ class SparseMatrix : public virtual Subscriptor const SparseMatrix &B, const Vector &V = Vector(), 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 &B, const Vector &V = Vector(), 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 &dst, const Vector &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 &dst, const Vector &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 r. 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 r. 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 friend class SparseMatrix; template friend class SparseLUDecomposition; template friend class SparseILU; - + /** * To allow it calling private * prepare_add() and * prepare_set(). - */ + */ template friend class BlockMatrixBase; }; @@ -2153,9 +2139,9 @@ unsigned int SparseMatrix::n () const // Inline the set() and add() - // functions, since they will be + // functions, since they will be // called frequently. -template +template inline void SparseMatrix::set (const unsigned int i, @@ -2185,8 +2171,8 @@ SparseMatrix::set (const unsigned int i, -template -template +template +template inline void SparseMatrix::set (const std::vector &indices, @@ -2204,8 +2190,8 @@ SparseMatrix::set (const std::vector &indices, -template -template +template +template inline void SparseMatrix::set (const std::vector &row_indices, @@ -2225,8 +2211,8 @@ SparseMatrix::set (const std::vector &row_indices, -template -template +template +template inline void SparseMatrix::set (const unsigned int row, @@ -2243,7 +2229,7 @@ SparseMatrix::set (const unsigned int row, -template +template inline void SparseMatrix::add (const unsigned int i, @@ -2276,8 +2262,8 @@ SparseMatrix::add (const unsigned int i, -template -template +template +template inline void SparseMatrix::add (const std::vector &indices, @@ -2295,8 +2281,8 @@ SparseMatrix::add (const std::vector &indices, -template -template +template +template inline void SparseMatrix::add (const std::vector &row_indices, @@ -2316,8 +2302,8 @@ SparseMatrix::add (const std::vector &row_indices, -template -template +template +template inline void SparseMatrix::add (const unsigned int row, @@ -2411,7 +2397,7 @@ number SparseMatrix::diag_element (const unsigned int i) const Assert (cols != 0, ExcNotInitialized()); Assert (cols->optimize_diagonal(), ExcNotQuadratic()); Assert (i::diag_element (const unsigned int i) Assert (cols != 0, ExcNotInitialized()); Assert (cols->optimize_diagonal(), ExcNotQuadratic()); Assert (i::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 @@ -2539,7 +2525,7 @@ namespace SparseMatrixIterators SparsityPatternIterators::Accessor (a), matrix (&a.get_matrix()) {} - + template @@ -2551,7 +2537,7 @@ namespace SparseMatrixIterators } - + template inline typename Accessor::MatrixType & @@ -2561,7 +2547,7 @@ namespace SparseMatrixIterators } - + template inline Accessor::Reference:: @@ -2570,9 +2556,9 @@ namespace SparseMatrixIterators : accessor (accessor) {} - - + + template inline Accessor::Reference::operator number() const @@ -2580,9 +2566,9 @@ namespace SparseMatrixIterators return accessor->matrix->raw_entry(accessor->a_row, accessor->a_index); } - - + + template inline const typename Accessor::Reference & @@ -2592,9 +2578,9 @@ namespace SparseMatrixIterators accessor->matrix->set (accessor->row(), accessor->column(), n); return *this; } - - + + template inline const typename Accessor::Reference & @@ -2605,9 +2591,9 @@ namespace SparseMatrixIterators static_cast(*this) + n); return *this; } - - + + template inline const typename Accessor::Reference & @@ -2631,9 +2617,9 @@ namespace SparseMatrixIterators static_cast(*this)*n); return *this; } - - + + template inline const typename Accessor::Reference & @@ -2644,9 +2630,9 @@ namespace SparseMatrixIterators static_cast(*this)/n); return *this; } - - + + template inline Accessor:: @@ -2669,7 +2655,7 @@ namespace SparseMatrixIterators SparsityPatternIterators::Accessor (&matrix->get_sparsity_pattern()), matrix (matrix) {} - + template @@ -2682,7 +2668,7 @@ namespace SparseMatrixIterators - + template inline typename Accessor::MatrixType & @@ -2692,7 +2678,7 @@ namespace SparseMatrixIterators } - + template inline Iterator:: @@ -2722,8 +2708,8 @@ namespace SparseMatrixIterators : accessor(*i) {} - - + + template 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); } - + } diff --git a/deal.II/lac/include/lac/vector.h b/deal.II/lac/include/lac/vector.h index 7c9abe9647..ad1ad3e760 100644 --- a/deal.II/lac/include/lac/vector.h +++ b/deal.II/lac/include/lac/vector.h @@ -53,32 +53,6 @@ template class BlockVector; template 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 * @@>; 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 @@ -147,9 +121,9 @@ class Vector : public Subscriptor typedef typename numbers::NumberTraits::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 &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 &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 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 &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 & operator = (const Number s); - + /** * Copy the given vector. Resize the * present vector if necessary. */ Vector & operator= (const Vector &c); - + /** * Copy the given vector. Resize the * present vector if necessary. @@ -431,7 +405,7 @@ class Vector : public Subscriptor * vector. */ Vector & operator= (const BlockVector &v); - + #ifdef DEAL_II_USE_PETSC /** * Another copy operator: copy the @@ -515,7 +489,7 @@ class Vector : public Subscriptor */ template bool operator == (const Vector &v) const; - + /** * Test for inequality. This function * assumes that the present vector and @@ -526,7 +500,7 @@ class Vector : public Subscriptor */ template bool operator != (const Vector &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 vector<> 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 * operator +=. */ void add (const Vector &V); - + /** * Simple addition of a multiple of a * vector, i.e. *this += a*V. */ void add (const Number a, const Vector &V); - + /** * Multiple addition of scaled vectors, * i.e. *this += a*V+b*W. */ void add (const Number a, const Vector &V, const Number b, const Vector &W); - + /** * Scaling and simple vector addition, * i.e. @@ -712,7 +686,7 @@ class Vector : public Subscriptor */ void sadd (const Number s, const Vector &V); - + /** * Scaling and simple addition, i.e. * *this = s*(*this)+a*V. @@ -720,7 +694,7 @@ class Vector : public Subscriptor void sadd (const Number s, const Number a, const Vector &V); - + /** * Scaling and multiple addition. */ @@ -729,7 +703,7 @@ class Vector : public Subscriptor const Vector &V, const Number b, const Vector &W); - + /** * Scaling and multiple addition. * *this = s*(*this)+a*V + b*W + c*X. @@ -738,10 +712,10 @@ class Vector : public Subscriptor const Number a, const Vector &V, const Number b, - const Vector &W, + const Vector &W, const Number c, const Vector &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 & 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 &scaling_factors); - + /** * Scale each element of this * vector by the corresponding @@ -802,13 +776,13 @@ class Vector : public Subscriptor */ template void equ (const Number a, const Vector& u); - + /** * Assignment *this = a*u + b*v. */ void equ (const Number a, const Vector& u, const Number b, const Vector& v); - + /** * Assignment *this = a*u + b*v + b*w. */ @@ -1019,14 +993,14 @@ template inline void Vector::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 inline Vector & Vector::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, _1, _2, s), internal::Vector::minimum_parallel_grain_size); @@ -1071,8 +1045,8 @@ unsigned int Vector::size () const template inline -typename Vector::iterator -Vector::begin () +typename Vector::iterator +Vector::begin () { return &val[0]; } @@ -1081,8 +1055,8 @@ Vector::begin () template inline -typename Vector::const_iterator -Vector::begin () const +typename Vector::const_iterator +Vector::begin () const { return &val[0]; } @@ -1092,7 +1066,7 @@ Vector::begin () const template inline typename Vector::iterator -Vector::end () +Vector::end () { return &val[vec_size]; } @@ -1134,7 +1108,7 @@ inline Vector & Vector::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 & Vector::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::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::add (const Number a, const Vector& 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::sadd (const Number x, const Number a, const Vector& 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()); diff --git a/deal.II/lac/source/sparse_matrix.cc b/deal.II/lac/source/sparse_matrix.cc index 0a703781c3..cdd677efe3 100644 --- a/deal.II/lac/source/sparse_matrix.cc +++ b/deal.II/lac/source/sparse_matrix.cc @@ -17,25 +17,6 @@ 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 diff --git a/deal.II/lac/source/vector.cc b/deal.II/lac/source/vector.cc index 7a41a6c426..39607ff73a 100644 --- a/deal.II/lac/source/vector.cc +++ b/deal.II/lac/source/vector.cc @@ -16,27 +16,6 @@ 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::Vector (const Vector &) -#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,std::complex); Vector::DEAL_II_MEMBER_OP_TEMPLATE_INST \ operator=(const Vector&); \ template void Vector::scale (const Vector&); \ - template void Vector::equ (const S1, const Vector&) + template void Vector::equ (const S1, const Vector&) TEMPL_OP_EQ(double,float); TEMPL_OP_EQ(float,double);