mod_profiling Module

Performance profiling and execution timing utilities.

Supports: - Flat timing report for all named regions. - Optional nested report based on profiler_start/profiler_stop call stack. - Runtime enable/disable via profiler_configure().

Timings are inclusive. Flat profiler rows are not additive when nested timers are enabled. Current top-level timer names include Transport_Update, Projection_Step, Species_Transport, Energy_Transport, Diagnostics_Write_Flow, Diagnostics_Write_Energy, and Output_Write_VTU; energy Cantera sync timers are Energy_Cantera_PreSync and Energy_Cantera_PostSync.



Variables

Type Visibility Attributes Name Initial
integer, private, parameter :: MAX_EDGES = 4096
integer, private, parameter :: MAX_STACK = 128
integer, private, parameter :: MAX_TIMERS = 512
integer, private, parameter :: NAME_LEN = 96
type(profiler_edge_t), private, save :: edges(MAX_EDGES)
integer, private, save :: nedges = 0
logical, private, save :: nested_enabled = .true.
integer, private, save :: ntimers = 0
logical, private, save :: profiling_enabled = .true.
integer, private, save :: stack_depth = 0
integer, private, save :: stack_ids(MAX_STACK) = 0
real(kind=rk), private, save :: stack_start(MAX_STACK) = 0.0_rk
type(profiler_timer_t), private, save :: timers(MAX_TIMERS)

Derived Types

type, private ::  profiler_edge_t

Components

Type Visibility Attributes Name Initial
integer, public :: calls = 0
integer, public :: child = 0
integer, public :: parent = 0
real(kind=rk), public :: total_time = 0.0_rk

type, private ::  profiler_timer_t

Components

Type Visibility Attributes Name Initial
integer, public :: calls = 0
character(len=NAME_LEN), public :: name = ''
real(kind=rk), public :: total_time = 0.0_rk

Functions

private function find_or_create_timer(name) result(idx)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Return Value integer


Subroutines

public subroutine profiler_configure(enabled, nested)

Configure profiling behavior at runtime.

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: enabled
logical, intent(in) :: nested

public subroutine profiler_register_standard_timers()

Registers the solver's standard timers on all ranks in deterministic order.

Arguments

None

public subroutine profiler_register_timer(name)

Pre-registers a timer name without starting it.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

public subroutine profiler_report(comm, rank, nprocs)

Generates a collective performance report across all MPI ranks.

Arguments

Type IntentOptional Attributes Name
type(MPI_Comm), intent(in) :: comm
integer, intent(in) :: rank
integer, intent(in) :: nprocs

public subroutine profiler_reset()

Reset all profiler state.

Arguments

None

public subroutine profiler_start(name)

Starts a timer for a named kernel.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

public subroutine profiler_stop(name)

Stops a timer and accumulates the elapsed time.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

private subroutine check_mpi(ierr, where)

Internal utility to check MPI return codes and abort on failure.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ierr

The MPI return code.

character(len=*), intent(in) :: where

Descriptive string of where the failure occurred.

private subroutine record_edge(parent, child, elapsed)

Updates the call tree edge statistics between two timers.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: parent

Index of the calling timer.

integer, intent(in) :: child

Index of the called timer.

real(kind=rk), intent(in) :: elapsed

Wall time spent in this call.