From ea2f21c171bf309bf75e93e7ef92b210bd60bbcb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Oberhuber?= <oberhuber.tomas@gmail.com>
Date: Sat, 30 Jan 2021 13:25:05 +0100
Subject: [PATCH] Split of legacy CSR sparse matrix unit tests.

---
 .gitignore                                    |   1 +
 src/UnitTests/Matrices/Legacy/CMakeLists.txt  |   7 +-
 .../Legacy/Legacy_SparseMatrixTest_CSR.cpp    |   1 -
 .../Legacy/Legacy_SparseMatrixTest_CSR.cu     |   1 -
 .../Legacy_SparseMatrixTest_CSRAdaptive.cpp   |  12 ++
 .../Legacy_SparseMatrixTest_CSRAdaptive.cu    |  11 ++
 .../Legacy_SparseMatrixTest_CSRAdaptive.h     | 123 ++++++++++++++++++
 .../Legacy_SparseMatrixTest_CSRLight.cpp      |  12 ++
 .../Legacy_SparseMatrixTest_CSRLight.cu       |  11 ++
 .../Legacy/Legacy_SparseMatrixTest_CSRLight.h | 123 ++++++++++++++++++
 ...SparseMatrixTest_CSRLightWithoutAtomic.cpp |  11 ++
 ..._SparseMatrixTest_CSRLightWithoutAtomic.cu |  11 ++
 ...y_SparseMatrixTest_CSRLightWithoutAtomic.h | 123 ++++++++++++++++++
 ...Legacy_SparseMatrixTest_CSRMultiVector.cpp |  11 ++
 .../Legacy_SparseMatrixTest_CSRMultiVector.cu |  11 ++
 .../Legacy_SparseMatrixTest_CSRMultiVector.h  | 123 ++++++++++++++++++
 .../Legacy_SparseMatrixTest_CSRScalar.cpp     |  11 ++
 .../Legacy_SparseMatrixTest_CSRScalar.cu      |  11 ++
 ....h => Legacy_SparseMatrixTest_CSRScalar.h} |  50 +------
 .../Legacy_SparseMatrixTest_CSRVector.cpp     |  11 ++
 .../Legacy_SparseMatrixTest_CSRVector.cu      |  11 ++
 .../Legacy_SparseMatrixTest_CSRVector.h       | 123 ++++++++++++++++++
 22 files changed, 759 insertions(+), 50 deletions(-)
 delete mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSR.cpp
 delete mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSR.cu
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRAdaptive.cpp
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRAdaptive.cu
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRAdaptive.h
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLight.cpp
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLight.cu
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLight.h
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLightWithoutAtomic.cpp
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLightWithoutAtomic.cu
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLightWithoutAtomic.h
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRMultiVector.cpp
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRMultiVector.cu
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRMultiVector.h
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRScalar.cpp
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRScalar.cu
 rename src/UnitTests/Matrices/Legacy/{Legacy_SparseMatrixTest_CSR.h => Legacy_SparseMatrixTest_CSRScalar.h} (53%)
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRVector.cpp
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRVector.cu
 create mode 100644 src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRVector.h

diff --git a/.gitignore b/.gitignore
index 15a758dbdd..d22aa829ed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@
 
 # VSCode
 /.vscode
