Skip to content
Snippets Groups Projects
Commit b4cadcda authored by Tomáš Oberhuber's avatar Tomáš Oberhuber Committed by Tomáš Oberhuber
Browse files

Deleting deprecated methods in SparseMatrix and SparseMatrixView.

parent 2e95ddda
No related branches found
No related tags found
1 merge request!48Segments
......@@ -56,6 +56,7 @@ public:
virtual void setCompressedRowLengths( ConstCompressedRowLengthsVectorView rowLengths ) = 0;
[[deprecated]]
virtual IndexType getRowLength( const IndexType row ) const = 0;
// TODO: implementation is not parallel
......@@ -79,12 +80,6 @@ public:
__cuda_callable__
IndexType getColumns() const;
/****
* TODO: The fast variants of the following methods cannot be virtual.
* If they were, they could not be used in the CUDA kernels. If CUDA allows it
* in the future and it does not slow down, declare them as virtual here.
*/
virtual bool setElement( const IndexType row,
const IndexType column,
const RealType& value ) = 0;
......@@ -94,17 +89,6 @@ public:
const RealType& value,
const RealType& thisElementMultiplicator = 1.0 ) = 0;
virtual bool setRow( const IndexType row,
const IndexType* columns,
const RealType* values,
const IndexType numberOfElements ) = 0;
virtual bool addRow( const IndexType row,
const IndexType* columns,
const RealType* values,
const IndexType numberOfElements,
const RealType& thisElementMultiplicator = 1.0 ) = 0;
virtual Real getElement( const IndexType row,
const IndexType column ) const = 0;
......
......@@ -90,17 +90,6 @@ public:
const RealType& value,
const RealType& thisElementMultiplicator = 1.0 ) = 0;
virtual bool setRow( const IndexType row,
const IndexType* columns,
const RealType* values,
const IndexType numberOfElements ) = 0;
virtual bool addRow( const IndexType row,
const IndexType* columns,
const RealType* values,
const IndexType numberOfElements,
const RealType& thisElementMultiplicator = 1.0 ) = 0;
virtual Real getElement( const IndexType row,
const IndexType column ) const = 0;
......
......@@ -91,18 +91,17 @@ class SparseMatrix : public Matrix< Real, Device, Index, RealAllocator >
template< typename Vector >
void getCompressedRowLengths( Vector& rowLengths ) const;
IndexType getRowLength( const IndexType row ) const;
__cuda_callable__
IndexType getRowLengthFast( const IndexType row ) const;
IndexType getNonZeroRowLength( const IndexType row ) const;
__cuda_callable__
IndexType getNonZeroRowLengthFast( const IndexType row ) const;
template< typename Real2, typename Device2, typename Index2, typename MatrixType2, template< typename, typename, typename > class Segments2, typename RealAllocator2, typename IndexAllocator2 >
void setLike( const SparseMatrix< Real2, Device2, Index2, MatrixType2, Segments2, RealAllocator2, IndexAllocator2 >& matrix );
[[deprecated]]
virtual IndexType getRowLength( const IndexType row ) const {};
template< typename Real_,
typename Device_,
typename Index_,
typename MatrixType_,
template< typename, typename, typename > class Segments_,
typename RealAllocator_,
typename IndexAllocator_ >
void setLike( const SparseMatrix< Real_, Device_, Index_, MatrixType_, Segments_, RealAllocator_, IndexAllocator_ >& matrix );
IndexType getNumberOfNonzeroMatrixElements() const;
......@@ -114,68 +113,18 @@ class SparseMatrix : public Matrix< Real, Device, Index, RealAllocator >
__cuda_callable__
RowView getRow( const IndexType& rowIdx );
[[deprecated("")]] __cuda_callable__
bool setElementFast( const IndexType row,
const IndexType column,
const RealType& value );
bool setElement( const IndexType row,
const IndexType column,
const RealType& value );
[[deprecated("")]] __cuda_callable__
bool addElementFast( const IndexType row,
const IndexType column,
const RealType& value,
const RealType& thisElementMultiplicator = 1.0 );
[[deprecated("")]]
bool addElement( const IndexType row,
const IndexType column,
const RealType& value,
const RealType& thisElementMultiplicator = 1.0 );
[[deprecated("")]] __cuda_callable__
bool setRowFast( const IndexType row,
const IndexType* columnIndexes,
const RealType* values,
const IndexType elements );
[[deprecated("")]]
bool setRow( const IndexType row,
const IndexType* columnIndexes,
const RealType* values,
const IndexType elements );
[[deprecated("")]] __cuda_callable__
bool addRowFast( const IndexType row,
const IndexType* columns,
const RealType* values,
const IndexType numberOfElements,
const RealType& thisElementMultiplicator = 1.0 );
[[deprecated("")]]
bool addRow( const IndexType row,
const IndexType* columns,
const RealType* values,
const IndexType numberOfElements,
const RealType& thisElementMultiplicator = 1.0 );
[[deprecated("")]] __cuda_callable__
RealType getElementFast( const IndexType row,
const IndexType column ) const;
const RealType& thisElementMultiplicator );
RealType getElement( const IndexType row,
const IndexType column ) const;
[[deprecated("")]] __cuda_callable__
void getRowFast( const IndexType row,
IndexType* columns,
RealType* values ) const;
template< typename Vector >
__cuda_callable__
typename Vector::RealType rowVectorProduct( const IndexType row,
......@@ -255,8 +204,6 @@ class SparseMatrix : public Matrix< Real, Device, Index, RealAllocator >
IndexAllocator indexAllocator;
RealAllocator realAllocator;
};
} // namespace Conatiners
......
......@@ -195,64 +195,6 @@ getCompressedRowLengths( Vector& rowLengths ) const
this->allRowsReduction( fetch, reduce, keep, 0 );
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename, typename > class Segments,
typename RealAllocator,
typename IndexAllocator >
Index
SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::
getRowLength( const IndexType row ) const
{
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename, typename > class Segments,
typename RealAllocator,
typename IndexAllocator >
__cuda_callable__
Index
SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::
getRowLengthFast( const IndexType row ) const
{
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename, typename > class Segments,
typename RealAllocator,
typename IndexAllocator >
Index
SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::
getNonZeroRowLength( const IndexType row ) const
{
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename, typename > class Segments,
typename RealAllocator,
typename IndexAllocator >
__cuda_callable__
Index
SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::
getNonZeroRowLengthFast( const IndexType row ) const
{
}
template< typename Real,
typename Device,
typename Index,
......@@ -331,23 +273,6 @@ getRow( const IndexType& rowIdx ) -> RowView
return RowView( this->segments.getSegmentView( rowIdx ), this->values.getView(), this->columnIndexes.getView() );
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename, typename > class Segments,
typename RealAllocator,
typename IndexAllocator >
__cuda_callable__
bool
SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::
setElementFast( const IndexType row,
const IndexType column,
const RealType& value )
{
return this->addElementFast( row, column, value, 0.0 );
}
template< typename Real,
typename Device,
typename Index,
......@@ -364,24 +289,6 @@ setElement( const IndexType row,
return this->addElement( row, column, value, 0.0 );
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename, typename > class Segments,
typename RealAllocator,
typename IndexAllocator >
__cuda_callable__
bool
SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::
addElementFast( const IndexType row,
const IndexType column,
const RealType& value,
const RealType& thisElementMultiplicator )
{
}
template< typename Real,
typename Device,
typename Index,
......@@ -448,107 +355,6 @@ addElement( const IndexType row,
}
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename, typename > class Segments,
typename RealAllocator,
typename IndexAllocator >
__cuda_callable__
bool
SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::
setRowFast( const IndexType row,
const IndexType* columnIndexes,
const RealType* values,
const IndexType elements )
{
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename, typename > class Segments,
typename RealAllocator,
typename IndexAllocator >
bool
SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::
setRow( const IndexType row,
const IndexType* columnIndexes,
const RealType* values,
const IndexType elements )
{
const IndexType rowLength = this->segments.getSegmentSize( row );
if( elements > rowLength )
return false;
for( IndexType i = 0; i < elements; i++ )
{
const IndexType globalIdx = this->segments.getGlobalIndex( row, i );
this->columnIndexes.setElement( globalIdx, columnIndexes[ i ] );
this->values.setElement( globalIdx, values[ i ] );
}
for( IndexType i = elements; i < rowLength; i++ )
this->columnIndexes.setElement( this->segments.getGlobalIndex( row, i ), this->getPaddingIndex() );
return true;
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename, typename > class Segments,
typename RealAllocator,
typename IndexAllocator >
__cuda_callable__
bool
SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::
addRowFast( const IndexType row,
const IndexType* columns,
const RealType* values,
const IndexType numberOfElements,
const RealType& thisElementMultiplicator )
{
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename, typename > class Segments,
typename RealAllocator,
typename IndexAllocator >
bool
SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::
addRow( const IndexType row,
const IndexType* columns,
const RealType* values,
const IndexType numberOfElements,
const RealType& thisElementMultiplicator )
{
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename, typename > class Segments,
typename RealAllocator,
typename IndexAllocator >
__cuda_callable__
Real
SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::
getElementFast( const IndexType row,
const IndexType column ) const
{
}
template< typename Real,
typename Device,
typename Index,
......@@ -573,23 +379,6 @@ getElement( const IndexType row,
return 0.0;
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename, typename > class Segments,
typename RealAllocator,
typename IndexAllocator >
__cuda_callable__
void
SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::
getRowFast( const IndexType row,
IndexType* columns,
RealType* values ) const
{
}
template< typename Real,
typename Device,
typename Index,
......
......@@ -79,16 +79,9 @@ class SparseMatrixView : public MatrixView< Real, Device, Index >
template< typename Vector >
void getCompressedRowLengths( Vector& rowLengths ) const;
[[deprecated]]
IndexType getRowLength( const IndexType row ) const;
__cuda_callable__
IndexType getRowLengthFast( const IndexType row ) const;
IndexType getNonZeroRowLength( const IndexType row ) const;
__cuda_callable__
IndexType getNonZeroRowLengthFast( const IndexType row ) const;
IndexType getNumberOfNonzeroMatrixElements() const;
void reset();
......@@ -99,68 +92,18 @@ class SparseMatrixView : public MatrixView< Real, Device, Index >
__cuda_callable__
RowView getRow( const IndexType& rowIdx );
[[deprecated("")]] __cuda_callable__
bool setElementFast( const IndexType row,
const IndexType column,
const RealType& value );
bool setElement( const IndexType row,
const IndexType column,
const RealType& value );
[[deprecated("")]] __cuda_callable__
bool addElementFast( const IndexType row,
const IndexType column,
const RealType& value,
const RealType& thisElementMultiplicator = 1.0 );
[[deprecated("")]]
bool addElement( const IndexType row,
const IndexType column,
const RealType& value,
const RealType& thisElementMultiplicator = 1.0 );
[[deprecated("")]] __cuda_callable__
bool setRowFast( const IndexType row,
const IndexType* columnIndexes,
const RealType* values,
const IndexType elements );
[[deprecated("")]]
bool setRow( const IndexType row,
const IndexType* columnIndexes,
const RealType* values,
const IndexType elements );
[[deprecated("")]] __cuda_callable__
bool addRowFast( const IndexType row,
const IndexType* columns,
const RealType* values,
const IndexType numberOfElements,
const RealType& thisElementMultiplicator = 1.0 );
[[deprecated("")]]
bool addRow( const IndexType row,
const IndexType* columns,
const RealType* values,
const IndexType numberOfElements,
const RealType& thisElementMultiplicator = 1.0 );
[[deprecated("")]] __cuda_callable__
RealType getElementFast( const IndexType row,
const IndexType column ) const;
RealType getElement( const IndexType row,
const IndexType column ) const;
[[deprecated("")]] __cuda_callable__
void getRowFast( const IndexType row,
IndexType* columns,
RealType* values ) const;
template< typename Vector >
__cuda_callable__
typename Vector::RealType rowVectorProduct( const IndexType row,
......
......@@ -142,44 +142,6 @@ getRowLength( const IndexType row ) const
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename > class SegmentsView >
__cuda_callable__
Index
SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >::
getRowLengthFast( const IndexType row ) const
{
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename > class SegmentsView >
Index
SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >::
getNonZeroRowLength( const IndexType row ) const
{
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename > class SegmentsView >
__cuda_callable__
Index
SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >::
getNonZeroRowLengthFast( const IndexType row ) const
{
}
template< typename Real,
typename Device,
typename Index,
......@@ -237,21 +199,6 @@ getRow( const IndexType& rowIdx ) -> RowView
return RowView( this->segments.getSegmentView( rowIdx ), this->values.getView(), this->columnIndexes.getView() );
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename > class SegmentsView >
__cuda_callable__
bool
SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >::
setElementFast( const IndexType row,
const IndexType column,
const RealType& value )
{
return this->addElementFast( row, column, value, 0.0 );
}
template< typename Real,
typename Device,
typename Index,
......@@ -266,22 +213,6 @@ setElement( const IndexType row,
return this->addElement( row, column, value, 0.0 );
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename > class SegmentsView >
__cuda_callable__
bool
SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >::
addElementFast( const IndexType row,
const IndexType column,
const RealType& value,
const RealType& thisElementMultiplicator )
{
}
template< typename Real,
typename Device,
typename Index,
......@@ -346,97 +277,6 @@ addElement( const IndexType row,
}
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename > class SegmentsView >
__cuda_callable__
bool
SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >::
setRowFast( const IndexType row,
const IndexType* columnIndexes,
const RealType* values,
const IndexType elements )
{
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename > class SegmentsView >
bool
SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >::
setRow( const IndexType row,
const IndexType* columnIndexes,
const RealType* values,
const IndexType elements )
{
const IndexType rowLength = this->segments.getSegmentSize( row );
if( elements > rowLength )
return false;
for( IndexType i = 0; i < elements; i++ )
{
const IndexType globalIdx = this->segments.getGlobalIndex( row, i );
this->columnIndexes.setElement( globalIdx, columnIndexes[ i ] );
this->values.setElement( globalIdx, values[ i ] );
}
for( IndexType i = elements; i < rowLength; i++ )
this->columnIndexes.setElement( this->segments.getGlobalIndex( row, i ), this->getPaddingIndex() );
return true;
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename > class SegmentsView >
__cuda_callable__
bool
SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >::
addRowFast( const IndexType row,
const IndexType* columns,
const RealType* values,
const IndexType numberOfElements,
const RealType& thisElementMultiplicator )
{
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename > class SegmentsView >
bool
SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >::
addRow( const IndexType row,
const IndexType* columns,
const RealType* values,
const IndexType numberOfElements,
const RealType& thisElementMultiplicator )
{
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename > class SegmentsView >
__cuda_callable__
Real
SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >::
getElementFast( const IndexType row,
const IndexType column ) const
{
}
template< typename Real,
typename Device,
typename Index,
......@@ -459,21 +299,6 @@ getElement( const IndexType row,
return 0.0;
}
template< typename Real,
typename Device,
typename Index,
typename MatrixType,
template< typename, typename > class SegmentsView >
__cuda_callable__
void
SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >::
getRowFast( const IndexType row,
IndexType* columns,
RealType* values ) const
{
}
template< typename Real,
typename Device,
typename Index,
......
......@@ -817,78 +817,6 @@ void test_AddElement()
EXPECT_EQ( m.getElement( 5, 4 ), 18 );
}
template< typename Matrix >
void test_SetRow()
{
using RealType = typename Matrix::RealType;
using DeviceType = typename Matrix::DeviceType;
using IndexType = typename Matrix::IndexType;
/*
* Sets up the following 3x7 sparse matrix:
*
* / 0 0 0 1 1 1 0 \
* | 2 2 2 0 0 0 0 |
* \ 3 3 3 0 0 0 0 /
*/
const IndexType rows = 3;
const IndexType cols = 7;
Matrix m;
m.reset();
m.setDimensions( rows, cols );
typename Matrix::CompressedRowLengthsVector rowLengths;
rowLengths.setSize( rows );
rowLengths.setValue( 6 );
rowLengths.setElement( 1, 3 );
m.setCompressedRowLengths( rowLengths );
RealType value = 1;
for( IndexType i = 0; i < 3; i++ )
{
m.setElement( 0, i + 3, value );
m.setElement( 1, i, value + 1 );
m.setElement( 2, i, value + 2 );
}
RealType row1 [ 3 ] = { 11, 11, 11 }; IndexType colIndexes1 [ 3 ] = { 0, 1, 2 };
RealType row2 [ 3 ] = { 22, 22, 22 }; IndexType colIndexes2 [ 3 ] = { 0, 1, 2 };
RealType row3 [ 3 ] = { 33, 33, 33 }; IndexType colIndexes3 [ 3 ] = { 3, 4, 5 };
RealType row = 0;
IndexType elements = 3;
m.setRow( row++, colIndexes1, row1, elements );
m.setRow( row++, colIndexes2, row2, elements );
m.setRow( row++, colIndexes3, row3, elements );
EXPECT_EQ( m.getElement( 0, 0 ), 11 );
EXPECT_EQ( m.getElement( 0, 1 ), 11 );
EXPECT_EQ( m.getElement( 0, 2 ), 11 );
EXPECT_EQ( m.getElement( 0, 3 ), 0 );
EXPECT_EQ( m.getElement( 0, 4 ), 0 );
EXPECT_EQ( m.getElement( 0, 5 ), 0 );
EXPECT_EQ( m.getElement( 0, 6 ), 0 );
EXPECT_EQ( m.getElement( 1, 0 ), 22 );
EXPECT_EQ( m.getElement( 1, 1 ), 22 );
EXPECT_EQ( m.getElement( 1, 2 ), 22 );
EXPECT_EQ( m.getElement( 1, 3 ), 0 );
EXPECT_EQ( m.getElement( 1, 4 ), 0 );
EXPECT_EQ( m.getElement( 1, 5 ), 0 );
EXPECT_EQ( m.getElement( 1, 6 ), 0 );
EXPECT_EQ( m.getElement( 2, 0 ), 0 );
EXPECT_EQ( m.getElement( 2, 1 ), 0 );
EXPECT_EQ( m.getElement( 2, 2 ), 0 );
EXPECT_EQ( m.getElement( 2, 3 ), 33 );
EXPECT_EQ( m.getElement( 2, 4 ), 33 );
EXPECT_EQ( m.getElement( 2, 5 ), 33 );
EXPECT_EQ( m.getElement( 2, 6 ), 0 );
}
template< typename Matrix >
void test_VectorProduct()
{
......
......@@ -116,13 +116,6 @@ TYPED_TEST( CSRMatrixTest, addElementTest )
test_AddElement< CSRMatrixType >();
}
TYPED_TEST( CSRMatrixTest, setRowTest )
{
using CSRMatrixType = typename TestFixture::CSRMatrixType;
test_SetRow< CSRMatrixType >();
}
TYPED_TEST( CSRMatrixTest, vectorProductTest )
{
using CSRMatrixType = typename TestFixture::CSRMatrixType;
......
......@@ -126,13 +126,6 @@ TYPED_TEST( EllpackMatrixTest, addElementTest )
test_AddElement< EllpackMatrixType >();
}
TYPED_TEST( EllpackMatrixTest, setRowTest )
{
using EllpackMatrixType = typename TestFixture::EllpackMatrixType;
test_SetRow< EllpackMatrixType >();
}
TYPED_TEST( EllpackMatrixTest, vectorProductTest )
{
using EllpackMatrixType = typename TestFixture::EllpackMatrixType;
......
......@@ -127,13 +127,6 @@ TYPED_TEST( SlicedEllpackMatrixTest, addElementTest )
test_AddElement< SlicedEllpackMatrixType >();
}
TYPED_TEST( SlicedEllpackMatrixTest, setRowTest )
{
using SlicedEllpackMatrixType = typename TestFixture::SlicedEllpackMatrixType;
test_SetRow< SlicedEllpackMatrixType >();
}
TYPED_TEST( SlicedEllpackMatrixTest, vectorProductTest )
{
using SlicedEllpackMatrixType = typename TestFixture::SlicedEllpackMatrixType;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment