* of bytes in the vectorized array, as opposed to casting a double address
* to VectorizedArray<double>*.
*/
- DEAL_II_ALWAYS_INLINE
- void
- load(const Number *ptr)
+ template <typename OtherNumber>
+ DEAL_II_ALWAYS_INLINE void
+ load(const OtherNumber *ptr)
{
data = *ptr;
}
* aligned by the amount of bytes in the vectorized array, as opposed to
* casting a double address to VectorizedArray<double>*.
*/
- DEAL_II_ALWAYS_INLINE
- void
- store(Number *ptr) const
+ template <typename OtherNumber>
+ DEAL_II_ALWAYS_INLINE void
+ store(OtherNumber *ptr) const
{
*ptr = data;
}
data = _mm512_loadu_pd(ptr);
}
+ DEAL_II_ALWAYS_INLINE
+ void
+ load(const float *ptr)
+ {
+ data = _mm512_cvtps_pd(_mm256_loadu_ps(ptr));
+ }
+
/**
* Write the content of the calling class into memory in form of @p
* size() to the given address. The memory need not be aligned by
_mm512_storeu_pd(ptr, data);
}
+ DEAL_II_ALWAYS_INLINE
+ void
+ store(float *ptr) const
+ {
+ _mm256_storeu_ps(ptr, _mm512_cvtpd_ps(data));
+ }
+
/**
* @copydoc VectorizedArray<Number>::streaming_store()
* @note Memory must be aligned by 64 bytes.
data = _mm256_loadu_pd(ptr);
}
+ DEAL_II_ALWAYS_INLINE
+ void
+ load(const float *ptr)
+ {
+ data = _mm256_cvtps_pd(_mm_loadu_ps(ptr));
+ }
+
/**
* Write the content of the calling class into memory in form of @p
* size() to the given address. The memory need not be aligned by
_mm256_storeu_pd(ptr, data);
}
+ DEAL_II_ALWAYS_INLINE
+ void
+ store(float *ptr) const
+ {
+ _mm_storeu_ps(ptr, _mm256_cvtpd_ps(data));
+ }
+
/**
* @copydoc VectorizedArray<Number>::streaming_store()
* @note Memory must be aligned by 32 bytes.
data = _mm_loadu_pd(ptr);
}
+ DEAL_II_ALWAYS_INLINE
+ void
+ load(const float *ptr)
+ {
+ DEAL_II_OPENMP_SIMD_PRAGMA
+ for (unsigned int i = 0; i < 2; ++i)
+ data[i] = ptr[i];
+ }
+
/**
* Write the content of the calling class into memory in form of @p
* size() to the given address. The memory need not be aligned by
_mm_storeu_pd(ptr, data);
}
+ DEAL_II_ALWAYS_INLINE
+ void
+ store(float *ptr) const
+ {
+ DEAL_II_OPENMP_SIMD_PRAGMA
+ for (unsigned int i = 0; i < 2; ++i)
+ ptr[i] = data[i];
+ }
+
/**
* @copydoc VectorizedArray<Number>::streaming_store()
* @note Memory must be aligned by 16 bytes.
#include "../tests.h"
-template <typename Number>
+template <typename Number, typename VectorizedArrayType>
void
test()
{
- const unsigned int n_vectors = VectorizedArray<Number>::size();
+ const unsigned int n_vectors = VectorizedArrayType::size();
std::vector<Number> values(n_vectors * 5);
for (unsigned int i = 0; i < values.size(); ++i)
values[i] = i;
- AlignedVector<VectorizedArray<Number>> copied(4);
+ AlignedVector<VectorizedArrayType> copied(4);
// test load operation for all possible values of alignment
for (unsigned int shift = 0; shift < n_vectors; ++shift)
{
for (unsigned int i = 0; i < 4; ++i)
{
- VectorizedArray<Number> tmp;
+ VectorizedArrayType tmp;
tmp.load(&values[i * n_vectors]);
tmp.store(&stored[i * n_vectors + shift]);
}
{
initlog();
- deallog.push("double");
- test<double>();
+ deallog.push("double <-> VectorizedArray<double, 1>");
+ test<double, VectorizedArray<double, 1>>();
deallog.pop();
- deallog.push("float");
- test<float>();
+ deallog.push("float <-> VectorizedArray<float, 1>");
+ test<float, VectorizedArray<float, 1>>();
deallog.pop();
+ deallog.push("float <-> VectorizedArray<double, 1>");
+ test<float, VectorizedArray<double, 1>>();
+ deallog.pop();
+
+#if DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 128
+ deallog.push("double <-> VectorizedArray<double, 2>");
+ test<double, VectorizedArray<double, 2>>();
+ deallog.pop();
+ deallog.push("float <-> VectorizedArray<float, 4>");
+ test<float, VectorizedArray<float, 4>>();
+ deallog.pop();
+ deallog.push("float <-> VectorizedArray<double, 2>");
+ test<float, VectorizedArray<double, 2>>();
+ deallog.pop();
+#endif
+
+#if DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 256
+ deallog.push("double <-> VectorizedArray<double, 4>");
+ test<double, VectorizedArray<double, 4>>();
+ deallog.pop();
+ deallog.push("float <-> VectorizedArray<float, 8>");
+ test<float, VectorizedArray<float, 8>>();
+ deallog.pop();
+ deallog.push("float <-> VectorizedArray<double, 4>");
+ test<float, VectorizedArray<double, 4>>();
+ deallog.pop();
+#endif
+
+#if DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 512
+ deallog.push("double <-> VectorizedArray<double, 8>");
+ test<double, VectorizedArray<double, 8>>();
+ deallog.pop();
+ deallog.push("float <-> VectorizedArray<float, 16>");
+ test<float, VectorizedArray<float, 16>>();
+ deallog.pop();
+ deallog.push("float <-> VectorizedArray<double, 8>");
+ test<float, VectorizedArray<double, 8>>();
+ deallog.pop();
+#endif
// test long double and unsigned int: in these cases, the default path of
// VectorizedArray is taken no matter what was done for double or float
deallog.push("long double");
- test<long double>();
+ test<long double, VectorizedArray<long double>>();
deallog.pop();
deallog.push("unsigned int");
- test<unsigned int>();
+ test<unsigned int, VectorizedArray<unsigned int>>();
deallog.pop();
}
-DEAL:double::load OK
-DEAL:double::store OK
-DEAL:float::load OK
-DEAL:float::store OK
+DEAL:double <-> VectorizedArray<double, 1>::load OK
+DEAL:double <-> VectorizedArray<double, 1>::store OK
+DEAL:float <-> VectorizedArray<float, 1>::load OK
+DEAL:float <-> VectorizedArray<float, 1>::store OK
+DEAL:float <-> VectorizedArray<double, 1>::load OK
+DEAL:float <-> VectorizedArray<double, 1>::store OK
DEAL:long double::load OK
DEAL:long double::store OK
DEAL:unsigned int::load OK
--- /dev/null
+
+DEAL:double <-> VectorizedArray<double, 1>::load OK
+DEAL:double <-> VectorizedArray<double, 1>::store OK
+DEAL:float <-> VectorizedArray<float, 1>::load OK
+DEAL:float <-> VectorizedArray<float, 1>::store OK
+DEAL:float <-> VectorizedArray<double, 1>::load OK
+DEAL:float <-> VectorizedArray<double, 1>::store OK
+DEAL:double <-> VectorizedArray<double, 2>::load OK
+DEAL:double <-> VectorizedArray<double, 2>::store OK
+DEAL:float <-> VectorizedArray<float, 4>::load OK
+DEAL:float <-> VectorizedArray<float, 4>::store OK
+DEAL:float <-> VectorizedArray<double, 2>::load OK
+DEAL:float <-> VectorizedArray<double, 2>::store OK
+DEAL:double <-> VectorizedArray<double, 4>::load OK
+DEAL:double <-> VectorizedArray<double, 4>::store OK
+DEAL:float <-> VectorizedArray<float, 8>::load OK
+DEAL:float <-> VectorizedArray<float, 8>::store OK
+DEAL:float <-> VectorizedArray<double, 4>::load OK
+DEAL:float <-> VectorizedArray<double, 4>::store OK
+DEAL:long double::load OK
+DEAL:long double::store OK
+DEAL:unsigned int::load OK
+DEAL:unsigned int::store OK
--- /dev/null
+
+DEAL:double <-> VectorizedArray<double, 1>::load OK
+DEAL:double <-> VectorizedArray<double, 1>::store OK
+DEAL:float <-> VectorizedArray<float, 1>::load OK
+DEAL:float <-> VectorizedArray<float, 1>::store OK
+DEAL:float <-> VectorizedArray<double, 1>::load OK
+DEAL:float <-> VectorizedArray<double, 1>::store OK
+DEAL:double <-> VectorizedArray<double, 2>::load OK
+DEAL:double <-> VectorizedArray<double, 2>::store OK
+DEAL:float <-> VectorizedArray<float, 4>::load OK
+DEAL:float <-> VectorizedArray<float, 4>::store OK
+DEAL:float <-> VectorizedArray<double, 2>::load OK
+DEAL:float <-> VectorizedArray<double, 2>::store OK
+DEAL:double <-> VectorizedArray<double, 4>::load OK
+DEAL:double <-> VectorizedArray<double, 4>::store OK
+DEAL:float <-> VectorizedArray<float, 8>::load OK
+DEAL:float <-> VectorizedArray<float, 8>::store OK
+DEAL:float <-> VectorizedArray<double, 4>::load OK
+DEAL:float <-> VectorizedArray<double, 4>::store OK
+DEAL:double <-> VectorizedArray<double, 8>::load OK
+DEAL:double <-> VectorizedArray<double, 8>::store OK
+DEAL:float <-> VectorizedArray<float, 16>::load OK
+DEAL:float <-> VectorizedArray<float, 16>::store OK
+DEAL:float <-> VectorizedArray<double, 8>::load OK
+DEAL:float <-> VectorizedArray<double, 8>::store OK
+DEAL:long double::load OK
+DEAL:long double::store OK
+DEAL:unsigned int::load OK
+DEAL:unsigned int::store OK
--- /dev/null
+
+DEAL:double <-> VectorizedArray<double, 1>::load OK
+DEAL:double <-> VectorizedArray<double, 1>::store OK
+DEAL:float <-> VectorizedArray<float, 1>::load OK
+DEAL:float <-> VectorizedArray<float, 1>::store OK
+DEAL:float <-> VectorizedArray<double, 1>::load OK
+DEAL:float <-> VectorizedArray<double, 1>::store OK
+DEAL:double <-> VectorizedArray<double, 2>::load OK
+DEAL:double <-> VectorizedArray<double, 2>::store OK
+DEAL:float <-> VectorizedArray<float, 4>::load OK
+DEAL:float <-> VectorizedArray<float, 4>::store OK
+DEAL:float <-> VectorizedArray<double, 2>::load OK
+DEAL:float <-> VectorizedArray<double, 2>::store OK
+DEAL:long double::load OK
+DEAL:long double::store OK
+DEAL:unsigned int::load OK
+DEAL:unsigned int::store OK