diff --git a/src/Benchmarks/SpMV/spmv.h b/src/Benchmarks/SpMV/spmv.h index e3a1ae047ee137980f18da8f0e790d7f1ad0a452..02a26854dc06a5ad0de8230a6f351d24a2526975 100644 --- a/src/Benchmarks/SpMV/spmv.h +++ b/src/Benchmarks/SpMV/spmv.h @@ -25,6 +25,7 @@ #include <TNL/Matrices/Legacy/BiEllpack.h> #include <TNL/Matrices/MatrixReader.h> +#include <TNL/Matrices/MatrixInfo.h> #include <TNL/Matrices/SparseMatrix.h> #include <TNL/Matrices/MatrixType.h> @@ -160,7 +161,7 @@ benchmarkSpMV( Benchmark& benchmark, { "non-zeros", convertToString( hostMatrix.getNumberOfNonzeroMatrixElements() ) }, { "rows", convertToString( hostMatrix.getRows() ) }, { "columns", convertToString( hostMatrix.getColumns() ) }, - { "matrix format", convertToString( getType( hostMatrix ) ) } + { "matrix format", MatrixInfo< HostMatrix >::getFormat() } //convertToString( getType( hostMatrix ) ) } } )); hostVector.setSize( hostMatrix.getColumns() ); @@ -294,7 +295,8 @@ benchmarkSpmvSynthetic( Benchmark& benchmark, benchmarkSpMV< Real, SlicedEllpackAlias >( benchmark, inputFileName, verboseMR ); benchmarkSpMV< Real, SparseMatrix_SlicedEllpack >( benchmark, inputFileName, verboseMR ); - //benchmarkSpMV< Real, Matrices::ChunkedEllpack >( benchmark, inputFileName, verboseMR ); + benchmarkSpMV< Real, Matrices::ChunkedEllpack >( benchmark, inputFileName, verboseMR ); + benchmarkSpMV< Real, Matrices::BiEllpack >( benchmark, inputFileName, verboseMR ); //// // Segments based sparse matrices diff --git a/src/TNL/Containers/Segments/CSR.h b/src/TNL/Containers/Segments/CSR.h index 3645e9f6a1964ed3a68f8d93ebf48c85d1c98582..89cad0c6af3d80d9b9b78d336f4dfb95ff69cfc6 100644 --- a/src/TNL/Containers/Segments/CSR.h +++ b/src/TNL/Containers/Segments/CSR.h @@ -47,6 +47,8 @@ class CSR static String getSerializationType(); + static String getSegmentsType(); + /** * \brief Set sizes of particular segments. */ diff --git a/src/TNL/Containers/Segments/CSR.hpp b/src/TNL/Containers/Segments/CSR.hpp index 55dcba74c9ac9cb83a736abc6eecacc621091e0c..9a948b04e2dac7311c6eab9f4149cf779256c59f 100644 --- a/src/TNL/Containers/Segments/CSR.hpp +++ b/src/TNL/Containers/Segments/CSR.hpp @@ -64,6 +64,16 @@ getSerializationType() return "CSR< [any_device], " + TNL::getSerializationType< IndexType >() + " >"; } +template< typename Device, + typename Index, + typename IndexAllocator > +String +CSR< Device, Index, IndexAllocator >:: +getSegmentsType() +{ + return ViewType::getSegmentsType(); +} + template< typename Device, typename Index, typename IndexAllocator > diff --git a/src/TNL/Containers/Segments/CSRView.h b/src/TNL/Containers/Segments/CSRView.h index 759fe8ff7f31364d6567bce3a2fca22c4ee937d1..f7cf815d04eb87e411cd213e0b0ca659c60bbb6c 100644 --- a/src/TNL/Containers/Segments/CSRView.h +++ b/src/TNL/Containers/Segments/CSRView.h @@ -52,6 +52,8 @@ class CSRView static String getSerializationType(); + static String getSegmentsType(); + __cuda_callable__ ViewType getView(); diff --git a/src/TNL/Containers/Segments/CSRView.hpp b/src/TNL/Containers/Segments/CSRView.hpp index 043e06e04ee305bafab795c45665cb7211487def..fab5c6da720b17b558d302efb0b8c8c1b87ea6b5 100644 --- a/src/TNL/Containers/Segments/CSRView.hpp +++ b/src/TNL/Containers/Segments/CSRView.hpp @@ -64,6 +64,15 @@ getSerializationType() return "CSR< [any_device], " + TNL::getSerializationType< IndexType >() + " >"; } +template< typename Device, + typename Index > +String +CSRView< Device, Index >:: +getSegmentsType() +{ + return "CSR"; +} + template< typename Device, typename Index > __cuda_callable__ diff --git a/src/TNL/Containers/Segments/Ellpack.h b/src/TNL/Containers/Segments/Ellpack.h index 6edacb1cff9718cba91916e6de2ad3798b3143e0..a1188a854e952f15f1f2449cc33c9535ccfac10a 100644 --- a/src/TNL/Containers/Segments/Ellpack.h +++ b/src/TNL/Containers/Segments/Ellpack.h @@ -39,7 +39,6 @@ class Ellpack //using ConstViewType = EllpackView< Device, std::add_const_t< Index >, RowMajorOrder, Alignment >; using SegmentViewType = SegmentView< IndexType, RowMajorOrder >; - Ellpack(); Ellpack( const SegmentsSizes& sizes ); @@ -52,6 +51,8 @@ class Ellpack static String getSerializationType(); + static String getSegmentsType(); + ViewType getView(); //ConstViewType getConstView() const; diff --git a/src/TNL/Containers/Segments/Ellpack.hpp b/src/TNL/Containers/Segments/Ellpack.hpp index 663a65bc80f853adf18a50bb2ebdf47a2c31987a..9c59c5529eada436df075bd130ddaa16f0ef20ea 100644 --- a/src/TNL/Containers/Segments/Ellpack.hpp +++ b/src/TNL/Containers/Segments/Ellpack.hpp @@ -88,6 +88,18 @@ getSerializationType() return "Ellpack< [any_device], " + TNL::getSerializationType< IndexType >() + " >"; } +template< typename Device, + typename Index, + typename IndexAllocator, + bool RowMajorOrder, + int Alignment > +String +Ellpack< Device, Index, IndexAllocator, RowMajorOrder, Alignment >:: +getSegmentsType() +{ + return ViewType::getSegmentsType(); +} + template< typename Device, typename Index, typename IndexAllocator, diff --git a/src/TNL/Containers/Segments/EllpackView.h b/src/TNL/Containers/Segments/EllpackView.h index dcbc56d1bad782f98c2c84ccac35310a45312465..10a89bd7bafd7de62a8e5f37f567478a3d4af1ee 100644 --- a/src/TNL/Containers/Segments/EllpackView.h +++ b/src/TNL/Containers/Segments/EllpackView.h @@ -54,6 +54,8 @@ class EllpackView static String getSerializationType(); + static String getSegmentsType(); + __cuda_callable__ ViewType getView(); diff --git a/src/TNL/Containers/Segments/EllpackView.hpp b/src/TNL/Containers/Segments/EllpackView.hpp index ea2dc0d216ed084707a1a2b8dc573a7098db417c..84086f380bfb12ac86113f82a76e40db1fbabdef 100644 --- a/src/TNL/Containers/Segments/EllpackView.hpp +++ b/src/TNL/Containers/Segments/EllpackView.hpp @@ -74,6 +74,17 @@ getSerializationType() return "Ellpack< [any_device], " + TNL::getSerializationType< IndexType >() + " >"; } +template< typename Device, + typename Index, + bool RowMajorOrder, + int Alignment > +String +EllpackView< Device, Index, RowMajorOrder, Alignment >:: +getSegmentsType() +{ + return "Ellpack"; +} + template< typename Device, typename Index, bool RowMajorOrder, diff --git a/src/TNL/Containers/Segments/SlicedEllpack.h b/src/TNL/Containers/Segments/SlicedEllpack.h index e1cdfa1d4d688a7783569a7296b8293760e854b0..2027f1d78a96d685806f2715257098a38a624800 100644 --- a/src/TNL/Containers/Segments/SlicedEllpack.h +++ b/src/TNL/Containers/Segments/SlicedEllpack.h @@ -49,6 +49,8 @@ class SlicedEllpack static String getSerializationType(); + static String getSegmentsType(); + ViewType getView(); ConstViewType getConstView() const; diff --git a/src/TNL/Containers/Segments/SlicedEllpack.hpp b/src/TNL/Containers/Segments/SlicedEllpack.hpp index 3d3a6d8c3d044f9ac6a8a4d9bfb2a947fb4e5844..9ba1276e3eaea3fdf39261c99e7376c6122d4f8b 100644 --- a/src/TNL/Containers/Segments/SlicedEllpack.hpp +++ b/src/TNL/Containers/Segments/SlicedEllpack.hpp @@ -81,6 +81,18 @@ getSerializationType() return "SlicedEllpack< [any_device], " + TNL::getSerializationType< IndexType >() + " >"; } +template< typename Device, + typename Index, + typename IndexAllocator, + bool RowMajorOrder, + int SliceSize > +String +SlicedEllpack< Device, Index, IndexAllocator, RowMajorOrder, SliceSize >:: +getSegmentsType() +{ + return ViewType::getSegmentsType(); +} + template< typename Device, typename Index, typename IndexAllocator, diff --git a/src/TNL/Containers/Segments/SlicedEllpackView.h b/src/TNL/Containers/Segments/SlicedEllpackView.h index 23001553c6cd567aebc908705095119efedf8ac9..6e2e55bbc3ef040c9b15f42a41b7e0a4bc14f7d7 100644 --- a/src/TNL/Containers/Segments/SlicedEllpackView.h +++ b/src/TNL/Containers/Segments/SlicedEllpackView.h @@ -56,6 +56,8 @@ class SlicedEllpackView static String getSerializationType(); + static String getSegmentsType(); + __cuda_callable__ ViewType getView(); diff --git a/src/TNL/Containers/Segments/SlicedEllpackView.hpp b/src/TNL/Containers/Segments/SlicedEllpackView.hpp index 3e3c8c09c2ef62cfa98409d01c31005f49090f38..f9e252fd933d583182964ddf553f72ff980e9df6 100644 --- a/src/TNL/Containers/Segments/SlicedEllpackView.hpp +++ b/src/TNL/Containers/Segments/SlicedEllpackView.hpp @@ -85,6 +85,17 @@ getSerializationType() return "SlicedEllpack< [any_device], " + TNL::getSerializationType< IndexType >() + " >"; } +template< typename Device, + typename Index, + bool RowMajorOrder, + int SliceSize > +String +SlicedEllpackView< Device, Index, RowMajorOrder, SliceSize >:: +getSegmentsType() +{ + return "SlicedEllpack"; +} + template< typename Device, typename Index, bool RowMajorOrder, diff --git a/src/TNL/Matrices/MatrixInfo.h b/src/TNL/Matrices/MatrixInfo.h index 34f85dd82d03b6827a8ccd7f0bc17efffa286008..75cac40557058db2c41b06ca334787e8eb5f356f 100644 --- a/src/TNL/Matrices/MatrixInfo.h +++ b/src/TNL/Matrices/MatrixInfo.h @@ -12,9 +12,17 @@ #include <TNL/String.h> #include <TNL/Matrices/Dense.h> -#include <TNL/Matrices/DenseView.h> +#include <TNL/Matrices/DenseMatrixView.h> #include <TNL/Matrices/SparseMatrix.h> #include <TNL/Matrices/SparseMatrixView.h> +#include <TNL/Containers/Segments/CSRView.h> +#include <TNL/Containers/Segments/EllpackView.h> +#include <TNL/Containers/Segments/SlicedEllpackView.h> +#include <TNL/Matrices/Legacy/CSR.h> +#include <TNL/Matrices/Legacy/Ellpack.h> +#include <TNL/Matrices/Legacy/SlicedEllpack.h> +#include <TNL/Matrices/Legacy/ChunkedEllpack.h> +#include <TNL/Matrices/Legacy/BiEllpack.h> namespace TNL { /** @@ -30,7 +38,7 @@ template< typename Real, typename Device, typename Index, bool RowMajorOrder > -struct MatrixInfo< DenseView< Real, Device, RowMajorOrder > > +struct MatrixInfo< DenseMatrixView< Real, Device, Index, RowMajorOrder > > { static String getDensity() { return String( "dense" ); }; }; @@ -40,12 +48,11 @@ template< typename Real, typename Index, bool RowMajorOrder, typename RealAllocator > -struct MatrixInfo< Dense< Real, Device, RowMajorOrder, RealAllocator > > -: public MatrixInfo< typename Dense< Real, Device, RowMajorOrder, RealAllocator >::ViewType > +struct MatrixInfo< Dense< Real, Device, Index, RowMajorOrder, RealAllocator > > +: public MatrixInfo< typename Dense< Real, Device, Index, RowMajorOrder, RealAllocator >::ViewType > { }; - template< typename Real, typename Device, typename Index, @@ -55,9 +62,7 @@ struct MatrixInfo< SparseMatrixView< Real, Device, Index, MatrixType, SegmentsVi { static String getDensity() { return String( "sparse" ); }; - static String getFormat() { - if( std::is_same< SegementsView ........ >) - }; + static String getFormat() { return SegmentsView< Device, Index >::getSegmentsType(); }; }; template< typename Real, @@ -68,9 +73,51 @@ template< typename Real, typename RealAllocator, typename IndexAllocator > struct MatrixInfo< SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator > > -:public MatrixInfo< typename SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::ViewType > +: public MatrixInfo< typename SparseMatrix< Real, Device, Index, MatrixType, Segments, RealAllocator, IndexAllocator >::ViewType > +{ +}; + +///// +// Legacy matrices +template< typename Real, typename Device, typename Index > +struct MatrixInfo< BiEllpack< Real, Device, Index > > +{ + static String getDensity() { return String( "sparse" ); }; + + static String getFormat() { return "BiEllpack Legacy"; }; +}; + +template< typename Real, typename Device, typename Index > +struct MatrixInfo< CSR< Real, Device, Index > > +{ + static String getDensity() { return String( "sparse" ); }; + + static String getFormat() { return "CSR Legacy"; }; +}; + +template< typename Real, typename Device, typename Index > +struct MatrixInfo< ChunkedEllpack< Real, Device, Index > > { -} + static String getDensity() { return String( "sparse" ); }; + + static String getFormat() { return "ChunkedEllpack Legacy"; }; +}; + +template< typename Real, typename Device, typename Index > +struct MatrixInfo< Ellpack< Real, Device, Index > > +{ + static String getDensity() { return String( "sparse" ); }; + + static String getFormat() { return "Ellpack Legacy"; }; +}; + +template< typename Real, typename Device, typename Index, int SliceSize > +struct MatrixInfo< SlicedEllpack< Real, Device, Index, SliceSize> > +{ + static String getDensity() { return String( "sparse" ); }; + + static String getFormat() { return "SlicedEllpack Legacy"; }; +}; } //namespace Matrices -} //namespace TNL \ No newline at end of file +} //namespace TNL