Loading src/Benchmarks/Benchmarks.h +7 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,13 @@ struct BenchmarkResult virtual RowElements getRowElements() const { return RowElements({ time, stddev, stddev / time, bandwidth, speedup }); RowElements elements; elements << time << stddev << stddev / time << bandwidth; if( speedup != 0 ) elements << speedup; else elements << "N/A"; return elements; } }; Loading src/Benchmarks/LinearSolvers/benchmarks.h +8 −2 Original line number Diff line number Diff line Loading @@ -160,8 +160,14 @@ benchmarkSolver( Benchmark& benchmark, r = b - r; const double residue_true = lpNorm( r, 2.0 ) / lpNorm( b, 2.0 ); return RowElements({ time, stddev, stddev/time, speedup, (double) converged, (double) iterations, residue_precond, residue_true }); RowElements elements; elements << time << stddev << stddev/time; if( speedup != 0 ) elements << speedup; else elements << "N/A"; elements << ( converged ? "yes" : "no" ) << iterations << residue_precond << residue_true; return elements; } }; MyBenchmarkResult benchmarkResult( solver, matrix, x, b ); Loading src/Benchmarks/Logging.h +52 −6 Original line number Diff line number Diff line Loading @@ -25,6 +25,55 @@ namespace TNL { namespace Benchmarks { class LoggingRowElements { public: LoggingRowElements() { stream << std::setprecision( 3 ) << std::fixed; } template< typename T > LoggingRowElements& operator << ( const T& b ) { stream << b; elements.push_back( stream.str() ); stream.str( std::string() ); return *this; } LoggingRowElements& operator << ( decltype( std::setprecision( 2 ) )& setprec ) { stream << setprec; return *this; } LoggingRowElements& operator << ( decltype( std::fixed )& setfixed ) // the same works also for std::scientific { stream << setfixed; return *this; } // iterators auto begin() noexcept { return elements.begin(); } auto begin() const noexcept { return elements.begin(); } auto cbegin() const noexcept { return elements.cbegin(); } auto end() noexcept { return elements.end(); } auto end() const noexcept { return elements.end(); } auto cend() const noexcept { return elements.cend(); } protected: std::list< String > elements; std::stringstream stream; }; class Logging { public: Loading @@ -33,7 +82,7 @@ public: using MetadataColumns = std::vector<MetadataElement>; using HeaderElements = std::vector< String >; using RowElements = std::vector< double >; using RowElements = LoggingRowElements; Logging( int verbose = true ) : verbose(verbose) Loading Loading @@ -131,9 +180,7 @@ public: // spanning element is printed as usual column to stdout std::cout << std::setw( 15 ) << spanningElement; for( auto & it : subElements ) { std::cout << std::setw( 15 ); if( it != 0.0 )std::cout << it; else std::cout << "N/A"; std::cout << std::setw( 15 ) << it; } std::cout << std::endl; } Loading @@ -147,8 +194,7 @@ public: // benchmark data are indented const String indent = " "; for( auto & it : subElements ) { if( it != 0.0 ) log << indent << it << std::endl; else log << indent << "N/A" << std::endl; log << indent << it << std::endl; } } Loading src/Benchmarks/SpMV/SpmvBenchmarkResult.h +9 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,15 @@ struct SpmvBenchmarkResult cusparseCopy = cusparseResult; a = cudaCopy - hostResult; b = cudaCopy - cusparseCopy; return RowElements({ time, stddev, stddev/time, speedup, max( abs( a ) ), lpNorm( a, 2.0 ), max( abs( b ) ), lpNorm( b, 2.0 ) }); return RowElements( { convertToString( time ), convertToString( stddev ), convertToString( stddev/time ), speedup != 0 ? convertToString( speedup ) : "N/A", convertToString( max( abs( a ) ) ), convertToString( lpNorm( a, 2.0 ) ), convertToString( max( abs( b ) ) ), convertToString( lpNorm( b, 2.0 ) ) } ); } HostVector &hostResult; Loading src/Benchmarks/SpMV/spmv.h +2 −2 Original line number Diff line number Diff line Loading @@ -214,7 +214,7 @@ benchmarkSpMV( Benchmark& benchmark, { "non-zeros", convertToString( hostMatrix.getNumberOfNonzeroMatrixElements() ) }, { "rows", convertToString( hostMatrix.getRows() ) }, { "columns", convertToString( hostMatrix.getColumns() ) }, { "matrix format", convertToString( "CSR-cuSPARSE-" + getFormatShort( hostMatrix ) ) } { "matrix format", convertToString( "CSR-cuSPARSE" ) } } )); SpmvBenchmarkResult< Real, int > benchmarkResult( deviceVector2, hostVector2, cusparseVector ); Loading Loading @@ -242,6 +242,7 @@ benchmarkSpmvSynthetic( Benchmark& benchmark, // Read the matrix for CSR, to set up cuSPARSE MatrixReader< CSR_HostMatrix >::readMtxFile( inputFileName, CSRhostMatrix, verboseMR ); TNL::CusparseCSR< Real > cusparseCSR; #ifdef HAVE_CUDA // cuSPARSE handle setup cusparseHandle_t cusparseHandle; Loading @@ -254,7 +255,6 @@ benchmarkSpmvSynthetic( Benchmark& benchmark, CSRhostMatrix.reset(); // Initialize the cusparseCSR matrix. TNL::CusparseCSR< Real > cusparseCSR; cusparseCSR.init( CSRdeviceMatrix, &cusparseHandle ); #endif Loading Loading
src/Benchmarks/Benchmarks.h +7 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,13 @@ struct BenchmarkResult virtual RowElements getRowElements() const { return RowElements({ time, stddev, stddev / time, bandwidth, speedup }); RowElements elements; elements << time << stddev << stddev / time << bandwidth; if( speedup != 0 ) elements << speedup; else elements << "N/A"; return elements; } }; Loading
src/Benchmarks/LinearSolvers/benchmarks.h +8 −2 Original line number Diff line number Diff line Loading @@ -160,8 +160,14 @@ benchmarkSolver( Benchmark& benchmark, r = b - r; const double residue_true = lpNorm( r, 2.0 ) / lpNorm( b, 2.0 ); return RowElements({ time, stddev, stddev/time, speedup, (double) converged, (double) iterations, residue_precond, residue_true }); RowElements elements; elements << time << stddev << stddev/time; if( speedup != 0 ) elements << speedup; else elements << "N/A"; elements << ( converged ? "yes" : "no" ) << iterations << residue_precond << residue_true; return elements; } }; MyBenchmarkResult benchmarkResult( solver, matrix, x, b ); Loading
src/Benchmarks/Logging.h +52 −6 Original line number Diff line number Diff line Loading @@ -25,6 +25,55 @@ namespace TNL { namespace Benchmarks { class LoggingRowElements { public: LoggingRowElements() { stream << std::setprecision( 3 ) << std::fixed; } template< typename T > LoggingRowElements& operator << ( const T& b ) { stream << b; elements.push_back( stream.str() ); stream.str( std::string() ); return *this; } LoggingRowElements& operator << ( decltype( std::setprecision( 2 ) )& setprec ) { stream << setprec; return *this; } LoggingRowElements& operator << ( decltype( std::fixed )& setfixed ) // the same works also for std::scientific { stream << setfixed; return *this; } // iterators auto begin() noexcept { return elements.begin(); } auto begin() const noexcept { return elements.begin(); } auto cbegin() const noexcept { return elements.cbegin(); } auto end() noexcept { return elements.end(); } auto end() const noexcept { return elements.end(); } auto cend() const noexcept { return elements.cend(); } protected: std::list< String > elements; std::stringstream stream; }; class Logging { public: Loading @@ -33,7 +82,7 @@ public: using MetadataColumns = std::vector<MetadataElement>; using HeaderElements = std::vector< String >; using RowElements = std::vector< double >; using RowElements = LoggingRowElements; Logging( int verbose = true ) : verbose(verbose) Loading Loading @@ -131,9 +180,7 @@ public: // spanning element is printed as usual column to stdout std::cout << std::setw( 15 ) << spanningElement; for( auto & it : subElements ) { std::cout << std::setw( 15 ); if( it != 0.0 )std::cout << it; else std::cout << "N/A"; std::cout << std::setw( 15 ) << it; } std::cout << std::endl; } Loading @@ -147,8 +194,7 @@ public: // benchmark data are indented const String indent = " "; for( auto & it : subElements ) { if( it != 0.0 ) log << indent << it << std::endl; else log << indent << "N/A" << std::endl; log << indent << it << std::endl; } } Loading
src/Benchmarks/SpMV/SpmvBenchmarkResult.h +9 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,15 @@ struct SpmvBenchmarkResult cusparseCopy = cusparseResult; a = cudaCopy - hostResult; b = cudaCopy - cusparseCopy; return RowElements({ time, stddev, stddev/time, speedup, max( abs( a ) ), lpNorm( a, 2.0 ), max( abs( b ) ), lpNorm( b, 2.0 ) }); return RowElements( { convertToString( time ), convertToString( stddev ), convertToString( stddev/time ), speedup != 0 ? convertToString( speedup ) : "N/A", convertToString( max( abs( a ) ) ), convertToString( lpNorm( a, 2.0 ) ), convertToString( max( abs( b ) ) ), convertToString( lpNorm( b, 2.0 ) ) } ); } HostVector &hostResult; Loading
src/Benchmarks/SpMV/spmv.h +2 −2 Original line number Diff line number Diff line Loading @@ -214,7 +214,7 @@ benchmarkSpMV( Benchmark& benchmark, { "non-zeros", convertToString( hostMatrix.getNumberOfNonzeroMatrixElements() ) }, { "rows", convertToString( hostMatrix.getRows() ) }, { "columns", convertToString( hostMatrix.getColumns() ) }, { "matrix format", convertToString( "CSR-cuSPARSE-" + getFormatShort( hostMatrix ) ) } { "matrix format", convertToString( "CSR-cuSPARSE" ) } } )); SpmvBenchmarkResult< Real, int > benchmarkResult( deviceVector2, hostVector2, cusparseVector ); Loading Loading @@ -242,6 +242,7 @@ benchmarkSpmvSynthetic( Benchmark& benchmark, // Read the matrix for CSR, to set up cuSPARSE MatrixReader< CSR_HostMatrix >::readMtxFile( inputFileName, CSRhostMatrix, verboseMR ); TNL::CusparseCSR< Real > cusparseCSR; #ifdef HAVE_CUDA // cuSPARSE handle setup cusparseHandle_t cusparseHandle; Loading @@ -254,7 +255,6 @@ benchmarkSpmvSynthetic( Benchmark& benchmark, CSRhostMatrix.reset(); // Initialize the cusparseCSR matrix. TNL::CusparseCSR< Real > cusparseCSR; cusparseCSR.init( CSRdeviceMatrix, &cusparseHandle ); #endif Loading