Loading src/TNL/Matrices/CSR.h +19 −3 Original line number Diff line number Diff line Loading @@ -30,6 +30,15 @@ class CSRDeviceDependentCode; template< typename Real, typename Device = Devices::Host, typename Index = int > class CSR : public Sparse< Real, Device, Index > { private: // convenient template alias for controlling the selection of copy-assignment operator template< typename Device2 > using Enabler = std::enable_if< ! std::is_same< Device2, Device >::value >; // friend class will be needed for templated assignment operators template< typename Real2, typename Device2, typename Index2 > friend class CSR; public: typedef Real RealType; Loading Loading @@ -161,6 +170,14 @@ class CSR : public Sparse< Real, Device, Index > Vector& x, const RealType& omega = 1.0 ) const; // copy assignment CSR& operator=( const CSR& matrix ); // cross-device copy assignment template< typename Real2, typename Device2, typename Index2, typename = typename Enabler< Device2 >::type > CSR& operator=( const CSR< Real2, Device2, Index2 >& matrix ); bool save( File& file ) const; bool load( File& file ); Loading Loading @@ -255,4 +272,3 @@ class CSR : public Sparse< Real, Device, Index > } // namespace TNL #include <TNL/Matrices/CSR_impl.h> src/TNL/Matrices/CSR_impl.h +31 −1 Original line number Diff line number Diff line Loading @@ -290,7 +290,7 @@ bool CSR< Real, Device, Index > :: setRowFast( const IndexType row, for( IndexType i = 0; i < elements; i++ ) { printf( "Setting element row: %d column: %d value: %f \n", row, columnIndexes[ i ], values[ i ] ); //printf( "Setting element row: %d column: %d value: %f \n", row, columnIndexes[ i ], values[ i ] ); this->columnIndexes[ elementPointer ] = columnIndexes[ i ]; this->values[ elementPointer ] = values[ i ]; elementPointer++; Loading Loading @@ -527,6 +527,36 @@ bool CSR< Real, Device, Index >::performSORIteration( const Vector& b, } // copy assignment template< typename Real, typename Device, typename Index > CSR< Real, Device, Index >& CSR< Real, Device, Index >::operator=( const CSR& matrix ) { this->setLike( matrix ); this->values = matrix.values; this->columnIndexes = matrix.columnIndexes; this->rowPointers = matrix.rowPointers; return *this; } // cross-device copy assignment template< typename Real, typename Device, typename Index > template< typename Real2, typename Device2, typename Index2, typename > CSR< Real, Device, Index >& CSR< Real, Device, Index >::operator=( const CSR< Real2, Device2, Index2 >& matrix ) { this->setLike( matrix ); this->values = matrix.values; this->columnIndexes = matrix.columnIndexes; this->rowPointers = matrix.rowPointers; return *this; } template< typename Real, typename Device, typename Index > Loading src/TNL/Matrices/ChunkedEllpack.h +18 −3 Original line number Diff line number Diff line Loading @@ -62,8 +62,16 @@ __global__ void ChunkedEllpackVectorProductCudaKernel( const ChunkedEllpack< Rea template< typename Real, typename Device, typename Index > class ChunkedEllpack : public Sparse< Real, Device, Index > { public: private: // convenient template alias for controlling the selection of copy-assignment operator template< typename Device2 > using Enabler = std::enable_if< ! std::is_same< Device2, Device >::value >; // friend class will be needed for templated assignment operators template< typename Real2, typename Device2, typename Index2 > friend class ChunkedEllpack; public: typedef Real RealType; typedef Device DeviceType; typedef Index IndexType; Loading Loading @@ -221,6 +229,14 @@ class ChunkedEllpack : public Sparse< Real, Device, Index > Vector& x, const RealType& omega = 1.0 ) const; // copy assignment ChunkedEllpack& operator=( const ChunkedEllpack& matrix ); // cross-device copy assignment template< typename Real2, typename Device2, typename Index2, typename = typename Enabler< Device2 >::type > ChunkedEllpack& operator=( const ChunkedEllpack< Real2, Device2, Index2 >& matrix ); bool save( File& file ) const; bool load( File& file ); Loading @@ -236,7 +252,6 @@ class ChunkedEllpack : public Sparse< Real, Device, Index > protected: void resolveSliceSizes( const Containers::Vector< Index, Devices::Host, Index >& rowLengths ); bool setSlice( const CompressedRowLengthsVector& rowLengths, Loading src/TNL/Matrices/ChunkedEllpack_impl.h +40 −0 Original line number Diff line number Diff line Loading @@ -1190,6 +1190,46 @@ bool ChunkedEllpack< Real, Device, Index >::performSORIteration( const Vector& b } // copy assignment template< typename Real, typename Device, typename Index > ChunkedEllpack< Real, Device, Index >& ChunkedEllpack< Real, Device, Index >::operator=( const ChunkedEllpack& matrix ) { this->setLike( matrix ); this->values = matrix.values; this->columnIndexes = matrix.columnIndexes; this->chunksInSlice = matrix.chunksInSlice; this->desiredChunkSize = matrix.desiredChunkSize; this->rowToChunkMapping = matrix.rowToChunkMapping; this->rowToSliceMapping = matrix.rowToSliceMapping; this->rowPointers = matrix.rowPointers; this->slices = matrix.slices; this->numberOfSlices = matrix.numberOfSlices; return *this; } // cross-device copy assignment template< typename Real, typename Device, typename Index > template< typename Real2, typename Device2, typename Index2, typename > ChunkedEllpack< Real, Device, Index >& ChunkedEllpack< Real, Device, Index >::operator=( const ChunkedEllpack< Real2, Device2, Index2 >& matrix ) { static_assert( std::is_same< Device, Devices::Host >::value || std::is_same< Device, Devices::Cuda >::value, "unknown device" ); static_assert( std::is_same< Device2, Devices::Host >::value || std::is_same< Device2, Devices::Cuda >::value, "unknown device" ); this->setLike( matrix ); std::cerr << "Cross-device assignment for the ChunkedEllpack format is not implemented yet." << std::endl; throw 1; } template< typename Real, typename Device, typename Index > Loading src/TNL/Matrices/Dense.h +18 −4 Original line number Diff line number Diff line Loading @@ -26,8 +26,16 @@ template< typename Real = double, typename Index = int > class Dense : public Matrix< Real, Device, Index > { public: private: // convenient template alias for controlling the selection of copy-assignment operator template< typename Device2 > using Enabler = std::enable_if< ! std::is_same< Device2, Device >::value >; // friend class will be needed for templated assignment operators template< typename Real2, typename Device2, typename Index2 > friend class Dense; public: typedef Real RealType; typedef Device DeviceType; typedef Index IndexType; Loading Loading @@ -175,6 +183,14 @@ class Dense : public Matrix< Real, Device, Index > Vector& x, const RealType& omega = 1.0 ) const; // copy assignment Dense& operator=( const Dense& matrix ); // cross-device copy assignment template< typename Real2, typename Device2, typename Index2, typename = typename Enabler< Device2 >::type > Dense& operator=( const Dense< Real2, Device2, Index2 >& matrix ); bool save( const String& fileName ) const; bool load( const String& fileName ); Loading @@ -193,11 +209,9 @@ class Dense : public Matrix< Real, Device, Index > typedef DenseDeviceDependentCode< DeviceType > DeviceDependentCode; friend class DenseDeviceDependentCode< DeviceType >; }; } // namespace Matrices } // namespace TNL #include <TNL/Matrices/Dense_impl.h> Loading
src/TNL/Matrices/CSR.h +19 −3 Original line number Diff line number Diff line Loading @@ -30,6 +30,15 @@ class CSRDeviceDependentCode; template< typename Real, typename Device = Devices::Host, typename Index = int > class CSR : public Sparse< Real, Device, Index > { private: // convenient template alias for controlling the selection of copy-assignment operator template< typename Device2 > using Enabler = std::enable_if< ! std::is_same< Device2, Device >::value >; // friend class will be needed for templated assignment operators template< typename Real2, typename Device2, typename Index2 > friend class CSR; public: typedef Real RealType; Loading Loading @@ -161,6 +170,14 @@ class CSR : public Sparse< Real, Device, Index > Vector& x, const RealType& omega = 1.0 ) const; // copy assignment CSR& operator=( const CSR& matrix ); // cross-device copy assignment template< typename Real2, typename Device2, typename Index2, typename = typename Enabler< Device2 >::type > CSR& operator=( const CSR< Real2, Device2, Index2 >& matrix ); bool save( File& file ) const; bool load( File& file ); Loading Loading @@ -255,4 +272,3 @@ class CSR : public Sparse< Real, Device, Index > } // namespace TNL #include <TNL/Matrices/CSR_impl.h>
src/TNL/Matrices/CSR_impl.h +31 −1 Original line number Diff line number Diff line Loading @@ -290,7 +290,7 @@ bool CSR< Real, Device, Index > :: setRowFast( const IndexType row, for( IndexType i = 0; i < elements; i++ ) { printf( "Setting element row: %d column: %d value: %f \n", row, columnIndexes[ i ], values[ i ] ); //printf( "Setting element row: %d column: %d value: %f \n", row, columnIndexes[ i ], values[ i ] ); this->columnIndexes[ elementPointer ] = columnIndexes[ i ]; this->values[ elementPointer ] = values[ i ]; elementPointer++; Loading Loading @@ -527,6 +527,36 @@ bool CSR< Real, Device, Index >::performSORIteration( const Vector& b, } // copy assignment template< typename Real, typename Device, typename Index > CSR< Real, Device, Index >& CSR< Real, Device, Index >::operator=( const CSR& matrix ) { this->setLike( matrix ); this->values = matrix.values; this->columnIndexes = matrix.columnIndexes; this->rowPointers = matrix.rowPointers; return *this; } // cross-device copy assignment template< typename Real, typename Device, typename Index > template< typename Real2, typename Device2, typename Index2, typename > CSR< Real, Device, Index >& CSR< Real, Device, Index >::operator=( const CSR< Real2, Device2, Index2 >& matrix ) { this->setLike( matrix ); this->values = matrix.values; this->columnIndexes = matrix.columnIndexes; this->rowPointers = matrix.rowPointers; return *this; } template< typename Real, typename Device, typename Index > Loading
src/TNL/Matrices/ChunkedEllpack.h +18 −3 Original line number Diff line number Diff line Loading @@ -62,8 +62,16 @@ __global__ void ChunkedEllpackVectorProductCudaKernel( const ChunkedEllpack< Rea template< typename Real, typename Device, typename Index > class ChunkedEllpack : public Sparse< Real, Device, Index > { public: private: // convenient template alias for controlling the selection of copy-assignment operator template< typename Device2 > using Enabler = std::enable_if< ! std::is_same< Device2, Device >::value >; // friend class will be needed for templated assignment operators template< typename Real2, typename Device2, typename Index2 > friend class ChunkedEllpack; public: typedef Real RealType; typedef Device DeviceType; typedef Index IndexType; Loading Loading @@ -221,6 +229,14 @@ class ChunkedEllpack : public Sparse< Real, Device, Index > Vector& x, const RealType& omega = 1.0 ) const; // copy assignment ChunkedEllpack& operator=( const ChunkedEllpack& matrix ); // cross-device copy assignment template< typename Real2, typename Device2, typename Index2, typename = typename Enabler< Device2 >::type > ChunkedEllpack& operator=( const ChunkedEllpack< Real2, Device2, Index2 >& matrix ); bool save( File& file ) const; bool load( File& file ); Loading @@ -236,7 +252,6 @@ class ChunkedEllpack : public Sparse< Real, Device, Index > protected: void resolveSliceSizes( const Containers::Vector< Index, Devices::Host, Index >& rowLengths ); bool setSlice( const CompressedRowLengthsVector& rowLengths, Loading
src/TNL/Matrices/ChunkedEllpack_impl.h +40 −0 Original line number Diff line number Diff line Loading @@ -1190,6 +1190,46 @@ bool ChunkedEllpack< Real, Device, Index >::performSORIteration( const Vector& b } // copy assignment template< typename Real, typename Device, typename Index > ChunkedEllpack< Real, Device, Index >& ChunkedEllpack< Real, Device, Index >::operator=( const ChunkedEllpack& matrix ) { this->setLike( matrix ); this->values = matrix.values; this->columnIndexes = matrix.columnIndexes; this->chunksInSlice = matrix.chunksInSlice; this->desiredChunkSize = matrix.desiredChunkSize; this->rowToChunkMapping = matrix.rowToChunkMapping; this->rowToSliceMapping = matrix.rowToSliceMapping; this->rowPointers = matrix.rowPointers; this->slices = matrix.slices; this->numberOfSlices = matrix.numberOfSlices; return *this; } // cross-device copy assignment template< typename Real, typename Device, typename Index > template< typename Real2, typename Device2, typename Index2, typename > ChunkedEllpack< Real, Device, Index >& ChunkedEllpack< Real, Device, Index >::operator=( const ChunkedEllpack< Real2, Device2, Index2 >& matrix ) { static_assert( std::is_same< Device, Devices::Host >::value || std::is_same< Device, Devices::Cuda >::value, "unknown device" ); static_assert( std::is_same< Device2, Devices::Host >::value || std::is_same< Device2, Devices::Cuda >::value, "unknown device" ); this->setLike( matrix ); std::cerr << "Cross-device assignment for the ChunkedEllpack format is not implemented yet." << std::endl; throw 1; } template< typename Real, typename Device, typename Index > Loading
src/TNL/Matrices/Dense.h +18 −4 Original line number Diff line number Diff line Loading @@ -26,8 +26,16 @@ template< typename Real = double, typename Index = int > class Dense : public Matrix< Real, Device, Index > { public: private: // convenient template alias for controlling the selection of copy-assignment operator template< typename Device2 > using Enabler = std::enable_if< ! std::is_same< Device2, Device >::value >; // friend class will be needed for templated assignment operators template< typename Real2, typename Device2, typename Index2 > friend class Dense; public: typedef Real RealType; typedef Device DeviceType; typedef Index IndexType; Loading Loading @@ -175,6 +183,14 @@ class Dense : public Matrix< Real, Device, Index > Vector& x, const RealType& omega = 1.0 ) const; // copy assignment Dense& operator=( const Dense& matrix ); // cross-device copy assignment template< typename Real2, typename Device2, typename Index2, typename = typename Enabler< Device2 >::type > Dense& operator=( const Dense< Real2, Device2, Index2 >& matrix ); bool save( const String& fileName ) const; bool load( const String& fileName ); Loading @@ -193,11 +209,9 @@ class Dense : public Matrix< Real, Device, Index > typedef DenseDeviceDependentCode< DeviceType > DeviceDependentCode; friend class DenseDeviceDependentCode< DeviceType >; }; } // namespace Matrices } // namespace TNL #include <TNL/Matrices/Dense_impl.h>