diff --git a/src/TNL/Containers/Segments/CSR.hpp b/src/TNL/Containers/Segments/CSR.hpp index 9a05d84f75ad60b11c831846e8ee0beed1a17932..55dcba74c9ac9cb83a736abc6eecacc621091e0c 100644 --- a/src/TNL/Containers/Segments/CSR.hpp +++ b/src/TNL/Containers/Segments/CSR.hpp @@ -253,6 +253,7 @@ CSR< Device, Index, IndexAllocator >:: operator=( const CSR< Device_, Index_, IndexAllocator_ >& source ) { this->offsets = source.offsets; + return *this; } template< typename Device, diff --git a/src/TNL/Containers/Segments/CSRView.h b/src/TNL/Containers/Segments/CSRView.h index 2ad849f976a5c82268ff4678f72dabc4345ea0c4..759fe8ff7f31364d6567bce3a2fca22c4ee937d1 100644 --- a/src/TNL/Containers/Segments/CSRView.h +++ b/src/TNL/Containers/Segments/CSRView.h @@ -52,8 +52,10 @@ class CSRView static String getSerializationType(); + __cuda_callable__ ViewType getView(); + __cuda_callable__ ConstViewType getConstView() const; /** diff --git a/src/TNL/Containers/Segments/CSRView.hpp b/src/TNL/Containers/Segments/CSRView.hpp index d6ec55b6afd5c1ccc1bd423bc071b7d5c413dcbf..043e06e04ee305bafab795c45665cb7211487def 100644 --- a/src/TNL/Containers/Segments/CSRView.hpp +++ b/src/TNL/Containers/Segments/CSRView.hpp @@ -66,6 +66,7 @@ getSerializationType() template< typename Device, typename Index > +__cuda_callable__ typename CSRView< Device, Index >::ViewType CSRView< Device, Index >:: getView() @@ -75,6 +76,7 @@ getView() template< typename Device, typename Index > +__cuda_callable__ typename CSRView< Device, Index >::ConstViewType CSRView< Device, Index >:: getConstView() const @@ -156,7 +158,6 @@ auto CSRView< Device, Index >:: getSegmentView( const IndexType segmentIdx ) const -> SegmentViewType { - printf( "----> segmentIdx %d offset %d size %d ptr %p \n", segmentIdx, offsets[ segmentIdx ], offsets.getSize(), offsets.getData() ); return SegmentViewType( offsets[ segmentIdx ], offsets[ segmentIdx + 1 ] - offsets[ segmentIdx ], 1 ); } @@ -167,7 +168,7 @@ void CSRView< Device, Index >:: forSegments( IndexType first, IndexType last, Function& f, Args... args ) const { - const auto offsetsView = this->offsets.getConstView(); + const auto offsetsView = this->offsets; auto l = [=] __cuda_callable__ ( const IndexType segmentIdx, Args... args ) mutable { const IndexType begin = offsetsView[ segmentIdx ]; const IndexType end = offsetsView[ segmentIdx + 1 ]; @@ -228,6 +229,7 @@ CSRView< Device, Index >:: operator=( const CSRView& view ) { this->offsets.copy( view.offsets ); + return *this; } template< typename Device, diff --git a/src/TNL/Containers/Segments/Ellpack.hpp b/src/TNL/Containers/Segments/Ellpack.hpp index 8763c2e5dc88c648709b4f03793dde22b8ae84d8..663a65bc80f853adf18a50bb2ebdf47a2c31987a 100644 --- a/src/TNL/Containers/Segments/Ellpack.hpp +++ b/src/TNL/Containers/Segments/Ellpack.hpp @@ -293,7 +293,7 @@ void Ellpack< Device, Index, IndexAllocator, RowMajorOrder, Alignment >:: forAll( Function& f, Args... args ) const { - this->forSegments( 0, this->getSize(), f, args... ); + this->forSegments( 0, this->getSegmentsCount(), f, args... ); } template< typename Device, @@ -364,6 +364,7 @@ operator=( const Ellpack< Device_, Index_, IndexAllocator_, RowMajorOrder_, Alig this->segmentSize = source.segmentSize; this->size = source.size; this->alignedSize = roundUpDivision( size, this->getAlignment() ) * this->getAlignment(); + return *this; } template< typename Device, diff --git a/src/TNL/Containers/Segments/EllpackView.h b/src/TNL/Containers/Segments/EllpackView.h index f64b04068ea6846ae847426577b300943ee4fd58..3870f080280a8d3ac63d060ba2b402e40f48d432 100644 --- a/src/TNL/Containers/Segments/EllpackView.h +++ b/src/TNL/Containers/Segments/EllpackView.h @@ -37,7 +37,7 @@ class EllpackView template< typename Device_, typename Index_ > using ViewTemplate = EllpackView< Device_, Index_ >; using ViewType = EllpackView; - //using ConstViewType = EllpackView< Device, std::add_const_t< Index > >; + using ConstViewType = EllpackView< Device, std::add_const_t< Index > >; using SegmentViewType = SegmentView< IndexType, RowMajorOrder >; __cuda_callable__ @@ -54,9 +54,11 @@ class EllpackView static String getSerializationType(); + __cuda_callable__ ViewType getView(); - //ConstViewType getConstView() const; + __cuda_callable__ + ConstViewType getConstView() const; /** * \brief Number segments. diff --git a/src/TNL/Containers/Segments/EllpackView.hpp b/src/TNL/Containers/Segments/EllpackView.hpp index c0d0b37215a0041d3fa1f31ae974706ea7b6e63c..ea2dc0d216ed084707a1a2b8dc573a7098db417c 100644 --- a/src/TNL/Containers/Segments/EllpackView.hpp +++ b/src/TNL/Containers/Segments/EllpackView.hpp @@ -78,6 +78,7 @@ template< typename Device, typename Index, bool RowMajorOrder, int Alignment > +__cuda_callable__ typename EllpackView< Device, Index, RowMajorOrder, Alignment >::ViewType EllpackView< Device, Index, RowMajorOrder, Alignment >:: getView() @@ -85,16 +86,17 @@ getView() return ViewType( segmentSize, size, alignedSize ); } -/*template< typename Device, +template< typename Device, typename Index, bool RowMajorOrder, int Alignment > +__cuda_callable__ typename EllpackView< Device, Index, RowMajorOrder, Alignment >::ConstViewType EllpackView< Device, Index, RowMajorOrder, Alignment >:: getConstView() const { return ConstViewType( segmentSize, size, alignedSize ); -}*/ +} template< typename Device, typename Index, @@ -233,7 +235,7 @@ void EllpackView< Device, Index, RowMajorOrder, Alignment >:: forAll( Function& f, Args... args ) const { - this->forSegments( 0, this->getSize(), f, args... ); + this->forSegments( 0, this->getSegmentsCount(), f, args... ); } template< typename Device, @@ -302,6 +304,7 @@ operator=( const EllpackView< Device, Index, RowMajorOrder, Alignment >& view ) this->segmentSize = view.segmentSize; this->size = view.size; this->alignedSize = view.alignedSize; + return *this; } template< typename Device, diff --git a/src/TNL/Containers/Segments/SlicedEllpack.hpp b/src/TNL/Containers/Segments/SlicedEllpack.hpp index 62e2ca7d5876b41d12e1082110dbfd0212a024c2..3d3a6d8c3d044f9ac6a8a4d9bfb2a947fb4e5844 100644 --- a/src/TNL/Containers/Segments/SlicedEllpack.hpp +++ b/src/TNL/Containers/Segments/SlicedEllpack.hpp @@ -408,6 +408,7 @@ operator=( const SlicedEllpack< Device_, Index_, IndexAllocator_, RowMajorOrder_ this->segmentsCount = source.segmentsCount; this->sliceOffsets = source.sliceOffsets; this->sliceSegmentSizes = source.sliceSegmentSizes; + return *this; } template< typename Device, diff --git a/src/TNL/Containers/Segments/SlicedEllpackView.h b/src/TNL/Containers/Segments/SlicedEllpackView.h index c8c73c3f26af6de29a2733fc6574d3023712c3f7..2b310a805a5fc470522ca1baa038b5c7ab837395 100644 --- a/src/TNL/Containers/Segments/SlicedEllpackView.h +++ b/src/TNL/Containers/Segments/SlicedEllpackView.h @@ -56,8 +56,10 @@ class SlicedEllpackView static String getSerializationType(); + __cuda_callable__ ViewType getView(); + __cuda_callable__ ConstViewType getConstView() const; __cuda_callable__ diff --git a/src/TNL/Containers/Segments/SlicedEllpackView.hpp b/src/TNL/Containers/Segments/SlicedEllpackView.hpp index 98a3d9b8147ca9b4168b2264d2b4cd18641057ae..3e3c8c09c2ef62cfa98409d01c31005f49090f38 100644 --- a/src/TNL/Containers/Segments/SlicedEllpackView.hpp +++ b/src/TNL/Containers/Segments/SlicedEllpackView.hpp @@ -89,6 +89,7 @@ template< typename Device, typename Index, bool RowMajorOrder, int SliceSize > +__cuda_callable__ typename SlicedEllpackView< Device, Index, RowMajorOrder, SliceSize >::ViewType SlicedEllpackView< Device, Index, RowMajorOrder, SliceSize >:: getView() @@ -100,6 +101,7 @@ template< typename Device, typename Index, bool RowMajorOrder, int SliceSize > +__cuda_callable__ typename SlicedEllpackView< Device, Index, RowMajorOrder, SliceSize >::ConstViewType SlicedEllpackView< Device, Index, RowMajorOrder, SliceSize >:: getConstView() const @@ -357,6 +359,7 @@ operator=( const SlicedEllpackView< Device, Index, RowMajorOrder, SliceSize >& v this->segmentsCount = view.segmentsCount; this->sliceOffsets.copy( view.sliceOffsets ); this->sliceSegmentSizes.copy( view.sliceSegmentSizes ); + return *this; } template< typename Device, diff --git a/src/TNL/Matrices/Dense.hpp b/src/TNL/Matrices/Dense.hpp index e1acfee67e74a6128589160e7a604b4d83d63838..91a98e7f9587dea347f0dd88efbbd7fe7c6cf96c 100644 --- a/src/TNL/Matrices/Dense.hpp +++ b/src/TNL/Matrices/Dense.hpp @@ -925,7 +925,6 @@ operator=( const Dense< RHSReal, RHSDevice, RHSIndex, RHSRowMajorOrder, RHSRealA auto this_view = this->view; if( std::is_same< DeviceType, RHSDeviceType >::value ) { - const auto segments_view = this->segments.getView(); auto f = [=] __cuda_callable__ ( RHSIndexType rowIdx, RHSIndexType localIdx, RHSIndexType columnIdx, const RHSRealType& value, bool& compute ) mutable { this_view( rowIdx, columnIdx ) = value; }; diff --git a/src/TNL/Matrices/DenseMatrixView.hpp b/src/TNL/Matrices/DenseMatrixView.hpp index 890606436c5940c530c6fb44a8778d8d1555d777..a11ff263cdb2a4bb9148a8d6bdf572fcfa7164ed 100644 --- a/src/TNL/Matrices/DenseMatrixView.hpp +++ b/src/TNL/Matrices/DenseMatrixView.hpp @@ -901,6 +901,7 @@ operator=( const DenseMatrixView& matrix ) { MatrixView< Real, Device, Index >::operator=( matrix ); this->segments = matrix.segments; + return *this; } template< typename Real, diff --git a/src/TNL/Matrices/MatrixView.hpp b/src/TNL/Matrices/MatrixView.hpp index 275a2287043c1d1c1a7cbafb5dab03eba8485142..360478d0552b142533e71dcf9d66318a929b240d 100644 --- a/src/TNL/Matrices/MatrixView.hpp +++ b/src/TNL/Matrices/MatrixView.hpp @@ -131,6 +131,7 @@ operator=( const MatrixView& view ) rows = view.rows; columns = view.columns; values.copy( view.values ); + return *this; } template< typename Real, diff --git a/src/TNL/Matrices/Multidiagonal.h b/src/TNL/Matrices/Multidiagonal.h index 927e524491959bdfbe33cb9baff28d079a4aaf7c..749ddfae7f18d690a4d1dc92ff0dc47e2d3cf9c8 100644 --- a/src/TNL/Matrices/Multidiagonal.h +++ b/src/TNL/Matrices/Multidiagonal.h @@ -113,8 +113,10 @@ class Multidiagonal : public Matrix< Real, Device, Index, RealAllocator > template< typename Real_, typename Device_, typename Index_, bool RowMajorOrder_, typename RealAllocator_ > bool operator != ( const Multidiagonal< Real_, Device_, Index_, RowMajorOrder_, RealAllocator_ >& matrix ) const; + __cuda_callable__ RowView getRow( const IndexType& rowIdx ); + __cuda_callable__ const RowView getRow( const IndexType& rowIdx ) const; void setValue( const RealType& v ); diff --git a/src/TNL/Matrices/Multidiagonal.hpp b/src/TNL/Matrices/Multidiagonal.hpp index 5d83004f299ed6c65f00687131e1c73b669238c9..659d6d4ebe054bb67d705a76c3d43bbed98b8cf4 100644 --- a/src/TNL/Matrices/Multidiagonal.hpp +++ b/src/TNL/Matrices/Multidiagonal.hpp @@ -683,9 +683,7 @@ operator=( const Multidiagonal< Real_, Device_, Index_, RowMajorOrder_, RealAllo Containers::Vector< RealType, DeviceType, IndexType, RealAllocatorType > thisValuesBuffer( bufferSize ); Containers::Vector< IndexType, DeviceType, IndexType, IndexAllocatorType > thisColumnsBuffer( bufferSize ); auto matrixValuesBuffer_view = matrixValuesBuffer.getView(); - auto matrixColumnsBuffer_view = matrixColumnsBuffer.getView(); auto thisValuesBuffer_view = thisValuesBuffer.getView(); - auto thisColumnsBuffer_view = thisColumnsBuffer.getView(); IndexType baseRow( 0 ); const IndexType rowsCount = this->getRows(); @@ -716,6 +714,7 @@ operator=( const Multidiagonal< Real_, Device_, Index_, RowMajorOrder_, RealAllo } } } + return *this; } template< typename Real, diff --git a/src/TNL/Matrices/MultidiagonalMatrixView.h b/src/TNL/Matrices/MultidiagonalMatrixView.h index f623a3ca66fe7bd2761a242220047b416bcf2e1d..97ff94f85c6b81cb06b6832c1836ace71a7fdbbd 100644 --- a/src/TNL/Matrices/MultidiagonalMatrixView.h +++ b/src/TNL/Matrices/MultidiagonalMatrixView.h @@ -87,8 +87,10 @@ class MultidiagonalMatrixView : public MatrixView< Real, Device, Index > template< typename Real_, typename Device_, typename Index_, bool RowMajorOrder_ > bool operator != ( const MultidiagonalMatrixView< Real_, Device_, Index_, RowMajorOrder_ >& matrix ) const; + __cuda_callable__ RowView getRow( const IndexType& rowIdx ); + __cuda_callable__ const RowView getRow( const IndexType& rowIdx ) const; void setValue( const RealType& v ); diff --git a/src/TNL/Matrices/MultidiagonalMatrixView.hpp b/src/TNL/Matrices/MultidiagonalMatrixView.hpp index f35c6d713f17ef30944cdc4f7717847af594ebab..33010cebc817fb85f6612e1e64e331e913bfce9d 100644 --- a/src/TNL/Matrices/MultidiagonalMatrixView.hpp +++ b/src/TNL/Matrices/MultidiagonalMatrixView.hpp @@ -338,6 +338,7 @@ operator=( const MultidiagonalMatrixView& view ) this->diagonalsShifts.copy( view.diagonalsShifts ); this->hostDiagonalsShifts.copy( view.hostDiagonalsShifts ); this->indexer = view.indexer; + return *this; } template< typename Real, diff --git a/src/TNL/Matrices/SparseMatrix.h b/src/TNL/Matrices/SparseMatrix.h index 26d5d2d8406000a9071a6a9afb380d318908a789..9f91ee7d186764324e9a8d5e67eab729b48f008a 100644 --- a/src/TNL/Matrices/SparseMatrix.h +++ b/src/TNL/Matrices/SparseMatrix.h @@ -93,7 +93,7 @@ class SparseMatrix : public Matrix< Real, Device, Index, RealAllocator > void getCompressedRowLengths( Vector& rowLengths ) const; [[deprecated]] - virtual IndexType getRowLength( const IndexType row ) const {}; + virtual IndexType getRowLength( const IndexType row ) const { return 0;}; template< typename Matrix > void setLike( const Matrix& matrix ); diff --git a/src/TNL/Matrices/SparseMatrix.hpp b/src/TNL/Matrices/SparseMatrix.hpp index 447d8d250909423c88b607d15c9d8130cc6f0c98..cf4472922baa6a4b70d12611a181dd670f9f6aff 100644 --- a/src/TNL/Matrices/SparseMatrix.hpp +++ b/src/TNL/Matrices/SparseMatrix.hpp @@ -210,7 +210,7 @@ Index SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >:: getNumberOfNonzeroMatrixElements() const { - this->view.getNumberOfNonzeroMatrixElements(); + return this->view.getNumberOfNonzeroMatrixElements(); } template< typename Real, @@ -602,7 +602,6 @@ operator=( const Dense< Real_, Device_, Index_, RowMajorOrder, RealAllocator_ >& Containers::Vector< IndexType, DeviceType, IndexType, IndexAllocatorType > thisColumnsBuffer( bufferSize ); auto matrixValuesBuffer_view = matrixValuesBuffer.getView(); auto thisValuesBuffer_view = thisValuesBuffer.getView(); - auto thisColumnsBuffer_view = thisColumnsBuffer.getView(); IndexType baseRow( 0 ); const IndexType rowsCount = this->getRows(); @@ -689,11 +688,10 @@ operator=( const RHSMatrix& matrix ) auto rowLocalIndexes_view = rowLocalIndexes.getView(); columns_view = paddingIndex; - if( std::is_same< DeviceType, RHSDeviceType >::value ) + /*if( std::is_same< DeviceType, RHSDeviceType >::value ) { const auto segments_view = this->segments.getView(); auto f = [=] __cuda_callable__ ( RHSIndexType rowIdx, RHSIndexType localIdx_, RHSIndexType columnIndex, const RHSRealType& value, bool& compute ) mutable { - RealType inValue( 0.0 ); IndexType localIdx( rowLocalIndexes_view[ rowIdx ] ); if( value != 0.0 && columnIndex != paddingIndex ) { @@ -705,7 +703,7 @@ operator=( const RHSMatrix& matrix ) }; matrix.forAllRows( f ); } - else + else*/ { const IndexType maxRowLength = max( rowLengths ); const IndexType bufferRowsCount( 128 ); @@ -714,10 +712,13 @@ operator=( const RHSMatrix& matrix ) Containers::Vector< RHSIndexType, RHSDeviceType, RHSIndexType > matrixColumnsBuffer( bufferSize ); Containers::Vector< RealType, DeviceType, IndexType, RealAllocatorType > thisValuesBuffer( bufferSize ); Containers::Vector< IndexType, DeviceType, IndexType > thisColumnsBuffer( bufferSize ); + Containers::Vector< IndexType, DeviceType, IndexType > thisRowLengths; + thisRowLengths = rowLengths; auto matrixValuesBuffer_view = matrixValuesBuffer.getView(); auto matrixColumnsBuffer_view = matrixColumnsBuffer.getView(); auto thisValuesBuffer_view = thisValuesBuffer.getView(); auto thisColumnsBuffer_view = thisColumnsBuffer.getView(); + matrixValuesBuffer_view = 0.0; IndexType baseRow( 0 ); const IndexType rowsCount = this->getRows(); @@ -735,6 +736,7 @@ operator=( const RHSMatrix& matrix ) const IndexType bufferIdx = ( rowIdx - baseRow ) * maxRowLength + localIdx; matrixColumnsBuffer_view[ bufferIdx ] = columnIndex; matrixValuesBuffer_view[ bufferIdx ] = value; + //std::cerr << " <<<<< rowIdx = " << rowIdx << " localIdx = " << localIdx << " value = " << value << " bufferIdx = " << bufferIdx << std::endl; } }; matrix.forRows( baseRow, lastRow, f1 ); @@ -748,20 +750,20 @@ operator=( const RHSMatrix& matrix ) // Copy matrix elements from the buffer to the matrix and ignoring // zero matrix elements const IndexType matrix_columns = this->getColumns(); - auto matrix_view = matrix.getView(); - auto f2 = [=] __cuda_callable__ ( IndexType rowIdx, IndexType localIdx_, IndexType& columnIndex, RealType& value, bool& compute ) mutable { + const auto thisRowLengths_view = thisRowLengths.getConstView(); + auto f2 = [=] __cuda_callable__ ( IndexType rowIdx, IndexType localIdx, IndexType& columnIndex, RealType& value, bool& compute ) mutable { RealType inValue( 0.0 ); - IndexType bufferIdx, localIdx( rowLocalIndexes_view[ rowIdx ] ); - auto matrixRow = matrix_view.getRow( rowIdx ); - IndexType s = matrixRow.getSize(); - //printf( " row %d size %d \n", rowIdx, s ); - while( inValue == 0.0 && localIdx < 0 ) + size_t bufferIdx; + IndexType bufferLocalIdx( rowLocalIndexes_view[ rowIdx ] ); + while( inValue == 0.0 && localIdx < thisRowLengths_view[ rowIdx ] ) { - bufferIdx = ( rowIdx - baseRow ) * maxRowLength + localIdx++; + bufferIdx = ( rowIdx - baseRow ) * maxRowLength + bufferLocalIdx++; TNL_ASSERT_LT( bufferIdx, bufferSize, "" ); - //inValue = thisValuesBuffer_view[ bufferIdx ]; + inValue = thisValuesBuffer_view[ bufferIdx ]; } - /*rowLocalIndexes_view[ rowIdx ] = localIdx; + //std::cerr << "rowIdx = " << rowIdx << " localIdx = " << localIdx << " bufferLocalIdx = " << bufferLocalIdx + // << " inValue = " << inValue << " bufferIdx = " << bufferIdx << std::endl; + rowLocalIndexes_view[ rowIdx ] = bufferLocalIdx; if( inValue == 0.0 ) { columnIndex = paddingIndex; @@ -771,7 +773,7 @@ operator=( const RHSMatrix& matrix ) { columnIndex = thisColumnsBuffer_view[ bufferIdx ];//column - 1; value = inValue; - }*/ + } }; this->forRows( baseRow, lastRow, f2 ); baseRow += bufferRowsCount; diff --git a/src/TNL/Matrices/SparseMatrixView.hpp b/src/TNL/Matrices/SparseMatrixView.hpp index 965a51b8b6811ede34c7e957bf3299e12a1104b7..4ac0a29b8030b6fcb4d5dbefa34ca30f10510382 100644 --- a/src/TNL/Matrices/SparseMatrixView.hpp +++ b/src/TNL/Matrices/SparseMatrixView.hpp @@ -139,7 +139,7 @@ Index SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >:: getRowLength( const IndexType row ) const { - + return 0; } template< typename Real, @@ -525,6 +525,7 @@ operator=( const SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView MatrixView< Real, Device, Index >::operator=( matrix ); this->columnIndexes.copy( matrix.columnIndexes ); this->segments = matrix.segments; + return *this; } template< typename Real, diff --git a/src/TNL/Matrices/Tridiagonal.h b/src/TNL/Matrices/Tridiagonal.h index 3f89023106215aaf54d6cc2da5f50f66baa52b3c..6f0c6a548ef1de1ae925701e9af0d91ae5f1c1ca 100644 --- a/src/TNL/Matrices/Tridiagonal.h +++ b/src/TNL/Matrices/Tridiagonal.h @@ -91,8 +91,10 @@ class Tridiagonal : public Matrix< Real, Device, Index, RealAllocator > template< typename Real_, typename Device_, typename Index_, bool RowMajorOrder_, typename RealAllocator_ > bool operator != ( const Tridiagonal< Real_, Device_, Index_, RowMajorOrder_, RealAllocator_ >& matrix ) const; + __cuda_callable__ RowView getRow( const IndexType& rowIdx ); + __cuda_callable__ const RowView getRow( const IndexType& rowIdx ) const; void setValue( const RealType& v ); diff --git a/src/TNL/Matrices/Tridiagonal.hpp b/src/TNL/Matrices/Tridiagonal.hpp index d99715a47c2eb707f524adb6490cc229c38ffbe2..2ccdc4838f981f47b2f241507a65c127238c4e9d 100644 --- a/src/TNL/Matrices/Tridiagonal.hpp +++ b/src/TNL/Matrices/Tridiagonal.hpp @@ -592,6 +592,7 @@ operator=( const Tridiagonal< Real_, Device_, Index_, RowMajorOrder_, RealAlloca this->forAllRows( f ); } } + return *this; } template< typename Real, diff --git a/src/UnitTests/Containers/Segments/SegmentsTest.hpp b/src/UnitTests/Containers/Segments/SegmentsTest.hpp index 590b39881fbb859037433c4d919dd7550f43b462..6d4692dbe76785970d75bc7763216ad98f9b7be4 100644 --- a/src/UnitTests/Containers/Segments/SegmentsTest.hpp +++ b/src/UnitTests/Containers/Segments/SegmentsTest.hpp @@ -127,17 +127,12 @@ void test_AllReduction_MaximumInSegments() TNL::Containers::Vector< IndexType, DeviceType, IndexType > v( segments.getStorageSize() ); - /*IndexType k( 1 ); - for( IndexType i = 0; i < segmentsCount; i++ ) - for( IndexType j = 0; j < segmentSize; j++ ) - v.setElement( segments.getGlobalIndex( i, j ), k++ );*/ auto view = v.getView(); auto init = [=] __cuda_callable__ ( const IndexType segmentIdx, const IndexType localIdx, const IndexType globalIdx ) mutable -> bool { view[ globalIdx ] = segmentIdx * 5 + localIdx + 1; return true; }; segments.forAll( init ); - std::cerr << v << std::endl; TNL::Containers::Vector< IndexType, DeviceType, IndexType >result( segmentsCount ); diff --git a/src/UnitTests/Matrices/SparseMatrixCopyTest.h b/src/UnitTests/Matrices/SparseMatrixCopyTest.h index 46777f6c006373c63b257d193259d9d42ded5817..053f1e9fb5d0ee21214b42ae0d33f1fa028fa61e 100644 --- a/src/UnitTests/Matrices/SparseMatrixCopyTest.h +++ b/src/UnitTests/Matrices/SparseMatrixCopyTest.h @@ -458,6 +458,7 @@ void tridiagonalMatrixAssignment() RowCapacitiesType rowCapacities; matrix.getCompressedRowLengths( rowCapacities ); RowCapacitiesType exactRowLengths{ 1, 3, 3, 3, 3, 3, 3, 3, 3, 2 }; + EXPECT_EQ( rowCapacities, exactRowLengths ); for( IndexType i = 0; i < rows; i++ ) for( IndexType j = 0; j < columns; j++ ) @@ -510,6 +511,10 @@ void multidiagonalMatrixAssignment() RowCapacitiesType rowCapacities; matrix.getCompressedRowLengths( rowCapacities ); RowCapacitiesType exactRowLengths{ 3, 4, 5, 5, 6, 5, 5, 4, 4, 3 }; + /*std::cerr << "hostMatrix " << hostMatrix << std::endl; + std::cerr << "matrix " << matrix << std::endl; + std::cerr << "rowCapacities " << rowCapacities << std::endl;*/ + EXPECT_EQ( rowCapacities, exactRowLengths ); for( IndexType i = 0; i < rows; i++ ) for( IndexType j = 0; j < columns; j++ )