Added initial experimental support for explicit vectorization.

Currently only the following platform/operations are supported:
 - SSE2 compatible architecture
 - compiler compatible with intel's SSE2 intrinsics
 - float, double and int data types
 - fixed size matrices with a storage major dimension multiple of 4 (or 2 for double)
 - scalar-matrix product, component wise: +,-,*,min,max
 - matrix-matrix product only if the left matrix is vectorizable and column major
   or the right matrix is vectorizable and row major, e.g.:
   a.transpose() * b is not vectorized with the default column major storage.
To use it you must define EIGEN_VECTORIZE and EIGEN_INTEL_PLATFORM.
This commit is contained in:
Gael Guennebaud
2008-04-09 12:31:55 +00:00
parent 4920f2011e
commit 1985fb0551
25 changed files with 436 additions and 93 deletions

View File

@@ -79,7 +79,10 @@ struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> >
ColsAtCompileTime = _Cols,
MaxRowsAtCompileTime = _MaxRows,
MaxColsAtCompileTime = _MaxCols,
Flags = _Flags,
Flags = (_Flags & ~VectorizableBit)
| (( (ei_packet_traits<Scalar>::size>1) && (_Rows!=Dynamic) && (_Cols!=Dynamic)
&& ((_Flags&RowMajorBit) && ((_Cols%ei_packet_traits<Scalar>::size)==0)
|| ((_Rows%ei_packet_traits<Scalar>::size)==0) ) ) ? VectorizableBit : 0),
CoeffReadCost = NumTraits<Scalar>::ReadCost
};
};
@@ -119,6 +122,23 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols,
return m_storage.data()[row + col * m_storage.rows()];
}
PacketScalar _packetCoeff(int row, int col) const
{
ei_internal_assert(Flags & VectorizableBit);
if(Flags & RowMajorBit)
return ei_pload(&m_storage.data()[col + row * m_storage.cols()]);
else
return ei_pload(&m_storage.data()[row + col * m_storage.rows()]);
}
void _writePacketCoeff(int row, int col, const PacketScalar& x)
{
ei_internal_assert(Flags & VectorizableBit);
if(Flags & RowMajorBit)
ei_pstore(&m_storage.data()[col + row * m_storage.cols()], x);
else
ei_pstore(&m_storage.data()[row + col * m_storage.rows()], x);
}
public:
/** \returns a const pointer to the data array of this matrix */
const Scalar *data() const