From: Martin Kronbichler Date: Fri, 17 May 2024 12:48:29 +0000 (+0200) Subject: Simplify cmath functions for VectorizedArray X-Git-Tag: v9.6.0-rc1~250^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F17039%2Fhead;p=dealii.git Simplify cmath functions for VectorizedArray --- diff --git a/include/deal.II/base/vectorization.h b/include/deal.II/base/vectorization.h index 41c5bb5fac..b43f59a83a 100644 --- a/include/deal.II/base/vectorization.h +++ b/include/deal.II/base/vectorization.h @@ -6588,17 +6588,10 @@ namespace std inline ::dealii::VectorizedArray sin(const ::dealii::VectorizedArray &x) { - // put values in an array and later read in that array with an unaligned - // read. This should save some instructions as compared to directly - // setting the individual elements and also circumvents a compiler - // optimization bug in gcc-4.6 with SSE2 (see also deal.II developers list - // from April 2014, topic "matrix_free/step-48 Test"). - Number values[::dealii::VectorizedArray::size()]; + ::dealii::VectorizedArray out; for (unsigned int i = 0; i < dealii::VectorizedArray::size(); ++i) - values[i] = std::sin(x[i]); - ::dealii::VectorizedArray out; - out.load(&values[0]); + out[i] = std::sin(x[i]); return out; } @@ -6615,12 +6608,10 @@ namespace std inline ::dealii::VectorizedArray cos(const ::dealii::VectorizedArray &x) { - Number values[::dealii::VectorizedArray::size()]; + ::dealii::VectorizedArray out; for (unsigned int i = 0; i < dealii::VectorizedArray::size(); ++i) - values[i] = std::cos(x[i]); - ::dealii::VectorizedArray out; - out.load(&values[0]); + out[i] = std::cos(x[i]); return out; } @@ -6637,12 +6628,10 @@ namespace std inline ::dealii::VectorizedArray tan(const ::dealii::VectorizedArray &x) { - Number values[::dealii::VectorizedArray::size()]; + ::dealii::VectorizedArray out; for (unsigned int i = 0; i < dealii::VectorizedArray::size(); ++i) - values[i] = std::tan(x[i]); - ::dealii::VectorizedArray out; - out.load(&values[0]); + out[i] = std::tan(x[i]); return out; } @@ -6839,12 +6828,10 @@ namespace std inline ::dealii::VectorizedArray exp(const ::dealii::VectorizedArray &x) { - Number values[::dealii::VectorizedArray::size()]; + ::dealii::VectorizedArray out; for (unsigned int i = 0; i < dealii::VectorizedArray::size(); ++i) - values[i] = std::exp(x[i]); - ::dealii::VectorizedArray out; - out.load(&values[0]); + out[i] = std::exp(x[i]); return out; } @@ -6861,12 +6848,10 @@ namespace std inline ::dealii::VectorizedArray log(const ::dealii::VectorizedArray &x) { - Number values[::dealii::VectorizedArray::size()]; + ::dealii::VectorizedArray out; for (unsigned int i = 0; i < dealii::VectorizedArray::size(); ++i) - values[i] = std::log(x[i]); - ::dealii::VectorizedArray out; - out.load(&values[0]); + out[i] = std::log(x[i]); return out; } @@ -6899,12 +6884,10 @@ namespace std inline ::dealii::VectorizedArray pow(const ::dealii::VectorizedArray &x, const Number p) { - Number values[::dealii::VectorizedArray::size()]; + ::dealii::VectorizedArray out; for (unsigned int i = 0; i < dealii::VectorizedArray::size(); ++i) - values[i] = std::pow(x[i], p); - ::dealii::VectorizedArray out; - out.load(&values[0]); + out[i] = std::pow(x[i], p); return out; } @@ -6923,12 +6906,10 @@ namespace std pow(const ::dealii::VectorizedArray &x, const ::dealii::VectorizedArray &p) { - Number values[::dealii::VectorizedArray::size()]; + ::dealii::VectorizedArray out; for (unsigned int i = 0; i < dealii::VectorizedArray::size(); ++i) - values[i] = std::pow(x[i], p[i]); - ::dealii::VectorizedArray out; - out.load(&values[0]); + out[i] = std::pow(x[i], p[i]); return out; }