Skip to content

Commit

Permalink
Merge pull request #16840 from tamiko/vectorization_type_trait
Browse files Browse the repository at this point in the history
Vectorization type trait
  • Loading branch information
bangerth committed Apr 6, 2024
2 parents d3ed7f5 + ed71f69 commit 79b1eb9
Showing 1 changed file with 76 additions and 3 deletions.
79 changes: 76 additions & 3 deletions include/deal.II/base/vectorization.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,15 @@ class VectorizedArray
*/
using value_type = Number;

static_assert(width == 1,
"You specified an illegal width that is not supported.");
/**
* A constexpr boolean indicating whether the VectorizedArray with the
* given choice of template parameters @p Number and @p width is indeed
* implemented. The generic implementation is only implemented for
* @p width equal to one. For specializations of this class (which are
* defined depending on the instruction sets available) the boolean is
* set to true as well.
*/
static constexpr bool is_implemented = (width == 1);

/**
* Default empty constructor, leaving the data in an uninitialized state
Expand All @@ -469,6 +476,9 @@ class VectorizedArray
*/
VectorizedArray(const Number scalar)
{
static_assert(width == 1,
"You specified an illegal width that is not supported.");

this->operator=(scalar);
}

Expand All @@ -478,7 +488,10 @@ class VectorizedArray
template <typename U>
VectorizedArray(const std::initializer_list<U> &list)
: VectorizedArrayBase<VectorizedArray<Number, width>, 1>(list)
{}
{
static_assert(width == 1,
"You specified an illegal width that is not supported.");
}

/**
* This function assigns a scalar to the current object.
Expand Down Expand Up @@ -1011,6 +1024,12 @@ class VectorizedArray<double, 2>
*/
using value_type = double;

/**
* Record the fact that the given specialization of VectorizedArray is
* indeed implemented.
*/
static constexpr bool is_implemented = true;

/**
* Default empty constructor, leaving the data in an uninitialized state
* similar to float/double.
Expand Down Expand Up @@ -1297,6 +1316,12 @@ class VectorizedArray<float, 4>
*/
using value_type = float;

/**
* Record the fact that the given specialization of VectorizedArray is
* indeed implemented.
*/
static constexpr bool is_implemented = true;

/**
* Default empty constructor, leaving the data in an uninitialized state
* similar to float/double.
Expand Down Expand Up @@ -1570,6 +1595,12 @@ class VectorizedArray<double, 2>
*/
using value_type = double;

/**
* Record the fact that the given specialization of VectorizedArray is
* indeed implemented.
*/
static constexpr bool is_implemented = true;

/**
* Default empty constructor, leaving the data in an uninitialized state
* similar to float/double.
Expand Down Expand Up @@ -2055,6 +2086,12 @@ class VectorizedArray<float, 4>
*/
using value_type = float;

/**
* Record the fact that the given specialization of VectorizedArray is
* indeed implemented.
*/
static constexpr bool is_implemented = true;

/**
* Default empty constructor, leaving the data in an uninitialized state
* similar to float/double.
Expand Down Expand Up @@ -2563,6 +2600,12 @@ class VectorizedArray<double, 4>
*/
using value_type = double;

/**
* Record the fact that the given specialization of VectorizedArray is
* indeed implemented.
*/
static constexpr bool is_implemented = true;

/**
* Default empty constructor, leaving the data in an uninitialized state
* similar to float/double.
Expand Down Expand Up @@ -3141,6 +3184,12 @@ class VectorizedArray<float, 8>
*/
using value_type = float;

/**
* Record the fact that the given specialization of VectorizedArray is
* indeed implemented.
*/
static constexpr bool is_implemented = true;

/**
* Default empty constructor, leaving the data in an uninitialized state
* similar to float/double.
Expand Down Expand Up @@ -3742,6 +3791,12 @@ class VectorizedArray<double, 8>
*/
using value_type = double;

/**
* Record the fact that the given specialization of VectorizedArray is
* indeed implemented.
*/
static constexpr bool is_implemented = true;

/**
* Default empty constructor, leaving the data in an uninitialized state
* similar to float/double.
Expand Down Expand Up @@ -4372,6 +4427,12 @@ class VectorizedArray<float, 16>
*/
using value_type = float;

/**
* Record the fact that the given specialization of VectorizedArray is
* indeed implemented.
*/
static constexpr bool is_implemented = true;

/**
* Default empty constructor, leaving the data in an uninitialized state
* similar to float/double.
Expand Down Expand Up @@ -5081,6 +5142,12 @@ class VectorizedArray<double, 2>
*/
using value_type = double;

/**
* Record the fact that the given specialization of VectorizedArray is
* indeed implemented.
*/
static constexpr bool is_implemented = true;

/**
* Default empty constructor, leaving the data in an uninitialized state
* similar to float/double.
Expand Down Expand Up @@ -5336,6 +5403,12 @@ class VectorizedArray<float, 4>
*/
using value_type = float;

/**
* Record the fact that the given specialization of VectorizedArray is
* indeed implemented.
*/
static constexpr bool is_implemented = true;

/**
* Default empty constructor, leaving the data in an uninitialized state
* similar to float/double.
Expand Down

0 comments on commit 79b1eb9

Please sign in to comment.