[702] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | function 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 | |
---|
| 11 | function create_run() # NBP TIME_STEP NSPLIT OMP_LEVEL_SIZE NB_MPI NB_OMP |
---|
| 12 | { |
---|
| 13 | NBP=$1 |
---|
| 14 | TIME_STEP=$2 |
---|
| 15 | shift; shift |
---|
| 16 | |
---|
| 17 | NAME="run_$1_$2_$3_$4" |
---|
| 18 | mkdir $NAME |
---|
| 19 | cp run.def job.sh mpmd.conf gcm.sh *.xml $NAME |
---|
| 20 | cd $NAME |
---|
| 21 | touch params.sh |
---|
| 22 | |
---|
| 23 | replace NBP $NBP run.def |
---|
| 24 | replace TIME_STEP $TIME_STEP run.def |
---|
| 25 | replace NSPLIT $1 run.def |
---|
| 26 | replace OMP_LEVEL_SIZE $2 run.def |
---|
| 27 | replace NUM_MPI $3 mpmd.conf |
---|
| 28 | replace NUM_MPI $3 job.sh |
---|
| 29 | replace NUM_OMP $4 job.sh |
---|
| 30 | cd .. |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | function cmd_create_220km() |
---|
| 34 | { |
---|
| 35 | rm -rf run_* |
---|
| 36 | create_run 41 600 4 6 040 24 |
---|
| 37 | create_run 41 600 4 6 080 12 |
---|
| 38 | create_run 41 600 4 6 160 06 |
---|
| 39 | create_run 41 600 4 4 160 04 |
---|
| 40 | create_run 41 600 4 4 080 08 |
---|
| 41 | create_run 41 600 4 2 040 08 |
---|
| 42 | create_run 41 600 4 1 020 08 |
---|
| 43 | create_run 41 600 4 1 040 04 |
---|
| 44 | create_run 41 600 4 1 080 02 |
---|
| 45 | create_run 41 600 4 1 160 01 |
---|
| 46 | create_run 41 600 2 1 040 01 |
---|
| 47 | ls -d run_* |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | function cmd_create_110km() |
---|
| 51 | { |
---|
| 52 | rm -rf run_* |
---|
| 53 | create_run 81 300 4 1 160 01 |
---|
| 54 | create_run 81 300 6 1 360 01 |
---|
| 55 | create_run 81 300 8 1 160 04 |
---|
| 56 | create_run 81 300 8 1 640 01 |
---|
| 57 | ls -d run_* |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | function cmd_create_70km() |
---|
| 61 | { |
---|
| 62 | rm -rf run_* |
---|
| 63 | create_run 129 200 8 1 640 01 |
---|
| 64 | create_run 129 200 10 1 1000 01 |
---|
| 65 | create_run 129 200 12 1 1440 01 |
---|
| 66 | create_run 129 200 16 1 2560 01 |
---|
| 67 | ls -d run_* |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | function cmd_create_35km() |
---|
| 71 | { |
---|
| 72 | rm -rf run_* |
---|
| 73 | create_run 257 100 12 1 1440 1 |
---|
| 74 | create_run 257 100 12 1 0720 2 |
---|
| 75 | create_run 257 100 12 1 0360 4 |
---|
| 76 | create_run 257 100 12 1 0120 12 |
---|
| 77 | create_run 257 100 12 1 0060 24 |
---|
| 78 | create_run 257 100 12 2 1440 2 |
---|
| 79 | create_run 257 100 12 4 1440 4 |
---|
| 80 | create_run 257 100 12 6 1440 6 |
---|
| 81 | create_run 257 100 12 8 1440 8 |
---|
| 82 | create_run 257 100 16 1 2560 1 |
---|
| 83 | create_run 257 100 16 1 1280 2 |
---|
| 84 | create_run 257 100 16 1 0640 4 |
---|
| 85 | create_run 257 100 16 1 0320 8 |
---|
| 86 | create_run 257 100 16 4 2560 4 |
---|
| 87 | create_run 257 100 16 6 2560 6 |
---|
| 88 | create_run 257 100 16 8 2560 8 |
---|
| 89 | create_run 257 100 24 4 5760 4 |
---|
| 90 | ls -d run_* |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | function cmd_create_8km() |
---|
| 94 | { |
---|
| 95 | rm -rf run_* |
---|
| 96 | create_run 1025 20 32 1 2560 4 |
---|
| 97 | ls -d run_* |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | function cmd_submit() |
---|
| 101 | { |
---|
| 102 | for RUN in run_* ; do |
---|
| 103 | cd $RUN |
---|
| 104 | if [ -f already_done ]; then |
---|
| 105 | echo "$RUN has run already." |
---|
| 106 | else |
---|
| 107 | ccc_msub job.sh |
---|
| 108 | fi |
---|
| 109 | cd .. |
---|
| 110 | done |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | #------------------------------------- Reporting -------------------------------------- |
---|
| 114 | |
---|
| 115 | function get_troughput() |
---|
| 116 | { |
---|
| 117 | grep Throughput logs/gcm.log | tail -n 5 | awk '{print $12}' | sort -r | head -n 1 |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | function get_ms_step() |
---|
| 121 | { |
---|
| 122 | grep 'ms/step' logs/gcm.log | tail -n 5 | awk '{print $8}' | sort -r | head -n 1 |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | function get_frac() |
---|
| 126 | { |
---|
| 127 | grep $1 logs/gcm.log | grep -v DEFAULT | grep -v caldyn | grep -v nqdyn | tail -n 4 | head -n 1 | awk '{print $3}' |
---|
| 128 | } |
---|
| 129 | function cmd_stats() |
---|
| 130 | { |
---|
| 131 | echo RUN frac_dyn_adv frac_MPI Throughput ms/step |
---|
| 132 | for RUN in run_* ; do |
---|
| 133 | cd $RUN |
---|
| 134 | # pwd |
---|
| 135 | # ls logs/gcm.log |
---|
| 136 | frac_adv=$(get_frac adv) |
---|
| 137 | frac_dyn=$(get_frac dyn) |
---|
| 138 | frac_adv_MPI=$(get_frac adv_MPI) |
---|
| 139 | frac_dyn_MPI=$(get_frac dyn_MPI) |
---|
| 140 | # echo $frac_adv $frac_dyn $frac_adv_MPI $frac_dyn_MPI |
---|
| 141 | echo $RUN $(( frac_adv+frac_dyn )) $((frac_adv_MPI+frac_dyn_MPI)) $(get_troughput) $(get_ms_step) |
---|
| 142 | cd .. |
---|
| 143 | done |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | function MPI() |
---|
| 147 | { |
---|
| 148 | run=$1 |
---|
| 149 | cmd=$2 |
---|
| 150 | nprocs=$(echo $run | tr "_" ' ' | awk '{print $4'} ) |
---|
| 151 | nprocs=$(compute $nprocs) |
---|
| 152 | stats=$(grep MPI_$cmd $run/logs/gcm.log | tail -n 1) |
---|
| 153 | time=$(echo $stats | awk '{print $3}') |
---|
| 154 | count=$(echo $stats | awk '{print $4}') |
---|
| 155 | wall=$(echo $stats | awk '{print $5}') |
---|
| 156 | # echo $stats |
---|
| 157 | # echo $nprocs $time $count $wall >&2 |
---|
| 158 | # echo $run $cmd |
---|
| 159 | echo $run $cmd $(compute "$time/$nprocs") $((count/nprocs)) $wall |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | function compute() |
---|
| 163 | { |
---|
| 164 | bc <<< "scale=2 ; $1" |
---|
| 165 | } |
---|
| 166 | function cmd_MPI() |
---|
| 167 | { |
---|
| 168 | # 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 |
---|
| 169 | echo '# [run] [func] [time] [count] <%wall>' |
---|
| 170 | for cmd in Alltoall Allreduce Bcast Waitall Barrier ; do |
---|
| 171 | for run in run_* ; do |
---|
| 172 | # echo $run $(grep MPI_$cmd $run/logs/gcm.log) |
---|
| 173 | MPI $run $cmd |
---|
| 174 | done |
---|
| 175 | done |
---|
| 176 | } |
---|
| 177 | function elapsed() |
---|
| 178 | { |
---|
| 179 | cd $1 |
---|
| 180 | useful=$(grep elapsed logs/gcm.log | awk '{print $4}') |
---|
| 181 | echo $useful |
---|
| 182 | hhmmss=$(grep icosa_gcm.exe DYN_bench*.o | awk '{print $7}') |
---|
| 183 | minutes=$(date +'%M' -d $hhmmss) |
---|
| 184 | seconds=$(date +'%S' -d $hhmmss) |
---|
| 185 | echo $(compute "$seconds+60*$minutes-$useful") |
---|
| 186 | cd .. |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | function cmd_elapsed() |
---|
| 190 | { |
---|
| 191 | for x in run_* ; do |
---|
| 192 | echo $x $(elapsed $x) |
---|
| 193 | done |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | #--------------------------------------------------------------------------------------- |
---|
| 197 | |
---|
| 198 | function cmd_clean() |
---|
| 199 | { |
---|
| 200 | rm -f $(find . -name restart.nc) |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | echo "Usage : benchmark.sh COMMAND" |
---|
| 204 | echo "Available commands : create_220km create_35km submit clean stats" |
---|
| 205 | echo "Your command : $1" |
---|
| 206 | |
---|
| 207 | cmd_$1 |
---|