TABLE OF CONTENTS
ABINIT/timab [ Functions ]
NAME
timab
FUNCTION
Timing subroutine. Calls machine-dependent "timein" which returns elapsed cpu and wall clock times in sec. Depending on value of "option" routine will: (0) zero all accumulators (1) start with new incremental time slice for accumulator n using explicit call to timein (or PAPI) (2) stop time slice; add time to accumulator n also increase by one the counter for this accumulator (3) start with new incremental time slice for accumulator n using stored values for cpu, wall, and PAPI infos ( ! do not use for stop ) (4) report time slice for accumlator n (not full time accumlated) (5) option to suppress timing (nn should be 0) or reenable it (nn /=0) If, on first entry, subroutine is not being initialized, it will automatically initialize as well as rezero accumulator n. However, initialization SHOULD be done explicitly by the user so that it can be done near the top of his/her main routine.
COPYRIGHT
Copyright (C) 1998-2018 ABINIT group (DCA, XG, GMR) This file is distributed under the terms of the GNU General Public License, see ~abinit/COPYING or http://www.gnu.org/copyleft/gpl.txt . For the initials of contributors, see ~abinit/doc/developers/contributors.txt .
INPUTS
nn=index of accumulator (distinguish what is being timed); NOT used if option=0 option=see comment above
OUTPUT
on option=4 : tottim(2,nn)=accumulated time for accumulator nn; otherwise tottim is a dummy variable. option gives the number of times that the accumulator has been incremented
PARENTS
abinit,afterscfloop,atm2fft,bethe_salpeter,calc_sigc_me,calc_sigx_me calcdensph,cchi0,cgq_builder,cgwf,chebfi,cohsex_me,corrmetalwf1,d2frnl density_rec,dfpt_cgwf,dfpt_dyfro,dfpt_dyxc1,dfpt_eltfrhar,dfpt_eltfrkin dfpt_eltfrloc,dfpt_eltfrxc,dfpt_ewald,dfpt_looppert,dfpt_mkrho dfpt_mkvxc,dfpt_mkvxc_noncoll,dfpt_mkvxcstr,dfpt_newvtr,dfpt_nstdy dfpt_nstpaw,dfpt_nstwf,dfpt_rhofermi,dfpt_rhotov,dfpt_scfcv,dfpt_vtorho dfpt_vtowfk,dfpt_wfkfermi,dfptnl_loop,dielmt,dieltcel,dmft_solve dotprodm_v,dotprodm_vn,driver,dyson,eig2stern,eig2tot,elt_ewald eltxccore,energy,entropyrec,etotfor,exc_build_block,exc_build_ham fermisolverec,first_rec,fock2ACE,fock_getghc,forces,forstr,forstrnps fourdp,fourwf,fxphas,getgh1c,getghc,getgsc,getngrec,gran_potrec green_kernel,gstate,gstateimg,gwls_ComputeCorrelationEnergy gwls_DielectricArray,gwls_QR_factorization,gwls_lineqsolver gwls_model_polarisability,gwls_polarisability,gwls_sternheimer,hartre impurity_solve,initberry,initorbmag,initwf,inkpts,invars2,inwffil listkk,lobpcgwf,m_ab7_invars_f90,m_ab7_mixing,m_cgtools,m_dyson_solver m_fftcore,m_fftw3,m_fock,m_green,m_haydock,m_hexc,m_invovl,m_iowf m_lobpcg,m_lobpcg2,m_lobpcgwf,m_paral_pert,m_sg2002,m_wfutils,m_xg m_xgScalapack,mag_constr,mkcore,mkcore_paw,mkcore_wvl,mkffnl mklocl_realspace,mklocl_recipspace,mkresi,mkrho,newkpt,newocc,newrho newvtr,nhatgrid,nlenergyrec,nonlinear,nonlop,odamix,opernla_ylm optics_paw,optics_paw_core,optics_vloc,outkss,outscfcv,pareigocc partial_dos_fractions_paw,pawdenpot,pawdfptenergy,pawinit,pawmknhat pawmknhat_psipsi,pawmkrho,pawpolev,prep_bandfft_tabs,prep_calc_ucrpa prep_fourwf,prep_getghc,prep_nonlop,pspatm,pspheads_comm,pspini pw_orthon,rayleigh_ritz,recursion,recursion_nl,respfn,rhotov,rhotoxc rwwf,scfcv,screening,setsym,setvtr,sigma,sqnormm_v,status,stress,strhar suscep_stat,susk,suskmm,symrhg,symsgcube,tddft,timana,vn_nl_rec,vtorho vtorhorec,vtorhotf,vtowfk,wf_mixing,wfconv,wfk_analyze,wfsinp wvl_nhatgrid,xcden,xcpot
CHILDREN
papif_flops,papif_perror,timein
SOURCE
80 #if defined HAVE_CONFIG_H 81 #include "config.h" 82 #endif 83 84 #include "abi_common.h" 85 86 subroutine timab(nn,option,tottim) 87 88 use defs_basis 89 use defs_time 90 use m_profiling_abi 91 use m_errors 92 use iso_c_binding 93 94 !This section has been created automatically by the script Abilint (TD). 95 !Do not modify the following lines by hand. 96 #undef ABI_FUNC 97 #define ABI_FUNC 'timab' 98 use interfaces_18_timing, except_this_one => timab 99 !End of the abilint section 100 101 implicit none 102 103 #ifdef HAVE_PAPI 104 #include "f90papi.h" 105 #endif 106 107 !Arguments ------------------------------------ 108 !scalars 109 integer,intent(in) :: nn,option 110 !arrays 111 real(dp),intent(out) :: tottim(2) 112 113 !Local variables------------------------------- 114 !scalars 115 real(dp),save :: cpu,wall 116 character(len=500) :: message 117 #ifdef HAVE_PAPI 118 integer(C_INT) :: check 119 integer(C_LONG_LONG),save :: flops1 120 real(C_FLOAT),save :: real_time,proc_time 121 real(C_FLOAT) :: mflops1 122 character(len=PAPI_MAX_STR_LEN) :: papi_errstr 123 #endif 124 ! ************************************************************************* 125 126 if (option==5) timopt=nn 127 128 !If timopt was set to zero by a call with option=5, suppress 129 !all action of this routine (might as well return at this point !) 130 if(timopt/=0 .and. option/=5)then 131 ! 132 ! Check that nn lies in sensible bounds 133 if (nn<1.or.nn>mtim) then 134 write(message,'(a,i0,a,i0)')' mtim = ',mtim,' but input nn = ',nn 135 MSG_BUG(message) 136 end if 137 138 #ifdef HAVE_PAPI 139 ! for all active options for time if papi analysis has been selected. 140 if (option/=3.and.time_get_papiopt()==1) then 141 call PAPIf_flops(real_time, proc_time, flops1, mflops1, check) 142 if (check /= PAPI_OK) then 143 call papif_perror(check,papi_errstr,check) 144 write(std_out,*) 'Problem to initialize papi high level inteface' 145 write(std_out,*) 'Error code', papi_errstr 146 end if 147 if (flops1 < 0) then 148 MSG_WARNING("Number of floating point instruction Overflow") 149 papi_flops(:)=-1 150 end if 151 end if 152 #endif 153 154 select case (option) 155 case (0) 156 ! Zero out all accumulators of time and init timers 157 acctim(:,:) = 0.0d0 158 tzero(:,:) = 0.0d0 159 ncount(:) = 0 160 papi_flops(:) = 0 161 papi_acctim(:,:) = 0. 162 papi_accflops(:) = 0. 163 papi_tzero(:,:) = 0. 164 165 case (1) 166 ! Initialize timab for nn 167 call timein(cpu,wall) 168 tzero(1,nn)=cpu 169 tzero(2,nn)=wall 170 #ifdef HAVE_PAPI 171 papi_flops(nn) = flops1 ! Initialize megaflops for nn 172 papi_tzero(1,nn) = proc_time 173 papi_tzero(2,nn) = real_time 174 #endif 175 176 case (2) 177 ! Accumulate time for nn (also keep the values of cpu, wall, proc_time, real_time, flops1) 178 call timein(cpu,wall) 179 acctim(1,nn)=acctim(1,nn)+cpu -tzero(1,nn) 180 acctim(2,nn)=acctim(2,nn)+wall-tzero(2,nn) 181 ncount(nn)=ncount(nn)+1 182 #ifdef HAVE_PAPI 183 ! accumulate time and flops for nn Difference between 2 calls to Papif_flops 184 papi_acctim(1,nn)=papi_acctim(1,nn)+ proc_time - papi_tzero(1,nn) 185 papi_acctim(2,nn)=papi_acctim(2,nn)+ real_time - papi_tzero(2,nn) 186 papi_accflops(nn)=papi_accflops(nn)+ flops1- papi_flops(nn) 187 #endif 188 189 case (3) 190 ! Use previously obtained values to initialize timab for nn 191 tzero(1,nn)=cpu 192 tzero(2,nn)=wall 193 #ifdef HAVE_PAPI 194 papi_flops(nn)=flops1 195 papi_tzero(1,nn) = proc_time 196 papi_tzero(2,nn) = real_time 197 #endif 198 199 case (4) 200 ! Return elapsed time for nn (do not accumulate) 201 call timein(cpu,wall) 202 tottim(1)=cpu-tzero(1,nn) 203 tottim(2)=wall-tzero(2,nn) 204 #ifdef HAVE_PAPI 205 ! return elapsed floating point operationfor nn (do not accumulate) 206 papi_tottim(1,nn)= proc_time - papi_tzero(1,nn) 207 papi_tottim(2,nn)= real_time - papi_tzero(2,nn) 208 papi_totflops(nn)= flops1 - papi_flops(nn) 209 #endif 210 211 case default 212 write(message,'(a,i10,a)')' Input option not valid, =',option,'.' 213 MSG_BUG(message) 214 end select 215 end if 216 217 end subroutine timab