V3FIT
Data Types | Functions/Subroutines | Variables
profiler Module Reference

Defines functions for measuring an tabulating performance of function and subroutine calls. These routines are only active when the PROFILE_ON macro is defined. More...

Data Types

type  profiler_bucket
 Full table of profiled functions. More...
 

Functions/Subroutines

subroutine profiler_construct ()
 Construct a profiler. More...
 
subroutine profiler_destruct ()
 Deconstruct a profiler. More...
 
subroutine profiler_set_stop_time (symbol_name, start_time)
 Gets the end time of profiled function. More...
 
real(rprec) function profiler_get_start_time ()
 Gets the start time of profiled function. More...
 
recursive subroutine profiler_sort (low_index, high_index)
 Sorts the profile table based on the average call time. More...
 
integer function profiler_hash_function (symbol_name)
 Computes a hash for the symbol name. More...
 
subroutine profiler_write (iou)
 Write out the profiled data to an output file. More...
 

Variables

integer, parameter profiler_string_size = 68
 Max string length.
 
integer, parameter profiler_bucket_size = 1000
 Max number of buckets.
 
type(profiler_bucket), dimension(profiler_bucket_size), save buckets
 Array of buckets to hold the values.
 

Detailed Description

Defines functions for measuring an tabulating performance of function and subroutine calls. These routines are only active when the PROFILE_ON macro is defined.

Function/Subroutine Documentation

◆ profiler_construct()

subroutine profiler::profiler_construct

Construct a profiler.

This only sets up OpenMP locks if OpenMP support is compiled in. The profile table uses a fixed memory size in global memory.

Definition at line 67 of file profiler.f.

◆ profiler_destruct()

subroutine profiler::profiler_destruct

Deconstruct a profiler.

This only destroys OpenMP locks if OpenMP support is compiled in. The profile table uses a fixed memory size in global memory.

Definition at line 91 of file profiler.f.

◆ profiler_get_start_time()

real (rprec) function profiler::profiler_get_start_time

Gets the start time of profiled function.

Gets a starting time of a function. When profiling is turned off, this returns 0 instead.

Returns
The start time of a function.

Definition at line 194 of file profiler.f.

◆ profiler_hash_function()

integer function profiler::profiler_hash_function ( character (len=*), intent(in)  symbol_name)

Computes a hash for the symbol name.

The hash is computed using the djb2 algorithm.

hash_0 = 5381
hash_i+1 = hash_i * 33 ^ c_i

The magic numbers of 5381 and 33 help the hash function avoid collision and good distribution.

Parameters
[in]symbol_nameName of the symbol to hash.
Returns
The hash value of the symbol.

Definition at line 306 of file profiler.f.

◆ profiler_set_stop_time()

subroutine profiler::profiler_set_stop_time ( character (len=*), intent(in)  symbol_name,
real (rprec), intent(in)  start_time 
)

Gets the end time of profiled function.

Sets the end time of profiled function and adds the result to the table. The symbol name is hashed to determine the index of the array it lives in. If the index is full, the next instance is used. When profiling is turned off, this does nothing. To avoid race conditons in multi threaded code, this must only be run by one thread or process at a time.

Parameters
[in]symbol_nameName of the symbol to profile.
[in]start_timeStarting time of the symbol call.

Definition at line 121 of file profiler.f.

◆ profiler_sort()

recursive subroutine profiler::profiler_sort ( integer, intent(in)  low_index,
integer, intent(in)  high_index 
)

Sorts the profile table based on the average call time.

A recursive merge sort algorithm.

Parameters
[in]low_indexLower index to sort.
[in]high_indexHigher index to sort.

Definition at line 221 of file profiler.f.

◆ profiler_write()

subroutine profiler::profiler_write ( integer, intent(in)  iou)

Write out the profiled data to an output file.

This loops through the buckets and prints out the profiled data. Any empty buckets get skiped.

Parameters
[in]iouInput/output unit of the output file.

Definition at line 336 of file profiler.f.