profiler_start Subroutine

public subroutine profiler_start(name, nvtx_only)

Start a named profiling region

If nvtx_only is true, the region only appears in NVTX timeline, not in the text report from profiler_report().

Arguments

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

Calls

proc~~profiler_start~~CallsGraph proc~profiler_start profiler_start proc~find_or_create_region find_or_create_region proc~profiler_start->proc~find_or_create_region proc~nvtx_range_push nvtx_range_push proc~profiler_start->proc~nvtx_range_push proc~timer_start timer_type%timer_start proc~profiler_start->proc~timer_start

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: idx

Source Code

   subroutine profiler_start(name, nvtx_only)
      !! Start a named profiling region
      !!
      !! If nvtx_only is true, the region only appears in NVTX timeline,
      !! not in the text report from profiler_report().
      character(len=*), intent(in) :: name
      logical, intent(in), optional :: nvtx_only
      integer(default_int) :: idx

#ifdef PIC_DISABLE_PROFILER
      return
#endif

      if (.not. state%enabled) return

      idx = find_or_create_region(name)
      if (idx < 0) return

      ! Don't start if already active (nested calls to same region)
      if (state%regions(idx)%active) return

      if (present(nvtx_only) .and. state%regions(idx)%call_count == 0) then
         state%regions(idx)%nvtx_only = nvtx_only
      end if

      state%regions(idx)%active = .true.
      call nvtx_range_push(name)
      call state%regions(idx)%timer%start()

      ! Push onto stack for stack-based stop
      state%stack_depth = state%stack_depth + 1
      state%stack(state%stack_depth) = idx
   end subroutine profiler_start