main Program

Uses

  • program~~main~21~~UsesGraph program~main~21 main module~mapl_profiler mapl_Profiler program~main~21->module~mapl_profiler mpi mpi program~main~21->mpi

Calls

program~~main~21~~CallsGraph program~main~21 main mpi_finalize mpi_finalize program~main~21->mpi_finalize mpi_init mpi_init program~main~21->mpi_init none~accumulate~2 BaseProfiler%accumulate program~main~21->none~accumulate~2 none~add_column MultiColumn%add_column program~main~21->none~add_column none~generate_report ProfileReporter%generate_report program~main~21->none~generate_report none~reset~28 BaseProfiler%reset program~main~21->none~reset~28 none~start~82 TimeProfiler%start program~main~21->none~start~82 proc~do_lap~2 do_lap program~main~21->proc~do_lap~2 accumulate accumulate none~accumulate~2->accumulate none~back~32 MeterNodeStack%back none~accumulate~2->none~back~32 none~get_root_node BaseProfiler%get_root_node none~accumulate~2->none~get_root_node get_num_rows_header get_num_rows_header none~add_column->get_num_rows_header none~get_num_rows_separator TextColumn%get_num_rows_separator none~add_column->none~get_num_rows_separator none~get_width TextColumn%get_width none~add_column->none~get_width none~push_back~47 TextColumnVector%push_back none~add_column->none~push_back~47 none~set_width TextColumn%set_width none~add_column->none~set_width none~generate_report_profiler ProfileReporter%generate_report_profiler none~generate_report->none~generate_report_profiler begin begin none~reset~28->begin get_meter get_meter none~reset~28->get_meter next next none~reset~28->next none~reset~28->none~get_root_node none~start~46 BaseProfiler%start none~reset~28->none~start~46 reset reset none~reset~28->reset none~start_self BaseProfiler%start_self none~start~82->none~start_self proc~do_lap~2->none~start~82 none~generate_report_profiler->none~get_root_node none~generate_report_profiler->none~get_width none~get_header~5 MultiColumn%get_header none~generate_report_profiler->none~get_header~5 none~get_rows~7 MultiColumn%get_rows none~generate_report_profiler->none~get_rows~7 none~capacity~277 TextColumnVector%capacity none~push_back~47->none~capacity~277 none~resize~94 TextColumnVector%resize none~push_back~47->none~resize~94 none~start_self->none~start~46 interface~mapl_assert MAPL_Assert none~start_self->interface~mapl_assert none~get_name~2 MeterNode%get_name none~start_self->none~get_name~2 proc~mapl_return MAPL_Return none~start_self->proc~mapl_return none~start~46->none~start_self

Variables

Type Attributes Name Initial
character(len=:), allocatable :: report_lines(:)
integer :: i
integer :: ierror
type(ProfileReporter) :: reporter
type(TimeProfiler), target :: lap_prof
type(TimeProfiler), target :: main_prof

Subroutines

subroutine do_lap(prof)

Arguments

Type IntentOptional Attributes Name
type(TimeProfiler), target :: prof

Source Code

