gko::stop::Time#

Stops the solver after a wall-clock budget elapses. Useful for benchmarking and for production runs where convergence is a soft target and the iteration count is bounded by available time rather than by a residual threshold.

gko::stop::time_limit(duration) builds this criterion from a std::chrono duration of any unit.

class Time #

Inherits from

The Time class is a stopping criterion which stops the iteration process after a certain amount of time has passed.

struct parameters_type#

Public Members

std::chrono::nanoseconds time_limit#

Amount of seconds to wait (default value: 10 seconds)

deferred_factory_parameter<Time::Factory> gko::stop::time_limit(
std::chrono::nanoseconds duration,
)#

Creates the precursor to a Time stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory. This stopping criterion will stop the iteration after the specified amount of time since the start of the solver run has elapsed.

Full usage example: Stop after 1 second or when the relative residual norm is below \(10^{-10}\), whichever happens first.

auto factory = gko::solver::Cg<double>::build()
                   .with_criteria(
gko::stop::time_limit(std::chrono::seconds(1)),
gko::stop::relative_residual_norm(1e-10))
                   .on(exec);

Parameters:

duration – the time limit after which to stop the iteration. Thanks to std::chrono’s converting constructors, you can specify any time units, and they will be converted to nanoseconds automatically.

Returns:

a deferred_factory_parameter that can be passed to the with_criteria function when building a solver.