Loading src/TNL/Matrices/SlicedEllpack.h +2 −1 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ class SlicedEllpack : public Sparse< Real, Device, Index > typedef SlicedEllpack< Real, Devices::Cuda, Index > CudaType; typedef Sparse< Real, Device, Index > BaseType; typedef typename BaseType::MatrixRow MatrixRow; typedef SparseRow< const RealType, const IndexType > ConstMatrixRow; SlicedEllpack(); Loading Loading @@ -150,7 +151,7 @@ class SlicedEllpack : public Sparse< Real, Device, Index > MatrixRow getRow( const IndexType rowIndex ); __cuda_callable__ const MatrixRow getRow( const IndexType rowIndex ) const; ConstMatrixRow getRow( const IndexType rowIndex ) const; template< typename Vector > __cuda_callable__ Loading src/TNL/Matrices/SlicedEllpack_impl.h +5 −5 Original line number Diff line number Diff line Loading @@ -454,14 +454,14 @@ template< typename Real, typename Index, int SliceSize > __cuda_callable__ const typename SlicedEllpack< Real, Device, Index, SliceSize >::MatrixRow typename SlicedEllpack< Real, Device, Index, SliceSize >::ConstMatrixRow SlicedEllpack< Real, Device, Index, SliceSize >:: getRow( const IndexType rowIndex ) const { Index rowBegin, rowEnd, step; DeviceDependentCode::initRowTraverseFast( *this, rowIndex, rowBegin, rowEnd, step ); const IndexType slice = rowIndex / SliceSize; return MatrixRow( &this->columnIndexes[ rowBegin ], return ConstMatrixRow( &this->columnIndexes[ rowBegin ], &this->values[ rowBegin ], this->sliceCompressedRowsLengths[ slice ], step ); Loading src/TNL/Matrices/SparseRow.h +10 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,10 @@ #pragma once #include <type_traits> #include <TNL/Devices/Cuda.h> namespace TNL { namespace Matrices { Loading Loading @@ -39,6 +43,12 @@ class SparseRow const Index& column, const Real& value ); __cuda_callable__ const Index& getElementColumn( const Index& elementIndex ) const; __cuda_callable__ const Real& getElementValue( const Index& elementIndex ) const; void print( std::ostream& str ) const; protected: Loading src/TNL/Matrices/SparseRow_impl.h +29 −2 Original line number Diff line number Diff line Loading @@ -10,6 +10,8 @@ #pragma once #include <TNL/Matrices/SparseRow.h> namespace TNL { namespace Matrices { Loading Loading @@ -72,13 +74,38 @@ setElement( const Index& elementIndex, this->values[ elementIndex * step ] = value; } template< typename Real, typename Index > __cuda_callable__ const Index& SparseRow< Real, Index >:: getElementColumn( const Index& elementIndex ) const { TNL_ASSERT( elementIndex >= 0 && elementIndex < this->length, std::cerr << "elementIndex = " << elementIndex << " this->length = " << this->length ); return this->columns[ elementIndex * step ]; } template< typename Real, typename Index > __cuda_callable__ const Real& SparseRow< Real, Index >:: getElementValue( const Index& elementIndex ) const { TNL_ASSERT( elementIndex >= 0 && elementIndex < this->length, std::cerr << "elementIndex = " << elementIndex << " this->length = " << this->length ); return this->values[ elementIndex * step ]; } template< typename Real, typename Index > void SparseRow< Real, Index >:: print( std::ostream& str ) const { Index pos( 0 ); for( Index i = 0; i < length; i++ ) using NonConstIndex = typename std::remove_const< Index >::type; NonConstIndex pos( 0 ); for( NonConstIndex i = 0; i < length; i++ ) { str << " [ " << columns[ pos ] << " ] = " << values[ pos ] << ", "; pos += step; Loading Loading
src/TNL/Matrices/SlicedEllpack.h +2 −1 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ class SlicedEllpack : public Sparse< Real, Device, Index > typedef SlicedEllpack< Real, Devices::Cuda, Index > CudaType; typedef Sparse< Real, Device, Index > BaseType; typedef typename BaseType::MatrixRow MatrixRow; typedef SparseRow< const RealType, const IndexType > ConstMatrixRow; SlicedEllpack(); Loading Loading @@ -150,7 +151,7 @@ class SlicedEllpack : public Sparse< Real, Device, Index > MatrixRow getRow( const IndexType rowIndex ); __cuda_callable__ const MatrixRow getRow( const IndexType rowIndex ) const; ConstMatrixRow getRow( const IndexType rowIndex ) const; template< typename Vector > __cuda_callable__ Loading
src/TNL/Matrices/SlicedEllpack_impl.h +5 −5 Original line number Diff line number Diff line Loading @@ -454,14 +454,14 @@ template< typename Real, typename Index, int SliceSize > __cuda_callable__ const typename SlicedEllpack< Real, Device, Index, SliceSize >::MatrixRow typename SlicedEllpack< Real, Device, Index, SliceSize >::ConstMatrixRow SlicedEllpack< Real, Device, Index, SliceSize >:: getRow( const IndexType rowIndex ) const { Index rowBegin, rowEnd, step; DeviceDependentCode::initRowTraverseFast( *this, rowIndex, rowBegin, rowEnd, step ); const IndexType slice = rowIndex / SliceSize; return MatrixRow( &this->columnIndexes[ rowBegin ], return ConstMatrixRow( &this->columnIndexes[ rowBegin ], &this->values[ rowBegin ], this->sliceCompressedRowsLengths[ slice ], step ); Loading
src/TNL/Matrices/SparseRow.h +10 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,10 @@ #pragma once #include <type_traits> #include <TNL/Devices/Cuda.h> namespace TNL { namespace Matrices { Loading Loading @@ -39,6 +43,12 @@ class SparseRow const Index& column, const Real& value ); __cuda_callable__ const Index& getElementColumn( const Index& elementIndex ) const; __cuda_callable__ const Real& getElementValue( const Index& elementIndex ) const; void print( std::ostream& str ) const; protected: Loading
src/TNL/Matrices/SparseRow_impl.h +29 −2 Original line number Diff line number Diff line Loading @@ -10,6 +10,8 @@ #pragma once #include <TNL/Matrices/SparseRow.h> namespace TNL { namespace Matrices { Loading Loading @@ -72,13 +74,38 @@ setElement( const Index& elementIndex, this->values[ elementIndex * step ] = value; } template< typename Real, typename Index > __cuda_callable__ const Index& SparseRow< Real, Index >:: getElementColumn( const Index& elementIndex ) const { TNL_ASSERT( elementIndex >= 0 && elementIndex < this->length, std::cerr << "elementIndex = " << elementIndex << " this->length = " << this->length ); return this->columns[ elementIndex * step ]; } template< typename Real, typename Index > __cuda_callable__ const Real& SparseRow< Real, Index >:: getElementValue( const Index& elementIndex ) const { TNL_ASSERT( elementIndex >= 0 && elementIndex < this->length, std::cerr << "elementIndex = " << elementIndex << " this->length = " << this->length ); return this->values[ elementIndex * step ]; } template< typename Real, typename Index > void SparseRow< Real, Index >:: print( std::ostream& str ) const { Index pos( 0 ); for( Index i = 0; i < length; i++ ) using NonConstIndex = typename std::remove_const< Index >::type; NonConstIndex pos( 0 ); for( NonConstIndex i = 0; i < length; i++ ) { str << " [ " << columns[ pos ] << " ] = " << values[ pos ] << ", "; pos += step; Loading