source: configs/testing/benchmark/benchmark.sh @ 994

Last change on this file since 994 was 994, checked in by dubos, 4 years ago

testing : update benchmark scripts

File size: 6.1 KB
Line 
1#!/bin/bash
2
3function replace() # KEY VALUE FILE
4{
5  # strip leading zeros that confuse ccc_msub
6  VALUE=$(echo $2 | sed 's/^0*//')
7  sed -i -e "s/$1/$VALUE/g" $3
8  echo "$1=$VALUE" >> params.sh
9}
10
11function create_run2() # NBP LLM TIME_STEP NSPLIT_I NSPLIT_J OMP_LEVEL_SIZE NB_MPI NB_OMP
12{
13  NBP=$1
14  LLM=$2
15  TIME_STEP=$3
16  shift; shift; shift
17
18  NAME="run_$1_$2_$3_$4_$5"
19  mkdir $NAME
20  cp run.def job.sh mpmd.conf gcm.sh *.xml $NAME
21  cd $NAME
22  touch params.sh
23
24  replace NBP $NBP run.def
25  replace LLM $LLM run.def
26  replace TIME_STEP $TIME_STEP run.def
27  replace NSPLIT_I $1 run.def
28  replace NSPLIT_J $2 run.def
29  replace OMP_LEVEL_SIZE $3 run.def
30  replace NUM_MPI $4 mpmd.conf
31  replace NUM_MPI $4 job.sh
32  replace NUM_OMP $5 job.sh
33  cd ..
34}
35
36function create_run() # NBP TIME_STEP NSPLIT OMP_LEVEL_SIZE NB_MPI NB_OMP
37{
38    create_run2 $1 79 $2 $3 $3 $4 $5 $6
39}
40
41function cmd_create_220km_39()
42{
43  rm -rf run_*
44  create_run2 41 39 600 2 2 1 040 01
45  create_run2 41 39 600 2 2 1 010 04
46  create_run2 41 39 600 2 2 2 040 02
47  create_run2 41 39 600 2 2 2 010 08
48  create_run2 41 39 600 2 2 4 040 04
49  create_run2 41 39 600 2 2 4 010 16
50
51  create_run2 41 39 600 2 3 1 060 01
52  create_run2 41 39 600 2 3 1 010 06
53  create_run2 41 39 600 2 3 2 060 02
54  create_run2 41 39 600 2 3 2 010 12
55  create_run2 41 39 600 2 3 4 060 04
56  create_run2 41 39 600 2 3 4 010 24
57
58  create_run2 41 39 600 3 3 1 090 01
59
60  create_run2 41 39 600 3 4 1 120 01
61  create_run2 41 39 600 3 4 1 020 06
62  create_run2 41 39 600 3 4 1 010 12
63  create_run2 41 39 600 3 4 2 120 01
64  create_run2 41 39 600 3 4 2 020 12
65  create_run2 41 39 600 3 4 2 010 24
66  create_run2 41 39 600 3 4 4 120 04
67  create_run2 41 39 600 3 4 4 020 12
68  create_run2 41 39 600 3 4 4 010 24
69
70  create_run2 41 39 600 4 4 1 160 01
71  create_run2 41 39 600 4 4 1 040 04
72  create_run2 41 39 600 4 4 2 160 02
73  create_run2 41 39 600 4 4 2 040 08
74  create_run2 41 39 600 4 4 4 160 04
75  create_run2 41 39 600 4 4 4 040 16
76  ls -d run_*
77}
78
79function cmd_create_220km()
80{
81  rm -rf run_*
82  create_run 41 600 4 6 040 24
83  create_run 41 600 4 6 080 12
84  create_run 41 600 4 6 160 06
85  create_run 41 600 4 4 160 04
86  create_run 41 600 4 4 080 08
87  create_run 41 600 4 2 040 08
88  create_run 41 600 4 1 020 08
89  create_run 41 600 4 1 040 04
90  create_run 41 600 4 1 080 02
91  create_run 41 600 4 1 160 01
92  create_run 41 600 2 1 040 01
93  ls -d run_*
94}
95
96function cmd_create_110km()
97{
98  rm -rf run_*
99  create_run 81 300 4 1 160 01
100  create_run 81 300 6 1 360 01
101  create_run 81 300 8 1 160 04
102  create_run 81 300 8 1 640 01
103  ls -d run_*
104}
105
106function cmd_create_70km()
107{
108  rm -rf run_*
109  create_run 129 200 8 1 640 01
110  create_run 129 200 10 1 1000 01
111  create_run 129 200 12 1 1440 01
112  create_run 129 200 16 1 2560 01
113  ls -d run_*
114}
115
116function cmd_create_35km()
117{
118  rm -rf run_*
119  create_run 257 100 12 1 1440 1
120  create_run 257 100 12 1 0720 2
121  create_run 257 100 12 1 0360 4
122  create_run 257 100 12 1 0120 12
123  create_run 257 100 12 1 0060 24
124  create_run 257 100 12 2 1440 2
125  create_run 257 100 12 4 1440 4
126  create_run 257 100 12 6 1440 6
127  create_run 257 100 12 8 1440 8
128  create_run 257 100 16 1 2560 1
129  create_run 257 100 16 1 1280 2
130  create_run 257 100 16 1 0640 4
131  create_run 257 100 16 1 0320 8
132  create_run 257 100 16 4 2560 4
133  create_run 257 100 16 6 2560 6
134  create_run 257 100 16 8 2560 8
135  create_run 257 100 24 4 5760 4
136  ls -d run_*
137}
138
139function cmd_create_8km()
140{
141  rm -rf run_*
142  create_run 1025 20 32 1 2560 4
143  ls -d run_*
144}
145
146function cmd_submit()
147{
148  for RUN in run_* ; do
149      cd $RUN
150      if [ -f already_done ]; then
151          echo "$RUN has run already."
152      else
153          ccc_msub job.sh
154      fi
155      cd ..
156  done
157}
158
159#------------------------------------- Reporting --------------------------------------
160
161function get_troughput()
162{
163    grep Throughput logs/gcm.log | tail -n 5 | awk '{print $12}' | sort -r | head -n 1
164}
165
166function get_ms_step()
167{
168    grep 'ms/step' logs/gcm.log | tail -n 5 | awk '{print $8}' | sort -r | head -n 1
169}
170
171function get_frac()
172{
173    grep $1 logs/gcm.log | grep -v DEFAULT | grep -v caldyn | grep -v nqdyn | tail -n 4 | head -n 1 | awk '{print $3}'
174}
175function cmd_stats()
176{
177    echo RUN frac_dyn_adv frac_MPI Throughput ms/step
178    for RUN in run_* ; do
179        cd $RUN
180#       pwd
181#       ls logs/gcm.log
182        frac_adv=$(get_frac adv)
183        frac_dyn=$(get_frac dyn)
184        frac_adv_MPI=$(get_frac adv_MPI)
185        frac_dyn_MPI=$(get_frac dyn_MPI)
186#       echo $frac_adv $frac_dyn $frac_adv_MPI $frac_dyn_MPI
187        echo $RUN $(( frac_adv+frac_dyn )) $((frac_adv_MPI+frac_dyn_MPI)) $(get_troughput) $(get_ms_step)
188        cd ..
189    done
190}
191
192function MPI()
193{
194    run=$1
195    cmd=$2
196    nprocs=$(echo $run | tr "_" ' ' | awk '{print $4'} )
197    nprocs=$(compute $nprocs)
198    stats=$(grep MPI_$cmd $run/logs/gcm.log | tail -n 1)
199    time=$(echo $stats | awk '{print $3}')
200    count=$(echo $stats | awk '{print $4}')
201    wall=$(echo $stats | awk '{print $5}')
202#    echo $stats
203#    echo $nprocs $time $count $wall >&2
204#    echo $run $cmd
205    echo $run $cmd $(compute "$time/$nprocs") $((count/nprocs)) $wall
206}
207
208function compute()
209{
210    bc <<< "scale=2 ; $1"
211}
212function cmd_MPI()
213{
214# MPI_Waitall MPI_Alltoall MPI_Allreduce MPI_Bcast MPI_Barrier MPI_Isend MPI_Comm_size MPI_Reduce MPI_Irecv MPI_Comm_rank MPI_Init MPI_Finalize
215    echo '# [run] [func] [time] [count] <%wall>'
216    for cmd in Alltoall Allreduce Bcast Waitall Barrier ; do
217        for run in run_* ; do 
218#           echo $run $(grep MPI_$cmd $run/logs/gcm.log)
219            MPI $run $cmd
220        done
221    done
222}
223function  elapsed()
224{
225    cd $1
226    useful=$(grep elapsed logs/gcm.log | awk '{print $4}')
227    echo $useful
228    hhmmss=$(grep icosa_gcm.exe DYN_bench*.o | awk '{print $7}')
229    minutes=$(date +'%M' -d $hhmmss)
230    seconds=$(date +'%S' -d $hhmmss)   
231    echo $(compute "$seconds+60*$minutes-$useful")
232    cd ..
233}
234
235function cmd_elapsed()
236{
237    for x in run_* ; do
238        echo $x $(elapsed $x)
239    done
240}
241
242#---------------------------------------------------------------------------------------
243
244function cmd_clean()
245{
246    rm -f $(find . -name restart.nc)
247}
248
249echo "Usage : benchmark.sh COMMAND"
250echo "Available commands : create_220km create_110km create_70km create_35km create_8km submit clean stats"
251echo "Your command : $1"
252
253cmd_$1
Note: See TracBrowser for help on using the repository browser.