Changeset 3749


Ignore:
Timestamp:
Jul 8, 2020, 7:49:06 PM (4 years ago)
Author:
adurocher
Message:

Added getin parameter to enable/disable profiling

Location:
LMDZ6/branches/Optimisation_LMDZ/libf/phy_common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/Optimisation_LMDZ/libf/phy_common/ioipsl_getin_p_mod.F90

    r2352 r3749  
    1717!-
    1818PRIVATE
    19 PUBLIC :: getin_p
     19PUBLIC :: getin_p, getin
    2020!-
    2121INTERFACE getin_p
  • LMDZ6/branches/Optimisation_LMDZ/libf/phy_common/profiling_physic.F90

    r3746 r3749  
    3737  REAL, ALLOCATABLE :: elapsed(:,:)!(omp_size, max_id) ! Cumulative time for each timer
    3838  SCOREP_DEFINE_HANDLE_ARRAY(scorep_handle)
     39
     40  LOGICAL :: profiling_enabled = .false.
    3941 
    4042  PUBLIC :: enter_profile, exit_profile, print_profile
     
    4345  ! Be sure to init mod_phys_lmdz_omp_data before profiling
    4446  SUBROUTINE init_profiling
     47    use ioipsl_getin_p_mod, only : getin
     48    call getin("phy_profiling_enable", profiling_enabled)
    4549    nb_id=0
    4650    allocate(depth(0:omp_size-1))
     
    9498      !$omp end master
    9599      !$omp barrier
    96     end if   
    97     ! Create prof_id at first call with 'name'
    98     if( .not. exists(ids, name) ) then
    99        call checked_omp_barrier(name)
    100        !$omp master
    101        call register_id(name,id)
    102        call insert_or_assign(ids, name, id)
    103        !$omp end master
    104        !$omp barrier
    105     end if
    106     call enter_profile_aux(get_val(ids, name))
     100    end if
     101    if( profiling_enabled ) then
     102      ! Create prof_id at first call with 'name'
     103      if( .not. exists(ids, name) ) then
     104        call checked_omp_barrier(name)
     105        !$omp master
     106        call register_id(name,id)
     107        call insert_or_assign(ids, name, id)
     108        !$omp end master
     109        !$omp barrier
     110      end if
     111      call enter_profile_aux(get_val(ids, name))
     112    endif
    107113  END SUBROUTINE
    108114 
     
    118124  ! Region must exist and be active on current thread
    119125  SUBROUTINE exit_profile(name)
    120     CHARACTER(*) :: name   
    121     if(.not. exists(ids, name)) call abort_physic(modname, "Exit unknown timer", 1)
    122     call exit_profile_aux(get_val(ids,name))
     126    CHARACTER(*) :: name
     127    if( profiling_enabled ) then   
     128      if(.not. exists(ids, name)) call abort_physic(modname, "Exit unknown timer", 1)
     129      call exit_profile_aux(get_val(ids,name))
     130    endif
    123131  END SUBROUTINE
    124132   
     
    155163    REAL :: mean_time, max_process, min_process, percent
    156164
    157     call enter_profile("print_profile")
    158 
    159     !$OMP MASTER
    160     ! mean_total : mean of sum of all timers on all threads and all procs
    161     mean_total_local = SUM(elapsed(:,1:nb_id))/omp_size/mpi_size
    162     !call MPI_Reduce(mean_total_local, mean_total, 1, MPI_DOUBLE, MPI_SUM, 0, comm_icosa, ierr)
    163     call reduce_sum_mpi( mean_total_local, mean_total )
    164     ! min_total : min on all procs of sum of all timers on all threads
    165     min_total_local = MINVAL( SUM(elapsed(:,1:nb_id), 2) )
    166     !call MPI_Reduce(min_total_local, min_total, 1, MPI_DOUBLE, MPI_MIN, 0, comm_icosa, ierr)
    167     call reduce_min_mpi(min_total_local, min_total)
    168     ! max_total : max on all procs of sum of all timers on all threads
    169     max_total_local = MAXVAL( SUM(elapsed(:,1:nb_id), 2) )
    170     !call MPI_Reduce(max_total_local, max_total, 1, MPI_DOUBLE, MPI_MAX, 0, comm_icosa, ierr)
    171     call reduce_max_mpi(max_total_local, max_total)
    172 
    173     if(is_mpi_root) PRINT *, '---------------------- Profiling (Physic) --------------'
    174     if(is_mpi_root) PRINT ('(A15, F12.3, A, F12.3, A, F12.3, A)'), 'Total (Physic) (s) : ', mean_total, "  [", min_total, ",", max_total, "]"
    175     if(is_mpi_root) PRINT ('(A15, A7, A47, A47)'), " ","  %  ","  Process mean(s)[ min, max, diff/mean(%) ]  ", "Process 1 threads(s)[ min, max, diff/mean(%) ]"
    176     DO i=1,nb_id
    177        omp_mean_time_local = SUM(elapsed(:,i))/omp_size ! Mean time of timer on local threads
    178        omp_min_time_local = MINVAL(elapsed(:,i)) ! Max time of timer on local threads
    179        omp_max_time_local = MAXVAL(elapsed(:,i)) ! Min time of timer on local threads
    180        !omp_inbalance_local = 100*(max_time-min_time)/min_time
    181        
    182        ! mean_time : mean of timer on all threads and all procs
    183        !call MPI_Reduce(omp_mean_time_local, mean_time, 1, MPI_DOUBLE, MPI_SUM, 0, comm_icosa, ierr);
    184        call reduce_sum_mpi( omp_mean_time_local, mean_time )
    185        mean_time = mean_time/mpi_size
    186        ! max_process_time : max on procs of mean omp time
    187        !call MPI_Reduce(omp_mean_time_local, max_process, 1, MPI_DOUBLE, MPI_MAX, 0, comm_icosa, ierr)
    188        call reduce_max_mpi(omp_mean_time_local, max_process)
    189        ! min_process_time : min on procs of mean omp time
    190        !call MPI_Reduce(omp_mean_time_local, min_process, 1, MPI_DOUBLE, MPI_MIN, 0, comm_icosa, ierr)
    191        call reduce_min_mpi(omp_mean_time_local, min_process)
    192 
    193        percent = 100*mean_time/mean_total
    194 
    195        if(is_mpi_root) PRINT ('(A15, F5.1, F12.3, A, F12.3, A, F12.3, A, F6.1, A, F12.3, A, F12.3, A, F12.3, A, F6.1, A)'), name(i), percent, mean_time, " [", min_process, ",", max_process, "," , inbalance(mean_time, min_process, max_process),  "]", omp_mean_time_local, " [", omp_min_time_local, ",", omp_max_time_local, "," , inbalance(omp_mean_time_local, omp_min_time_local, omp_max_time_local) , "]"
    196     END DO
    197     if(is_mpi_root) PRINT *, '---------------------- Profiling -----------------------'
    198     !$OMP END MASTER
    199     call exit_profile("print_profile")
     165    if( profiling_enabled ) then
     166      call enter_profile("print_profile")
     167
     168      !$OMP MASTER
     169      ! mean_total : mean of sum of all timers on all threads and all procs
     170      mean_total_local = SUM(elapsed(:,1:nb_id))/omp_size/mpi_size
     171      !call MPI_Reduce(mean_total_local, mean_total, 1, MPI_DOUBLE, MPI_SUM, 0, comm_icosa, ierr)
     172      call reduce_sum_mpi( mean_total_local, mean_total )
     173      ! min_total : min on all procs of sum of all timers on all threads
     174      min_total_local = MINVAL( SUM(elapsed(:,1:nb_id), 2) )
     175      !call MPI_Reduce(min_total_local, min_total, 1, MPI_DOUBLE, MPI_MIN, 0, comm_icosa, ierr)
     176      call reduce_min_mpi(min_total_local, min_total)
     177      ! max_total : max on all procs of sum of all timers on all threads
     178      max_total_local = MAXVAL( SUM(elapsed(:,1:nb_id), 2) )
     179      !call MPI_Reduce(max_total_local, max_total, 1, MPI_DOUBLE, MPI_MAX, 0, comm_icosa, ierr)
     180      call reduce_max_mpi(max_total_local, max_total)
     181
     182      if(is_mpi_root) PRINT *, '---------------------- Profiling (Physic) --------------'
     183      if(is_mpi_root) PRINT ('(A15, F12.3, A, F12.3, A, F12.3, A)'), 'Total (Physic) (s) : ', mean_total, "  [", min_total, ",", max_total, "]"
     184      if(is_mpi_root) PRINT ('(A15, A7, A47, A47)'), " ","  %  ","  Process mean(s)[ min, max, diff/mean(%) ]  ", "Process 1 threads(s)[ min, max, diff/mean(%) ]"
     185      DO i=1,nb_id
     186        omp_mean_time_local = SUM(elapsed(:,i))/omp_size ! Mean time of timer on local threads
     187        omp_min_time_local = MINVAL(elapsed(:,i)) ! Max time of timer on local threads
     188        omp_max_time_local = MAXVAL(elapsed(:,i)) ! Min time of timer on local threads
     189        !omp_inbalance_local = 100*(max_time-min_time)/min_time
     190       
     191        ! mean_time : mean of timer on all threads and all procs
     192        !call MPI_Reduce(omp_mean_time_local, mean_time, 1, MPI_DOUBLE, MPI_SUM, 0, comm_icosa, ierr);
     193        call reduce_sum_mpi( omp_mean_time_local, mean_time )
     194        mean_time = mean_time/mpi_size
     195        ! max_process_time : max on procs of mean omp time
     196        !call MPI_Reduce(omp_mean_time_local, max_process, 1, MPI_DOUBLE, MPI_MAX, 0, comm_icosa, ierr)
     197        call reduce_max_mpi(omp_mean_time_local, max_process)
     198        ! min_process_time : min on procs of mean omp time
     199        !call MPI_Reduce(omp_mean_time_local, min_process, 1, MPI_DOUBLE, MPI_MIN, 0, comm_icosa, ierr)
     200        call reduce_min_mpi(omp_mean_time_local, min_process)
     201
     202        percent = 100*mean_time/mean_total
     203
     204        if(is_mpi_root) PRINT ('(A15, F5.1, F12.3, A, F12.3, A, F12.3, A, F6.1, A, F12.3, A, F12.3, A, F12.3, A, F6.1, A)'), name(i), percent, mean_time, " [", min_process, ",", max_process, "," , inbalance(mean_time, min_process, max_process),  "]", omp_mean_time_local, " [", omp_min_time_local, ",", omp_max_time_local, "," , inbalance(omp_mean_time_local, omp_min_time_local, omp_max_time_local) , "]"
     205      END DO
     206      if(is_mpi_root) PRINT *, '---------------------- Profiling -----------------------'
     207      !$OMP END MASTER
     208      call exit_profile("print_profile")
     209    endif
    200210  contains
    201211    function inbalance( mean, min, max )
Note: See TracChangeset for help on using the changeset viewer.