From 0a0c44ca642e06dabc824041a706f136c16ae973 Mon Sep 17 00:00:00 2001 From: Lukas Cejka <lukas.ostatek@gmail.com> Date: Sun, 3 Mar 2019 20:58:06 +0100 Subject: [PATCH] Added useful functions to begind implementation. Commiting for backup purposes. --- src/Benchmarks/SpMV/spmv.h | 27 ++++++++++++++++++++++++ src/Benchmarks/SpMV/tnl-benchmark-spmv.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/Benchmarks/SpMV/spmv.h b/src/Benchmarks/SpMV/spmv.h index 2c28d57d31..7f47cf2518 100644 --- a/src/Benchmarks/SpMV/spmv.h +++ b/src/Benchmarks/SpMV/spmv.h @@ -20,6 +20,8 @@ #include <TNL/Matrices/SlicedEllpack.h> #include <TNL/Matrices/ChunkedEllpack.h> +//#include <TNL/Matrices/MatrixReader.h> + namespace TNL { namespace Benchmarks { @@ -27,6 +29,16 @@ namespace Benchmarks { template< typename Real, typename Device, typename Index > using SlicedEllpack = Matrices::SlicedEllpack< Real, Device, Index >; +//template< typename Matrix > +//void printMatrixInfo( const String& inputFileName, +// const Matrix& matrix, +// std::ostream& str ) +//{ +// str << " Rows: " << std::setw( 8 ) << matrix.getRows(); +// str << " Columns: " << std::setw( 8 ) << matrix.getColumns(); +// str << " Nonzero Elements: " << std::setw( 10 ) << matrix.getNumberOfNonzeroMatrixElements(); +//} + template< typename Matrix > int setHostTestMatrix( Matrix& matrix, const int elementsPerRow ) @@ -176,6 +188,21 @@ benchmarkSpmvSynthetic( Benchmark & benchmark, const int & size, const int & elementsPerRow ) { +// typedef Matrices::CSR< Real, Devices::Host, int > CSRType; +// CSRType csrMatrix; +// try +// { +// if( ! MatrixReader< CSRType >::readMtxFile( inputFileName, csrMatrix ) ) +// { +// std::cerr << "I am not able to read the matrix file " << inputFileName << "." << std::endl; +// return false; +// } +// } +// catch( std::bad_alloc ) +// { +// std::cerr << "Not enough memory to read the matrix." << std::endl; +// return false; +// } bool result = true; // TODO: benchmark all formats from tnl-benchmark-spmv (different parameters of the base formats) result |= benchmarkSpMV< Real, Matrices::CSR >( benchmark, size, elementsPerRow ); diff --git a/src/Benchmarks/SpMV/tnl-benchmark-spmv.h b/src/Benchmarks/SpMV/tnl-benchmark-spmv.h index 97e47f2a0f..b3ad3102e1 100644 --- a/src/Benchmarks/SpMV/tnl-benchmark-spmv.h +++ b/src/Benchmarks/SpMV/tnl-benchmark-spmv.h @@ -64,6 +64,7 @@ void setupConfig( Config::ConfigDescription & config ) { config.addDelimiter( "Benchmark settings:" ); + config.addRequiredEntry< String >( "input-file", "Input file name." ); config.addEntry< String >( "log-file", "Log file name.", "tnl-benchmark-blas.log"); config.addEntry< String >( "output-mode", "Mode for opening the log file.", "overwrite" ); config.addEntryEnum( "append" ); -- GitLab