+.gdb_history
diff --git a/src/UnitTests/Matrices/Legacy/CMakeLists.txt b/src/UnitTests/Matrices/Legacy/CMakeLists.txt
index a5a425295a..0decf44e25 100644
--- a/src/UnitTests/Matrices/Legacy/CMakeLists.txt
+++ b/src/UnitTests/Matrices/Legacy/CMakeLists.txt
@@ -5,7 +5,12 @@ set( COMMON_TESTS
             #SparseMatrixTest_AdEllpack
             Legacy_SparseMatrixTest_BiEllpack
             Legacy_SparseMatrixTest_ChunkedEllpack
-            Legacy_SparseMatrixTest_CSR
+            Legacy_SparseMatrixTest_CSRScalar
+            Legacy_SparseMatrixTest_CSRVector
+            Legacy_SparseMatrixTest_CSRMultiVector
+            Legacy_SparseMatrixTest_CSRLight
+            Legacy_SparseMatrixTest_CSRLightWithoutAtomic
+            Legacy_SparseMatrixTest_CSRAdaptive
             Legacy_SparseMatrixTest_Ellpack
             Legacy_SparseMatrixTest_SlicedEllpack
 )
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSR.cpp b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSR.cpp
deleted file mode 100644
index 981914b3be..0000000000
--- a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSR.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "Legacy_SparseMatrixTest_CSR.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSR.cu b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSR.cu
deleted file mode 100644
index 981914b3be..0000000000
--- a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSR.cu
+++ /dev/null
@@ -1 +0,0 @@
-#include "Legacy_SparseMatrixTest_CSR.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRAdaptive.cpp b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRAdaptive.cpp
new file mode 100644
index 0000000000..5dec3baadb
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRAdaptive.cpp
@@ -0,0 +1,12 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRAdaptive.cpp -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+
+#include "Legacy_SparseMatrixTest_CSRAdaptive.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRAdaptive.cu b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRAdaptive.cu
new file mode 100644
index 0000000000..b99a7406d3
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRAdaptive.cu
@@ -0,0 +1,11 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRAdaptive.cu -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include "Legacy_SparseMatrixTest_CSRAdaptive.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRAdaptive.h b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRAdaptive.h
new file mode 100644
index 0000000000..5a245390d5
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRAdaptive.h
@@ -0,0 +1,123 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRAdaptive.h -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include <Benchmarks/SpMV/ReferenceFormats/Legacy/CSR.h>
+
+#include "Legacy_SparseMatrixTest.hpp"
+#include <iostream>
+
+#ifdef HAVE_GTEST
+#include <gtest/gtest.h>
+
+// test fixture for typed tests
+template< typename Matrix >
+class CSRMatrixTest : public ::testing::Test
+{
+protected:
+   using CSRMatrixType = Matrix;
+};
+
+using namespace TNL::Benchmarks::SpMV::ReferenceFormats;
+
+// types for which MatrixTest is instantiated
+using CSRMatrixTypes = ::testing::Types
+<
+#ifdef HAVE_CUDA
+   Legacy::CSR< int,    TNL::Devices::Cuda, int,  Legacy::CSRAdaptive >,
+   Legacy::CSR< float,  TNL::Devices::Cuda, int,  Legacy::CSRAdaptive >,
+   Legacy::CSR< double, TNL::Devices::Cuda, int,  Legacy::CSRAdaptive >,
+   Legacy::CSR< int,    TNL::Devices::Cuda, long, Legacy::CSRAdaptive >,
+   Legacy::CSR< float,  TNL::Devices::Cuda, long, Legacy::CSRAdaptive >,
+   Legacy::CSR< double, TNL::Devices::Cuda, long, Legacy::CSRAdaptive >
+#endif
+>;
+
+TYPED_TEST_SUITE( CSRMatrixTest, CSRMatrixTypes);
+
+TYPED_TEST( CSRMatrixTest, setDimensionsTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetDimensions< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setLikeTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetLike< CSRMatrixType, CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, resetTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_Reset< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setElementTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetElement< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, addElementTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_AddElement< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setRowTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetRow< CSRMatrixType >();
+}
+
+/* TYPED_TEST( CSRMatrixTest, vectorProductTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProduct< CSRMatrixType >();
+} */
+
+/*TYPED_TEST( CSRMatrixTest, vectorProductLargerTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProductLarger< CSRMatrixType >();
+}*/
+
+TYPED_TEST( CSRMatrixTest, vectorProductCSRApadtiveTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProductCSRAdaptive< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, saveAndLoadTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SaveAndLoad< CSRMatrixType >( "test_Legacy_SparseMatrixTest_CSRAdaptive" );
+}
+
+TYPED_TEST( CSRMatrixTest, printTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_Print< CSRMatrixType >();
+}
+
+#endif
+
+#include "../../main.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLight.cpp b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLight.cpp
new file mode 100644
index 0000000000..1b2c1e37af
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLight.cpp
@@ -0,0 +1,12 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRLight.cpp -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+
+#include "Legacy_SparseMatrixTest_CSRLight.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLight.cu b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLight.cu
new file mode 100644
index 0000000000..1ddf2763dd
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLight.cu
@@ -0,0 +1,11 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRLight.cu -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include "Legacy_SparseMatrixTest_CSRLight.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLight.h b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLight.h
new file mode 100644
index 0000000000..9c495da01e
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLight.h
@@ -0,0 +1,123 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRLight.h -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include <Benchmarks/SpMV/ReferenceFormats/Legacy/CSR.h>
+
+#include "Legacy_SparseMatrixTest.hpp"
+#include <iostream>
+
+#ifdef HAVE_GTEST
+#include <gtest/gtest.h>
+
+// test fixture for typed tests
+template< typename Matrix >
+class CSRMatrixTest : public ::testing::Test
+{
+protected:
+   using CSRMatrixType = Matrix;
+};
+
+using namespace TNL::Benchmarks::SpMV::ReferenceFormats;
+
+// types for which MatrixTest is instantiated
+using CSRMatrixTypes = ::testing::Types
+<
+#ifdef HAVE_CUDA
+   Legacy::CSR< int,    TNL::Devices::Cuda, int,  Legacy::CSRLight >,
+   Legacy::CSR< float,  TNL::Devices::Cuda, int,  Legacy::CSRLight >,
+   Legacy::CSR< double, TNL::Devices::Cuda, int,  Legacy::CSRLight >,
+   Legacy::CSR< int,    TNL::Devices::Cuda, long, Legacy::CSRLight >,
+   Legacy::CSR< float,  TNL::Devices::Cuda, long, Legacy::CSRLight >,
+   Legacy::CSR< double, TNL::Devices::Cuda, long, Legacy::CSRLight >
+#endif
+>;
+
+TYPED_TEST_SUITE( CSRMatrixTest, CSRMatrixTypes);
+
+TYPED_TEST( CSRMatrixTest, setDimensionsTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetDimensions< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setLikeTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetLike< CSRMatrixType, CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, resetTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_Reset< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setElementTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetElement< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, addElementTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_AddElement< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setRowTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetRow< CSRMatrixType >();
+}
+
+/* TYPED_TEST( CSRMatrixTest, vectorProductTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProduct< CSRMatrixType >();
+} */
+
+/*TYPED_TEST( CSRMatrixTest, vectorProductLargerTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProductLarger< CSRMatrixType >();
+}*/
+
+TYPED_TEST( CSRMatrixTest, vectorProductCSRApadtiveTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProductCSRAdaptive< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, saveAndLoadTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SaveAndLoad< CSRMatrixType >( "test_Legacy_SparseMatrixTest_CSRLight" );
+}
+
+TYPED_TEST( CSRMatrixTest, printTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_Print< CSRMatrixType >();
+}
+
+#endif
+
+#include "../../main.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLightWithoutAtomic.cpp b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLightWithoutAtomic.cpp
new file mode 100644
index 0000000000..c3576c70c4
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLightWithoutAtomic.cpp
@@ -0,0 +1,11 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRLightWithoutAtomic.cpp -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include "Legacy_SparseMatrixTest_CSRLightWithoutAtomic.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLightWithoutAtomic.cu b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLightWithoutAtomic.cu
new file mode 100644
index 0000000000..030ae2a885
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLightWithoutAtomic.cu
@@ -0,0 +1,11 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRLightWithoutAtomic.cu -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include "Legacy_SparseMatrixTest_CSRLightWithoutAtomic.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLightWithoutAtomic.h b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLightWithoutAtomic.h
new file mode 100644
index 0000000000..553bda6643
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRLightWithoutAtomic.h
@@ -0,0 +1,123 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRLightWithoutAtomic.h -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include <Benchmarks/SpMV/ReferenceFormats/Legacy/CSR.h>
+
+#include "Legacy_SparseMatrixTest.hpp"
+#include <iostream>
+
+#ifdef HAVE_GTEST
+#include <gtest/gtest.h>
+
+// test fixture for typed tests
+template< typename Matrix >
+class CSRMatrixTest : public ::testing::Test
+{
+protected:
+   using CSRMatrixType = Matrix;
+};
+
+using namespace TNL::Benchmarks::SpMV::ReferenceFormats;
+
+// types for which MatrixTest is instantiated
+using CSRMatrixTypes = ::testing::Types
+<
+#ifdef HAVE_CUDA
+   Legacy::CSR< int,    TNL::Devices::Cuda, int,  Legacy::CSRLightWithoutAtomic >,
+   Legacy::CSR< float,  TNL::Devices::Cuda, int,  Legacy::CSRLightWithoutAtomic >,
+   Legacy::CSR< double, TNL::Devices::Cuda, int,  Legacy::CSRLightWithoutAtomic >,
+   Legacy::CSR< int,    TNL::Devices::Cuda, long, Legacy::CSRLightWithoutAtomic >,
+   Legacy::CSR< float,  TNL::Devices::Cuda, long, Legacy::CSRLightWithoutAtomic >,
+   Legacy::CSR< double, TNL::Devices::Cuda, long, Legacy::CSRLightWithoutAtomic >
+#endif
+>;
+
+TYPED_TEST_SUITE( CSRMatrixTest, CSRMatrixTypes);
+
+TYPED_TEST( CSRMatrixTest, setDimensionsTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetDimensions< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setLikeTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetLike< CSRMatrixType, CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, resetTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_Reset< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setElementTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetElement< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, addElementTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_AddElement< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setRowTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetRow< CSRMatrixType >();
+}
+
+/* TYPED_TEST( CSRMatrixTest, vectorProductTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProduct< CSRMatrixType >();
+} */
+
+/*TYPED_TEST( CSRMatrixTest, vectorProductLargerTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProductLarger< CSRMatrixType >();
+}*/
+
+TYPED_TEST( CSRMatrixTest, vectorProductCSRApadtiveTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProductCSRAdaptive< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, saveAndLoadTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SaveAndLoad< CSRMatrixType >( "test_Legacy_SparseMatrixTest_CSRLightWithoutAtomic" );
+}
+
+TYPED_TEST( CSRMatrixTest, printTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_Print< CSRMatrixType >();
+}
+
+#endif
+
+#include "../../main.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRMultiVector.cpp b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRMultiVector.cpp
new file mode 100644
index 0000000000..fb25de11a1
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRMultiVector.cpp
@@ -0,0 +1,11 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRMultiVector.cpp -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include "Legacy_SparseMatrixTest_CSRMultiVector.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRMultiVector.cu b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRMultiVector.cu
new file mode 100644
index 0000000000..3af7c3ed88
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRMultiVector.cu
@@ -0,0 +1,11 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRMultiVector.cu -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include "Legacy_SparseMatrixTest_CSRMultiVector.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRMultiVector.h b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRMultiVector.h
new file mode 100644
index 0000000000..fbab0318c6
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRMultiVector.h
@@ -0,0 +1,123 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRMultiVector.h -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include <Benchmarks/SpMV/ReferenceFormats/Legacy/CSR.h>
+
+#include "Legacy_SparseMatrixTest.hpp"
+#include <iostream>
+
+#ifdef HAVE_GTEST
+#include <gtest/gtest.h>
+
+// test fixture for typed tests
+template< typename Matrix >
+class CSRMatrixTest : public ::testing::Test
+{
+protected:
+   using CSRMatrixType = Matrix;
+};
+
+using namespace TNL::Benchmarks::SpMV::ReferenceFormats;
+
+// types for which MatrixTest is instantiated
+using CSRMatrixTypes = ::testing::Types
+<
+#ifdef HAVE_CUDA
+   Legacy::CSR< int,    TNL::Devices::Cuda, int,  Legacy::CSRMultiVector >,
+   Legacy::CSR< float,  TNL::Devices::Cuda, int,  Legacy::CSRMultiVector >,
+   Legacy::CSR< double, TNL::Devices::Cuda, int,  Legacy::CSRMultiVector >,
+   Legacy::CSR< int,    TNL::Devices::Cuda, long, Legacy::CSRMultiVector >,
+   Legacy::CSR< float,  TNL::Devices::Cuda, long, Legacy::CSRMultiVector >,
+   Legacy::CSR< double, TNL::Devices::Cuda, long, Legacy::CSRMultiVector >
+#endif
+>;
+
+TYPED_TEST_SUITE( CSRMatrixTest, CSRMatrixTypes);
+
+TYPED_TEST( CSRMatrixTest, setDimensionsTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetDimensions< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setLikeTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetLike< CSRMatrixType, CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, resetTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_Reset< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setElementTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetElement< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, addElementTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_AddElement< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setRowTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetRow< CSRMatrixType >();
+}
+
+/* TYPED_TEST( CSRMatrixTest, vectorProductTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProduct< CSRMatrixType >();
+} */
+
+/*TYPED_TEST( CSRMatrixTest, vectorProductLargerTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProductLarger< CSRMatrixType >();
+}*/
+
+TYPED_TEST( CSRMatrixTest, vectorProductCSRApadtiveTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProductCSRAdaptive< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, saveAndLoadTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SaveAndLoad< CSRMatrixType >( "test_Legacy_SparseMatrixTest_CSR_MultiVector" );
+}
+
+TYPED_TEST( CSRMatrixTest, printTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_Print< CSRMatrixType >();
+}
+
+#endif
+
+#include "../../main.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRScalar.cpp b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRScalar.cpp
new file mode 100644
index 0000000000..49b62efb58
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRScalar.cpp
@@ -0,0 +1,11 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRScalar.cpp -  description
+                             -------------------
+    begin                : Nov 2, 2018
+    copyright            : (C) 2018 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include "Legacy_SparseMatrixTest_CSRScalar.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRScalar.cu b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRScalar.cu
new file mode 100644
index 0000000000..3ea72a7445
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRScalar.cu
@@ -0,0 +1,11 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRScalar.cu -  description
+                             -------------------
+    begin                : Nov 2, 2018
+    copyright            : (C) 2018 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include "Legacy_SparseMatrixTest_CSRScalar.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSR.h b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRScalar.h
similarity index 53%
rename from src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSR.h
rename to src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRScalar.h
index 33aaab2607..156211c59f 100644
--- a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSR.h
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRScalar.h
@@ -1,5 +1,5 @@
 /***************************************************************************
-                          SparseMatrixTest_CSR.h -  description
+                          SparseMatrixTest_CSRScalar.h -  description
                              -------------------
     begin                : Nov 2, 2018
     copyright            : (C) 2018 by Tomas Oberhuber et al.
@@ -41,37 +41,7 @@ using CSRMatrixTypes = ::testing::Types
    Legacy::CSR< double, TNL::Devices::Cuda, int,  Legacy::CSRScalar >,
    Legacy::CSR< int,    TNL::Devices::Cuda, long, Legacy::CSRScalar >,
    Legacy::CSR< float,  TNL::Devices::Cuda, long, Legacy::CSRScalar >,
-   Legacy::CSR< double, TNL::Devices::Cuda, long, Legacy::CSRScalar >,
-   Legacy::CSR< int,    TNL::Devices::Cuda, int,  Legacy::CSRVector >,
-   Legacy::CSR< float,  TNL::Devices::Cuda, int,  Legacy::CSRVector >,
-   Legacy::CSR< double, TNL::Devices::Cuda, int,  Legacy::CSRVector >,
-   Legacy::CSR< int,    TNL::Devices::Cuda, long, Legacy::CSRVector >,
-   Legacy::CSR< float,  TNL::Devices::Cuda, long, Legacy::CSRVector >,
-   Legacy::CSR< double, TNL::Devices::Cuda, long, Legacy::CSRVector >,
-   Legacy::CSR< int,    TNL::Devices::Cuda, int,  Legacy::CSRLight >,
-   Legacy::CSR< float,  TNL::Devices::Cuda, int,  Legacy::CSRLight >,
-   Legacy::CSR< double, TNL::Devices::Cuda, int,  Legacy::CSRLight >,
-   Legacy::CSR< int,    TNL::Devices::Cuda, long, Legacy::CSRLight >,
-   Legacy::CSR< float,  TNL::Devices::Cuda, long, Legacy::CSRLight >,
-   Legacy::CSR< double, TNL::Devices::Cuda, long, Legacy::CSRLight >,
- /*Legacy::CSR< int,    TNL::Devices::Cuda, int,  Legacy::CSRAdaptive >, // Does not work, needs to be fixed.
-   Legacy::CSR< float,  TNL::Devices::Cuda, int,  Legacy::CSRAdaptive >,
-   Legacy::CSR< double, TNL::Devices::Cuda, int,  Legacy::CSRAdaptive >,
-   Legacy::CSR< int,    TNL::Devices::Cuda, long, Legacy::CSRAdaptive >,
-   Legacy::CSR< float,  TNL::Devices::Cuda, long, Legacy::CSRAdaptive >,
-   Legacy::CSR< double, TNL::Devices::Cuda, long, Legacy::CSRAdaptive >,*/
-   Legacy::CSR< int,    TNL::Devices::Cuda, int,  Legacy::CSRMultiVector >,
-   Legacy::CSR< float,  TNL::Devices::Cuda, int,  Legacy::CSRMultiVector >,
-   Legacy::CSR< double, TNL::Devices::Cuda, int,  Legacy::CSRMultiVector >,
-   Legacy::CSR< int,    TNL::Devices::Cuda, long, Legacy::CSRMultiVector >,
-   Legacy::CSR< float,  TNL::Devices::Cuda, long, Legacy::CSRMultiVector >,
-   Legacy::CSR< double, TNL::Devices::Cuda, long, Legacy::CSRMultiVector >,
-   Legacy::CSR< int,    TNL::Devices::Cuda, int,  Legacy::CSRLightWithoutAtomic >,
-   Legacy::CSR< float,  TNL::Devices::Cuda, int,  Legacy::CSRLightWithoutAtomic >,
-   Legacy::CSR< double, TNL::Devices::Cuda, int,  Legacy::CSRLightWithoutAtomic >,
-   Legacy::CSR< int,    TNL::Devices::Cuda, long, Legacy::CSRLightWithoutAtomic >,
-   Legacy::CSR< float,  TNL::Devices::Cuda, long, Legacy::CSRLightWithoutAtomic >,
-   Legacy::CSR< double, TNL::Devices::Cuda, long, Legacy::CSRLightWithoutAtomic >
+   Legacy::CSR< double, TNL::Devices::Cuda, long, Legacy::CSRScalar >
 #endif
 >;
 
