Skip to content
Snippets Groups Projects
Commit dafcb6f4 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added --size-step-factor parameter to tnl-cuda-benchmarks

parent d3975a55
No related branches found
No related tags found
No related merge requests found
...@@ -194,6 +194,7 @@ runCudaBenchmarks( Benchmark & benchmark, ...@@ -194,6 +194,7 @@ runCudaBenchmarks( Benchmark & benchmark,
Benchmark::MetadataMap metadata, Benchmark::MetadataMap metadata,
const unsigned & minSize, const unsigned & minSize,
const unsigned & maxSize, const unsigned & maxSize,
const double & sizeStepFactor,
const unsigned & loops, const unsigned & loops,
const unsigned & elementsPerRow ) const unsigned & elementsPerRow )
{ {
...@@ -213,7 +214,7 @@ runCudaBenchmarks( Benchmark & benchmark, ...@@ -213,7 +214,7 @@ runCudaBenchmarks( Benchmark & benchmark,
// Vector operations // Vector operations
benchmark.newBenchmark( tnlString("Vector operations (") + precision + ")", benchmark.newBenchmark( tnlString("Vector operations (") + precision + ")",
metadata ); metadata );
for( unsigned size = minSize; size <= maxSize; size *= 2 ) { for( unsigned size = minSize; size <= maxSize; size *= sizeStepFactor ) {
benchmark.setMetadataColumns( Benchmark::MetadataColumns({ benchmark.setMetadataColumns( Benchmark::MetadataColumns({
{"size", size}, {"size", size},
} )); } ));
...@@ -247,9 +248,10 @@ setupConfig( tnlConfigDescription & config ) ...@@ -247,9 +248,10 @@ setupConfig( tnlConfigDescription & config )
config.addEntryEnum( "float" ); config.addEntryEnum( "float" );
config.addEntryEnum( "double" ); config.addEntryEnum( "double" );
config.addEntryEnum( "all" ); config.addEntryEnum( "all" );
config.addEntry< int >( "min-size", "Minimum size of arrays/vectors used in the benchmark (next size is 2*min-size and so on, up to max-size).", 100000 ); config.addEntry< int >( "min-size", "Minimum size of arrays/vectors used in the benchmark.", 100000 );
config.addEntry< int >( "max-size", "Minimum size of arrays/vectors used in the benchmark (next size is 2*min-size and so on, up to max-size).", 10000000 ); config.addEntry< int >( "max-size", "Minimum size of arrays/vectors used in the benchmark.", 10000000 );
config.addEntry< int >( "loops", "Number of iterations for every computation.", 1.0 ); config.addEntry< int >( "size-step-factor", "Factor determining the size of arrays/vectors used in the benchmark. First size is min-size and each following size is stepFactor*previousSize, up to max-size.", 2 );
config.addEntry< int >( "loops", "Number of iterations for every computation.", 10 );
config.addEntry< int >( "elements-per-row", "Number of elements per row of the sparse matrix used in the matrix-vector multiplication benchmark.", 5 ); config.addEntry< int >( "elements-per-row", "Number of elements per row of the sparse matrix used in the matrix-vector multiplication benchmark.", 5 );
config.addEntry< int >( "verbose", "Verbose mode.", 1 ); config.addEntry< int >( "verbose", "Verbose mode.", 1 );
} }
...@@ -272,10 +274,16 @@ main( int argc, char* argv[] ) ...@@ -272,10 +274,16 @@ main( int argc, char* argv[] )
const tnlString & precision = parameters.getParameter< tnlString >( "precision" ); const tnlString & precision = parameters.getParameter< tnlString >( "precision" );
const unsigned minSize = parameters.getParameter< unsigned >( "min-size" ); const unsigned minSize = parameters.getParameter< unsigned >( "min-size" );
const unsigned maxSize = parameters.getParameter< unsigned >( "max-size" ); const unsigned maxSize = parameters.getParameter< unsigned >( "max-size" );
const unsigned sizeStepFactor = parameters.getParameter< unsigned >( "size-step-factor" );
const unsigned loops = parameters.getParameter< unsigned >( "loops" ); const unsigned loops = parameters.getParameter< unsigned >( "loops" );
const unsigned elementsPerRow = parameters.getParameter< unsigned >( "elements-per-row" ); const unsigned elementsPerRow = parameters.getParameter< unsigned >( "elements-per-row" );
const unsigned verbose = parameters.getParameter< unsigned >( "verbose" ); const unsigned verbose = parameters.getParameter< unsigned >( "verbose" );
if( sizeStepFactor <= 1 ) {
cerr << "The value of --size-step-factor must be greater than 1." << endl;
return EXIT_FAILURE;
}
// init benchmark and common metadata // init benchmark and common metadata
Benchmark benchmark( loops, verbose ); Benchmark benchmark( loops, verbose );
// TODO: add hostname, CPU info, GPU info, date, ... // TODO: add hostname, CPU info, GPU info, date, ...
...@@ -284,9 +292,9 @@ main( int argc, char* argv[] ) ...@@ -284,9 +292,9 @@ main( int argc, char* argv[] )
}; };
if( precision == "all" || precision == "float" ) if( precision == "all" || precision == "float" )
runCudaBenchmarks< float >( benchmark, metadata, minSize, maxSize, loops, elementsPerRow ); runCudaBenchmarks< float >( benchmark, metadata, minSize, maxSize, sizeStepFactor, loops, elementsPerRow );
if( precision == "all" || precision == "double" ) if( precision == "all" || precision == "double" )
runCudaBenchmarks< double >( benchmark, metadata, minSize, maxSize, loops, elementsPerRow ); runCudaBenchmarks< double >( benchmark, metadata, minSize, maxSize, sizeStepFactor, loops, elementsPerRow );
if( ! benchmark.save( logFile ) ) { if( ! benchmark.save( logFile ) ) {
cerr << "Failed to write the benchmark results to file '" << parameters.getParameter< tnlString >( "log-file" ) << "'." << endl; cerr << "Failed to write the benchmark results to file '" << parameters.getParameter< tnlString >( "log-file" ) << "'." << endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment