1 | #!/bin/ksh |
---|
2 | # $Id$ |
---|
3 | ############################################################## |
---|
4 | # Original : C. Talandier for NEMO team |
---|
5 | # Contact : nemo_st@locean-ipsl.upmc.fr |
---|
6 | # |
---|
7 | # It is called by the assessment.ksh script for a |
---|
8 | # given configuration |
---|
9 | # |
---|
10 | # INPUT ARGS: 6 |
---|
11 | # - zrunt : run type to treat |
---|
12 | # - zfile1 : mon run timing input file name |
---|
13 | # - zfile2 : mpi run timing input file name |
---|
14 | # - zconf : configuration name |
---|
15 | # - zout : output file name |
---|
16 | # - ztag : tag name to which are compared files |
---|
17 | # - zxis : (0/1) reference timing files (do/do not) exist |
---|
18 | # |
---|
19 | # WORK: It aims to : |
---|
20 | # |
---|
21 | # - Treat output timing from the aix target for |
---|
22 | # mon & mpi run |
---|
23 | # *- compare it to a reference version |
---|
24 | # |
---|
25 | # * this step is performed only if a reference tag |
---|
26 | # is specified with the -t option and if files exist. |
---|
27 | # See the Makefile under ./config/NVTK directory |
---|
28 | # |
---|
29 | ############################################################## |
---|
30 | #set -xv |
---|
31 | ############################################################## |
---|
32 | |
---|
33 | # Get the name of the present script |
---|
34 | nscript=$( (basename $0) ) |
---|
35 | |
---|
36 | # |
---|
37 | # help_CPU_time() To print help |
---|
38 | # |
---|
39 | function help_CPU_time |
---|
40 | { |
---|
41 | echo "Usage: $nscript [-r] [-a] [-b] [-c] [-o] [-t] [-x]" |
---|
42 | echo "Options: These are optional argument" |
---|
43 | echo " -r : run type to treat" |
---|
44 | echo " -a : current version timing input file name" |
---|
45 | echo " -b : reference version timing input file name" |
---|
46 | echo " -c : configuration name" |
---|
47 | echo " -o : output file name" |
---|
48 | echo " -t : tag name to which are compared files" |
---|
49 | echo " -x : (0/1) reference timing files (do/do not) exist" |
---|
50 | echo " their values are not taken)" |
---|
51 | exit 1 |
---|
52 | } |
---|
53 | |
---|
54 | # Initialization |
---|
55 | zrunt= |
---|
56 | zfile1= |
---|
57 | zfile2= |
---|
58 | zconf= |
---|
59 | zout= |
---|
60 | ztag= |
---|
61 | zxis=1 |
---|
62 | |
---|
63 | # Get arguments |
---|
64 | while getopts r:a:b:c:o:t:x: opt |
---|
65 | do |
---|
66 | case "$opt" in |
---|
67 | r) zrunt="$OPTARG";; |
---|
68 | a) zfile1="$OPTARG";; |
---|
69 | b) zfile2="$OPTARG";; |
---|
70 | c) zconf="$OPTARG";; |
---|
71 | o) zout="$OPTARG";; |
---|
72 | t) ztag="$OPTARG";; |
---|
73 | x) zxis="$OPTARG";; |
---|
74 | *) help_CPU_time;; |
---|
75 | esac |
---|
76 | done |
---|
77 | |
---|
78 | # Check if results must be compare to the reference version |
---|
79 | test -n "${ztag}" |
---|
80 | evaltag=$? |
---|
81 | |
---|
82 | case "${zrunt}" in |
---|
83 | |
---|
84 | 'mon' ) |
---|
85 | |
---|
86 | # OUTPUT TIMING OF THE MON RUN |
---|
87 | ############################## |
---|
88 | |
---|
89 | if [ ${evaltag} -a ${zxis} == 0 ] ; then |
---|
90 | # Get values from the reference tag |
---|
91 | zreal=$( awk '/wall clock time/ {print $6}' ${zfile2} ) |
---|
92 | zuser=$( awk '/Total amount of time in u/ {print $9}' ${zfile2} ) |
---|
93 | zmemo=$( awk '/Maximum resident set size/ {print $6/1024}' ${zfile2} ) |
---|
94 | zuzra=$( awk '/Utilization rate/ {print $4}' ${zfile2} ) |
---|
95 | # Print: Variable long name | current version values | reference version values | variations |
---|
96 | echo " Current version ${ztag} version Variation " >> ${zout} |
---|
97 | echo " " >> ${zout} |
---|
98 | awk '/wall clock time/ { creal=$6 ; printf("%-6s %.33s %8s %12.2f | %12.2f | %7.2f % \n", " ", $0, "(sec) :" , $6 , invar, ((creal-invar)/invar)*100 ) }' invar=${zreal} ${zfile1} >> ${zout} |
---|
99 | awk '/Total amount of time in u/ { cuser=$9 ; printf("%-6s %.34s %7s %12.2f | %12.2f | %7.2f % \n", " ", $0, "(sec) :" , $9 , invar, ((cuser-invar)/invar)*100 ) }' invar=${zuser} ${zfile1} >> ${zout} |
---|
100 | awk '/Maximum resident set size/ { cmflo=$6/1024 ; printf("%-6s %.26s %15s %12.2f | %12.2f | %7.2f % \n", " ", $0, "(Mo) :" ,cmflo, invar, ((cmflo-invar)/invar)*100 ) }' invar=${zmemo} ${zfile1} >> ${zout} |
---|
101 | awk '/Utilization rate/ { cuzra=$4 ; printf("%-5s %.24s %18s %12.2f | %12.2f | %7.2f % \n", " ", $0, "~100% (%) :", $4 , invar, ((cuzra-invar)/invar)*100 ) }' invar=${zuzra} ${zfile1} >> ${zout} |
---|
102 | else |
---|
103 | # Print: Variable long name | current version values |
---|
104 | echo " Current version " >> ${zout} |
---|
105 | echo " " >> ${zout} |
---|
106 | awk '/wall clock time/ {printf("%-6s %.33s %8s %9.2f \n", " ", $0, "(sec) :" , $6 ) }' ${zfile1} >> ${zout} |
---|
107 | awk '/Total amount of time in u/ {printf("%-6s %.34s %7s %9.2f \n", " ", $0, "(sec) :" , $9 ) }' ${zfile1} >> ${zout} |
---|
108 | awk '/Maximum resident set size/ {printf("%-6s %.26s %15s %9.2f \n", " ", $0, "(Mo) :" , $6/1024) }' ${zfile1} >> ${zout} |
---|
109 | awk '/Utilization rate/ {printf("%-5s %.24s %18s %9.2f \n", " ", $0, "~100% (%) :", $4 ) }' ${zfile1} >> ${zout} |
---|
110 | fi |
---|
111 | |
---|
112 | ;; |
---|
113 | |
---|
114 | 'mpi' ) |
---|
115 | |
---|
116 | # OUTPUT TIMING OF THE MPI RUN |
---|
117 | ############################## |
---|
118 | |
---|
119 | if [ ${evaltag} -a ${zxis} == 0 ] ; then |
---|
120 | # Get values from the reference tag |
---|
121 | awk '/wall clock time/ {print}' ${zfile2} > temp1 |
---|
122 | awk '/Maximum resident set size/ {print}' ${zfile2} > temp2 |
---|
123 | awk '/Utilization rate/ {print}' ${zfile2} > temp3 |
---|
124 | |
---|
125 | zreal=$( awk '/wall clock time/ {cum += $6} END {printf("%f", cum/NR) }' temp1 ) |
---|
126 | zuser=$( awk '/Total amount of time in u/ {cum += $9} END {printf("%f", cum ) }' ${zfile2}) |
---|
127 | zmemo=$( awk '/Maximum resident set size/ {cum += $6} END {printf("%f", cum/(1024*NR)) }' temp2 ) |
---|
128 | zuzra=$( awk '/Utilization rate/ {cum += $4} END {printf("%f", cum/NR) }' temp3 ) |
---|
129 | |
---|
130 | # Get values from the current version |
---|
131 | awk '/wall clock time/ {print}' ${zfile1} > temp1 |
---|
132 | awk '/Maximum resident set size/ {print}' ${zfile1} > temp2 |
---|
133 | awk '/Utilization rate/ {print}' ${zfile1} > temp3 |
---|
134 | |
---|
135 | echo " Current version ${ztag} version Variation " >> ${zout} |
---|
136 | echo " " >> ${zout} |
---|
137 | awk '/wall clock time/ {cum += $6} END {printf("%-7s %-39s %1s %11.2f | %12.2f | %7.2f %\n" , " ", "Execution time (wall clock time) (sec)", ":", cum/NR , invar, ((cum/NR-invar)/invar)*100 ) }' invar=${zreal} temp1 >> ${zout} |
---|
138 | awk '/Total amount of time in u/ {cum += $9} END {printf("%-7s %-39s %1s %11.2f | %12.2f | %7.2f %\n" , " ", "Total amount of time in user mode (sec)", ":", cum , invar, ((cum-invar)/invar)*100 ) }' invar=${zuser} ${zfile1} >> ${zout} |
---|
139 | awk '/Maximum resident set size/ {cum += $6} END {printf("%-7s %-25s %15s %12.2f | %12.2f | %7.2f %\n", " ", "Maximum resident set size", "(Mo) :" , cum/(1024*NR), invar, ((cum/(1024*NR)-invar)/invar)*100 ) }' invar=${zmemo} temp2 >> ${zout} |
---|
140 | awk '/Utilization rate/ {cum += $4} END {printf("%-7s %-16s %24s %12.2f | %12.2f | %7.2f %\n", " ", "Utilization rate", "(%) :" , cum/NR , invar, ((cum/NR-invar)/invar)*100 ) }' invar=${zuzra} temp3 >> ${zout} |
---|
141 | |
---|
142 | echo " " >> ${zout} |
---|
143 | |
---|
144 | \rm temp* |
---|
145 | |
---|
146 | else |
---|
147 | # Get values from the current version |
---|
148 | awk '/wall clock time/ {print}' ${zfile1} > temp1 |
---|
149 | awk '/Maximum resident set size/ {print}' ${zfile1} > temp2 |
---|
150 | awk '/Utilization rate/ {print}' ${zfile1} > temp3 |
---|
151 | |
---|
152 | echo " Current version " >> ${zout} |
---|
153 | echo " " >> ${zout} |
---|
154 | awk '/wall clock time/ {cum += $6} END {printf("%-7s %-39s %1s %9.2f\n" , " ", "Execution time (wall clock time) (sec)", ":", cum/NR ) }' temp1 >> ${zout} |
---|
155 | awk '/Total amount of time in u/ {cum += $9} END {printf("%-7s %-39s %1s %9.2f\n" , " ", "Total amount of time in user mode (sec)", ":", cum ) }' ${zfile1} >> ${zout} |
---|
156 | awk '/Maximum resident set size/ {cum += $6} END {printf("%-7s %-25s %15s %9.2f\n", " ", "Maximum resident set size", "(Mo) :", cum/(1024*NR) ) }' temp2 >> ${zout} |
---|
157 | awk '/Utilization rate/ {cum += $4} END {printf("%-7s %-16s %24s %9.2f\n", " ", "Utilization rate", "(%) :", cum/NR ) }' temp3 >> ${zout} |
---|
158 | |
---|
159 | echo " " >> ${zout} |
---|
160 | |
---|
161 | \rm temp* |
---|
162 | fi |
---|
163 | |
---|
164 | ;; |
---|
165 | esac |
---|