program main
   use MPI
   use MAPL_Profiler
   implicit none


   !type (MemoryProfiler), target :: mem_prof
   type (TimeProfiler), target :: main_prof
   type (TimeProfiler), target :: lap_prof
   type (ProfileReporter) :: reporter
   !type (ProfileReporter) :: mem_reporter

   character(:), allocatable :: report_lines(:)
   integer :: i
   integer :: ierror

   call MPI_Init(ierror)
   main_prof = TimeProfiler('TOTAL')   ! timer 1
   call main_prof%start()
   lap_prof = TimeProfiler('Lap')
   call lap_prof%start()
   !mem_prof = MemoryProfiler('TOTAL')
   
   call main_prof%start('init reporter')
   call reporter%add_column(NameColumn(20))
   call reporter%add_column(FormattedTextColumn('#-cycles','(i5.0)', 5, NumCyclesColumn()))
   call reporter%add_column(FormattedTextColumn(' T(inc)','(f9.6)', 9, InclusiveColumn()))
   call reporter%add_column(FormattedTextColumn(' T(exc)','(f9.6)', 9, ExclusiveColumn()))
   call reporter%add_column(FormattedTextColumn('%(inc)','(f6.2)', 6, PercentageColumn(InclusiveColumn())))
   call reporter%add_column(FormattedTextColumn('%(exc)','(f6.2)', 6, PercentageColumn(ExclusiveColumn())))
   call reporter%add_column(FormattedTextColumn('  std. dev ','(f12.4)', 12, StdDevColumn()))
   call reporter%add_column(FormattedTextColumn('  rel. dev ','(f12.4)', 12, StdDevColumn(relative=.true.)))
   call reporter%add_column(FormattedTextColumn('  max cyc ','(f12.8)', 12, MaxCycleColumn()))
   call reporter%add_column(FormattedTextColumn('  min cyc ','(f12.8)', 12, MinCycleColumn()))
   call reporter%add_column(FormattedTextColumn(' mean cyc','(f12.8)', 12, MeanCycleColumn()))

   !call mem_reporter%add_column(NameColumn(20))
   !call mem_reporter%add_column(FormattedTextColumn('#-cycles','(i5.0)', 5, NumCyclesColumn()))
   !call mem_reporter%add_column(MemoryTextColumn('  RSS  ','(i4,1x,a2)', 7, InclusiveColumn()))
   !call mem_reporter%add_column(MemoryTextColumn('Cyc RSS','(i4,1x,a2)', 7, MeanCycleColumn()))

   call main_prof%stop('init reporter')


   !call mem_prof%start('lap')
   call do_lap(lap_prof) ! lap 1
   call lap_prof%stop()
   call main_prof%accumulate(lap_prof)
   !call mem_prof%stop('lap')


   call main_prof%start('use reporter')
   report_lines = reporter%generate_report(lap_prof)
   write(*,'(a)')'Lap 1'
   write(*,'(a)')'====='
   do i = 1, size(report_lines)
      write(*,'(a)') report_lines(i)
   end do
   write(*,'(a)')''
   call main_prof%stop('use reporter')

   !call mem_prof%start('lap')
   call lap_prof%reset()
   call do_lap(lap_prof) ! lap 2
   call lap_prof%stop()
   call main_prof%accumulate(lap_prof)
   call main_prof%start('use reporter')
   report_lines = reporter%generate_report(lap_prof)
   write(*,'(a)')'Lap 2'
   write(*,'(a)')'====='
   do i = 1, size(report_lines)
      write(*,'(a)') report_lines(i)
   end do
   write(*,'(a)') ''
   call main_prof%stop('use reporter')
   !call mem_prof%stop('lap')

   call main_prof%stop()
   report_lines = reporter%generate_report(main_prof)
   write(*,'(a)')'Final profile'
   write(*,'(a)')'============='
   do i = 1, size(report_lines)
      write(*,'(a)') report_lines(i)
   end do
   write(*,'(a)') ''


   call MPI_Finalize(ierror)

   !call mem_prof%finalize()
   !report_lines = mem_reporter%generate_report(mem_prof)
   !write(*,'(a)')'Memory profile'
   !write(*,'(a)')'=============='
   !do i = 1, size(report_lines)
   !   write(*,'(a)') report_lines(i)
   !end do
   !write(*,'(a)') ''

contains

   subroutine do_lap(prof)
      type (TimeProfiler), target :: prof

      real, pointer :: x(:)

      allocate(x(10**7))
      call random_number(x)
      print*,sum(x)
      call prof%start('timer_1') ! 2
      call prof%start('timer_1a')! 3
      call prof%stop('timer_1a')
      call prof%start('timer_1b') ! 4
      call prof%start('timer_1b1') ! 5
      call prof%stop('timer_1b1')
      call prof%stop('timer_1b')
      call prof%stop('timer_1')
      call prof%start('timer_2') ! 6
      call prof%start('timer_2b')! 7
      call prof%stop('timer_2b')
      call prof%stop('timer_2')

      call prof%start('timer_1') ! 2
      call prof%start('timer_1a')! 3
      call prof%stop('timer_1a')
      call prof%stop('timer_1')

      call prof%start('timer_2') ! 6
      call prof%stop('timer_2')
      call prof%start('timer_2') ! 6
      call prof%stop('timer_2')
   end subroutine do_lap


end program main