main Program

Uses

  • program~~main~11~~UsesGraph program~main~11 main module~mapl_errorhandlingmod MAPL_ErrorHandlingMod program~main~11->module~mapl_errorhandlingmod module~mapl_profiler mapl_Profiler program~main~11->module~mapl_profiler mpi mpi program~main~11->mpi

Calls

program~~main~11~~CallsGraph program~main~11 main _verify _verify program~main~11->_verify mpi_finalize mpi_finalize program~main~11->mpi_finalize mpi_init mpi_init program~main~11->mpi_init none~accumulate~5 BaseProfiler%accumulate program~main~11->none~accumulate~5 none~add_column MultiColumn%add_column program~main~11->none~add_column none~generate_report ProfileReporter%generate_report program~main~11->none~generate_report none~reset~68 BaseProfiler%reset program~main~11->none~reset~68 none~start~83 TimeProfiler%start program~main~11->none~start~83 proc~do_lap~2 do_lap program~main~11->proc~do_lap~2 accumulate accumulate none~accumulate~5->accumulate none~back~42 MeterNodeStack%back none~accumulate~5->none~back~42 none~get_root_node BaseProfiler%get_root_node none~accumulate~5->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 TextColumnVector%push_back none~add_column->none~push_back 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~68->begin get_meter get_meter none~reset~68->get_meter next next none~reset~68->next none~reset~68->none~get_root_node none~start~47 BaseProfiler%start none~reset~68->none~start~47 reset reset none~reset~68->reset none~start_self BaseProfiler%start_self none~start~83->none~start_self proc~do_lap~2->none~start~83 none~generate_report_profiler->none~get_root_node none~generate_report_profiler->none~get_width none~get_header~4 MultiColumn%get_header none~generate_report_profiler->none~get_header~4 none~get_rows~6 MultiColumn%get_rows none~generate_report_profiler->none~get_rows~6 none~capacity TextColumnVector%capacity none~push_back->none~capacity none~resize~2 TextColumnVector%resize none~push_back->none~resize~2 none~start_self->none~start~47 interface~mapl_assert MAPL_Assert none~start_self->interface~mapl_assert none~get_name~5 MeterNode%get_name none~start_self->none~get_name~5 proc~mapl_return MAPL_Return none~start_self->proc~mapl_return none~start~47->none~start_self

Variables

Type Attributes Name Initial
character(len=:), allocatable :: report_lines(:)
integer :: i
integer :: ierror
integer :: rc
integer :: status
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
   use MAPL_ErrorHandlingMod
   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, rc, status

   call MPI_Init(ierror)
   _VERIFY(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