Loading src/implementation/matrices/tnlCOOMatrix_impl.h +37 −4 Original line number Diff line number Diff line Loading @@ -11,7 +11,8 @@ template< typename Real, typename Index > tnlCOOMatrix< Real, Device, Index >::tnlCOOMatrix() :cudaWarpSize( 32 ), numberOfUsedValues( 0 ) numberOfUsedValues( 0 ), appendMode( true ) { }; Loading Loading @@ -89,8 +90,14 @@ template< typename Real, typename Index > void tnlCOOMatrix< Real, Device, Index >::getRowLengths(tnlVector< IndexType, DeviceType, IndexType >& rowLengthsVector) const { IndexType rowLength; for(IndexType row = 0; row < this->getRows(); row++) rowLengthsVector.setElement(row, this->getRowLength(row)); rowLengthsVector.setElement(row, 0); for(IndexType elementPtr = 0; elementPtr < this->values.getSize(); elementPtr++) { rowLength = rowLengthsVector.getElement(this->rowIndexes.getElement(elementPtr)); rowLengthsVector.setElement(this->rowIndexes.getElement(elementPtr), rowLength++); } } template< typename Real, Loading @@ -112,7 +119,10 @@ bool tnlCOOMatrix< Real, Device, Index >::setElement( const IndexType row, const IndexType column, const RealType& value ) { if( this->appendMode ) return this->addElement( row, column, value, 1.0 ); else return this->appendElement( row, column, value ); } template< typename Real, Loading @@ -129,6 +139,8 @@ bool tnlCOOMatrix< Real, Device, Index >::addElement( const IndexType row, << " column = " << column << " this->rows = " << this->rows << " this->columns = " << this->columns ); if( appendMode ) return this->appendElement( row, column, value ); IndexType endPtr = this->getNumberOfUsedValues(); for(IndexType elementPtr = 0; elementPtr < endPtr; elementPtr++) Loading @@ -150,6 +162,25 @@ bool tnlCOOMatrix< Real, Device, Index >::addElement( const IndexType row, return false; } template< typename Real, typename Device, typename Index > bool tnlCOOMatrix< Real, Device, Index >::appendElement( const IndexType row, const IndexType column, const RealType& value ) { if( !this->getNumberOfUsedValues < this->values.getSize() ) return false; else { this->rowIndexes.setElement( this->getNumberOfUsedValues(), row ); this->columnIndexes.setElement( this->getNumberOfUsedValues(), column ); this->values.setElement( this->getNumberOfUsedValues(), value ); this->numberOfUsedValues++; } return true; } template< typename Real, typename Device, typename Index > Loading Loading @@ -236,6 +267,8 @@ template< typename InVector, void tnlCOOMatrix< Real, Device, Index >::vectorProductHost(const InVector& inVector, OutVector& outVector) const { for(IndexType row = 0; row < this->getRows(); row++) outVector[ row ] = 0; for(IndexType i = 0; i < this->values.getSize(); i++) outVector[ this->rowIndexes.getElement(i) ] = this->values.getElement(i)*inVector[ this->columnIndexes.getElement(i) ]; } Loading src/matrices/tnlCOOMatrix.h +8 −0 Original line number Diff line number Diff line /* u addElement by nejspis melo byt realokovani pole jinak se asi prvek, ktery * na danem miste nebyl pridat neda, leda by se puvodne naalokovalo pole o neco vetsi * * u getRowLengths dat jeden cyklus co projede vsechny prvky a nastavi rovnou cele pole */ #ifndef TNLCOOMATRIX_H_ #define TNLCOOMATRIX_H_ Loading Loading @@ -51,6 +53,10 @@ public: const RealType& value, const RealType& thisElementMultiplicator = 1.0); bool appendElement( const IndexType row, const IndexType column, const RealType& value); bool setRow(const IndexType row, const IndexType* columns, const RealType* values, Loading Loading @@ -106,6 +112,8 @@ private: IndexType numberOfUsedValues; int cudaWarpSize; bool appendMode; }; #include <implementation/matrices/tnlCOOMatrix_impl.h> Loading tests/benchmarks/tnlCusparseCSRMatrix.h +7 −5 Original line number Diff line number Diff line Loading @@ -110,18 +110,19 @@ class tnlCusparseCSRMatrix< double > : public tnlCusparseCSRMatrixBase< double > { tnlAssert( matrix, ); #ifdef HAVE_CUDA /*cusparseDcsrmv( *( this->cusparseHandle ), cusparseDcsrmv( *( this->cusparseHandle ), CUSPARSE_OPERATION_NON_TRANSPOSE, this->matrix->getRows(), this->matrix->getColumns(), this->matrix->values.getSize(), 1.0, this->matrixDescriptor, this->matrix->values.getData(), this->matrix->rowPointers.getData(), this->matrix->columnIndexes.getData(), inVector.getData(), 1.0, outVector.getData() );*/ outVector.getData() ); #endif } }; Loading @@ -138,18 +139,19 @@ class tnlCusparseCSRMatrix< float > : public tnlCusparseCSRMatrixBase< float > { tnlAssert( matrix, ); #ifdef HAVE_CUDA /*cusparseScsrmv( *( this->cusparseHandle ), cusparseScsrmv( *( this->cusparseHandle ), CUSPARSE_OPERATION_NON_TRANSPOSE, this->matrix->getRows(), this->matrix->getColumns(), this->matrix->values.getSize(), 1.0, this->matrixDescriptor, this->matrix->values.getData(), this->matrix->rowPointers.getData(), this->matrix->columnIndexes.getData(), inVector.getData(), 0, outVector.getData() );*/ outVector.getData() ); #endif } }; Loading Loading
src/implementation/matrices/tnlCOOMatrix_impl.h +37 −4 Original line number Diff line number Diff line Loading @@ -11,7 +11,8 @@ template< typename Real, typename Index > tnlCOOMatrix< Real, Device, Index >::tnlCOOMatrix() :cudaWarpSize( 32 ), numberOfUsedValues( 0 ) numberOfUsedValues( 0 ), appendMode( true ) { }; Loading Loading @@ -89,8 +90,14 @@ template< typename Real, typename Index > void tnlCOOMatrix< Real, Device, Index >::getRowLengths(tnlVector< IndexType, DeviceType, IndexType >& rowLengthsVector) const { IndexType rowLength; for(IndexType row = 0; row < this->getRows(); row++) rowLengthsVector.setElement(row, this->getRowLength(row)); rowLengthsVector.setElement(row, 0); for(IndexType elementPtr = 0; elementPtr < this->values.getSize(); elementPtr++) { rowLength = rowLengthsVector.getElement(this->rowIndexes.getElement(elementPtr)); rowLengthsVector.setElement(this->rowIndexes.getElement(elementPtr), rowLength++); } } template< typename Real, Loading @@ -112,7 +119,10 @@ bool tnlCOOMatrix< Real, Device, Index >::setElement( const IndexType row, const IndexType column, const RealType& value ) { if( this->appendMode ) return this->addElement( row, column, value, 1.0 ); else return this->appendElement( row, column, value ); } template< typename Real, Loading @@ -129,6 +139,8 @@ bool tnlCOOMatrix< Real, Device, Index >::addElement( const IndexType row, << " column = " << column << " this->rows = " << this->rows << " this->columns = " << this->columns ); if( appendMode ) return this->appendElement( row, column, value ); IndexType endPtr = this->getNumberOfUsedValues(); for(IndexType elementPtr = 0; elementPtr < endPtr; elementPtr++) Loading @@ -150,6 +162,25 @@ bool tnlCOOMatrix< Real, Device, Index >::addElement( const IndexType row, return false; } template< typename Real, typename Device, typename Index > bool tnlCOOMatrix< Real, Device, Index >::appendElement( const IndexType row, const IndexType column, const RealType& value ) { if( !this->getNumberOfUsedValues < this->values.getSize() ) return false; else { this->rowIndexes.setElement( this->getNumberOfUsedValues(), row ); this->columnIndexes.setElement( this->getNumberOfUsedValues(), column ); this->values.setElement( this->getNumberOfUsedValues(), value ); this->numberOfUsedValues++; } return true; } template< typename Real, typename Device, typename Index > Loading Loading @@ -236,6 +267,8 @@ template< typename InVector, void tnlCOOMatrix< Real, Device, Index >::vectorProductHost(const InVector& inVector, OutVector& outVector) const { for(IndexType row = 0; row < this->getRows(); row++) outVector[ row ] = 0; for(IndexType i = 0; i < this->values.getSize(); i++) outVector[ this->rowIndexes.getElement(i) ] = this->values.getElement(i)*inVector[ this->columnIndexes.getElement(i) ]; } Loading
src/matrices/tnlCOOMatrix.h +8 −0 Original line number Diff line number Diff line /* u addElement by nejspis melo byt realokovani pole jinak se asi prvek, ktery * na danem miste nebyl pridat neda, leda by se puvodne naalokovalo pole o neco vetsi * * u getRowLengths dat jeden cyklus co projede vsechny prvky a nastavi rovnou cele pole */ #ifndef TNLCOOMATRIX_H_ #define TNLCOOMATRIX_H_ Loading Loading @@ -51,6 +53,10 @@ public: const RealType& value, const RealType& thisElementMultiplicator = 1.0); bool appendElement( const IndexType row, const IndexType column, const RealType& value); bool setRow(const IndexType row, const IndexType* columns, const RealType* values, Loading Loading @@ -106,6 +112,8 @@ private: IndexType numberOfUsedValues; int cudaWarpSize; bool appendMode; }; #include <implementation/matrices/tnlCOOMatrix_impl.h> Loading
tests/benchmarks/tnlCusparseCSRMatrix.h +7 −5 Original line number Diff line number Diff line Loading @@ -110,18 +110,19 @@ class tnlCusparseCSRMatrix< double > : public tnlCusparseCSRMatrixBase< double > { tnlAssert( matrix, ); #ifdef HAVE_CUDA /*cusparseDcsrmv( *( this->cusparseHandle ), cusparseDcsrmv( *( this->cusparseHandle ), CUSPARSE_OPERATION_NON_TRANSPOSE, this->matrix->getRows(), this->matrix->getColumns(), this->matrix->values.getSize(), 1.0, this->matrixDescriptor, this->matrix->values.getData(), this->matrix->rowPointers.getData(), this->matrix->columnIndexes.getData(), inVector.getData(), 1.0, outVector.getData() );*/ outVector.getData() ); #endif } }; Loading @@ -138,18 +139,19 @@ class tnlCusparseCSRMatrix< float > : public tnlCusparseCSRMatrixBase< float > { tnlAssert( matrix, ); #ifdef HAVE_CUDA /*cusparseScsrmv( *( this->cusparseHandle ), cusparseScsrmv( *( this->cusparseHandle ), CUSPARSE_OPERATION_NON_TRANSPOSE, this->matrix->getRows(), this->matrix->getColumns(), this->matrix->values.getSize(), 1.0, this->matrixDescriptor, this->matrix->values.getData(), this->matrix->rowPointers.getData(), this->matrix->columnIndexes.getData(), inVector.getData(), 0, outVector.getData() );*/ outVector.getData() ); #endif } }; Loading