@@ -84,20 +54,6 @@ TYPED_TEST( CSRMatrixTest, setDimensionsTest )
     test_SetDimensions< CSRMatrixType >();
 }
 
-//TYPED_TEST( CSRMatrixTest, setCompressedRowLengthsTest )
-//{
-////    using CSRMatrixType = typename TestFixture::CSRMatrixType;
-//
-////    test_SetCompressedRowLengths< CSRMatrixType >();
-//
-//    bool testRan = false;
-//    EXPECT_TRUE( testRan );
-//    std::cout << "\nTEST DID NOT RUN. NOT WORKING.\n\n";
-//    std::cout << "      This test is dependent on the input format. \n";
-//    std::cout << "      Almost every format allocates elements per row differently.\n\n";
-//    std::cout << "\n    TODO: Finish implementation of getNonZeroRowLength (Only non-zero elements, not the number of allocated elements.)\n\n";
-//}
-
 TYPED_TEST( CSRMatrixTest, setLikeTest )
 {
     using CSRMatrixType = typename TestFixture::CSRMatrixType;
@@ -158,7 +114,7 @@ TYPED_TEST( CSRMatrixTest, saveAndLoadTest )
 {
     using CSRMatrixType = typename TestFixture::CSRMatrixType;
 
-    test_SaveAndLoad< CSRMatrixType >( "test_SparseMatrixTest_CSR" );
+    test_SaveAndLoad< CSRMatrixType >( "test_Legacy_SparseMatrixTest_CSRScalar" );
 }
 
 TYPED_TEST( CSRMatrixTest, printTest )
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRVector.cpp b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRVector.cpp
new file mode 100644
index 0000000000..58e9aebd07
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRVector.cpp
@@ -0,0 +1,11 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRVector.cpp -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include "Legacy_SparseMatrixTest_CSRVector.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRVector.cu b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRVector.cu
new file mode 100644
index 0000000000..f19a0d0d78
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRVector.cu
@@ -0,0 +1,11 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRVector.cu -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include "Legacy_SparseMatrixTest_CSRVector.h"
diff --git a/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRVector.h b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRVector.h
new file mode 100644
index 0000000000..34329467aa
--- /dev/null
+++ b/src/UnitTests/Matrices/Legacy/Legacy_SparseMatrixTest_CSRVector.h
@@ -0,0 +1,123 @@
+/***************************************************************************
+                          SparseMatrixTest_CSRVector.h -  description
+                             -------------------
+    begin                : Jan 30, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber et al.
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include <Benchmarks/SpMV/ReferenceFormats/Legacy/CSR.h>
+
+#include "Legacy_SparseMatrixTest.hpp"
+#include <iostream>
+
+#ifdef HAVE_GTEST
+#include <gtest/gtest.h>
+
+// test fixture for typed tests
+template< typename Matrix >
+class CSRMatrixTest : public ::testing::Test
+{
+protected:
+   using CSRMatrixType = Matrix;
+};
+
+using namespace TNL::Benchmarks::SpMV::ReferenceFormats;
+
+// types for which MatrixTest is instantiated
+using CSRMatrixTypes = ::testing::Types
+<
+#ifdef HAVE_CUDA
+   Legacy::CSR< int,    TNL::Devices::Cuda, int,  Legacy::CSRVector >,
+   Legacy::CSR< float,  TNL::Devices::Cuda, int,  Legacy::CSRVector >,
+   Legacy::CSR< double, TNL::Devices::Cuda, int,  Legacy::CSRVector >,
+   Legacy::CSR< int,    TNL::Devices::Cuda, long, Legacy::CSRVector >,
+   Legacy::CSR< float,  TNL::Devices::Cuda, long, Legacy::CSRVector >,
+   Legacy::CSR< double, TNL::Devices::Cuda, long, Legacy::CSRVector >
+#endif
+>;
+
+TYPED_TEST_SUITE( CSRMatrixTest, CSRMatrixTypes);
+
+TYPED_TEST( CSRMatrixTest, setDimensionsTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetDimensions< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setLikeTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetLike< CSRMatrixType, CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, resetTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_Reset< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setElementTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetElement< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, addElementTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_AddElement< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, setRowTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetRow< CSRMatrixType >();
+}
+
+/* TYPED_TEST( CSRMatrixTest, vectorProductTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProduct< CSRMatrixType >();
+} */
+
+/*TYPED_TEST( CSRMatrixTest, vectorProductLargerTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProductLarger< CSRMatrixType >();
+}*/
+
+TYPED_TEST( CSRMatrixTest, vectorProductCSRApadtiveTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_VectorProductCSRAdaptive< CSRMatrixType >();
+}
+
+TYPED_TEST( CSRMatrixTest, saveAndLoadTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SaveAndLoad< CSRMatrixType >( "test_Legacy_SparseMatrixTest_CSRVector" );
+}
+
+TYPED_TEST( CSRMatrixTest, printTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_Print< CSRMatrixType >();
+}
+
+#endif
+
+#include "../../main.h"
-- 
GitLab