From a16d4530444e634494e9e884c98cac682dcebdd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz> Date: Fri, 23 Dec 2016 10:55:39 +0100 Subject: [PATCH] Fixed access to constant SparseRow in CSR and Ellpack matrices --- src/TNL/Matrices/CSR.h | 3 ++- src/TNL/Matrices/CSR_impl.h | 10 +++++----- src/TNL/Matrices/Ellpack.h | 3 ++- src/TNL/Matrices/Ellpack_impl.h | 10 +++++----- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/TNL/Matrices/CSR.h b/src/TNL/Matrices/CSR.h index e42fca6b73..5ad4327a63 100644 --- a/src/TNL/Matrices/CSR.h +++ b/src/TNL/Matrices/CSR.h @@ -41,6 +41,7 @@ class CSR : public Sparse< Real, Device, Index > typedef CSR< Real, Devices::Cuda, Index > CudaType; typedef Sparse< Real, Device, Index > BaseType; typedef typename BaseType::MatrixRow MatrixRow; + typedef SparseRow< const RealType, const IndexType > ConstMatrixRow; enum SPMVCudaKernel { scalar, vector, hybrid }; @@ -125,7 +126,7 @@ class CSR : 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__ diff --git a/src/TNL/Matrices/CSR_impl.h b/src/TNL/Matrices/CSR_impl.h index 0b10050539..e021dc52c4 100644 --- a/src/TNL/Matrices/CSR_impl.h +++ b/src/TNL/Matrices/CSR_impl.h @@ -406,16 +406,16 @@ template< typename Real, typename Device, typename Index > __cuda_callable__ -const typename CSR< Real, Device, Index >::MatrixRow +typename CSR< Real, Device, Index >::ConstMatrixRow CSR< Real, Device, Index >:: getRow( const IndexType rowIndex ) const { const IndexType rowOffset = this->rowPointers[ rowIndex ]; const IndexType rowLength = this->rowPointers[ rowIndex + 1 ] - rowOffset; - return MatrixRow( &this->columnIndexes[ rowOffset ], - &this->values[ rowOffset ], - rowLength, - 1 ); + return ConstMatrixRow( &this->columnIndexes[ rowOffset ], + &this->values[ rowOffset ], + rowLength, + 1 ); } template< typename Real, diff --git a/src/TNL/Matrices/Ellpack.h b/src/TNL/Matrices/Ellpack.h index f7d0b9cca0..64bb18123d 100644 --- a/src/TNL/Matrices/Ellpack.h +++ b/src/TNL/Matrices/Ellpack.h @@ -35,6 +35,7 @@ class Ellpack : public Sparse< Real, Device, Index > typedef Ellpack< Real, Devices::Cuda, Index > CudaType; typedef Sparse< Real, Device, Index > BaseType; typedef typename BaseType::MatrixRow MatrixRow; + typedef SparseRow< const RealType, const IndexType > ConstMatrixRow; Ellpack(); @@ -128,7 +129,7 @@ class Ellpack : 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__ diff --git a/src/TNL/Matrices/Ellpack_impl.h b/src/TNL/Matrices/Ellpack_impl.h index 60c4c18a61..c183b47773 100644 --- a/src/TNL/Matrices/Ellpack_impl.h +++ b/src/TNL/Matrices/Ellpack_impl.h @@ -455,16 +455,16 @@ template< typename Real, typename Device, typename Index > __cuda_callable__ -const typename Ellpack< Real, Device, Index >::MatrixRow +typename Ellpack< Real, Device, Index >::ConstMatrixRow Ellpack< Real, Device, Index >:: getRow( const IndexType rowIndex ) const { //printf( "this->rowLengths = %d this = %p \n", this->rowLengths, this ); IndexType rowBegin = DeviceDependentCode::getRowBegin( *this, rowIndex ); - return MatrixRow( &this->columnIndexes[ rowBegin ], - &this->values[ rowBegin ], - this->rowLengths, - DeviceDependentCode::getElementStep( *this ) ); + return ConstMatrixRow( &this->columnIndexes[ rowBegin ], + &this->values[ rowBegin ], + this->rowLengths, + DeviceDependentCode::getElementStep( *this ) ); } template< typename Real, -- GitLab