-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_champsim.sh
102 lines (88 loc) · 3.12 KB
/
build_champsim.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
# ChampSim configuration
BRANCH=$1 # branch/*.bpred
L1D_PREFETCHER=$2 # prefetcher/*.l1d_pref
L2C_PREFETCHER=$3 # prefetcher/*.l2c_pref
LLC_REPLACEMENT=$4 # replacement/*.llc_repl
NUM_CORE=$5 # tested up to 8-core system
############## Some useful macros ###############
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
embed_newline()
{
local p="$1"
shift
for i in "$@"
do
p="$p\n$i" # Append
done
echo -e "$p" # Use -e
}
#################################################
# Sanity check
if [ ! -f ./branch/${BRANCH}.bpred ] || [ ! -f ./prefetcher/${L1D_PREFETCHER}.l1d_pref ] || [ ! -f ./prefetcher/${L2C_PREFETCHER}.l2c_pref ] || [ ! -f ./replacement/${LLC_REPLACEMENT}.llc_repl ]; then
echo "${BOLD}Possible Branch Predictor: ${NORMAL}"
LIST=$(ls branch/*.bpred | cut -d '/' -f2 | cut -d '.' -f1)
p=$( embed_newline $LIST )
echo "$p"
echo "${BOLD}Possible L1D Prefetcher: ${NORMAL}"
LIST=$(ls prefetcher/*.l1d_pref | cut -d '/' -f2 | cut -d '.' -f1)
p=$( embed_newline $LIST )
echo "$p"
echo
echo "${BOLD}Possible L2C Prefetcher: ${NORMAL}"
LIST=$(ls prefetcher/*.l2c_pref | cut -d '/' -f2 | cut -d '.' -f1)
p=$( embed_newline $LIST )
echo "$p"
echo
echo "${BOLD}Possible LLC Replacement: ${NORMAL}"
LIST=$(ls replacement/*.llc_repl | cut -d '/' -f2 | cut -d '.' -f1)
p=$( embed_newline $LIST )
echo "$p"
exit
fi
# Check for multi-core
if [ "$NUM_CORE" != "1" ]
then
echo "${BOLD}Building multi-core ChampSim...${NORMAL}"
sed -i.bak 's/\<NUM_CPUS 1\>/NUM_CPUS '${NUM_CORE}'/g' inc/champsim.h
sed -i.bak 's/\<DRAM_CHANNELS 1\>/DRAM_CHANNELS 2/g' inc/champsim.h
sed -i.bak 's/\<DRAM_CHANNELS_LOG2 0\>/DRAM_CHANNELS_LOG2 1/g' inc/champsim.h
else
echo "${BOLD}Building single-core ChampSim...${NORMAL}"
fi
echo
# Change prefetchers and replacement policy
cp branch/${BRANCH}.bpred branch/branch_predictor.cc
cp prefetcher/${L1D_PREFETCHER}.l1d_pref prefetcher/l1d_prefetcher.cc
cp prefetcher/${L2C_PREFETCHER}.l2c_pref prefetcher/l2c_prefetcher.cc
cp replacement/${LLC_REPLACEMENT}.llc_repl replacement/llc_replacement.cc
# Build
mkdir -p bin
rm -f bin/champsim
make clean
make
# Sanity check
echo ""
if [ ! -f bin/champsim ]; then
echo "${BOLD}ChampSim build FAILED!${NORMAL}"
echo ""
exit
fi
echo "${BOLD}ChampSim is successfully built"
echo "Branch Predictor: ${BRANCH}"
echo "L1D Prefetcher: ${L1D_PREFETCHER}"
echo "L2C Prefetcher: ${L2C_PREFETCHER}"
echo "LLC Replacement: ${LLC_REPLACEMENT}"
echo "Cores: ${NUM_CORE}"
BINARY_NAME="${BRANCH}-${L1D_PREFETCHER}-${L2C_PREFETCHER}-${LLC_REPLACEMENT}-${NUM_CORE}core"
echo "Binary: bin/${BINARY_NAME}${NORMAL}"
echo ""
mv bin/champsim bin/${BINARY_NAME}
# Restore to the default configuration
sed -i.bak 's/\<NUM_CPUS '${NUM_CORE}'\>/NUM_CPUS 1/g' inc/champsim.h
sed -i.bak 's/\<DRAM_CHANNELS 2\>/DRAM_CHANNELS 1/g' inc/champsim.h
sed -i.bak 's/\<DRAM_CHANNELS_LOG2 1\>/DRAM_CHANNELS_LOG2 0/g' inc/champsim.h
cp branch/bimodal.bpred branch/branch_predictor.cc
cp prefetcher/no.l1d_pref prefetcher/l1d_prefetcher.cc
cp prefetcher/no.l2c_pref prefetcher/l2c_prefetcher.cc
cp replacement/lru.llc_repl replacement/llc_replacement.cc