- add copyright line for Michael Olbrich

- some meta unrolling improvements
This commit is contained in:
Benoit Jacob 2007-10-01 06:23:05 +00:00
parent e116aba444
commit 656919619f
2 changed files with 19 additions and 14 deletions

View File

@ -2,6 +2,7 @@
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. Eigen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// Copyright (C) 2007 Michael Olbrich <michael.olbrich@gmx.net>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // Eigen is free software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the Free Software // terms of the GNU General Public License as published by the Free Software
@ -28,16 +29,16 @@
#include "Util.h" #include "Util.h"
template<int Size, int Rows> class EiLoop template<int UnrollCount, int Rows> class EiLoop
{ {
static const int col = (Size-1) / Rows; static const int col = (UnrollCount-1) / Rows;
static const int row = (Size-1) % Rows; static const int row = (UnrollCount-1) % Rows;
public: public:
template <typename Derived1, typename Derived2> template <typename Derived1, typename Derived2>
static void copy(Derived1 &dst, const Derived2 &src) static void copy(Derived1 &dst, const Derived2 &src)
{ {
EiLoop<Size-1, Rows>::copy(dst, src); EiLoop<UnrollCount-1, Rows>::copy(dst, src);
dst.write(row, col) = src.read(row, col); dst.write(row, col) = src.read(row, col);
} }
}; };
@ -56,17 +57,19 @@ template<int Rows> class EiLoop<0, Rows>
template<typename Scalar, typename Derived> class EiObject template<typename Scalar, typename Derived> class EiObject
{ {
static const int RowsAtCompileTime = Derived::RowsAtCompileTime, static const int RowsAtCompileTime = Derived::RowsAtCompileTime,
ColsAtCompileTime = Derived::ColsAtCompileTime, ColsAtCompileTime = Derived::ColsAtCompileTime;
SizeAtCompileTime = RowsAtCompileTime*ColsAtCompileTime > 0 ? static const bool HasDynamicSize = RowsAtCompileTime != EiDynamic
&& ColsAtCompileTime != EiDynamic;
static const int UnrollCount = HasDynamicSize ?
RowsAtCompileTime * ColsAtCompileTime : 0; RowsAtCompileTime * ColsAtCompileTime : 0;
template<typename OtherDerived> template<typename OtherDerived>
void _copy_helper(const EiObject<Scalar, OtherDerived>& other) void _copy_helper(const EiObject<Scalar, OtherDerived>& other)
{ {
if ((RowsAtCompileTime != EiDynamic) && if(HasDynamicSize
(ColsAtCompileTime != EiDynamic) && && RowsAtCompileTime <= EI_LOOP_UNROLLING_LIMIT
(SizeAtCompileTime <= 25)) && ColsAtCompileTime <= EI_LOOP_UNROLLING_LIMIT)
EiLoop<SizeAtCompileTime, RowsAtCompileTime>::copy(*this, other); EiLoop<UnrollCount, RowsAtCompileTime>::copy(*this, other);
else else
for(int i = 0; i < rows(); i++) for(int i = 0; i < rows(); i++)
for(int j = 0; j < cols(); j++) for(int j = 0; j < cols(); j++)

View File

@ -69,6 +69,8 @@ struct EiForwardDecl<EiMatrix<_Scalar, _Rows, _Cols> >
const int EiDynamic = -1; const int EiDynamic = -1;
#define EI_LOOP_UNROLLING_LIMIT 8
#define EI_UNUSED(x) (void)x #define EI_UNUSED(x) (void)x
#ifdef __GNUC__ #ifdef __GNUC__