Lightweight profiler for named code regions with optional NVTX support
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=default_int), | private, | parameter | :: | MAX_NAME_LEN | = | 64 |
Maximum length of region names |
| integer(kind=default_int), | private, | parameter | :: | MAX_REGIONS | = | 256 |
Maximum number of distinct profiling regions |
| type(profiler_state), | private, | save | :: | state |
Global profiler state (module-level singleton) |
Internal type for global profiler state
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| logical, | public | :: | enabled | = | .true. | ||
| logical, | public | :: | initialized | = | .false. | ||
| integer(kind=default_int), | public | :: | num_regions | = | 0 | ||
| type(tracked_region), | public | :: | regions(MAX_REGIONS) | ||||
| integer(kind=default_int), | public | :: | stack(MAX_REGIONS) |
Stack of active region indices (for stack-based stop) |
|||
| integer(kind=default_int), | public | :: | stack_depth | = | 0 |
Current depth of the active region stack |
Internal type for tracking a single profiling region
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| logical, | public | :: | active | = | .false. | ||
| integer(kind=default_int), | public | :: | call_count | = | 0 | ||
| character(len=MAX_NAME_LEN), | public | :: | name | = | '' | ||
| logical, | public | :: | nvtx_only | = | .false. |
If true, only shows in NVTX timeline, not in text report |
|
| type(timer_type), | public | :: | timer |
PIC timer for this region |
|||
| real(kind=dp), | public | :: | total_time | = | 0.0_dp |
Get accumulated time for a named region
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | name |
Find an existing region by name or create a new one Returns -1 if MAX_REGIONS is exceeded
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | name |
Enable profiling (if it was disabled)
Initialize the profiler
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| logical, | intent(in), | optional | :: | enabled |
Print profiling report sorted by time
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in), | optional | :: | title | ||
| character(len=*), | intent(in), | optional | :: | root_region |
Start a named profiling region
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | name | |||
| logical, | intent(in), | optional | :: | nvtx_only |
Stop a profiling region
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in), | optional | :: | name |
Pop an NVTX range (no-op if PIC_USE_NVTX not defined)
Push an NVTX range (no-op if PIC_USE_NVTX not defined)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | name |
Remove a region index from the stack (helper for explicit stop)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | idx |