aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2007-10-01 06:23:05 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2007-10-01 06:23:05 +0000
commit656919619fe4ce39776571d280fc402edeef795a (patch)
tree17c247f8f15632754ee7eec1d35063b259f2f69c
parente116aba444d18a031d12389b1257dc1ffe752dd1 (diff)
- add copyright line for Michael Olbrich
- some meta unrolling improvements
-rw-r--r--src/internal/Object.h31
-rw-r--r--src/internal/Util.h2
2 files changed, 19 insertions, 14 deletions
diff --git a/src/internal/Object.h b/src/internal/Object.h
index dd92e2915..bbd6458de 100644
--- a/src/internal/Object.h
+++ b/src/internal/Object.h
@@ -2,6 +2,7 @@
// for linear algebra. Eigen itself is part of the KDE project.
//
// 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
// terms of the GNU General Public License as published by the Free Software
@@ -28,16 +29,16 @@
#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 row = (Size-1) % Rows;
+ static const int col = (UnrollCount-1) / Rows;
+ static const int row = (UnrollCount-1) % Rows;
public:
template <typename Derived1, typename Derived2>
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);
}
};
@@ -56,21 +57,23 @@ template<int Rows> class EiLoop<0, Rows>
template<typename Scalar, typename Derived> class EiObject
{
static const int RowsAtCompileTime = Derived::RowsAtCompileTime,
- ColsAtCompileTime = Derived::ColsAtCompileTime,
- SizeAtCompileTime = RowsAtCompileTime*ColsAtCompileTime > 0 ?
- RowsAtCompileTime*ColsAtCompileTime : 0;
+ ColsAtCompileTime = Derived::ColsAtCompileTime;
+ static const bool HasDynamicSize = RowsAtCompileTime != EiDynamic
+ && ColsAtCompileTime != EiDynamic;
+ static const int UnrollCount = HasDynamicSize ?
+ RowsAtCompileTime * ColsAtCompileTime : 0;
template<typename OtherDerived>
void _copy_helper(const EiObject<Scalar, OtherDerived>& other)
{
- if ((RowsAtCompileTime != EiDynamic) &&
- (ColsAtCompileTime != EiDynamic) &&
- (SizeAtCompileTime <= 25))
- EiLoop<SizeAtCompileTime, RowsAtCompileTime>::copy(*this, other);
+ if(HasDynamicSize
+ && RowsAtCompileTime <= EI_LOOP_UNROLLING_LIMIT
+ && ColsAtCompileTime <= EI_LOOP_UNROLLING_LIMIT)
+ EiLoop<UnrollCount, RowsAtCompileTime>::copy(*this, other);
else
- for(int i = 0; i < rows(); i++)
- for(int j = 0; j < cols(); j++)
- write(i, j) = other.read(i, j);
+ for(int i = 0; i < rows(); i++)
+ for(int j = 0; j < cols(); j++)
+ write(i, j) = other.read(i, j);
}
public:
diff --git a/src/internal/Util.h b/src/internal/Util.h
index d00a309e4..60413a8af 100644
--- a/src/internal/Util.h
+++ b/src/internal/Util.h
@@ -69,6 +69,8 @@ struct EiForwardDecl<EiMatrix<_Scalar, _Rows, _Cols> >
const int EiDynamic = -1;
+#define EI_LOOP_UNROLLING_LIMIT 8
+
#define EI_UNUSED(x) (void)x
#ifdef __GNUC__