Loading src/Benchmarks/Benchmarks.h +13 −35 Original line number Diff line number Diff line Loading @@ -76,7 +76,6 @@ public: config.addEntry< int >( "loops", "Number of iterations for every computation.", 10 ); config.addEntry< bool >( "reset", "Call reset function between loops.", true ); config.addEntry< double >( "min-time", "Minimal real time in seconds for every computation.", 0.0 ); config.addEntry< bool >( "timing", "Turns off (or on) the timing (for the purpose of profiling).", true ); config.addEntry< int >( "verbose", "Verbose mode, the higher number the more verbosity.", 1 ); } Loading @@ -85,7 +84,6 @@ public: this->loops = parameters.getParameter< int >( "loops" ); this->reset = parameters.getParameter< bool >( "reset" ); this->minTime = parameters.getParameter< double >( "min-time" ); this->timing = parameters.getParameter< bool >( "timing" ); const int verbose = parameters.getParameter< int >( "verbose" ); Logging::setVerbose( verbose ); } Loading Loading @@ -121,7 +119,6 @@ public: metadata["loops"] = convertToString(loops); metadata["reset"] = convertToString( reset ); metadata["minimal test time"] = convertToString( minTime ); metadata["timing"] = convertToString( timing ); writeMetadata( metadata ); } Loading Loading @@ -208,28 +205,16 @@ public: if( verbose > 1 ) { // run the monitor main loop Solvers::SolverMonitorThread monitor_thread( monitor ); if( this->timing ) if( this->reset ) result.time = functionTimer. template timeFunction< true >( compute, reset, loops, minTime, verbose, monitor ); result.time = functionTimer.timeFunction( compute, reset, loops, minTime, verbose, monitor ); else result.time = functionTimer. template timeFunction< true >( compute, loops, minTime, verbose, monitor ); else if( this->reset ) result.time = functionTimer. template timeFunction< false >( compute, reset, loops, minTime, verbose, monitor ); else result.time = functionTimer. template timeFunction< false >( compute, loops, minTime, verbose, monitor ); result.time = functionTimer.timeFunction( compute, loops, minTime, verbose, monitor ); } else { if( this->timing ) if( this->reset ) result.time = functionTimer. template timeFunction< true >( compute, reset, loops, minTime, verbose, monitor ); else result.time = functionTimer. template timeFunction< true >( compute, loops, minTime, verbose, monitor ); else if( this->reset ) result.time = functionTimer. template timeFunction< false >( compute, reset, loops, minTime, verbose, monitor ); result.time = functionTimer.timeFunction( compute, reset, loops, minTime, verbose, monitor ); else result.time = functionTimer. template timeFunction< false >( compute, loops, minTime, verbose, monitor ); result.time = functionTimer.timeFunction( compute, loops, minTime, verbose, monitor ); } this->performedLoops = functionTimer.getPerformedLoops(); } Loading Loading @@ -277,16 +262,10 @@ public: if( verbose > 1 ) { // run the monitor main loop Solvers::SolverMonitorThread monitor_thread( monitor ); if( this->timing ) result.time = functionTimer. template timeFunction< true >( compute, loops, minTime, verbose, monitor ); else result.time = functionTimer. template timeFunction< false >( compute, loops, minTime, verbose, monitor ); result.time = functionTimer.timeFunction( compute, loops, minTime, verbose, monitor ); } else { if( this->timing ) result.time = functionTimer. template timeFunction< true >( compute, loops, minTime, verbose, monitor ); else result.time = functionTimer. template timeFunction< false >( compute, loops, minTime, verbose, monitor ); result.time = functionTimer.timeFunction( compute, loops, minTime, verbose, monitor ); } } catch ( const std::exception& e ) { Loading Loading @@ -345,7 +324,6 @@ protected: double minTime = 0.0; double datasetSize = 0.0; double baseTime = 0.0; bool timing = true; bool reset = true; SolverMonitorType monitor; }; Loading src/Benchmarks/FunctionTimer.h +12 −21 Original line number Diff line number Diff line Loading @@ -28,8 +28,7 @@ class FunctionTimer public: using DeviceType = Device; template< bool timing, typename ComputeFunction, template< typename ComputeFunction, typename ResetFunction, typename Monitor = TNL::Solvers::IterativeSolverMonitor< double, int > > double Loading Loading @@ -61,26 +60,24 @@ class FunctionTimer if( std::is_same< Device, Devices::Cuda >::value ) cudaDeviceSynchronize(); #endif if( timing ) timer.start(); for( loops = 0; loops < maxLoops || ( timing && timer.getRealTime() < minTime ); ++loops) loops < maxLoops || timer.getRealTime() < minTime; loops++ ) compute(); // Explicit synchronization of the CUDA device #ifdef HAVE_CUDA if( std::is_same< Device, Devices::Cuda >::value ) cudaDeviceSynchronize(); #endif if( timing ) timer.stop(); } else { for( loops = 0; loops < maxLoops || ( timing && timer.getRealTime() < minTime ); ++loops) loops < maxLoops || timer.getRealTime() < minTime; loops++ ) { // abuse the monitor's "time" for loops monitor.setTime( loops + 1 ); Loading @@ -91,25 +88,19 @@ class FunctionTimer if( std::is_same< Device, Devices::Cuda >::value ) cudaDeviceSynchronize(); #endif if( timing ) timer.start(); compute(); #ifdef HAVE_CUDA if( std::is_same< Device, Devices::Cuda >::value ) cudaDeviceSynchronize(); #endif if( timing ) timer.stop(); } } if( timing ) return timer.getRealTime() / ( double ) loops; else return std::numeric_limits<double>::quiet_NaN(); } template< bool timing, typename ComputeFunction, template< typename ComputeFunction, typename Monitor = TNL::Solvers::IterativeSolverMonitor< double, int > > double timeFunction( ComputeFunction compute, Loading @@ -119,7 +110,7 @@ class FunctionTimer Monitor && monitor = Monitor() ) { auto noReset = [] () {}; return timeFunction< timing >( compute, noReset, maxLoops, minTime, verbose, monitor, false ); return timeFunction( compute, noReset, maxLoops, minTime, verbose, monitor, false ); } int getPerformedLoops() const Loading Loading
src/Benchmarks/Benchmarks.h +13 −35 Original line number Diff line number Diff line Loading @@ -76,7 +76,6 @@ public: config.addEntry< int >( "loops", "Number of iterations for every computation.", 10 ); config.addEntry< bool >( "reset", "Call reset function between loops.", true ); config.addEntry< double >( "min-time", "Minimal real time in seconds for every computation.", 0.0 ); config.addEntry< bool >( "timing", "Turns off (or on) the timing (for the purpose of profiling).", true ); config.addEntry< int >( "verbose", "Verbose mode, the higher number the more verbosity.", 1 ); } Loading @@ -85,7 +84,6 @@ public: this->loops = parameters.getParameter< int >( "loops" ); this->reset = parameters.getParameter< bool >( "reset" ); this->minTime = parameters.getParameter< double >( "min-time" ); this->timing = parameters.getParameter< bool >( "timing" ); const int verbose = parameters.getParameter< int >( "verbose" ); Logging::setVerbose( verbose ); } Loading Loading @@ -121,7 +119,6 @@ public: metadata["loops"] = convertToString(loops); metadata["reset"] = convertToString( reset ); metadata["minimal test time"] = convertToString( minTime ); metadata["timing"] = convertToString( timing ); writeMetadata( metadata ); } Loading Loading @@ -208,28 +205,16 @@ public: if( verbose > 1 ) { // run the monitor main loop Solvers::SolverMonitorThread monitor_thread( monitor ); if( this->timing ) if( this->reset ) result.time = functionTimer. template timeFunction< true >( compute, reset, loops, minTime, verbose, monitor ); result.time = functionTimer.timeFunction( compute, reset, loops, minTime, verbose, monitor ); else result.time = functionTimer. template timeFunction< true >( compute, loops, minTime, verbose, monitor ); else if( this->reset ) result.time = functionTimer. template timeFunction< false >( compute, reset, loops, minTime, verbose, monitor ); else result.time = functionTimer. template timeFunction< false >( compute, loops, minTime, verbose, monitor ); result.time = functionTimer.timeFunction( compute, loops, minTime, verbose, monitor ); } else { if( this->timing ) if( this->reset ) result.time = functionTimer. template timeFunction< true >( compute, reset, loops, minTime, verbose, monitor ); else result.time = functionTimer. template timeFunction< true >( compute, loops, minTime, verbose, monitor ); else if( this->reset ) result.time = functionTimer. template timeFunction< false >( compute, reset, loops, minTime, verbose, monitor ); result.time = functionTimer.timeFunction( compute, reset, loops, minTime, verbose, monitor ); else result.time = functionTimer. template timeFunction< false >( compute, loops, minTime, verbose, monitor ); result.time = functionTimer.timeFunction( compute, loops, minTime, verbose, monitor ); } this->performedLoops = functionTimer.getPerformedLoops(); } Loading Loading @@ -277,16 +262,10 @@ public: if( verbose > 1 ) { // run the monitor main loop Solvers::SolverMonitorThread monitor_thread( monitor ); if( this->timing ) result.time = functionTimer. template timeFunction< true >( compute, loops, minTime, verbose, monitor ); else result.time = functionTimer. template timeFunction< false >( compute, loops, minTime, verbose, monitor ); result.time = functionTimer.timeFunction( compute, loops, minTime, verbose, monitor ); } else { if( this->timing ) result.time = functionTimer. template timeFunction< true >( compute, loops, minTime, verbose, monitor ); else result.time = functionTimer. template timeFunction< false >( compute, loops, minTime, verbose, monitor ); result.time = functionTimer.timeFunction( compute, loops, minTime, verbose, monitor ); } } catch ( const std::exception& e ) { Loading Loading @@ -345,7 +324,6 @@ protected: double minTime = 0.0; double datasetSize = 0.0; double baseTime = 0.0; bool timing = true; bool reset = true; SolverMonitorType monitor; }; Loading
src/Benchmarks/FunctionTimer.h +12 −21 Original line number Diff line number Diff line Loading @@ -28,8 +28,7 @@ class FunctionTimer public: using DeviceType = Device; template< bool timing, typename ComputeFunction, template< typename ComputeFunction, typename ResetFunction, typename Monitor = TNL::Solvers::IterativeSolverMonitor< double, int > > double Loading Loading @@ -61,26 +60,24 @@ class FunctionTimer if( std::is_same< Device, Devices::Cuda >::value ) cudaDeviceSynchronize(); #endif if( timing ) timer.start(); for( loops = 0; loops < maxLoops || ( timing && timer.getRealTime() < minTime ); ++loops) loops < maxLoops || timer.getRealTime() < minTime; loops++ ) compute(); // Explicit synchronization of the CUDA device #ifdef HAVE_CUDA if( std::is_same< Device, Devices::Cuda >::value ) cudaDeviceSynchronize(); #endif if( timing ) timer.stop(); } else { for( loops = 0; loops < maxLoops || ( timing && timer.getRealTime() < minTime ); ++loops) loops < maxLoops || timer.getRealTime() < minTime; loops++ ) { // abuse the monitor's "time" for loops monitor.setTime( loops + 1 ); Loading @@ -91,25 +88,19 @@ class FunctionTimer if( std::is_same< Device, Devices::Cuda >::value ) cudaDeviceSynchronize(); #endif if( timing ) timer.start(); compute(); #ifdef HAVE_CUDA if( std::is_same< Device, Devices::Cuda >::value ) cudaDeviceSynchronize(); #endif if( timing ) timer.stop(); } } if( timing ) return timer.getRealTime() / ( double ) loops; else return std::numeric_limits<double>::quiet_NaN(); } template< bool timing, typename ComputeFunction, template< typename ComputeFunction, typename Monitor = TNL::Solvers::IterativeSolverMonitor< double, int > > double timeFunction( ComputeFunction compute, Loading @@ -119,7 +110,7 @@ class FunctionTimer Monitor && monitor = Monitor() ) { auto noReset = [] () {}; return timeFunction< timing >( compute, noReset, maxLoops, minTime, verbose, monitor, false ); return timeFunction( compute, noReset, maxLoops, minTime, verbose, monitor, false ); } int getPerformedLoops() const Loading