-
Notifications
You must be signed in to change notification settings - Fork 53
/
gen_binaries.sh
executable file
·149 lines (127 loc) · 4.7 KB
/
gen_binaries.sh
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
#!/bin/bash
#set -e
#############
# TODO
# * allow the user to input their desired input set
# * auto-handle output file generation
if [ -z "$SPEC_DIR" ]; then
echo " Please set the SPEC_DIR environment variable to point to your copy of SPEC CPU2006."
exit 1
fi
CONFIG=riscv
CONFIGFILE=${CONFIG}.cfg
RUN="spike pk -c "
CMD_FILE=commands.txt
INPUT_TYPE=test
# the integer set
BENCHMARKS=(400.perlbench 401.bzip2 403.gcc 429.mcf 445.gobmk 456.hmmer 458.sjeng 462.libquantum 464.h264ref 471.omnetpp 473.astar 483.xalancbmk)
# idiomatic parameter and option handling in sh
compileFlag=false
runFlag=false
copyFlag=false
while test $# -gt 0
do
case "$1" in
--compile)
compileFlag=true
;;
--run)
runFlag=true
;;
--copy)
copyFlag=true
;;
--*) echo "ERROR: bad option $1"
echo " --compile (compile the SPEC benchmarks), --run (to run the benchmarks) --copy (copies, not symlinks, benchmarks to a new dir)"
exit 1
;;
*) echo "ERROR: bad argument $1"
echo " --compile (compile the SPEC benchmarks), --run (to run the benchmarks) --copy (copies, not symlinks, benchmarks to a new dir)"
exit 2
;;
esac
shift
done
echo "== Speckle Options =="
echo " Config : " ${CONFIG}
echo " Input : " ${INPUT_TYPE}
echo " compile: " $compileFlag
echo " run : " $runFlag
echo " copy : " $copyFlag
echo ""
BUILD_DIR=$PWD/build
COPY_DIR=$PWD/${CONFIG}-spec-${INPUT_TYPE}
mkdir -p build;
# compile the binaries
if [ "$compileFlag" = true ]; then
echo "Compiling SPEC..."
# copy over the config file we will use to compile the benchmarks
cp $BUILD_DIR/../${CONFIGFILE} $SPEC_DIR/config/${CONFIGFILE}
cd $SPEC_DIR; . ./shrc; time runspec --config ${CONFIG} --size ${INPUT_TYPE} --action setup int
# cd $SPEC_DIR; . ./shrc; time runspec --config ${CONFIG} --size ${INPUT_TYPE} --action scrub int
if [ "$copyFlag" = true ]; then
rm -rf $COPY_DIR
mkdir -p $COPY_DIR
fi
# copy back over the binaries. Fuck xalancbmk for being different.
# Do this for each input type.
# assume the CPU2006 directories are clean. I've hard-coded the directories I'm going to copy out of
for b in ${BENCHMARKS[@]}; do
echo ${b}
SHORT_EXE=${b##*.} # cut off the numbers ###.short_exe
if [ $b == "483.xalancbmk" ]; then
SHORT_EXE=Xalan #WTF SPEC???
fi
BMK_DIR=$SPEC_DIR/benchspec/CPU2006/$b/run/run_base_${INPUT_TYPE}_${CONFIG}.0000;
echo ""
echo "ls $SPEC_DIR/benchspec/CPU2006/$b/run"
ls $SPEC_DIR/benchspec/CPU2006/$b/run
ls $SPEC_DIR/benchspec/CPU2006/$b/run/run_base_${INPUT_TYPE}_${CONFIG}.0000
echo ""
# make a symlink to SPEC (to prevent data duplication for huge input files)
echo "ln -sf $BMK_DIR $BUILD_DIR/${b}_${INPUT_TYPE}"
if [ -d $BUILD_DIR/${b}_${INPUT_TYPE} ]; then
echo "unlink $BUILD_DIR/${b}_${INPUT_TYPE}"
unlink $BUILD_DIR/${b}_${INPUT_TYPE}
fi
ln -sf $BMK_DIR $BUILD_DIR/${b}_${INPUT_TYPE}
if [ "$copyFlag" = true ]; then
echo "---- copying benchmarks ----- "
mkdir -p $COPY_DIR/$b
cp -r $BUILD_DIR/../commands $COPY_DIR/commands
cp $BUILD_DIR/../run.sh $COPY_DIR/run.sh
sed -i '4s/.*/INPUT_TYPE='${INPUT_TYPE}' #this line was auto-generated from gen_binaries.sh/' $COPY_DIR/run.sh
for f in $BMK_DIR/*; do
echo $f
if [[ -d $f ]]; then
cp -r $f $COPY_DIR/$b/$(basename "$f")
else
cp $f $COPY_DIR/$b/$(basename "$f")
fi
done
mv $COPY_DIR/$b/${SHORT_EXE}_base.${CONFIG} $COPY_DIR/$b/${SHORT_EXE}
fi
done
fi
# running the binaries/building the command file
# we could also just run through BUILD_DIR/CMD_FILE and run those...
if [ "$runFlag" = true ]; then
for b in ${BENCHMARKS[@]}; do
cd $BUILD_DIR/${b}_${INPUT_TYPE}
SHORT_EXE=${b##*.} # cut off the numbers ###.short_exe
# handle benchmarks that don't conform to the naming convention
if [ $b == "482.sphinx3" ]; then SHORT_EXE=sphinx_livepretend; fi
if [ $b == "483.xalancbmk" ]; then SHORT_EXE=Xalan; fi
# read the command file
IFS=$'\n' read -d '' -r -a commands < $BUILD_DIR/../commands/${b}.${INPUT_TYPE}.cmd
for input in "${commands[@]}"; do
if [[ ${input:0:1} != '#' ]]; then # allow us to comment out lines in the cmd files
echo "~~~Running ${b}"
echo " ${RUN} ${SHORT_EXE}_base.${CONFIG} ${input}"
eval ${RUN} ${SHORT_EXE}_base.${CONFIG} ${input}
fi
done
done
fi
echo ""
echo "Done!"