Loading src/Benchmarks/SpMV/spmv.h +5 −1 Original line number Diff line number Diff line Loading @@ -728,13 +728,17 @@ benchmarkSpmv( BenchmarkType& benchmark, // Perform benchmark on host with CSR as a reference CPU format // benchmark.setMetadataColumns({ { "matrix name", convertToString( inputFileName ) }, { "matrix name", inputFileName }, { "rows", convertToString( csrHostMatrix.getRows() ) }, { "columns", convertToString( csrHostMatrix.getColumns() ) }, { "nonzeros", convertToString( nonzeros ) }, // NOTE: this can be easily calculated with Pandas based on the other metadata //{ "nonzeros per row", convertToString( ( double ) nonzeros / ( double ) csrHostMatrix.getRows() ) }, }); benchmark.setMetadataWidths({ { "matrix name", 32 }, { "format", 35 }, }); HostVector hostInVector( csrHostMatrix.getRows() ), hostOutVector( csrHostMatrix.getRows() ); Loading src/TNL/Benchmarks/Benchmarks.h +3 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,9 @@ class Benchmark // changing MetadataColumns that were set using the previous method. void setMetadataElement( const typename MetadataColumns::value_type & element ); // Sets the width of metadata columns when printed to the terminal. void setMetadataWidths( const std::map< std::string, int > & widths ); // Sets the dataset size and base time for the calculations of bandwidth // and speedup in the benchmarks result. void setDatasetSize( const double datasetSize = 0.0, // in GB Loading src/TNL/Benchmarks/Benchmarks.hpp +8 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,14 @@ setMetadataElement( const typename MetadataColumns::value_type & element ) logger.setMetadataElement( element ); } template< typename Logger > void Benchmark< Logger >:: setMetadataWidths( const std::map< std::string, int > & widths ) { logger.setMetadataWidths( widths ); } template< typename Logger > void Benchmark< Logger >:: Loading src/TNL/Benchmarks/CustomLogging.h +15 −2 Original line number Diff line number Diff line Loading @@ -84,13 +84,24 @@ public: } } virtual void setMetadataWidths( const std::map< std::string, int > & widths ) override { for( auto & it : widths ) if( metadataWidths.count( it.first ) ) metadataWidths[ it.first ] = it.second; else metadataWidths.insert( it ); } void writeTableHeader( const std::string & spanningElement, const HeaderElements & subElements ) { if( verbose && header_changed ) { for( auto & it : metadataColumns ) { std::cout << std::setw( 20 ) << it.first; const int width = (metadataWidths.count( it.first )) ? metadataWidths[ it.first ] : 15; std::cout << std::setw( width ) << it.first; } // spanning element is printed as usual column to stdout, Loading Loading @@ -124,7 +135,8 @@ public: { if( verbose ) { for( auto & it : metadataColumns ) { std::cout << std::setw( 20 ) << it.second; const int width = (metadataWidths.count( it.first )) ? metadataWidths[ it.first ] : 15; std::cout << std::setw( width ) << it.second; } // spanning element is printed as usual column to stdout std::cout << std::setw( 15 ) << spanningElement; Loading Loading @@ -220,6 +232,7 @@ protected: std::stringstream log; MetadataColumns metadataColumns; std::map< std::string, int > metadataWidths; bool header_changed = true; }; Loading src/TNL/Benchmarks/JsonLogging.h +19 −4 Original line number Diff line number Diff line Loading @@ -79,13 +79,25 @@ public: } } virtual void setMetadataWidths( const std::map< std::string, int > & widths ) override { for( auto & it : widths ) if( metadataWidths.count( it.first ) ) metadataWidths[ it.first ] = it.second; else metadataWidths.insert( it ); } void writeHeader( const HeaderElements& headerElements, const WidthHints& widths ) { TNL_ASSERT_EQ( headerElements.size(), widths.size(), "elements must have equal sizes" ); if( verbose && header_changed ) { for( auto & lg : metadataColumns ) std::cout << std::setw( 20 ) << lg.first; for( auto & lg : metadataColumns ) { const int width = (metadataWidths.count( lg.first )) ? metadataWidths[ lg.first ] : 14; std::cout << std::setw( width ) << lg.first; } for( std::size_t i = 0; i < headerElements.size(); i++ ) std::cout << std::setw( widths[ i ] ) << headerElements[ i ]; std::cout << std::endl; Loading @@ -107,8 +119,10 @@ public: int idx( 0 ); for( auto lg : this->metadataColumns ) { if( verbose ) std::cout << std::setw( 20 ) << lg.second; if( verbose ) { const int width = (metadataWidths.count( lg.first )) ? metadataWidths[ lg.first ] : 14; std::cout << std::setw( width ) << lg.second; } if( idx++ > 0 ) log << ", "; log << "\"" << lg.first << "\": \"" << lg.second << "\""; Loading Loading @@ -200,6 +214,7 @@ protected: std::stringstream log; MetadataColumns metadataColumns; std::map< std::string, int > metadataWidths; bool header_changed = true; }; Loading Loading
src/Benchmarks/SpMV/spmv.h +5 −1 Original line number Diff line number Diff line Loading @@ -728,13 +728,17 @@ benchmarkSpmv( BenchmarkType& benchmark, // Perform benchmark on host with CSR as a reference CPU format // benchmark.setMetadataColumns({ { "matrix name", convertToString( inputFileName ) }, { "matrix name", inputFileName }, { "rows", convertToString( csrHostMatrix.getRows() ) }, { "columns", convertToString( csrHostMatrix.getColumns() ) }, { "nonzeros", convertToString( nonzeros ) }, // NOTE: this can be easily calculated with Pandas based on the other metadata //{ "nonzeros per row", convertToString( ( double ) nonzeros / ( double ) csrHostMatrix.getRows() ) }, }); benchmark.setMetadataWidths({ { "matrix name", 32 }, { "format", 35 }, }); HostVector hostInVector( csrHostMatrix.getRows() ), hostOutVector( csrHostMatrix.getRows() ); Loading
src/TNL/Benchmarks/Benchmarks.h +3 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,9 @@ class Benchmark // changing MetadataColumns that were set using the previous method. void setMetadataElement( const typename MetadataColumns::value_type & element ); // Sets the width of metadata columns when printed to the terminal. void setMetadataWidths( const std::map< std::string, int > & widths ); // Sets the dataset size and base time for the calculations of bandwidth // and speedup in the benchmarks result. void setDatasetSize( const double datasetSize = 0.0, // in GB Loading
src/TNL/Benchmarks/Benchmarks.hpp +8 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,14 @@ setMetadataElement( const typename MetadataColumns::value_type & element ) logger.setMetadataElement( element ); } template< typename Logger > void Benchmark< Logger >:: setMetadataWidths( const std::map< std::string, int > & widths ) { logger.setMetadataWidths( widths ); } template< typename Logger > void Benchmark< Logger >:: Loading
src/TNL/Benchmarks/CustomLogging.h +15 −2 Original line number Diff line number Diff line Loading @@ -84,13 +84,24 @@ public: } } virtual void setMetadataWidths( const std::map< std::string, int > & widths ) override { for( auto & it : widths ) if( metadataWidths.count( it.first ) ) metadataWidths[ it.first ] = it.second; else metadataWidths.insert( it ); } void writeTableHeader( const std::string & spanningElement, const HeaderElements & subElements ) { if( verbose && header_changed ) { for( auto & it : metadataColumns ) { std::cout << std::setw( 20 ) << it.first; const int width = (metadataWidths.count( it.first )) ? metadataWidths[ it.first ] : 15; std::cout << std::setw( width ) << it.first; } // spanning element is printed as usual column to stdout, Loading Loading @@ -124,7 +135,8 @@ public: { if( verbose ) { for( auto & it : metadataColumns ) { std::cout << std::setw( 20 ) << it.second; const int width = (metadataWidths.count( it.first )) ? metadataWidths[ it.first ] : 15; std::cout << std::setw( width ) << it.second; } // spanning element is printed as usual column to stdout std::cout << std::setw( 15 ) << spanningElement; Loading Loading @@ -220,6 +232,7 @@ protected: std::stringstream log; MetadataColumns metadataColumns; std::map< std::string, int > metadataWidths; bool header_changed = true; }; Loading
src/TNL/Benchmarks/JsonLogging.h +19 −4 Original line number Diff line number Diff line Loading @@ -79,13 +79,25 @@ public: } } virtual void setMetadataWidths( const std::map< std::string, int > & widths ) override { for( auto & it : widths ) if( metadataWidths.count( it.first ) ) metadataWidths[ it.first ] = it.second; else metadataWidths.insert( it ); } void writeHeader( const HeaderElements& headerElements, const WidthHints& widths ) { TNL_ASSERT_EQ( headerElements.size(), widths.size(), "elements must have equal sizes" ); if( verbose && header_changed ) { for( auto & lg : metadataColumns ) std::cout << std::setw( 20 ) << lg.first; for( auto & lg : metadataColumns ) { const int width = (metadataWidths.count( lg.first )) ? metadataWidths[ lg.first ] : 14; std::cout << std::setw( width ) << lg.first; } for( std::size_t i = 0; i < headerElements.size(); i++ ) std::cout << std::setw( widths[ i ] ) << headerElements[ i ]; std::cout << std::endl; Loading @@ -107,8 +119,10 @@ public: int idx( 0 ); for( auto lg : this->metadataColumns ) { if( verbose ) std::cout << std::setw( 20 ) << lg.second; if( verbose ) { const int width = (metadataWidths.count( lg.first )) ? metadataWidths[ lg.first ] : 14; std::cout << std::setw( width ) << lg.second; } if( idx++ > 0 ) log << ", "; log << "\"" << lg.first << "\": \"" << lg.second << "\""; Loading Loading @@ -200,6 +214,7 @@ protected: std::stringstream log; MetadataColumns metadataColumns; std::map< std::string, int > metadataWidths; bool header_changed = true; }; Loading