From: Peter Munch Date: Thu, 19 Mar 2020 09:56:03 +0000 (+0100) Subject: Change type of template argument width of VectorizedArray to std::size_t X-Git-Tag: v9.2.0-rc1~399^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52c77673be2372b52b9d80d612049d1ccda35f73;p=dealii.git Change type of template argument width of VectorizedArray to std::size_t --- diff --git a/include/deal.II/base/memory_consumption.h b/include/deal.II/base/memory_consumption.h index 85abcd1f35..491c465303 100644 --- a/include/deal.II/base/memory_consumption.h +++ b/include/deal.II/base/memory_consumption.h @@ -128,7 +128,7 @@ namespace MemoryConsumption * Determine the amount of memory in bytes consumed by a * VectorizedArray variable. */ - template + template inline std::size_t memory_consumption(const VectorizedArray &); @@ -296,7 +296,7 @@ namespace MemoryConsumption - template + template inline std::size_t memory_consumption(const VectorizedArray &) { diff --git a/include/deal.II/base/numbers.h b/include/deal.II/base/numbers.h index e02ce6c7b2..6f83910403 100644 --- a/include/deal.II/base/numbers.h +++ b/include/deal.II/base/numbers.h @@ -128,7 +128,7 @@ namespace internal // forward declarations to support abs or sqrt operations on VectorizedArray #ifndef DOXYGEN template ::max_width> class VectorizedArray; template @@ -154,36 +154,36 @@ DEAL_II_NAMESPACE_CLOSE namespace std { - template + template DEAL_II_ALWAYS_INLINE ::dealii::VectorizedArray sqrt(const ::dealii::VectorizedArray &); - template + template DEAL_II_ALWAYS_INLINE ::dealii::VectorizedArray abs(const ::dealii::VectorizedArray &); - template + template DEAL_II_ALWAYS_INLINE ::dealii::VectorizedArray max(const ::dealii::VectorizedArray &, const ::dealii::VectorizedArray &); - template + template DEAL_II_ALWAYS_INLINE ::dealii::VectorizedArray min(const ::dealii::VectorizedArray &, const ::dealii::VectorizedArray &); - template + template ::dealii::VectorizedArray pow(const ::dealii::VectorizedArray &, const Number p); - template + template ::dealii::VectorizedArray sin(const ::dealii::VectorizedArray &); - template + template ::dealii::VectorizedArray cos(const ::dealii::VectorizedArray &); - template + template ::dealii::VectorizedArray tan(const ::dealii::VectorizedArray &); - template + template ::dealii::VectorizedArray exp(const ::dealii::VectorizedArray &); - template + template ::dealii::VectorizedArray log(const ::dealii::VectorizedArray &); } // namespace std diff --git a/include/deal.II/base/vectorization.h b/include/deal.II/base/vectorization.h index a6df94d475..26bc11e0a5 100644 --- a/include/deal.II/base/vectorization.h +++ b/include/deal.II/base/vectorization.h @@ -77,7 +77,7 @@ DEAL_II_NAMESPACE_OPEN // Enable the EnableIfScalar type trait for VectorizedArray such // that it can be used as a Number type in Tensor, etc. -template +template struct EnableIfScalar> { using type = VectorizedArray::type, width>; @@ -100,7 +100,7 @@ public: * @param data The actual VectorizedArray. * @param lane A pointer to the current lane. */ - VectorizedArrayIterator(T &data, const unsigned int lane) + VectorizedArrayIterator(T &data, const std::size_t lane) : data(&data) , lane(lane) {} @@ -177,7 +177,7 @@ public: * reference to *this. */ VectorizedArrayIterator & - operator+=(const unsigned int offset) + operator+=(const std::size_t offset) { AssertIndexRange(lane + offset, T::size() + 1); lane += offset; @@ -204,7 +204,7 @@ public: * Create new iterator, which is shifted by @p offset. */ VectorizedArrayIterator - operator+(const unsigned int offset) const + operator+(const std::size_t &offset) const { AssertIndexRange(lane + offset, T::size() + 1); return VectorizedArrayIterator(*data, lane + offset); @@ -213,11 +213,11 @@ public: /** * Compute distance between this iterator and iterator @p other. */ - unsigned int + std::ptrdiff_t operator-(const VectorizedArrayIterator &other) const { - AssertIndexRange(other.lane, lane + 1); - return lane - other.lane; + return static_cast(lane) - + static_cast(other.lane); } private: @@ -229,7 +229,7 @@ private: /** * Pointer to the current lane. */ - unsigned int lane; + std::size_t lane; }; @@ -253,7 +253,7 @@ public: * Return the number of elements in the array stored in the variable * n_array_elements of VectorizedArray. */ - static constexpr unsigned int + static constexpr std::size_t size() { return T::n_array_elements; @@ -388,7 +388,7 @@ public: * * @author Katharina Kormann, Martin Kronbichler, Peter Munch, 2010, 2011, 2019 */ -template +template class VectorizedArray : public VectorizedArrayBase> { @@ -679,17 +679,17 @@ private: } // Make a few functions friends. - template + template friend VectorizedArray std::sqrt(const VectorizedArray &); - template + template friend VectorizedArray std::abs(const VectorizedArray &); - template + template friend VectorizedArray std::max(const VectorizedArray &, const VectorizedArray &); - template + template friend VectorizedArray std::min(const VectorizedArray &, const VectorizedArray &); @@ -698,7 +698,7 @@ private: // We need to have a separate declaration for static const members -template +template const unsigned int VectorizedArray::n_array_elements; @@ -715,9 +715,9 @@ const unsigned int VectorizedArray::n_array_elements; * * @relatesalso VectorizedArray */ -template < - typename Number, - int width = internal::VectorizedArrayWidthSpecifier::max_width> +template ::max_width> inline DEAL_II_ALWAYS_INLINE VectorizedArray make_vectorized_array(const Number &u) { @@ -760,15 +760,13 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArrayType * out.data[v] = ptrs[v][offset]; * @endcode */ -template +template inline DEAL_II_ALWAYS_INLINE void -gather(VectorizedArray & out, - const std::array &ptrs, - const unsigned int offset) +gather(VectorizedArray & out, + const std::array &ptrs, + const unsigned int offset) { - static_assert(width == width_, "Length of input vector do not match!"); - - for (unsigned int v = 0; v < width_; v++) + for (unsigned int v = 0; v < width; v++) out.data[v] = ptrs[v][offset]; } @@ -799,7 +797,7 @@ gather(VectorizedArray & out, * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE void vectorized_load_and_transpose(const unsigned int n_entries, const Number * in, @@ -825,14 +823,12 @@ vectorized_load_and_transpose(const unsigned int n_entries, * of pointers and no assumption can be made that they belong to the same array, * i.e., they can have their origin in different memory allocations. */ -template +template inline DEAL_II_ALWAYS_INLINE void -vectorized_load_and_transpose(const unsigned int n_entries, - const std::array &in, - VectorizedArray * out) +vectorized_load_and_transpose(const unsigned int n_entries, + const std::array &in, + VectorizedArray * out) { - static_assert(width == width_, "Length of input vector do not match!"); - for (unsigned int i = 0; i < n_entries; ++i) for (unsigned int v = 0; v < VectorizedArray::n_array_elements; @@ -880,7 +876,7 @@ vectorized_load_and_transpose(const unsigned int n_entries, * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE void vectorized_transpose_and_store(const bool add_into, const unsigned int n_entries, @@ -914,15 +910,13 @@ vectorized_transpose_and_store(const bool add_into, * of pointers and no assumption can be made that they belong to the same array, * i.e., they can have their origin in different memory allocations. */ -template +template inline DEAL_II_ALWAYS_INLINE void vectorized_transpose_and_store(const bool add_into, const unsigned int n_entries, const VectorizedArray *in, - std::array & out) + std::array & out) { - static_assert(width == width_, "Length of input vector do not match!"); - if (add_into) for (unsigned int i = 0; i < n_entries; ++i) for (unsigned int v = 0; @@ -1236,17 +1230,17 @@ private: } // Make a few functions friends. - template + template friend VectorizedArray std::sqrt(const VectorizedArray &); - template + template friend VectorizedArray std::abs(const VectorizedArray &); - template + template friend VectorizedArray std::max(const VectorizedArray &, const VectorizedArray &); - template + template friend VectorizedArray std::min(const VectorizedArray &, const VectorizedArray &); @@ -1788,17 +1782,17 @@ private: } // Make a few functions friends. - template + template friend VectorizedArray std::sqrt(const VectorizedArray &); - template + template friend VectorizedArray std::abs(const VectorizedArray &); - template + template friend VectorizedArray std::max(const VectorizedArray &, const VectorizedArray &); - template + template friend VectorizedArray std::min(const VectorizedArray &, const VectorizedArray &); @@ -2427,17 +2421,17 @@ private: } // Make a few functions friends. - template + template friend VectorizedArray std::sqrt(const VectorizedArray &); - template + template friend VectorizedArray std::abs(const VectorizedArray &); - template + template friend VectorizedArray std::max(const VectorizedArray &, const VectorizedArray &); - template + template friend VectorizedArray std::min(const VectorizedArray &, const VectorizedArray &); @@ -2938,17 +2932,17 @@ private: } // Make a few functions friends. - template + template friend VectorizedArray std::sqrt(const VectorizedArray &); - template + template friend VectorizedArray std::abs(const VectorizedArray &); - template + template friend VectorizedArray std::max(const VectorizedArray &, const VectorizedArray &); - template + template friend VectorizedArray std::min(const VectorizedArray &, const VectorizedArray &); @@ -3469,17 +3463,17 @@ private: } // Make a few functions friends. - template + template friend VectorizedArray std::sqrt(const VectorizedArray &); - template + template friend VectorizedArray std::abs(const VectorizedArray &); - template + template friend VectorizedArray std::max(const VectorizedArray &, const VectorizedArray &); - template + template friend VectorizedArray std::min(const VectorizedArray &, const VectorizedArray &); @@ -3910,17 +3904,17 @@ private: } // Make a few functions friends. - template + template friend VectorizedArray std::sqrt(const VectorizedArray &); - template + template friend VectorizedArray std::abs(const VectorizedArray &); - template + template friend VectorizedArray std::max(const VectorizedArray &, const VectorizedArray &); - template + template friend VectorizedArray std::min(const VectorizedArray &, const VectorizedArray &); @@ -4347,17 +4341,17 @@ private: } // Make a few functions friends. - template + template friend VectorizedArray std::sqrt(const VectorizedArray &); - template + template friend VectorizedArray std::abs(const VectorizedArray &); - template + template friend VectorizedArray std::max(const VectorizedArray &, const VectorizedArray &); - template + template friend VectorizedArray std::min(const VectorizedArray &, const VectorizedArray &); @@ -4586,17 +4580,17 @@ private: } // Make a few functions friends. - template + template friend VectorizedArray std::sqrt(const VectorizedArray &); - template + template friend VectorizedArray std::abs(const VectorizedArray &); - template + template friend VectorizedArray std::max(const VectorizedArray &, const VectorizedArray &); - template + template friend VectorizedArray std::min(const VectorizedArray &, const VectorizedArray &); @@ -4618,7 +4612,7 @@ private: * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE bool operator==(const VectorizedArray &lhs, const VectorizedArray &rhs) @@ -4637,7 +4631,7 @@ operator==(const VectorizedArray &lhs, * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator+(const VectorizedArray &u, const VectorizedArray &v) @@ -4651,7 +4645,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator-(const VectorizedArray &u, const VectorizedArray &v) @@ -4665,7 +4659,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator*(const VectorizedArray &u, const VectorizedArray &v) @@ -4679,7 +4673,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator/(const VectorizedArray &u, const VectorizedArray &v) @@ -4694,7 +4688,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator+(const Number &u, const VectorizedArray &v) { @@ -4710,7 +4704,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator+(const double u, const VectorizedArray &v) { @@ -4724,7 +4718,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator+(const VectorizedArray &v, const Number &u) { @@ -4739,7 +4733,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator+(const VectorizedArray &v, const double u) { @@ -4752,7 +4746,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator-(const Number &u, const VectorizedArray &v) { @@ -4768,7 +4762,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator-(const double u, const VectorizedArray &v) { @@ -4782,7 +4776,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator-(const VectorizedArray &v, const Number &u) { @@ -4798,7 +4792,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator-(const VectorizedArray &v, const double u) { @@ -4812,7 +4806,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator*(const Number &u, const VectorizedArray &v) { @@ -4828,7 +4822,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator*(const double u, const VectorizedArray &v) { @@ -4842,7 +4836,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator*(const VectorizedArray &v, const Number &u) { @@ -4857,7 +4851,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator*(const VectorizedArray &v, const double u) { @@ -4870,7 +4864,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator/(const Number &u, const VectorizedArray &v) { @@ -4886,7 +4880,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator/(const double u, const VectorizedArray &v) { @@ -4900,7 +4894,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator/(const VectorizedArray &v, const Number &u) { @@ -4916,7 +4910,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator/(const VectorizedArray &v, const double u) { @@ -4929,7 +4923,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator+(const VectorizedArray &u) { @@ -4941,7 +4935,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator-(const VectorizedArray &u) { @@ -4955,7 +4949,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArray * * @relatesalso VectorizedArray */ -template +template inline std::ostream & operator<<(std::ostream &out, const VectorizedArray &p) { @@ -5290,7 +5284,7 @@ namespace std * * @relatesalso VectorizedArray */ - template + template inline ::dealii::VectorizedArray sin(const ::dealii::VectorizedArray &x) { @@ -5318,7 +5312,7 @@ namespace std * * @relatesalso VectorizedArray */ - template + template inline ::dealii::VectorizedArray cos(const ::dealii::VectorizedArray &x) { @@ -5341,7 +5335,7 @@ namespace std * * @relatesalso VectorizedArray */ - template + template inline ::dealii::VectorizedArray tan(const ::dealii::VectorizedArray &x) { @@ -5364,7 +5358,7 @@ namespace std * * @relatesalso VectorizedArray */ - template + template inline ::dealii::VectorizedArray exp(const ::dealii::VectorizedArray &x) { @@ -5387,7 +5381,7 @@ namespace std * * @relatesalso VectorizedArray */ - template + template inline ::dealii::VectorizedArray log(const ::dealii::VectorizedArray &x) { @@ -5410,7 +5404,7 @@ namespace std * * @relatesalso VectorizedArray */ - template + template inline ::dealii::VectorizedArray sqrt(const ::dealii::VectorizedArray &x) { @@ -5426,7 +5420,7 @@ namespace std * * @relatesalso VectorizedArray */ - template + template inline ::dealii::VectorizedArray pow(const ::dealii::VectorizedArray &x, const Number p) { @@ -5449,7 +5443,7 @@ namespace std * * @relatesalso VectorizedArray */ - template + template inline ::dealii::VectorizedArray abs(const ::dealii::VectorizedArray &x) { @@ -5465,7 +5459,7 @@ namespace std * * @relatesalso VectorizedArray */ - template + template inline ::dealii::VectorizedArray max(const ::dealii::VectorizedArray &x, const ::dealii::VectorizedArray &y) @@ -5482,7 +5476,7 @@ namespace std * * @relatesalso VectorizedArray */ - template + template inline ::dealii::VectorizedArray min(const ::dealii::VectorizedArray &x, const ::dealii::VectorizedArray &y) @@ -5500,7 +5494,7 @@ namespace std { using iterator_category = random_access_iterator_tag; using value_type = typename T::value_type; - using difference_type = unsigned int; + using difference_type = std::ptrdiff_t; }; } // namespace std diff --git a/include/deal.II/matrix_free/shape_info.templates.h b/include/deal.II/matrix_free/shape_info.templates.h index c89ba34f22..8bb5aaec00 100644 --- a/include/deal.II/matrix_free/shape_info.templates.h +++ b/include/deal.II/matrix_free/shape_info.templates.h @@ -51,7 +51,7 @@ namespace internal return a; } - template + template Number get_first_array_element(const VectorizedArray a) {