diff --git a/src/Benchmarks/LinearSolvers/benchmarks.h b/src/Benchmarks/LinearSolvers/benchmarks.h index 032ed74ed2f708d65063e2356411ccfd39e51d23..e9811003d3d3b0f045c29a20acb88baf646d0e57 100644 --- a/src/Benchmarks/LinearSolvers/benchmarks.h +++ b/src/Benchmarks/LinearSolvers/benchmarks.h @@ -39,12 +39,29 @@ void barrier( const DistributedContainers::DistributedMatrix< Matrix, Communicat Communicator::Barrier( matrix.getCommunicationGroup() ); } +template< typename Device > +bool checkDevice( const Config::ParameterContainer& parameters ) +{ + const String device = parameters.getParameter< String >( "devices" ); + if( device == "all" ) + return true; + if( std::is_same< Device, Devices::Host >::value && device == "host" ) + return true; + if( std::is_same< Device, Devices::Cuda >::value && device == "cuda" ) + return true; + return false; +} + template< template<typename> class Preconditioner, typename Matrix > void benchmarkPreconditionerUpdate( Benchmark& benchmark, const Config::ParameterContainer& parameters, const SharedPointer< Matrix >& matrix ) { + // skip benchmarks on devices which the user did not select + if( ! checkDevice< typename Matrix::DeviceType >( parameters ) ) + return; + barrier( matrix ); const char* performer = getPerformer< typename Matrix::DeviceType >(); Preconditioner< Matrix > preconditioner; @@ -67,6 +84,10 @@ benchmarkSolver( Benchmark& benchmark, const Vector& x0, const Vector& b ) { + // skip benchmarks on devices which the user did not select + if( ! checkDevice< typename Matrix::DeviceType >( parameters ) ) + return; + barrier( matrix ); const char* performer = getPerformer< typename Matrix::DeviceType >(); diff --git a/src/Benchmarks/LinearSolvers/tnl-benchmark-linear-solvers.h b/src/Benchmarks/LinearSolvers/tnl-benchmark-linear-solvers.h index 555e6bd3b2cdf34f842e2d60643ae82e824c7a29..a898f156b4e2e25915e20ece50539991b25f47b2 100644 --- a/src/Benchmarks/LinearSolvers/tnl-benchmark-linear-solvers.h +++ b/src/Benchmarks/LinearSolvers/tnl-benchmark-linear-solvers.h @@ -497,6 +497,12 @@ configSetup( Config::ConfigDescription& config ) config.addEntry< String >( "solvers", "Comma-separated list of solvers to run benchmarks for. Options: gmres, cwygmres, tfqmr, bicgstab, bicgstab-ell.", "all" ); config.addEntry< String >( "preconditioners", "Comma-separated list of preconditioners to run benchmarks for. Options: jacobi, ilu0, ilut.", "all" ); config.addEntry< bool >( "with-preconditioner-update", "Run benchmark for the preconditioner update.", true ); + config.addEntry< String >( "devices", "Run benchmarks on these devices.", "all" ); + config.addEntryEnum( "all" ); + config.addEntryEnum( "host" ); + #ifdef HAVE_CUDA + config.addEntryEnum( "cuda" ); + #endif config.addDelimiter( "Device settings:" ); Devices::Host::configSetup( config );