* A base class for the various VectorizedArray template specializations,
* containing common functionalities.
*
- * @tparam T Type of the actual vectorized array. We are using the
- * Couriously Recurring Template Pattern (see
+ * @tparam VectorizedArrayType Type of the actual vectorized array this
+ * class is operating on. We are using the
+ * Curiously Recurring Template Pattern (see
* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern) in this
- * class to avoid having to resort to `virtual` member functions.
+ * class to avoid having to resort to `virtual` member functions. In
+ * other words, `VectorizedArrayType` is a class derived from the
+ * current class.
*/
-template <typename T, std::size_t width>
+template <typename VectorizedArrayType, std::size_t width>
class VectorizedArrayBase
{
public:
/**
* @return An iterator pointing to the beginning of the underlying data.
*/
- constexpr VectorizedArrayIterator<T>
+ constexpr VectorizedArrayIterator<VectorizedArrayType>
begin()
{
- return VectorizedArrayIterator<T>(static_cast<T &>(*this), 0);
+ return VectorizedArrayIterator<VectorizedArrayType>(
+ static_cast<VectorizedArrayType &>(*this), 0);
}
/**
* @return An iterator pointing to the beginning of the underlying data (`const`
* version).
*/
- constexpr VectorizedArrayIterator<const T>
+ constexpr VectorizedArrayIterator<const VectorizedArrayType>
begin() const
{
- return VectorizedArrayIterator<const T>(static_cast<const T &>(*this), 0);
+ return VectorizedArrayIterator<const VectorizedArrayType>(
+ static_cast<const VectorizedArrayType &>(*this), 0);
}
/**
* @return An iterator pointing to the end of the underlying data.
*/
- constexpr VectorizedArrayIterator<T>
+ constexpr VectorizedArrayIterator<VectorizedArrayType>
end()
{
- return VectorizedArrayIterator<T>(static_cast<T &>(*this), width);
+ return VectorizedArrayIterator<VectorizedArrayType>(
+ static_cast<VectorizedArrayType &>(*this), width);
}
/**
* @return An iterator pointing to the end of the underlying data (`const`
* version).
*/
- constexpr VectorizedArrayIterator<const T>
+ constexpr VectorizedArrayIterator<const VectorizedArrayType>
end() const
{
- return VectorizedArrayIterator<const T>(static_cast<const T &>(*this),
- width);
+ return VectorizedArrayIterator<const VectorizedArrayType>(
+ static_cast<const VectorizedArrayType &>(*this), width);
}
};
* operations. For floats and doubles, an array of numbers are packed together
* with the goal to be processed in a single-instruction/multiple-data (SIMD)
* fashion. In the SIMD context, the elements of such a short vector are often
- * called lanes. The number of elements packed together, i.e., the number of
+ * called "lanes". The number of elements packed together, i.e., the number of
* lanes, depends on the computer system and compiler flags that are used for
* compilation of deal.II. The fundamental idea of these packed data types is
* to use one single CPU instruction to perform arithmetic operations on the
* whole array using the processor's vector (SIMD) units. Most computer
* systems by 2010 standards will use an array of two doubles or four floats,
* respectively (this corresponds to the SSE/SSE2 data sets) when compiling
- * deal.II on 64-bit operating systems. On Intel Sandy Bridge processors and
- * newer or AMD Bulldozer processors and newer, four doubles or eight floats
- * are used when deal.II is configured using gcc with \--with-cpu=native
- * or \--with-cpu=corei7-avx. On compilations with AVX-512 support (e.g.,
- * Intel Skylake Server from 2017), eight doubles or sixteen floats are used.
+ * deal.II on 64-bit operating systems. On later processors (such as Intel Sandy
+ * Bridge and newer, or AMD Bulldozer processors and newer), four
+ * doubles or eight floats are used when deal.II is configured using gcc with
+ * `--with-cpu=native` or `--with-cpu=corei7-avx`. On compilations with
+ * AVX-512 support (e.g., Intel Skylake Server from 2017), eight doubles
+ * or sixteen floats are used.
*
- * This behavior of this class is made similar to the basic data types double
+ * The behavior of this class is made similar to the basic data types double
* and float. The definition of a vectorized array does not initialize the
* data field but rather leaves it undefined, as is the case for double and
* float. However, when calling something like `VectorizedArray<double> a =
* - VectorizedArray<double, 1>
* - VectorizedArray<double, 2>
*
- * for older x86 processors or in case no processor-specific compilation flags
+ * For older x86 processors or in case no processor-specific compilation flags
* were added (i.e., without `-D CMAKE_CXX_FLAGS=-march=native` or similar
* flags):
* - VectorizedArray<double, 1> // no vectorization (auto-optimization)
* Similar considerations also apply to the data type `float`.
*
* Wrongly selecting the width, e.g., width=3 or width=8 on a processor which
- * does not support AVX-512 leads to a static assert.
+ * does not support AVX-512 leads to a failing `static_assert`, i.e., you cannot
+ * compile code using a VectorizedArray class with a number of lanes that
+ * is not supported by the platform you are on. In particular, all platforms
+ * we are aware of only ever support widths that are powers of two.
*
- * @tparam Number underlying data type
- * @tparam width vector length (optional; if not set, the maximal width of the
- * architecture is used)
+ * @tparam Number The underlying scalar data type.
+ * @tparam width Vector length. (Optional; if not set, the maximal width of the
+ * architecture is used.)
*/
template <typename Number, std::size_t width>
class VectorizedArray
{
public:
/**
- * This gives the type of the array elements.
+ * The scalar type of the array elements.
*/
using value_type = Number;
}
/**
- * Addition
+ * Element-wise addition of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Subtraction
+ * Element-wise subtraction of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Multiplication
+ * Element-wise multiplication of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Division
+ * Element-wise division of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Addition.
+ * Element-wise addition of two arrays of numbers.
*/
VectorizedArray &
operator+=(const VectorizedArray &vec)
}
/**
- * Subtraction.
+ * Element-wise subtraction of two arrays of numbers.
*/
VectorizedArray &
operator-=(const VectorizedArray &vec)
}
/**
- * Multiplication.
+ * Element-wise multiplication of two arrays of numbers.
*/
VectorizedArray &
operator*=(const VectorizedArray &vec)
}
/**
- * Division.
+ * Element-wise division of two arrays of numbers.
*/
VectorizedArray &
operator/=(const VectorizedArray &vec)
}
/**
- * Addition.
+ * Element-wise addition of two arrays of numbers.
*/
VectorizedArray &
operator+=(const VectorizedArray &vec)
}
/**
- * Subtraction.
+ * Element-wise subtraction of two arrays of numbers.
*/
VectorizedArray &
operator-=(const VectorizedArray &vec)
}
/**
- * Multiplication.
+ * Element-wise multiplication of two arrays of numbers.
*/
VectorizedArray &
operator*=(const VectorizedArray &vec)
}
/**
- * Division.
+ * Element-wise division of two arrays of numbers.
*/
VectorizedArray &
operator/=(const VectorizedArray &vec)
}
/**
- * Addition.
+ * Element-wise addition of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Subtraction.
+ * Element-wise subtraction of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Multiplication.
+ * Element-wise multiplication of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Division.
+ * Element-wise division of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Addition.
+ * Element-wise addition of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Subtraction.
+ * Element-wise subtraction of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Multiplication.
+ * Element-wise multiplication of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Division.
+ * Element-wise division of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Addition.
+ * Element-wise addition of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Subtraction.
+ * Element-wise subtraction of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
return *this;
}
/**
- * Multiplication.
+ * Element-wise multiplication of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Division.
+ * Element-wise division of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Addition.
+ * Element-wise addition of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Subtraction.
+ * Element-wise subtraction of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
return *this;
}
/**
- * Multiplication.
+ * Element-wise multiplication of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Division.
+ * Element-wise division of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Addition.
+ * Element-wise addition of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Subtraction.
+ * Element-wise subtraction of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
return *this;
}
/**
- * Multiplication.
+ * Element-wise multiplication of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Division.
+ * Element-wise division of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Addition.
+ * Element-wise addition of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Subtraction.
+ * Element-wise subtraction of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
return *this;
}
/**
- * Multiplication.
+ * Element-wise multiplication of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Division.
+ * Element-wise division of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Addition.
+ * Element-wise addition of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Subtraction.
+ * Element-wise subtraction of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Multiplication.
+ * Element-wise multiplication of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Division.
+ * Element-wise division of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Addition.
+ * Element-wise addition of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Subtraction.
+ * Element-wise subtraction of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Multiplication.
+ * Element-wise multiplication of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &
}
/**
- * Division.
+ * Element-wise division of two arrays of numbers.
*/
DEAL_II_ALWAYS_INLINE
VectorizedArray &