]> AND Private Git Repository - loba.git/blob - Experimentations/extract-all
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Prepare next version.
[loba.git] / Experimentations / extract-all
1 #!/bin/bash
2
3 set -e
4 #set -x
5
6 usage() {
7     cat >&2 <<EOF
8 Usage: $0 [-c] <parameters file>
9 Options:
10     -h  print this help
11     -n  dry-run mode (for debugging)
12     -c  (continue) do not overwrite previous results
13 EOF
14     exit $1
15 }
16
17 log() {
18     echo "-#- $@" >&2
19 }
20
21 die() {
22     echo "ERROR: $@" >&2
23     exit 2
24 }
25
26 variable_check() {
27     eval test -n "\${$1}" || die "undefined $1"
28 }
29
30 array_check() {
31     eval test "\${#$1}" -gt 0 || die "undefined $1"
32 }
33
34 # read args
35 overwrite=1
36 debug=0
37 while getopts "chn" c; do
38     case "$c" in
39         'c') overwrite=0 ;;
40         'h') usage 0 ;;
41         'n') debug=1 ;;
42         '?') usage 1 ;;
43     esac
44 done
45 shift $((OPTIND - 1))
46 [ $# -eq 1 ] || usage 1
47 parameters="$1"
48
49 log "Running: $0 $@"
50 log "Hostname: $(hostname -f)"
51
52 declare -a TOPOLOGIES ALGORITHMS PLATFORMS COMMON_OPTS
53
54 # read parameters
55 log "Reading parameters from \"$1\"."
56 source "$parameters" || die "cannot read parameters file: \"$parameters\""
57
58 array_check TOPOLOGIES
59 array_check ALGORITHMS
60 array_check PLATFORMS
61 variable_check NHOSTS
62 variable_check LOAD
63 variable_check DEADLINE
64
65 # default values
66 : ${RESULTS:=$PWD/results}
67 : ${LOBA:=$PWD/loba}
68
69 COMMON_OPTS=(
70     --cfg=contexts/factory:raw
71 )
72
73 log "Results from : \"$RESULTS\"."
74
75 [ $debug = 1 ] && log "Running in dry-run mode"
76
77 outfile() {
78     echo "$*" | sed 's,[^ ]*/,,g;s/\.xml//;y/ /_/'
79 }
80 params=([0]="Load" [1]="Computation" [2]="Data send amount" [3]="Data send count" )
81 params_pos=(9 5 7 7)
82 firsttexline="|l|"
83 for algo in "${ALGORITHMS[@]}"; do
84         for bk in "" "-b"; do
85                 firsttexline=$(echo "$firsttexline r|")
86         done
87 done
88 firsttexline=$(echo -e "\\\begin{tabular}{$firsttexline}\n\\hline\c")
89
90 lasttexline="\\end{tabular}"
91
92 secondtexline="Param/Alg"
93 for algo in "${ALGORITHMS[@]}"; do
94         for bk in "" "-b"; do
95             secondtexline=$(echo -e "$secondtexline&\t${algo}${bk}")
96         done
97 done
98 secondtexline=$(echo -e "$secondtexline\\t \\\\\\\\  \\hline \\hline\c")
99
100 mediantexlineend=$(echo -e "\\\\\\\\ \\hline\c")
101 # mediantexlineend=$(echo -e "$mediantexlineend\c")
102
103
104 for plat in "${PLATFORMS[@]}"; do
105     tmp=$(basename "$plat" ".xml")
106     plat_output="$RESULTS/plat_$tmp"
107         for topo in "${TOPOLOGIES[@]}"; do
108                 topo_output="$plat_output/topo_$topo"
109                 topo_data_all_output="$plat_output/data_$topo-all.tex"
110                 echo "$firsttexline" > "$topo_data_all_output"
111                 echo "$secondtexline" >> "$topo_data_all_output"
112                 for target_i in "0" "1" "2" "3"; do
113                         target_param=${params[$target_i]};
114                         target_position=${params_pos[$target_i]};
115                         outfilesuffix=$(outfile  "${target_param[@]}")
116                         mediantexline="$target_param\t"
117                         for algo in "${ALGORITHMS[@]}"; do
118                                 topo_data_out="$plat_output/data_$topo-$outfilesuffix.tex"
119                                 algo_output="$topo_output/algo_$algo"
120                                 args=(
121                                          -T"$topo"
122                                         -a"$algo"
123                                         -N"$NHOSTS"
124                                         -L"$LOAD"
125                                         -t"$DEADLINE"
126                                         "$plat"
127                                 )
128                                 for bk in "" "-b"; do
129                                         tmp=$(outfile "loba" $bk "${args[@]}")
130                                         infile="$algo_output/$tmp.out"
131                                         variable=$(tail -17 "$infile" | awk '/'"$target_param"'/{print $'"$target_position"'}')
132                                         log "Reading $target_param from $infile : $variable"
133                                         mediantexline=$(echo -e "$mediantexline&$variable\t")
134                                         echo  -e "$algo$bk\t$variable\n" >> "$topo_data_out"
135                                 done
136                         done
137                         echo  "$mediantexline" >> "$topo_data_all_output"
138                         echo  "$mediantexlineend" >> "$topo_data_all_output"
139                 done
140         echo "$lasttexline" >> "$topo_data_all_output"
141         done
142 done