diff options
author | Gael Guennebaud <g.gael@free.fr> | 2013-02-07 19:06:14 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2013-02-07 19:06:14 +0100 |
commit | 5adcc6c7b48b7a213af91bc123a02ab87751228e (patch) | |
tree | 5e0ee840a8fb9acbbb48c5c48f1bffe0ca3cfe2a /Eigen/src/Core/Block.h | |
parent | e4ec63aee7233f5b934abc0b1d9ceada79a844ee (diff) |
Add support for NVCC5: most of the Core and part of LU are callable from CUDA code.
Still a lot to do.
Diffstat (limited to 'Eigen/src/Core/Block.h')
-rw-r--r-- | Eigen/src/Core/Block.h | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 5f6426517..fbc2cf227 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -111,6 +111,7 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel> class /** Column or Row constructor */ + EIGEN_DEVICE_FUNC inline Block(XprType& xpr, Index i) : Impl(xpr,i) { eigen_assert( (i>=0) && ( @@ -120,6 +121,7 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel> class /** Fixed-size constructor */ + EIGEN_DEVICE_FUNC inline Block(XprType& xpr, Index a_startRow, Index a_startCol) : Impl(xpr, a_startRow, a_startCol) { @@ -130,6 +132,7 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel> class /** Dynamic-size constructor */ + EIGEN_DEVICE_FUNC inline Block(XprType& xpr, Index a_startRow, Index a_startCol, Index blockRows, Index blockCols) @@ -153,8 +156,9 @@ class BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, Dense> public: typedef Impl Base; EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl) - inline BlockImpl(XprType& xpr, Index i) : Impl(xpr,i) {} - inline BlockImpl(XprType& xpr, Index a_startRow, Index a_startCol) : Impl(xpr, a_startRow, a_startCol) {} + EIGEN_DEVICE_FUNC inline BlockImpl(XprType& xpr, Index i) : Impl(xpr,i) {} + EIGEN_DEVICE_FUNC inline BlockImpl(XprType& xpr, Index a_startRow, Index a_startCol) : Impl(xpr, a_startRow, a_startCol) {} + EIGEN_DEVICE_FUNC inline BlockImpl(XprType& xpr, Index a_startRow, Index a_startCol, Index blockRows, Index blockCols) : Impl(xpr, a_startRow, a_startCol, blockRows, blockCols) {} }; @@ -176,6 +180,7 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H /** Column or Row constructor */ + EIGEN_DEVICE_FUNC inline BlockImpl_dense(XprType& xpr, Index i) : m_xpr(xpr), // It is a row if and only if BlockRows==1 and BlockCols==XprType::ColsAtCompileTime, @@ -190,6 +195,7 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H /** Fixed-size constructor */ + EIGEN_DEVICE_FUNC inline BlockImpl_dense(XprType& xpr, Index a_startRow, Index a_startCol) : m_xpr(xpr), m_startRow(a_startRow), m_startCol(a_startCol), m_blockRows(BlockRows), m_blockCols(BlockCols) @@ -197,6 +203,7 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H /** Dynamic-size constructor */ + EIGEN_DEVICE_FUNC inline BlockImpl_dense(XprType& xpr, Index a_startRow, Index a_startCol, Index blockRows, Index blockCols) @@ -204,9 +211,10 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H m_blockRows(blockRows), m_blockCols(blockCols) {} - inline Index rows() const { return m_blockRows.value(); } - inline Index cols() const { return m_blockCols.value(); } + EIGEN_DEVICE_FUNC inline Index rows() const { return m_blockRows.value(); } + EIGEN_DEVICE_FUNC inline Index cols() const { return m_blockCols.value(); } + EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index rowId, Index colId) { EIGEN_STATIC_ASSERT_LVALUE(XprType) @@ -214,17 +222,20 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H .coeffRef(rowId + m_startRow.value(), colId + m_startCol.value()); } + EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index rowId, Index colId) const { return m_xpr.derived() .coeffRef(rowId + m_startRow.value(), colId + m_startCol.value()); } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index rowId, Index colId) const { return m_xpr.coeff(rowId + m_startRow.value(), colId + m_startCol.value()); } + EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index index) { EIGEN_STATIC_ASSERT_LVALUE(XprType) @@ -233,6 +244,7 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0)); } + EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index index) const { return m_xpr.const_cast_derived() @@ -240,6 +252,7 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0)); } + EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index index) const { return m_xpr @@ -279,21 +292,24 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H #ifdef EIGEN_PARSED_BY_DOXYGEN /** \sa MapBase::data() */ - inline const Scalar* data() const; - inline Index innerStride() const; - inline Index outerStride() const; + EIGEN_DEVICE_FUNC inline const Scalar* data() const; + EIGEN_DEVICE_FUNC inline Index innerStride() const; + EIGEN_DEVICE_FUNC inline Index outerStride() const; #endif - const typename internal::remove_all<typename XprType::Nested>::type& nestedExpression() const + EIGEN_DEVICE_FUNC + const typename internal::remove_all<typename XprType::Nested>::type& nestedExpression() const { return m_xpr; } - Index startRow() const + EIGEN_DEVICE_FUNC + Index startRow() const { return m_startRow.value(); } + EIGEN_DEVICE_FUNC Index startCol() const { return m_startCol.value(); @@ -322,6 +338,7 @@ class BlockImpl_dense<XprType,BlockRows,BlockCols, InnerPanel,true> /** Column or Row constructor */ + EIGEN_DEVICE_FUNC inline BlockImpl_dense(XprType& xpr, Index i) : Base(internal::const_cast_ptr(&xpr.coeffRef( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0, @@ -335,6 +352,7 @@ class BlockImpl_dense<XprType,BlockRows,BlockCols, InnerPanel,true> /** Fixed-size constructor */ + EIGEN_DEVICE_FUNC inline BlockImpl_dense(XprType& xpr, Index startRow, Index startCol) : Base(internal::const_cast_ptr(&xpr.coeffRef(startRow,startCol))), m_xpr(xpr) { @@ -343,6 +361,7 @@ class BlockImpl_dense<XprType,BlockRows,BlockCols, InnerPanel,true> /** Dynamic-size constructor */ + EIGEN_DEVICE_FUNC inline BlockImpl_dense(XprType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols) @@ -352,12 +371,14 @@ class BlockImpl_dense<XprType,BlockRows,BlockCols, InnerPanel,true> init(); } - const typename internal::remove_all<typename XprType::Nested>::type& nestedExpression() const + EIGEN_DEVICE_FUNC + const typename internal::remove_all<typename XprType::Nested>::type& nestedExpression() const { return m_xpr; } /** \sa MapBase::innerStride() */ + EIGEN_DEVICE_FUNC inline Index innerStride() const { return internal::traits<BlockType>::HasSameStorageOrderAsXprType @@ -366,6 +387,7 @@ class BlockImpl_dense<XprType,BlockRows,BlockCols, InnerPanel,true> } /** \sa MapBase::outerStride() */ + EIGEN_DEVICE_FUNC inline Index outerStride() const { return m_outerStride; @@ -379,6 +401,7 @@ class BlockImpl_dense<XprType,BlockRows,BlockCols, InnerPanel,true> #ifndef EIGEN_PARSED_BY_DOXYGEN /** \internal used by allowAligned() */ + EIGEN_DEVICE_FUNC inline BlockImpl_dense(XprType& xpr, const Scalar* data, Index blockRows, Index blockCols) : Base(data, blockRows, blockCols), m_xpr(xpr) { @@ -387,6 +410,7 @@ class BlockImpl_dense<XprType,BlockRows,BlockCols, InnerPanel,true> #endif protected: + EIGEN_DEVICE_FUNC void init() { m_outerStride = internal::traits<BlockType>::HasSameStorageOrderAsXprType |