* Big change in Block and Map:

- added a MapBase base xpr on top of which Map and the specialization
    of Block are implemented
  - MapBase forces both aligned loads (and aligned stores, see below) in expressions
    such as "x.block(...) += other_expr"
* Significant vectorization improvement:
 - added a AlignedBit flag meaning the first coeff/packet is aligned,
   this allows to not generate extra code to deal with the first unaligned part
 - removed all unaligned stores when no unrolling
 - removed unaligned loads in Sum when the input as the DirectAccessBit flag
* Some code simplification in CacheFriendly product
* Some minor documentation improvements
This commit is contained in:
Gael Guennebaud
2008-08-09 18:41:24 +00:00
parent becbeda50a
commit 4fa40367e9
17 changed files with 397 additions and 296 deletions

View File

@@ -119,42 +119,47 @@ const unsigned int LinearAccessBit = 0x10;
*/
const unsigned int DirectAccessBit = 0x20;
/** \ingroup flags
*
* means the first coefficient packet is guaranteed to be aligned */
const unsigned int AlignedBit = 0x40;
/** \ingroup flags
*
* means all diagonal coefficients are equal to 0 */
const unsigned int ZeroDiagBit = 0x40;
const unsigned int ZeroDiagBit = 0x80;
/** \ingroup flags
*
* means all diagonal coefficients are equal to 1 */
const unsigned int UnitDiagBit = 0x80;
const unsigned int UnitDiagBit = 0x100;
/** \ingroup flags
*
* means the matrix is selfadjoint (M=M*). */
const unsigned int SelfAdjointBit = 0x100;
const unsigned int SelfAdjointBit = 0x200;
/** \ingroup flags
*
* means the strictly lower triangular part is 0 */
const unsigned int UpperTriangularBit = 0x200;
const unsigned int UpperTriangularBit = 0x400;
/** \ingroup flags
*
* means the strictly upper triangular part is 0 */
const unsigned int LowerTriangularBit = 0x400;
const unsigned int LowerTriangularBit = 0x800;
/** \ingroup flags
*
* means the expression includes sparse matrices and the sparse path has to be taken. */
const unsigned int SparseBit = 0x800;
const unsigned int SparseBit = 0x1000;
/** \ingroup flags
*
* currently unused. Means the matrix probably has a very big size.
* Could eventually be used as a hint to determine which algorithms
* to use. */
const unsigned int LargeBit = 0x1000;
const unsigned int LargeBit = 0x2000;
// list of flags that are inherited by default
const unsigned int HereditaryBits = RowMajorBit
@@ -175,15 +180,21 @@ const unsigned int UnitUpper = UpperTriangularBit | UnitDiagBit;
const unsigned int UnitLower = LowerTriangularBit | UnitDiagBit;
const unsigned int Diagonal = Upper | Lower;
enum { Aligned=0, Unaligned=1 };
enum { Aligned=0, Unaligned=1, Unknown=2 };
enum { ConditionalJumpCost = 5 };
enum CornerType { TopLeft, TopRight, BottomLeft, BottomRight };
enum DirectionType { Vertical, Horizontal };
enum ProductEvaluationMode { NormalProduct, CacheFriendlyProduct, DiagonalProduct, SparseProduct };
enum {
/** \internal Equivalent to a slice vectorization for fixed-size matrices having good alignement
* and good size */
InnerVectorization,
/** \internal Vectorization path using a single loop plus scalar loops for the
* unaligned boundaries */
LinearVectorization,
/** \internal Generic vectorization path using one vectorized loop per row/column with some
* scalar loops to handle the unaligned boundaries */
SliceVectorization,
NoVectorization
};

View File

@@ -43,8 +43,8 @@ template<typename ExpressionType, unsigned int Added, unsigned int Removed> clas
template<typename ExpressionType> class NestByValue;
template<typename ExpressionType> class SwapWrapper;
template<typename MatrixType> class Minor;
template<typename MatrixType, int BlockRows=Dynamic, int BlockCols=Dynamic,
int DirectAccessStatus = ei_traits<MatrixType>::Flags&DirectAccessBit> class Block;
template<typename MatrixType, int BlockRows=Dynamic, int BlockCols=Dynamic, int PacketAccess=Unaligned,
int _DirectAccessStatus = ei_traits<MatrixType>::Flags&DirectAccessBit> class Block;
template<typename MatrixType> class Transpose;
template<typename MatrixType> class Conjugate;
template<typename NullaryOp, typename MatrixType> class CwiseNullaryOp;
@@ -53,7 +53,7 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class CwiseBinaryOp;
template<typename Lhs, typename Rhs, int ProductMode> class Product;
template<typename CoeffsVectorType> class DiagonalMatrix;
template<typename MatrixType> class DiagonalCoeffs;
template<typename MatrixType, int Alignment = Unaligned> class Map;
template<typename MatrixType, int PacketAccess = Unaligned> class Map;
template<typename MatrixType, unsigned int Mode> class Part;
template<typename MatrixType, unsigned int Mode> class Extract;
template<typename ExpressionType> class Cwise;

View File

@@ -168,12 +168,14 @@ class ei_corrected_matrix_flags
packet_access_bit
= ei_packet_traits<Scalar>::size > 1
&& (is_big || linear_size%ei_packet_traits<Scalar>::size==0)
? PacketAccessBit : 0
? PacketAccessBit : 0,
aligned_bit = packet_access_bit
&& (is_big || linear_size%ei_packet_traits<Scalar>::size==0) ? AlignedBit : 0
};
public:
enum { ret = (SuggestedFlags & ~(EvalBeforeNestingBit | EvalBeforeAssigningBit | PacketAccessBit | RowMajorBit))
| LinearAccessBit | DirectAccessBit | packet_access_bit | row_major_bit
| LinearAccessBit | DirectAccessBit | packet_access_bit | row_major_bit | aligned_bit
};
};