From 93fd2bec864e6ba30f03af5ce58360a34e32cabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz> Date: Tue, 30 Oct 2018 15:09:34 +0100 Subject: [PATCH] Benchmarks: allow to run linear-solvers benchmarks only on GPU --- src/Benchmarks/LinearSolvers/benchmarks.h | 21 +++++++++++++++++++ .../tnl-benchmark-linear-solvers.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/src/Benchmarks/LinearSolvers/benchmarks.h b/src/Benchmarks/LinearSolvers/benchmarks.h index 032ed74ed2..e9811003d3 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 555e6bd3b2..a898f156b4 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 ); -- GitLab