1 subroutine timer (tcode) 2c 3c---------------------------------------------------------------------- 4c 5c This routine keeps track of the CPU-time statistics. 6c 7c input: 8c tcode : timer codes 9c name of processes to be timed 10c including 'Begin ', 'End ','Back ' 11c which are the control input 12c 13c 14c Flop count: 15c 16c x + y : 1 flop -> same as Cray Y-MP 17c x - y : 1 flop -> same as Cray Y-MP 18c x * y : 1 flop -> same as Cray Y-MP 19c x / y : 4 flops -> same as Cray Y-MP 20c sqrt(x) : 8 flops -> lower than Cray Y-MP 21c exp(x) : 24 flops -> same as Cray Y-MP 22c log(x) : 32 flops -> same as Cray Y-MP 23c 24c 25c 26c **** WARNING: this routine makes calls to the SECS function. 27c 28c Farzin Shakib, Summer 1985. 29c Zdenek Johan, Winter 1991. (Fortran 90) 30c---------------------------------------------------------------------- 31c 32 include "common.h" 33c 34 character*8 tcode 35c 36 dimension ratio(11) 37c 38c.... Find the code 39c 40 do i = 1, icd + 2 41 ii = i 42 if (tcode .eq. ccode(i)) exit 43 if (ii .eq. icd + 2) call error ('timer ', tcode, 0) 44 enddo 45c 46c.... ------------------------> 'Begin ' <------------------------- 47c 48c.... initialize the timers and the flop counter 49c 50 if (ii .eq. icd) then 51 comtim = zero 52 do i = 1, icd 53 cpu0(i) = zero 54 cpu(i) = zero 55 nacess(i) = 0 56 enddo 57c 58 flops = 0 59 gbytes = 0 60 sbytes = 0 61c 62 cpu0(icd) = secs() 63 nacess(icd) = 1 64 call system_clock (iclock) 65 return 66 endif 67c 68c.... ------------------------> 'Back ' <------------------------- 69c 70c.... if Back, stop the clock 71c 72 if (ii .eq. icd+2) then 73 cpu(icode) = cpu(icode) + secs() - cpu0(icode) 74 icode = icode2 75 icode2 = icode3 76 return 77 endif 78c 79c.... -------------------> Individual Processes <-------------------- 80c 81c.... restart the clock 82c 83 if (ii .ne. icd+1) then 84 icode3 = icode2 85 icode2 = icode 86 icode = ii 87 cpu0(icode) = secs() 88 nacess(icode) = nacess(icode) + 1 89 return 90 endif 91c 92c.... ------------------------> 'End ' <------------------------- 93c 94c.... print out execution time statistics 95c 96 if (ccode(icd) .eq. 'Total ') return ! redundant print 97c 98 call system_clock (icend, icrate, icmax) 99 iclock = icend - iclock 100 if (iclock .le. 0) iclock = iclock + icmax 101 wclock = float(iclock) / float(icrate) 102c 103 cpu(icd) = secs() - cpu0(icd) 104 ccode(icd) = 'Total ' 105c 106c.... CPU time returned by secs is in 100th of a second 107c 108 do i = 1, icd 109 cpu(i) = cpu(i) / 100. 110 enddo 111c 112c.... compute the percentage of total time spent 113c 114 do i = 1, icd 115 ratio(i) = 100.d0 * cpu(i) / cpu(icd) 116 enddo 117c 118 if (myrank == master) then 119 write (iecho,1000) ititle 120 write (iecho,1100) 121 write (iecho,1200) (ccode(i), nacess(i), cpu(i), ratio(i), 122 & i=1,icd-4) 123 write (iecho,1100) 124 write (iecho,1200) (ccode(i), nacess(i), cpu(i), ratio(i), 125 & i=icd-3,icd-1) 126 write (iecho,1100) 127 write (iecho,1300) (ccode(i), cpu(i), ratio(i), 128 & i=icd,icd) 129 write (iecho,1400) wclock 130 endif 131c 132c.... print out performance statistics 133c 134 solvr1 = cpu(3) + cpu(4) + cpu(5) 135 solvr2 = cpu(3) + cpu(4) + cpu(5) - cpu(9) - cpu(10) 136 gather = cpu(9) 137 scattr = cpu(10) 138c 139 if ((solvr1 .eq. zero) .or. (gather .eq. 0) .or. 140 & (scattr .eq. zero)) return 141c 142 if (myrank == master) then 143 write (iecho,2000) 144 write (iecho,2100) flops 145 write (iecho,2200) flops/(1.0d6*solvr1) 146 write (iecho,2300) flops/(1.0d6*solvr2) 147 write (iecho,2400) 8*gbytes 148 write (iecho,2500) 8*sbytes 149 write (iecho,2600) 8*gbytes/(float(2**20)*gather) 150 write (iecho,2700) 8*sbytes/(float(2**20)*scattr) 151 endif 152c 153c.... return 154c 155 return 156c 1571000 format(a80,//, 158 & ' E x e c u t i o n T i m e S t a t i s t i c s ',//, 159 & ' name No. access CPU-time %_total') 1601100 format(1x, 161 & '---------------------------------------------------') 1621200 format(1x,a8,4x,i7,5x,f11.2,8x,f7.2) 1631300 format(1x,a8,16x,f11.2,8x,f7.2) 1641400 format(/,' Wall-clock time : ',f8.1,' seconds') 1652000 format(///, 166 & ' P e r f o r m a n c e S t a t i s t i c s ',/) 1672100 format(1x,'No. of floating-point operations : ',i20,/) 1682200 format(1x,'Flop rate with gather/scatter : ',f5.1, 169 & ' Mflops/s',/) 1702300 format(1x,'Flop rate without gather/scatter :',f5.1, 171 & ' Mflops/s',//) 1722400 format(1x,'No. of bytes gathered : ',i20,/) 1732500 format(1x,'No. of bytes scattered : ',i20,/) 1742600 format(1x,'Gather transfer rate : ',f6.2, ' Mbytes/s',/) 1752700 format(1x,'Scatter transfer rate :',f6.2, ' Mbytes/s') 176c 177 end 178