1#!/bin/bash
2
3PAPERPATH=~/hg/papers/asplos11/barrelfish/plots
4
5ALGORITHMS="bridge_page.pl bridge_postorder.pl bridge_postorder_sorted.pl bridge_postorder_sorted_sum.pl bridge_postorder_sorted_ascending.pl bridge_postorder_sorted_sum_ascending.pl"
6ALGONAMES[0]="CLP"
7ALGONAMES[1]="postorder"
8ALGONAMES[2]="postorder_sorted"
9ALGONAMES[3]="postorder_sum"
10ALGONAMES[4]="postorder_asc"
11ALGONAMES[5]="postorder_asc_sum"
12
13SYSTEMS="nos3 nos4 nos5 nos6 gruyere sbrinz1 sbrinz2 ziger1 ziger2";
14SYSTEMNAMES="sys1 sys2 sys3 sys4 sys5 sys6 sys7 sys8 sys9";
15
16OUTFILE="algos_systems.dat"
17GNUPLOTFILE="algos_systems.gnuplot"
18PNGOUTPUT="algos_systems.eps"
19
20
21echo -n "" > $OUTFILE
22
23
24# allgemeine einstellungen
25echo "clear" > $GNUPLOTFILE
26echo "reset" >> $GNUPLOTFILE
27echo "set terminal postscript eps enhanced dashed color" >> $GNUPLOTFILE
28echo "set output \"$PNGOUTPUT\"" >> $GNUPLOTFILE
29echo "set boxwidth 0.1" >> $GNUPLOTFILE
30echo "set xlabel \"System\"" >> $GNUPLOTFILE
31echo "set ylabel \"Physical address size needed [bytes]\"" >> $GNUPLOTFILE
32#echo "set key bottom right" >> $GNUPLOTFILE
33
34echo -n "set xtics (" >> $GNUPLOTFILE
35count=0;
36for i in $SYSTEMNAMES; do
37    if [ 0 -ne $count ]; then
38        echo -n "," >> $GNUPLOTFILE;
39    fi
40    echo -n "\"$i\" " >> $GNUPLOTFILE;
41    echo -n "$count" >> $GNUPLOTFILE;
42    count=$[$count+1];
43done
44echo ")" >> $GNUPLOTFILE;
45
46echo "set output \"algos_systems_padding.eps\"" >> tmp1.$GNUPLOTFILE;
47echo "set xlabel \"System\""  >> tmp1.$GNUPLOTFILE;
48echo "set ylabel \"Padding overhead [bytes]\""  >> tmp1.$GNUPLOTFILE;
49echo -n "plot "  >> tmp1.$GNUPLOTFILE;
50
51echo "set output \"algos_systems_difference.eps\""  >> tmp2.$GNUPLOTFILE;
52echo "set xlabel \"System\""  >> tmp2.$GNUPLOTFILE;
53echo "set ylabel \"Difference to root limit\""  >> tmp2.$GNUPLOTFILE;
54echo "set key bottom right"  >> tmp2.$GNUPLOTFILE;
55echo -n "plot " >> tmp2.$GNUPLOTFILE;
56
57echo -n "plot \"algos_systems.dat\" index 0 using (\$0-0.1):8 title \"Root size\" with boxes, " >> $GNUPLOTFILE;
58count=0;
59for i in $ALGORITHMS; do
60    echo $i;
61    for j in $SYSTEMS; do
62        echo $j;
63        ./mach $i ../data/data_$j.txt > tmp.out.dat;
64        egrep Abort tmp.out.dat;
65        if [ 0 -eq $? ]; then
66            echo "ECLIPSE-Fehler";
67            echo "Algorithm: $i, count: $count";
68            exit 1;
69        fi
70
71        egrep No tmp.out.dat;
72        if [ 0 -eq $? ]; then
73            echo "ECLIPSE did not find a solution";
74            echo "Algorithm: $i, count: $count";
75            exit 1;
76        fi
77        zahlen=$(sed -r -e '/^res.*/!d' -e 's/res[\t]//' -e 's/\n//g' tmp.out.dat)
78        echo "$zahlen" >> $OUTFILE
79    done
80    echo "" >> $OUTFILE;
81    echo "" >> $OUTFILE;
82
83    if [ 0 -ne $count ]; then
84        echo -n "," >> $GNUPLOTFILE;
85        echo -n "," >> tmp1.$GNUPLOTFILE;
86        echo -n "," >> tmp2.$GNUPLOTFILE;
87    fi    
88    nama=$(echo ${ALGONAMES[$count]}|sed -r -e 's/_/\\_/g');
89    fillpattern=$[$count+1];
90    echo -n " \"./algos_systems.dat\" index $count using (\$0+0.1*$count):3 title '$nama' with boxes fill pattern $fillpattern" >> $GNUPLOTFILE;
91    echo -n " \"./algos_systems.dat\" index $count using (\$0+0.1*$count):5 title '$nama' with boxes fill pattern $fillpattern" >> tmp1.$GNUPLOTFILE;
92    echo -n " \"./algos_systems.dat\" index $count using (\$0+0.1*$count):12 title '$nama' with boxes fill pattern $fillpattern" >> tmp2.$GNUPLOTFILE;
93    count=$[$count+1];
94done
95
96echo "linux:"
97for j in $SYSTEMS; do
98    echo $j;
99    ./linux2skb_conversion ../data/data_linux_$j.txt
100    grep 'rootbridge(' ../data/data_$j.txt >> ../data/data_linux_$j.txt.pl.tmp;
101    echo -e "[compute_required_resources],[\"../data/data_linux_$j.txt.pl.tmp\"],[bridge_linux],bridge_programming(B,_)," \
102         "compute_required_resources([B], ResList, nodot).\n\nhalt." | eclipse-clp > tmp.out.dat;
103    egrep Abort tmp.out.dat;
104    if [ 0 -eq $? ]; then
105        echo "ECLIPSE-Fehler";
106        echo "Algorithm: Linux, count: $count";
107        exit 1;
108    fi
109
110    egrep No tmp.out.dat;
111    if [ 0 -eq $? ]; then
112        echo "ECLIPSE did not find a solution";
113        echo "Algorithm: Linux, count: $count";
114        exit 1;
115    fi
116    zahlen=$(sed -r -e '/^res.*/!d' -e 's/res[\t]//' -e 's/\n//g' tmp.out.dat)
117    echo "$zahlen" >> $OUTFILE
118done
119echo "" >> $OUTFILE;
120echo "" >> $OUTFILE;
121if [ 0 -ne $count ]; then
122    echo -n "," >> $GNUPLOTFILE;
123    echo -n "," >> tmp1.$GNUPLOTFILE;
124    echo -n "," >> tmp2.$GNUPLOTFILE;
125fi    
126nama="Linux";
127fillpattern=$[$count+1];
128echo -n " \"./algos_systems.dat\" index $count using (\$0+0.1*$count):3 title '$nama' with boxes fill pattern $fillpattern" >> $GNUPLOTFILE;
129echo -n " \"./algos_systems.dat\" index $count using (\$0+0.1*$count):5 title '$nama' with boxes fill pattern $fillpattern" >> tmp1.$GNUPLOTFILE;
130echo -n " \"./algos_systems.dat\" index $count using (\$0+0.1*$count):12 title '$nama' with boxes fill pattern $fillpattern" >> tmp2.$GNUPLOTFILE;
131count=$[$count+1];
132
133
134
135
136echo "" >> $GNUPLOTFILE;
137echo "" >> $GNUPLOTFILE;
138
139cat tmp1.$GNUPLOTFILE >> $GNUPLOTFILE;
140echo "" >> $GNUPLOTFILE;
141echo "" >> $GNUPLOTFILE;
142
143cat tmp2.$GNUPLOTFILE >> $GNUPLOTFILE;
144
145
146rm tmp1.$GNUPLOTFILE;
147rm tmp2.$GNUPLOTFILE;
148gnuplot $GNUPLOTFILE
149#cp $PNGOUTPUT $PAPERPATH
150#cp $OUTFILE $PAPERPATH
151cp *.eps $PAPERPATH
152echo "Fertig."
153
154