diff --git a/.gitignore b/.gitignore index 15a758dbdd2eee9d951328e4b7dd408c9d30b1e1..d22aa829ed3edc29a907851f5c4dcc0da2dd9374 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 a5a425295a74d5261eaf7dcb4fbfce9e0853c4ec..0decf44e255a78b128fd64d7773e93940ea48356 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 981914b3be40fe69e64533480f356a416e46873f..0000000000000000000000000000000000000000 --- 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 981914b3be40fe69e64533480f356a416e46873f..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..5dec3baadbcc1e92421c053a18a3aee9e55907ed --- /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 0000000000000000000000000000000000000000..b99a7406d32b1d9e9766fbe4dcb709c514b57331 --- /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 0000000000000000000000000000000000000000..5a245390d515120016d7144d0e07b5c54036ba35 --- /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 0000000000000000000000000000000000000000..1b2c1e37af719e0a806f64c424686e84dfa0eacf --- /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 0000000000000000000000000000000000000000..1ddf2763dd694cc3834fb325a862e0cfc7ec6bb2 --- /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 0000000000000000000000000000000000000000..9c495da01ee02ef058d7d9020608f3398c579018 --- /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 0000000000000000000000000000000000000000..c3576c70c4e9a35891c3a31e94ebf084e4c2c609 --- /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 0000000000000000000000000000000000000000..030ae2a88538a63a6673902c8ea8d04134292f1a --- /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 0000000000000000000000000000000000000000..553bda6643ad27d77c904ef5177affb7cd12a252 --- /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 0000000000000000000000000000000000000000..fb25de11a1d36046a48020837b0d30e89369a723 --- /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 0000000000000000000000000000000000000000..3af7c3ed8875f375e86323a9acc19ce8108b5c15 --- /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 0000000000000000000000000000000000000000..fbab0318c618a19a11936d437292b5654e3f7322 --- /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 0000000000000000000000000000000000000000..49b62efb58441df90f8a7bf736a433ee2ae6601f --- /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 0000000000000000000000000000000000000000..3ea72a74457d804d62e7c97e05552626216201f5 --- /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 33aaab2607e05e331acccd3d765772fa97fac882..156211c59ff7cd07b6f12730a22fa6b0a88d2cbc 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 0000000000000000000000000000000000000000..58e9aebd0758cd55f3cb9199438c50d8ca78adf5 --- /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 0000000000000000000000000000000000000000..f19a0d0d781320e6ecc5983fd50aa2ea2027cc2a --- /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 0000000000000000000000000000000000000000..34329467aa4d179080b95e897387e4cb3695ae0b --- /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"