-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtabarnac
executable file
·153 lines (141 loc) · 4.01 KB
/
tabarnac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
# Copyright (C) 2015 Beniamine, David <[email protected]>
# Author: Beniamine, David <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
usage()
{
echo -e "Usage :\n"
echo "$0 [Options] -- cmd args"
echo " -r [Run options] -- cmd args"
echo " -p [Plot options] bench"
echo -e "\nGeneral options\n"
echo " -h Display this help and quit"
echo " -p bench Do not run, plot only for benchmark named bench (no
need for -- cmd)"
echo " -r Run only (do not plot)"
echo -e "\nRun options:\n"
echo " -d directory Set pin install directory, default: $PIN_HOME"
echo -e "\nPlot options:\n"
echo " -i Do not ignore smally used structures. This might
produce a hard to read output"
echo " -b Do black and white plots"
echo " -s Save plots (png files)"
echo " -t Disable titles in figures"
echo " -S scale Set the scale for saved figures implies -s"
echo " -R ratio set plots_width=ratio*plot_height, default=1"
echo " -C Remove cache files (exp.structStats.csv
exp.structModif.csv and exp.acc.csv"
}
run=true
plot=true
titles=T
ratio=1
bw=F
save=F
ignore=TRUE
scale=1
rmCache=false
while getopts "trbshp:S:iR:d:C" opt; do
case $opt in
i)
ignore=FALSE
;;
r)
plot=false
;;
R)
ratio=$OPTARG
;;
t)
titles=F
;;
b)
bw="T"
;;
p)
run=false
PROG="$OPTARG"
;;
s)
save="T"
;;
S)
scale="$OPTARG"
save="T"
;;
h)
usage
exit 0
;;
d)
export PIN_HOME=$OPTARG
echo "export PIN_HOME=$OPTARG"
;;
C)
rmCache=true
;;
\?)
echo "Invalid option : -$OPTARG" >&2
usage
exit 1
;;
esac
done
if $run
then
if [ -z "$(echo $@ | cut -d '-' -f 3-)" ]
then
usage
exit 1
fi
set -o errexit -o nounset -o pipefail
# directory of this script
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# recompile pintool if necessary
(cd $DIR; make -q || make)
# program to trace and its arguments
PROGARGS=$(echo ${@} | sed s,.*--\ ,,)
PROG=$(echo $PROGARGS | { read first rest; echo $(basename $first) | sed s,\\s.*,, ; } )
# finally, run pin
echo -e "\n\n## running pin: $PROGARGS"
set -x
time -p pin -xyzzy -enable_vsm 0 -t $DIR/obj-*/*.so -- $PROGARGS
set +x
# sort output page csv's according to page address
for f in $PROG.*.page.csv; do
sort -n -t, -k 1,1 -o $f $f
done
lstopo --no-io topo.png
fi
if $plot
then
if $rmCache
then
rm -v ./$PROG.structsModif.csv
rm -v ./$PROG.structsStats.csv
rm -v ./$PROG.acc.csv
fi
dir=$(pwd)
cd $(dirname $0)
mkdir -p ./figure/
mv $dir/figure/topo.png figure/
mv $dir/topo.png figure/
Rscript plot.R $dir $PROG $save $bw $titles $scale $ignore $ratio
# Clean and copi figures
rm -rf $dir/figure plot.md
mv ./figure $dir/
cd -
mv ./$PROG*.png ./figure/ > /dev/null 2>&1
fi