Ginkgo: gko::log::Convergence< ValueType > Class Template Reference

| Ginkgo Generated from branch based on main. Ginkgo version 1.11.0 A numerical linear algebra library targeting many-core architectures

Loading...
Searching...
No Matches
gko::log::Convergence< ValueType > Class Template Reference
Logging

Convergence is a Logger which logs data strictly from the criterion_check_completed event. More...

`#include <ginkgo/core/log/convergence.hpp>`

Inheritance diagram for gko::log::Convergence< ValueType >:
[legend]
Collaboration diagram for gko::log::Convergence< ValueType >:
[legend]

## Public Member Functions
void | on_criterion_check_completed (const stop::Criterion *criterion, const size_type &num_iterations, const LinOp *residual, const LinOp *residual_norm, const LinOp *solution, const uint8 &stopping_id, const bool &set_finalized, const array< stopping_status > *status, const bool &one_changed, const bool &all_stopped) const override
| stop::Criterion's check completed event.
void | on_criterion_check_completed (const stop::Criterion *criterion, const size_type &num_iterations, const LinOp *residual, const LinOp *residual_norm, const LinOp *implicit_sq_resnorm, const LinOp *solution, const uint8 &stopping_id, const bool &set_finalized, const array< stopping_status > *status, const bool &one_changed, const bool &all_stopped) const override
| stop::Criterion's check completed event.
void | on_iteration_complete (const LinOp *solver, const LinOp *b, const LinOp *x, const size_type &num_iterations, const LinOp *residual, const LinOp *residual_norm, const LinOp *implicit_resnorm_sq, const array< stopping_status > *status, bool stopped) const override
| Register the iteration_complete event which logs every completed iterations.
bool | has_converged () const noexcept
| Returns true if the solver has converged.
void | reset_convergence_status ()
| Resets the convergence status to false.
const size_type & | get_num_iterations () const noexcept
| Returns the number of iterations.
const LinOp * | get_residual () const noexcept
| Returns the residual.
const LinOp * | get_residual_norm () const noexcept
| Returns the residual norm.
const LinOp * | get_implicit_sq_resnorm () const noexcept
| Returns the implicit squared residual norm.
Public Member Functions inherited from gko::log::Logger
template<size_type Event, typename... Params>
std::enable_if_t< Event==0 &&(0< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==1 &&(1< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==2 &&(2< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==3 &&(3< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==4 &&(4< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==5 &&(5< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==6 &&(6< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==7 &&(7< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==8 &&(8< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==9 &&(9< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==10 &&(10< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==11 &&(11< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==12 &&(12< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==13 &&(13< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==14 &&(14< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==15 &&(15< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==16 &&(16< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==17 &&(17< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==18 &&(18< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==19 &&(19< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==20 &&(20< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==21 &&(21< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==22 &&(22< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==23 &&(23< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==24 &&(24< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==25 &&(25< event_count_max)> | on (Params &&... params) const
template<size_type Event, typename... Params>
std::enable_if_t< Event==26 &&(26< event_count_max)> | on (Params &&... params) const
virtual bool | needs_propagation () const
| Returns true if this logger, when attached to an Executor, needs to be forwarded all events from objects on this executor.

## Static Public Member Functions
static std::unique_ptr< Convergence > | create (std::shared_ptr< const Executor >, const mask_type &enabled_events=Logger::criterion_events_mask|Logger::iteration_complete_mask)
| Creates a convergence logger.
static std::unique_ptr< Convergence > | create (const mask_type &enabled_events=Logger::criterion_events_mask|Logger::iteration_complete_mask)
| Creates a convergence logger.

## Additional Inherited Members
Public Types inherited from gko::log::Logger
using | mask_type = gko::uint64
Static Public Attributes inherited from gko::log::Logger
static constexpr size_type | event_count_max = sizeof(mask_type) * byte_size
| Maximum amount of events (bits) with the current implementation.
static constexpr mask_type | all_events_mask = ~mask_type{0}
| Bitset Mask which activates all events.
static constexpr size_type | allocation_started {0}
static constexpr mask_type | allocation_started_mask {mask_type{1} << 0}
static constexpr size_type | allocation_completed {1}
static constexpr mask_type | allocation_completed_mask {mask_type{1} << 1}
static constexpr size_type | free_started {2}
static constexpr mask_type | free_started_mask {mask_type{1} << 2}
static constexpr size_type | free_completed {3}
static constexpr mask_type | free_completed_mask {mask_type{1} << 3}
static constexpr size_type | copy_started {4}
static constexpr mask_type | copy_started_mask {mask_type{1} << 4}
static constexpr size_type | copy_completed {5}
static constexpr mask_type | copy_completed_mask {mask_type{1} << 5}
static constexpr size_type | operation_launched {6}
static constexpr mask_type | operation_launched_mask {mask_type{1} << 6}
static constexpr size_type | operation_completed {7}
static constexpr mask_type | operation_completed_mask {mask_type{1} << 7}
static constexpr size_type | polymorphic_object_create_started {8}
static constexpr mask_type | polymorphic_object_create_started_mask {mask_type{1} << 8}
static constexpr size_type | polymorphic_object_create_completed {9}
static constexpr mask_type | polymorphic_object_create_completed_mask {mask_type{1} << 9}
static constexpr size_type | polymorphic_object_copy_started {10}
static constexpr mask_type | polymorphic_object_copy_started_mask {mask_type{1} << 10}
static constexpr size_type | polymorphic_object_copy_completed {11}
static constexpr mask_type | polymorphic_object_copy_completed_mask {mask_type{1} << 11}
static constexpr size_type | polymorphic_object_deleted {12}
static constexpr mask_type | polymorphic_object_deleted_mask {mask_type{1} << 12}
static constexpr size_type | linop_apply_started {13}
static constexpr mask_type | linop_apply_started_mask {mask_type{1} << 13}
static constexpr size_type | linop_apply_completed {14}
static constexpr mask_type | linop_apply_completed_mask {mask_type{1} << 14}
static constexpr size_type | linop_advanced_apply_started {15}
static constexpr mask_type | linop_advanced_apply_started_mask {mask_type{1} << 15}
static constexpr size_type | linop_advanced_apply_completed {16}
static constexpr mask_type | linop_advanced_apply_completed_mask {mask_type{1} << 16}
static constexpr size_type | linop_factory_generate_started {17}
static constexpr mask_type | linop_factory_generate_started_mask {mask_type{1} << 17}
static constexpr size_type | linop_factory_generate_completed {18}
static constexpr mask_type | linop_factory_generate_completed_mask {mask_type{1} << 18}
static constexpr size_type | criterion_check_started {19}
static constexpr mask_type | criterion_check_started_mask {mask_type{1} << 19}
static constexpr size_type | criterion_check_completed {20}
static constexpr mask_type | criterion_check_completed_mask {mask_type{1} << 20}
static constexpr size_type | iteration_complete {21}
static constexpr mask_type | iteration_complete_mask {mask_type{1} << 21}
static constexpr size_type | polymorphic_object_move_started {22}
static constexpr mask_type | polymorphic_object_move_started_mask {mask_type{1} << 22}
static constexpr size_type | polymorphic_object_move_completed {23}
static constexpr mask_type | polymorphic_object_move_completed_mask {mask_type{1} << 23}
static constexpr size_type | batch_linop_factory_generate_started {24}
static constexpr mask_type | batch_linop_factory_generate_started_mask {mask_type{1} << 24}
static constexpr size_type | batch_linop_factory_generate_completed {25}
static constexpr mask_type | batch_linop_factory_generate_completed_mask {mask_type{1} << 25}
static constexpr size_type | batch_solver_completed {26}
static constexpr mask_type | batch_solver_completed_mask {mask_type{1} << 26}
static constexpr mask_type | executor_events_mask
| Bitset Mask which activates all executor events.
static constexpr mask_type | operation_events_mask
| Bitset Mask which activates all operation events.
static constexpr mask_type | polymorphic_object_events_mask
| Bitset Mask which activates all polymorphic object events.
static constexpr mask_type | linop_events_mask
| Bitset Mask which activates all linop events.
static constexpr mask_type | linop_factory_events_mask
| Bitset Mask which activates all linop factory events.
static constexpr mask_type | batch_linop_factory_events_mask
| Bitset Mask which activates all batch linop factory events.
static constexpr mask_type | criterion_events_mask
| Bitset Mask which activates all criterion events.

## Detailed Description

template<typename ValueType = default_precision>
class gko::log::Convergence< ValueType >

Convergence is a Logger which logs data strictly from the criterion_check_completed event.

The purpose of this logger is to give a simple access to standard data generated by the solver once it has stopped with minimal overhead.

This logger also computes the residual norm from the residual when the residual norm was not available. This can add some slight overhead.

## Member Function Documentation

## ◆ create() [1/2]

template<typename ValueType = default_precision>

std::unique_ptr< Convergence > gko::log::Convergence< ValueType >::create | ( | const mask_type & | enabled_events = Logger::criterion_events_mask | Logger::iteration_complete_mask | ) |
| inlinestatic

Creates a convergence logger.

This dynamically allocates the memory, constructs the object and returns an std::unique_ptr to this object.

Parameters

  enabled_events | the events enabled for this logger. By default all events.

Returns
  an std::unique_ptr to the the constructed object

References gko::log::Logger::criterion_events_mask.

## ◆ create() [2/2]

template<typename ValueType = default_precision>

std::unique_ptr< Convergence > gko::log::Convergence< ValueType >::create | ( | std::shared_ptr< const Executor > | ,
|  | const mask_type & | enabled_events = Logger::criterion_events_mask | Logger::iteration_complete_mask )
| inlinestatic

Creates a convergence logger.

This dynamically allocates the memory, constructs the object and returns an std::unique_ptr to this object.

Parameters

  exec | the executor
  enabled_events | the events enabled for this logger. By default all events.

Returns
  an std::unique_ptr to the the constructed object

References create(), and gko::log::Logger::criterion_events_mask.

Referenced by create().

## ◆ get_implicit_sq_resnorm()

template<typename ValueType = default_precision>

const LinOp * gko::log::Convergence< ValueType >::get_implicit_sq_resnorm | ( |  | ) | const
| inlinenoexcept

Returns the implicit squared residual norm.

Returns
  the implicit squared residual norm

## ◆ get_num_iterations()

template<typename ValueType = default_precision>

const size_type & gko::log::Convergence< ValueType >::get_num_iterations | ( |  | ) | const
| inlinenoexcept

Returns the number of iterations.

Returns
  the number of iterations

## ◆ get_residual()

template<typename ValueType = default_precision>

const LinOp * gko::log::Convergence< ValueType >::get_residual | ( |  | ) | const
| inlinenoexcept

Returns the residual.

Returns
  the residual

## ◆ get_residual_norm()

template<typename ValueType = default_precision>

const LinOp * gko::log::Convergence< ValueType >::get_residual_norm | ( |  | ) | const
| inlinenoexcept

Returns the residual norm.

Returns
  the residual norm

## ◆ has_converged()

template<typename ValueType = default_precision>

bool gko::log::Convergence< ValueType >::has_converged | ( |  | ) | const
| inlinenoexcept

Returns true if the solver has converged.

Returns
  the bool flag for convergence status

## ◆ on_criterion_check_completed() [1/2]

template<typename ValueType = default_precision>

void gko::log::Convergence< ValueType >::on_criterion_check_completed | ( | const stop::Criterion * | criterion,
|  | const size_type & | it,
|  | const LinOp * | r,
|  | const LinOp * | tau,
|  | const LinOp * | implicit_tau_sq,
|  | const LinOp * | x,
|  | const uint8 & | stopping_id,
|  | const bool & | set_finalized,
|  | const array< stopping_status > * | status,
|  | const bool & | one_changed,
|  | const bool & | all_converged ) const
| overridevirtual

stop::Criterion's check completed event.

Parameters are the Criterion, the stoppingId, the finalized boolean, the stopping status, plus the output one_changed boolean and output all_converged boolean.

Parameters

  criterion | the criterion used
  it | the current iteration count
  r | the residual
  tau | the residual norm
  implicit_tau_sq | the implicit residual norm squared
  x | the solution
  stopping_id | the id of the stopping criterion
  set_finalized | whether this finalizes the iteration
  status | the stopping status of the right hand sides
  one_changed | whether at least one right hand side converged or not
  all_converged | whether all right hand sides are converged

Reimplemented from gko::log::Logger.

## ◆ on_criterion_check_completed() [2/2]

template<typename ValueType = default_precision>

void gko::log::Convergence< ValueType >::on_criterion_check_completed | ( | const stop::Criterion * | criterion,
|  | const size_type & | it,
|  | const LinOp * | r,
|  | const LinOp * | tau,
|  | const LinOp * | x,
|  | const uint8 & | stopping_id,
|  | const bool & | set_finalized,
|  | const array< stopping_status > * | status,
|  | const bool & | one_changed,
|  | const bool & | all_converged ) const
| overridevirtual

stop::Criterion's check completed event.

Parameters are the Criterion, the stoppingId, the finalized boolean, the stopping status, plus the output one_changed boolean and output all_converged boolean.

Parameters

  criterion | the criterion used
  it | the current iteration count
  r | the residual
  tau | the residual norm
  x | the solution
  stopping_id | the id of the stopping criterion
  set_finalized | whether this finalizes the iteration
  status | the stopping status of the right hand sides
  one_changed | whether at least one right hand side converged or not
  all_converged | whether all right hand sides

Note
  The on_criterion_check_completed function that this macro declares is deprecated. Please use the one with the additional implicit_tau_sq parameter as below.

Reimplemented from gko::log::Logger.

## ◆ on_iteration_complete()

template<typename ValueType = default_precision>

void gko::log::Convergence< ValueType >::on_iteration_complete | ( | const LinOp * | solver,
|  | const LinOp * | b,
|  | const LinOp * | x,
|  | const size_type & | it,
|  | const LinOp * | r,
|  | const LinOp * | tau,
|  | const LinOp * | implicit_tau_sq,
|  | const array< stopping_status > * | status,
|  | bool | stopped ) const
| overridevirtual

Register the iteration_complete event which logs every completed iterations.

Parameters

  solver | the solver executing the iteration
  b | the right-hand-side vector
  x | the solution vector
  it | the current iteration count
  r | the residual (optional)
  tau | the implicit residual norm squared (optional)
  implicit_tau_sq | the residual norm (optional)
  status | the stopping status of the right hand sides (optional)
  stopped | whether all right hand sides have stopped (invalid if status is not provided)

Reimplemented from gko::log::Logger.

The documentation for this class was generated from the following file:

- ginkgo/core/log/convergence.hpp