lightkrylov_timer Derived Type

type, public :: lightkrylov_timer

Individual timer. Atomic timer that is associated to a particular 'event' by name which may be a procedure or a user-defined string at instantiation.

The timing information in gathered for each timer independently. The individual timers are gathered into groups (relevant only for timing output) and managed by a central watch that is derived from the abstract_watch type. The individual timers are rarely user independently but all timing actions are typically performed via procedures in the central timer.

A notable exception are the matvec/rmatvec as well as reponse timers associated with the types abstract_linop and abstract_system, respectively, which are managed via their parent types and the corresponding type-bound procedures only.


Components

Type Visibility Attributes Name Initial
character(len=128), public :: name = 'default_timer'

Timer name.


Type-Bound Procedures

procedure, public, pass(self) :: finalize => finalize_timer

Aggregate data and prepare summary.

  • private subroutine finalize_timer(self, if_silent)

    Type-bound to lightkrylov_timer: Prepare timer summary.

    Arguments

    Type IntentOptional Attributes Name
    class(lightkrylov_timer), intent(inout) :: self
    logical, intent(in), optional :: if_silent

    No output

procedure, public, pass(self) :: get_data => get_timer_data

Getter routine to access to all local data: etime, counts, etime_max, etime_min, etime_pause.

  • private subroutine get_timer_data(self, restart, etime, etmin, etmax, etimp, lcount, rcount, gcount)

    Type-bound to lightkrylov_timer: Getter routine to return the timer data. Note: If it is running, the timer is stopped.

    Arguments

    Type IntentOptional Attributes Name
    class(lightkrylov_timer), intent(inout) :: self
    logical, intent(in), optional :: restart
    real(kind=dp), intent(out), optional :: etime
    real(kind=dp), intent(out), optional :: etmin
    real(kind=dp), intent(out), optional :: etmax
    real(kind=dp), intent(out), optional :: etimp
    integer, intent(out), optional :: lcount
    integer, intent(out), optional :: rcount
    integer, intent(out), optional :: gcount

procedure, public, pass(self) :: get_time => get_timer_etime

Getter routine to access self%etime only.

  • private function get_timer_etime(self, restart) result(etime)

    Type-bound to lightkrylov_timer: Getter routine to return the current timer etime. Note: If it is running, the timer is stopped.

    Arguments

    Type IntentOptional Attributes Name
    class(lightkrylov_timer) :: self
    logical, optional :: restart

    Return Value real(kind=dp)

procedure, public, pass(self) :: pause => pause_timer

  • private subroutine pause_timer(self)

    Type-bound to lightkrylov_timer: Pause timer.

    Arguments

    Type IntentOptional Attributes Name
    class(lightkrylov_timer), intent(inout) :: self

procedure, public, pass(self) :: print_info => print_timer_info

Print timing data.

  • private subroutine print_timer_info(self)

    Type-bound to lightkrylov_timer: Compute spimple statistics and print timing information to screen.

    Arguments

    Type IntentOptional Attributes Name
    class(lightkrylov_timer), intent(inout) :: self

procedure, public, pass(self) :: reset => reset_timer

Reset timing data (soft/hard, clear/save data).

  • private subroutine reset_timer(self, soft, clean, verbose)

    Type-bound to lightkrylov_timer: Reset timer.

    Arguments

    Type IntentOptional Attributes Name
    class(lightkrylov_timer), intent(inout) :: self
    logical, intent(in), optional :: soft

    Save timing data and reset only if data was collected (i.e. timer was called), default = .true.

    logical, intent(in), optional :: clean

    Flush timing data as well as previously saved timing data, default = .false.

    logical, intent(in), optional :: verbose

    Always print information about the reset process.

procedure, public, pass(self) :: save_timer_data

Transfer timing data to arrays.

  • private subroutine save_timer_data(self)

    Type-bound to lightkrylov_timer: Save current timing information. Note: This is done irrespective of the call/run status of the timer.

    Arguments

    Type IntentOptional Attributes Name
    class(lightkrylov_timer), intent(inout) :: self

procedure, public, pass(self) :: start => start_timer

  • private subroutine start_timer(self)

    Type-bound to lightkrylov_timer: Start timer.

    Arguments

    Type IntentOptional Attributes Name
    class(lightkrylov_timer), intent(inout) :: self

procedure, public, pass(self) :: stop => stop_timer

  • private subroutine stop_timer(self)

    Type-bound to lightkrylov_timer: Stop timer.

    Arguments

    Type IntentOptional Attributes Name
    class(lightkrylov_timer), intent(inout) :: self

Source Code

   type, public :: lightkrylov_timer
      !! Individual timer.
      !! Atomic timer that is associated to a particular 'event' by name which may be a procedure or a 
      !! user-defined string at instantiation.
      !!
      !! The timing information in gathered for each timer independently. The individual timers are gathered
      !! into groups (relevant only for timing output) and managed by a central watch that is derived from 
      !! the `abstract_watch` type. The individual timers are rarely user independently but all timing 
      !! actions are typically performed via procedures in the central timer.
      !!
      !! A notable exception are the `matvec`/`rmatvec` as well as `reponse` timers associated with the types
      !! `abstract_linop` and `abstract_system`, respectively, which are managed via their parent types and the
      !! corresponding type-bound procedures only.
      private
      character(len=128), public :: name = 'default_timer'
      !! Timer name.
      real(dp) :: etime       = 0.0_dp
      !! Elapsed time since reset.
      real(dp) :: etime_pause = 0.0_dp
      !! Elapsed time up until most recent pause.
      real(dp) :: start_time  = 0.0_dp
      !! Start time for comparison.
      real(dp) :: etime_max   = 0.0_dp
      !! Maximum elapsed time since reset.
      real(dp) :: etime_min   = huge(1.0_dp)
      !! Minimum elapsed time since reset.
      integer :: local_count  = 0
      !! Call counter since reset.
      integer :: reset_count  = 0
      !! Reset counter.
      integer :: count        = 0
      !! Global counter (only reset when data is flushed).
      logical :: running      = .false.
      !! Protection against repeated starts.
      logical :: is_finalized = .false.
      !! Switch for printing.
      real(dp), dimension(:), allocatable :: etime_data
      real(dp), dimension(:), allocatable :: etavg_data
      real(dp), dimension(:), allocatable :: etmin_data
      real(dp), dimension(:), allocatable :: etmax_data
      integer,  dimension(:), allocatable :: count_data
   contains
      private
      procedure, pass(self), public :: start => start_timer
      procedure, pass(self), public :: stop => stop_timer
      procedure, pass(self), public :: pause => pause_timer
      procedure, pass(self), public :: reset => reset_timer
      !! Reset timing data (soft/hard, clear/save data).
      procedure, pass(self), public :: finalize => finalize_timer
      !! Aggregate data and prepare summary.
      procedure, pass(self), public :: get_time => get_timer_etime
      !! Getter routine to access self%etime only.
      procedure, pass(self), public :: get_data => get_timer_data
      !! Getter routine to access to all local data: etime, counts, etime_max, etime_min, etime_pause.
      procedure, pass(self), public :: print_info => print_timer_info
      !! Print timing data.
      procedure, pass(self), public :: save_timer_data
      !! Transfer timing data to arrays.
   end type lightkrylov_timer