Stop a profiling region
If name is omitted, stops the most recently started region (stack-based). If name is provided, stops that specific region (for explicit control). Time is accumulated across multiple start/stop pairs.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in), | optional | :: | name |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=default_int), | private | :: | idx |
subroutine profiler_stop(name) !! Stop a profiling region !! !! If name is omitted, stops the most recently started region (stack-based). !! If name is provided, stops that specific region (for explicit control). !! Time is accumulated across multiple start/stop pairs. character(len=*), intent(in), optional :: name integer(default_int) :: idx #ifdef PIC_DISABLE_PROFILER return #endif if (.not. state%enabled) return if (present(name)) then ! Find the region by name do idx = 1, state%num_regions if (trim(state%regions(idx)%name) == trim(name)) exit end do if (idx > state%num_regions) return if (.not. state%regions(idx)%active) return ! Remove from stack (may not be at top if using explicit names) call remove_from_stack(idx) else ! Stack-based: pop the most recent region if (state%stack_depth == 0) return idx = state%stack(state%stack_depth) state%stack_depth = state%stack_depth - 1 if (.not. state%regions(idx)%active) return end if call state%regions(idx)%timer%stop() call nvtx_range_pop() state%regions(idx)%total_time = state%regions(idx)%total_time + & state%regions(idx)%timer%get_elapsed_time() state%regions(idx)%call_count = state%regions(idx)%call_count + 1 state%regions(idx)%active = .false. end subroutine profiler_stop