diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-07-15 10:57:55 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-07-15 10:57:55 +0200 |
commit | f5aa64086228ca9ccfa27e6086667fd0bdbad22c (patch) | |
tree | 3b71b5f0d326ea3a01713dcacfc0f4d8cd41013f | |
parent | 7cecd39a849afec76305b76f5a121c10c2eafe09 (diff) |
Clean some previous changes and more cuda fixes
-rw-r--r-- | Eigen/src/Core/DenseBase.h | 8 | ||||
-rw-r--r-- | Eigen/src/Core/GlobalFunctions.h | 3 | ||||
-rw-r--r-- | Eigen/src/Core/MathFunctions.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/VectorwiseOp.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/Visitor.h | 12 | ||||
-rw-r--r-- | Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h | 2 | ||||
-rw-r--r-- | test/cuda_basic.cu | 9 |
8 files changed, 20 insertions, 22 deletions
diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index d486f3fd5..58f682dce 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -491,10 +491,10 @@ template<typename Derived> class DenseBase typedef VectorwiseOp<Derived, Vertical> ColwiseReturnType; typedef const VectorwiseOp<const Derived, Vertical> ConstColwiseReturnType; - ConstRowwiseReturnType rowwise() const; - RowwiseReturnType rowwise(); - ConstColwiseReturnType colwise() const; - ColwiseReturnType colwise(); + EIGEN_DEVICE_FUNC ConstRowwiseReturnType rowwise() const; + EIGEN_DEVICE_FUNC RowwiseReturnType rowwise(); + EIGEN_DEVICE_FUNC ConstColwiseReturnType colwise() const; + EIGEN_DEVICE_FUNC ColwiseReturnType colwise(); typedef CwiseNullaryOp<internal::scalar_random_op<Scalar>,PlainObject> RandomReturnType; static const RandomReturnType Random(Index rows, Index cols); diff --git a/Eigen/src/Core/GlobalFunctions.h b/Eigen/src/Core/GlobalFunctions.h index 1f5caab4f..15d92b862 100644 --- a/Eigen/src/Core/GlobalFunctions.h +++ b/Eigen/src/Core/GlobalFunctions.h @@ -34,7 +34,6 @@ } \ }; - namespace Eigen { EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(real,scalar_real_op) @@ -62,11 +61,9 @@ namespace Eigen EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(round,scalar_round_op) EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(floor,scalar_floor_op) EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(ceil,scalar_ceil_op) -#ifndef __CUDACC__ EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isnan,scalar_isnan_op) EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isinf,scalar_isinf_op) EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isfinite,scalar_isfinite_op) -#endif template<typename Derived> inline const Eigen::CwiseUnaryOp<Eigen::internal::scalar_pow_op<typename Derived::Scalar>, const Derived> diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index fd6519855..fb2e2a5f1 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -794,7 +794,6 @@ bool (isfinite)(const T& x) #endif } -#ifndef __CUDACC__ template<typename T> bool (isfinite)(const std::complex<T>& x) { @@ -812,7 +811,6 @@ bool (isinf)(const std::complex<T>& x) { return (numext::isinf(numext::real(x)) || numext::isinf(numext::imag(x))) && (!numext::isnan(x)); } -#endif template<typename T> EIGEN_DEVICE_FUNC diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 8549cf83c..7c66572d1 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -312,7 +312,7 @@ template<typename Derived> class MatrixBase template<bool Enable> inline const Derived& forceAlignedAccessIf() const { return derived(); } template<bool Enable> inline Derived& forceAlignedAccessIf() { return derived(); } - Scalar trace() const; + EIGEN_DEVICE_FUNC Scalar trace() const; template<int p> EIGEN_DEVICE_FUNC RealScalar lpNorm() const; diff --git a/Eigen/src/Core/VectorwiseOp.h b/Eigen/src/Core/VectorwiseOp.h index 273361bce..5ebcdc100 100644 --- a/Eigen/src/Core/VectorwiseOp.h +++ b/Eigen/src/Core/VectorwiseOp.h @@ -644,7 +644,6 @@ template<typename ExpressionType, int Direction> class VectorwiseOp * \sa rowwise(), class VectorwiseOp, \ref TutorialReductionsVisitorsBroadcasting */ template<typename Derived> -EIGEN_DEVICE_FUNC inline const typename DenseBase<Derived>::ConstColwiseReturnType DenseBase<Derived>::colwise() const { @@ -656,7 +655,6 @@ DenseBase<Derived>::colwise() const * \sa rowwise(), class VectorwiseOp, \ref TutorialReductionsVisitorsBroadcasting */ template<typename Derived> -EIGEN_DEVICE_FUNC inline typename DenseBase<Derived>::ColwiseReturnType DenseBase<Derived>::colwise() { @@ -671,7 +669,6 @@ DenseBase<Derived>::colwise() * \sa colwise(), class VectorwiseOp, \ref TutorialReductionsVisitorsBroadcasting */ template<typename Derived> -EIGEN_DEVICE_FUNC inline const typename DenseBase<Derived>::ConstRowwiseReturnType DenseBase<Derived>::rowwise() const { @@ -683,7 +680,6 @@ DenseBase<Derived>::rowwise() const * \sa colwise(), class VectorwiseOp, \ref TutorialReductionsVisitorsBroadcasting */ template<typename Derived> -EIGEN_DEVICE_FUNC inline typename DenseBase<Derived>::RowwiseReturnType DenseBase<Derived>::rowwise() { diff --git a/Eigen/src/Core/Visitor.h b/Eigen/src/Core/Visitor.h index 06c8bbf11..374972d3e 100644 --- a/Eigen/src/Core/Visitor.h +++ b/Eigen/src/Core/Visitor.h @@ -22,6 +22,7 @@ struct visitor_impl row = (UnrollCount-1) % Derived::RowsAtCompileTime }; + EIGEN_DEVICE_FUNC static inline void run(const Derived &mat, Visitor& visitor) { visitor_impl<Visitor, Derived, UnrollCount-1>::run(mat, visitor); @@ -32,6 +33,7 @@ struct visitor_impl template<typename Visitor, typename Derived> struct visitor_impl<Visitor, Derived, 1> { + EIGEN_DEVICE_FUNC static inline void run(const Derived &mat, Visitor& visitor) { return visitor.init(mat.coeff(0, 0), 0, 0); @@ -41,6 +43,7 @@ struct visitor_impl<Visitor, Derived, 1> template<typename Visitor, typename Derived> struct visitor_impl<Visitor, Derived, Dynamic> { + EIGEN_DEVICE_FUNC static inline void run(const Derived& mat, Visitor& visitor) { visitor.init(mat.coeff(0,0), 0, 0); @@ -57,6 +60,7 @@ template<typename XprType> class visitor_evaluator { public: + EIGEN_DEVICE_FUNC explicit visitor_evaluator(const XprType &xpr) : m_evaluator(xpr), m_xpr(xpr) {} typedef typename XprType::Scalar Scalar; @@ -67,11 +71,11 @@ public: CoeffReadCost = internal::evaluator<XprType>::CoeffReadCost }; - Index rows() const { return m_xpr.rows(); } - Index cols() const { return m_xpr.cols(); } - Index size() const { return m_xpr.size(); } + EIGEN_DEVICE_FUNC Index rows() const { return m_xpr.rows(); } + EIGEN_DEVICE_FUNC Index cols() const { return m_xpr.cols(); } + EIGEN_DEVICE_FUNC Index size() const { return m_xpr.size(); } - CoeffReturnType coeff(Index row, Index col) const + EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index row, Index col) const { return m_evaluator.coeff(row, col); } protected: diff --git a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h index 872866850..db6eba10d 100644 --- a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +++ b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h @@ -654,7 +654,7 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3 Index k(0), l(2); if(d0 > d1) { - std::swap(k,l); + numext::swap(k,l); d0 = d1; } diff --git a/test/cuda_basic.cu b/test/cuda_basic.cu index 300bced02..6ec9446c6 100644 --- a/test/cuda_basic.cu +++ b/test/cuda_basic.cu @@ -53,14 +53,17 @@ struct redux { void operator()(int i, const typename T::Scalar* in, typename T::Scalar* out) const { using namespace Eigen; - int N = 6; + int N = 10; T x1(in+i); out[i*N+0] = x1.minCoeff(); out[i*N+1] = x1.maxCoeff(); out[i*N+2] = x1.sum(); out[i*N+3] = x1.prod(); -// out[i*N+4] = x1.colwise().sum().maxCoeff(); -// out[i*N+5] = x1.rowwise().maxCoeff().sum(); + out[i*N+4] = x1.matrix().squaredNorm(); + out[i*N+5] = x1.matrix().norm(); + out[i*N+6] = x1.colwise().sum().maxCoeff(); + out[i*N+7] = x1.rowwise().maxCoeff().sum(); + out[i*N+8] = x1.matrix().colwise().squaredNorm().sum(); } }; |