Allow aligned assignment in TRMV.

This commit is contained in:
Antonio Sanchez 2024-03-06 09:14:58 -08:00 committed by Rasmus Munk Larsen
parent 3e8e63eb46
commit 6da34d9d9e

View File

@ -242,26 +242,18 @@ struct gemv_static_vector_if<Scalar, Size, Dynamic, true> {
template <typename Scalar, int Size, int MaxSize> template <typename Scalar, int Size, int MaxSize>
struct gemv_static_vector_if<Scalar, Size, MaxSize, true> { struct gemv_static_vector_if<Scalar, Size, MaxSize, true> {
enum {
ForceAlignment = internal::packet_traits<Scalar>::Vectorizable,
PacketSize = internal::packet_traits<Scalar>::size
};
#if EIGEN_MAX_STATIC_ALIGN_BYTES != 0 #if EIGEN_MAX_STATIC_ALIGN_BYTES != 0
internal::plain_array<Scalar, internal::min_size_prefer_fixed(Size, MaxSize), 0, internal::plain_array<Scalar, internal::min_size_prefer_fixed(Size, MaxSize), 0, AlignedMax>
internal::plain_enum_min(AlignedMax, PacketSize)>
m_data; m_data;
EIGEN_STRONG_INLINE Scalar* data() { return m_data.array; } EIGEN_STRONG_INLINE Scalar* data() { return m_data.array; }
#else #else
// Some architectures cannot align on the stack, // Some architectures cannot align on the stack,
// => let's manually enforce alignment by allocating more data and return the address of the first aligned element. // => let's manually enforce alignment by allocating more data and return the address of the first aligned element.
internal::plain_array< internal::plain_array<
Scalar, internal::min_size_prefer_fixed(Size, MaxSize) + (ForceAlignment ? EIGEN_MAX_ALIGN_BYTES : 0), 0> Scalar, internal::min_size_prefer_fixed(Size, MaxSize) + EIGEN_MAX_ALIGN_BYTES, 0>
m_data; m_data;
EIGEN_STRONG_INLINE Scalar* data() { EIGEN_STRONG_INLINE Scalar* data() {
return ForceAlignment return reinterpret_cast<Scalar*>((std::uintptr_t(m_data.array) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES - 1))) + EIGEN_MAX_ALIGN_BYTES);
? reinterpret_cast<Scalar*>((std::uintptr_t(m_data.array) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES - 1))) +
EIGEN_MAX_ALIGN_BYTES)
: m_data.array;
} }
#endif #endif
}; };