* Give Konstantinos a copyright line

* Fix compilation of Inverse.h with vectorisation
* Introduce EIGEN_GNUC_AT_LEAST(x,y) macro doing future-proof (e.g. gcc v5.0) check
* Only use ProductWIP if vectorisation is enabled
* rename EIGEN_ALWAYS_INLINE -> EIGEN_INLINE with fall-back to inline keyword
* some cleanup/indentation
This commit is contained in:
Benoit Jacob 2008-05-12 08:12:40 +00:00
parent 4f6d7abc87
commit 3562b01105
7 changed files with 34 additions and 31 deletions

View File

@ -3,26 +3,31 @@
#define EIGEN_WIP_PRODUCT #define EIGEN_WIP_PRODUCT
#ifdef __GNUC__
#define EIGEN_GNUC_AT_LEAST(x,y) (__GNUC__>=x && __GNUC_MINOR__>=y) || __GNUC__>x
#else
#define EIGEN_GNUC_AT_LEAST(x,y) false
#endif
#ifndef EIGEN_DONT_VECTORIZE #ifndef EIGEN_DONT_VECTORIZE
#if ((defined __SSE2__) && ( (!defined __GNUC__) || (__GNUC__>=4 && __GNUC_MINOR__>=2))) #if (defined __SSE2__) && ( (!defined __GNUC__) || EIGEN_GNUC_AT_LEAST(4,2) )
#define EIGEN_VECTORIZE #define EIGEN_VECTORIZE
#define EIGEN_VECTORIZE_SSE #define EIGEN_VECTORIZE_SSE
#include <emmintrin.h> #include <emmintrin.h>
#include <xmmintrin.h> #include <xmmintrin.h>
#ifdef __SSE3__ #ifdef __SSE3__
#include <pmmintrin.h> #include <pmmintrin.h>
#endif #endif
//#ifdef __SSSE3__ //#ifdef __SSSE3__
//#include <tmmintrin.h> //#include <tmmintrin.h>
//#endif //#endif
#endif #elif (defined __ALTIVEC__)
#ifdef __ALTIVEC__ // There are zero chances of both __SSE2__ AND __ALTIVEC__ been defined #define EIGEN_VECTORIZE
#define EIGEN_VECTORIZE #define EIGEN_VECTORIZE_ALTIVEC
#define EIGEN_VECTORIZE_ALTIVEC #include <altivec.h>
#include <altivec.h> // We _need_ to #undef bool as it's defined in <altivec.h> for some reason.
// We _need_ to #undef bool as it's defined in <altivec.h> for some reason. #undef bool
#undef bool #endif
#endif
#endif #endif
#include <cstdlib> #include <cstdlib>
@ -63,7 +68,7 @@ namespace Eigen {
#include "src/Core/CwiseBinaryOp.h" #include "src/Core/CwiseBinaryOp.h"
#include "src/Core/CwiseUnaryOp.h" #include "src/Core/CwiseUnaryOp.h"
#include "src/Core/CwiseNullaryOp.h" #include "src/Core/CwiseNullaryOp.h"
#ifdef EIGEN_WIP_PRODUCT #if (defined EIGEN_WIP_PRODUCT) && (defined EIGEN_VECTORIZE)
#include "src/Core/ProductWIP.h" #include "src/Core/ProductWIP.h"
#else #else
#include "src/Core/Product.h" #include "src/Core/Product.h"

View File

@ -184,7 +184,6 @@ struct ei_assignment_impl<Derived, OtherDerived, true, false>
static void execute(Derived & dst, const OtherDerived & src) static void execute(Derived & dst, const OtherDerived & src)
{ {
const bool unroll = Derived::SizeAtCompileTime * OtherDerived::CoeffReadCost <= EIGEN_UNROLLING_LIMIT; const bool unroll = Derived::SizeAtCompileTime * OtherDerived::CoeffReadCost <= EIGEN_UNROLLING_LIMIT;
ei_assert(dst.rows() == src.rows() && dst.cols() == src.cols());
if(unroll) if(unroll)
{ {
// std::cout << "vectorized unrolled\n"; // std::cout << "vectorized unrolled\n";

View File

@ -45,8 +45,8 @@ inline int ei_exp(int) { ei_assert(false); return 0; }
inline int ei_log(int) { ei_assert(false); return 0; } inline int ei_log(int) { ei_assert(false); return 0; }
inline int ei_sin(int) { ei_assert(false); return 0; } inline int ei_sin(int) { ei_assert(false); return 0; }
inline int ei_cos(int) { ei_assert(false); return 0; } inline int ei_cos(int) { ei_assert(false); return 0; }
// FIXME naive GCC version test, e.g. 5.0 would not pass
#if (defined __ICC) || (defined __GNUC__ && (__GNUC__<4 || __GNUC_MINOR__<3)) #if EIGEN_GNUC_AT_LEAST(4,3)
inline int ei_pow(int x, int y) { return int(std::pow(double(x), y)); } inline int ei_pow(int x, int y) { return int(std::pow(double(x), y)); }
#else #else
inline int ei_pow(int x, int y) { return std::pow(x, y); } inline int ei_pow(int x, int y) { return std::pow(x, y); }

View File

@ -409,7 +409,7 @@ template<typename Derived> class MatrixBase
template<typename NewType> template<typename NewType>
const CwiseUnaryOp<ei_scalar_cast_op<typename ei_traits<Derived>::Scalar, NewType>, Derived> cast() const; const CwiseUnaryOp<ei_scalar_cast_op<typename ei_traits<Derived>::Scalar, NewType>, Derived> cast() const;
const typename ei_eval<Derived>::type eval() const EIGEN_ALWAYS_INLINE EIGEN_INLINE const typename ei_eval<Derived>::type eval() const
{ {
return typename ei_eval<Derived>::type(derived()); return typename ei_eval<Derived>::type(derived());
} }

View File

@ -1,6 +1,7 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. Eigen itself is part of the KDE project.
// //
// Copyright (C) 2008 Konstantinos Margaritis <markos@codex.gr>
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr> // Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
@ -29,10 +30,7 @@
#error include PacketMath_Altivec without EIGEN_VECTORIZE_ALTIVEC #error include PacketMath_Altivec without EIGEN_VECTORIZE_ALTIVEC
#endif #endif
#ifdef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
#undef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 4 #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 4
#endif
static const vector int v0i = vec_splat_u32(0); static const vector int v0i = vec_splat_u32(0);
static const vector int v16i_ = vec_splat_u32(-16); static const vector int v16i_ = vec_splat_u32(-16);

View File

@ -85,10 +85,10 @@ using Eigen::MatrixBase;
// gcc 3.4.x reports the following compilation error: // gcc 3.4.x reports the following compilation error:
// Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval<Derived> Eigen::MatrixBase<Scalar, Derived>::eval() const' // Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval<Derived> Eigen::MatrixBase<Scalar, Derived>::eval() const'
// : function body not available // : function body not available
#if (defined __GNUC__) && (__GNUC__!=3) #if EIGEN_GNUC_AT_LEAST(4,0)
#define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) #define EIGEN_INLINE __attribute__((always_inline))
#else #else
#define EIGEN_ALWAYS_INLINE #define EIGEN_INLINE inline
#endif #endif
#if (defined __GNUC__) #if (defined __GNUC__)

View File

@ -84,9 +84,10 @@ template<typename MatrixType, bool CheckExistence> class Inverse : ei_no_assignm
return m_inverse.coeff(row, col); return m_inverse.coeff(row, col);
} }
template<int LoadMode>
PacketScalar _packetCoeff(int row, int col) const PacketScalar _packetCoeff(int row, int col) const
{ {
return m_inverse.packetCoeff(row, col); return m_inverse.template packetCoeff<LoadMode>(row, col);
} }
enum { _Size = MatrixType::RowsAtCompileTime }; enum { _Size = MatrixType::RowsAtCompileTime };