From 3562b011055aca8677c94511a5ce97d6011bede5 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Mon, 12 May 2008 08:12:40 +0000 Subject: [PATCH] * 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 --- Eigen/Core | 45 ++++++++++++++++------------- Eigen/src/Core/Assign.h | 1 - Eigen/src/Core/MathFunctions.h | 4 +-- Eigen/src/Core/MatrixBase.h | 2 +- Eigen/src/Core/PacketMath_Altivec.h | 4 +-- Eigen/src/Core/util/Macros.h | 6 ++-- Eigen/src/LU/Inverse.h | 3 +- 7 files changed, 34 insertions(+), 31 deletions(-) diff --git a/Eigen/Core b/Eigen/Core index aec206aea..b2e973a8c 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -3,26 +3,31 @@ #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 -#if ((defined __SSE2__) && ( (!defined __GNUC__) || (__GNUC__>=4 && __GNUC_MINOR__>=2))) -#define EIGEN_VECTORIZE -#define EIGEN_VECTORIZE_SSE -#include -#include -#ifdef __SSE3__ -#include -#endif -//#ifdef __SSSE3__ -//#include -//#endif -#endif -#ifdef __ALTIVEC__ // There are zero chances of both __SSE2__ AND __ALTIVEC__ been defined -#define EIGEN_VECTORIZE -#define EIGEN_VECTORIZE_ALTIVEC -#include -// We _need_ to #undef bool as it's defined in for some reason. -#undef bool -#endif + #if (defined __SSE2__) && ( (!defined __GNUC__) || EIGEN_GNUC_AT_LEAST(4,2) ) + #define EIGEN_VECTORIZE + #define EIGEN_VECTORIZE_SSE + #include + #include + #ifdef __SSE3__ + #include + #endif + //#ifdef __SSSE3__ + //#include + //#endif + #elif (defined __ALTIVEC__) + #define EIGEN_VECTORIZE + #define EIGEN_VECTORIZE_ALTIVEC + #include + // We _need_ to #undef bool as it's defined in for some reason. + #undef bool + #endif #endif #include @@ -63,7 +68,7 @@ namespace Eigen { #include "src/Core/CwiseBinaryOp.h" #include "src/Core/CwiseUnaryOp.h" #include "src/Core/CwiseNullaryOp.h" -#ifdef EIGEN_WIP_PRODUCT +#if (defined EIGEN_WIP_PRODUCT) && (defined EIGEN_VECTORIZE) #include "src/Core/ProductWIP.h" #else #include "src/Core/Product.h" diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index 384059185..ad62b209b 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -184,7 +184,6 @@ struct ei_assignment_impl static void execute(Derived & dst, const OtherDerived & src) { const bool unroll = Derived::SizeAtCompileTime * OtherDerived::CoeffReadCost <= EIGEN_UNROLLING_LIMIT; - ei_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); if(unroll) { // std::cout << "vectorized unrolled\n"; diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 72cf916f8..64ae7f97b 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -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_sin(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)); } #else inline int ei_pow(int x, int y) { return std::pow(x, y); } diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 97e8cab28..1e46b10d2 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -409,7 +409,7 @@ template class MatrixBase template const CwiseUnaryOp::Scalar, NewType>, Derived> cast() const; - const typename ei_eval::type eval() const EIGEN_ALWAYS_INLINE + EIGEN_INLINE const typename ei_eval::type eval() const { return typename ei_eval::type(derived()); } diff --git a/Eigen/src/Core/PacketMath_Altivec.h b/Eigen/src/Core/PacketMath_Altivec.h index eb702af8c..4056c1ddb 100644 --- a/Eigen/src/Core/PacketMath_Altivec.h +++ b/Eigen/src/Core/PacketMath_Altivec.h @@ -1,6 +1,7 @@ // This file is part of Eigen, a lightweight C++ template library // for linear algebra. Eigen itself is part of the KDE project. // +// Copyright (C) 2008 Konstantinos Margaritis // Copyright (C) 2008 Gael Guennebaud // // Eigen is free software; you can redistribute it and/or @@ -29,10 +30,7 @@ #error include PacketMath_Altivec without EIGEN_VECTORIZE_ALTIVEC #endif -#ifdef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD -#undef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 4 -#endif static const vector int v0i = vec_splat_u32(0); static const vector int v16i_ = vec_splat_u32(-16); diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index f703d159a..4b8c5fedb 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -85,10 +85,10 @@ using Eigen::MatrixBase; // gcc 3.4.x reports the following compilation error: // Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval Eigen::MatrixBase::eval() const' // : function body not available -#if (defined __GNUC__) && (__GNUC__!=3) -#define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) +#if EIGEN_GNUC_AT_LEAST(4,0) +#define EIGEN_INLINE __attribute__((always_inline)) #else -#define EIGEN_ALWAYS_INLINE +#define EIGEN_INLINE inline #endif #if (defined __GNUC__) diff --git a/Eigen/src/LU/Inverse.h b/Eigen/src/LU/Inverse.h index 00ffa25c8..e2494dd08 100644 --- a/Eigen/src/LU/Inverse.h +++ b/Eigen/src/LU/Inverse.h @@ -84,9 +84,10 @@ template class Inverse : ei_no_assignm return m_inverse.coeff(row, col); } + template PacketScalar _packetCoeff(int row, int col) const { - return m_inverse.packetCoeff(row, col); + return m_inverse.template packetCoeff(row, col); } enum { _Size = MatrixType::RowsAtCompileTime };