-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·261 lines (225 loc) · 10.8 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·261 lines (225 loc) · 10.8 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#!/usr/bin/env bash
# setup.sh — one-shot environment setup and build for the ZSim artifact.
#
# Run this once from the repository root on a Linux machine:
# ./setup.sh
#
# Flags:
# --rebuild Clean and force-rebuild all memory simulators and ZSim
# --build-damov Build DAMOV native simulator and experiment 00 benchmark only
#
# What it does:
# 1. Checks system dependencies (GCC, scons, Python packages, libconfig++)
# 2. Generates .zsim-env (resolves all paths automatically, prompts only for Pin)
# 3. Builds memory simulators (Ramulator, DRAMsim3, Ramulator2, optional DRAMSys)
# 4. Builds ZSim (release build)
# 5. Builds the benchmarks (ptr_chase and traffic_gen)
set -euo pipefail
REBUILD=false
BUILD_DAMOV=false
for arg in "$@"; do
case "$arg" in
--rebuild) REBUILD=true ;;
--build-damov) BUILD_DAMOV=true ;;
*) echo "Unknown argument: $arg"; exit 1 ;;
esac
done
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
REPO_ROOT="$SCRIPT_DIR"
RED='\033[0;31m'; GRN='\033[0;32m'; YLW='\033[1;33m'; BLD='\033[1m'; NC='\033[0m'
ok() { echo -e " ${GRN}✔${NC} $*"; }
warn() { echo -e " ${YLW}⚠${NC} $*"; }
err() { echo -e " ${RED}✘${NC} $*"; exit 1; }
step() { echo -e "\n${BLD}━━━ $* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"; }
# ── 0. Platform check ─────────────────────────────────────────────────────────
if [[ "$(uname -s)" != "Linux" ]]; then
err "This artifact requires Linux. Detected: $(uname -s)"
fi
if [[ "$BUILD_DAMOV" == true ]]; then
step "Building DAMOV native simulator and experiment 00 benchmark"
DAMOV_BUILD_SCRIPT="$REPO_ROOT/experiments/00-damov-native/scripts/build.sh"
if [[ ! -x "$DAMOV_BUILD_SCRIPT" ]]; then
err "DAMOV build helper is missing or not executable: $DAMOV_BUILD_SCRIPT"
fi
"$DAMOV_BUILD_SCRIPT"
ok "DAMOV native simulator and experiment 00 benchmark built successfully"
exit 0
fi
step "Step 1 / 5 — Checking system dependencies"
# GCC
if command -v gcc &>/dev/null; then
ok "GCC: $(gcc --version | head -1)"
else
err "GCC not found. Install GCC 11: sudo apt install gcc g++"
fi
# scons
if command -v scons &>/dev/null; then
ok "scons: $(scons --version 2>&1 | head -1)"
else
err "scons not found. Install it: sudo apt install scons"
fi
# unzip (needed for dependency downloads)
if command -v unzip &>/dev/null; then
ok "unzip: $(unzip -v 2>&1 | head -1)"
else
err "unzip not found. Install it: sudo apt install unzip"
fi
# cmake (needed for DRAMsim3 and Ramulator2)
if command -v cmake &>/dev/null; then
ok "cmake: $(cmake --version | head -1)"
else
err "cmake not found. Install it: sudo apt install cmake"
fi
cmake_major="$(cmake --version | awk 'NR==1 {split($3, v, "."); print v[1]}')"
CMAKE_COMPAT_ARGS=()
# CMake 4 removed compatibility with projects that still declare <3.5.
if [[ "$cmake_major" =~ ^[0-9]+$ ]] && (( cmake_major >= 4 )); then
CMAKE_COMPAT_ARGS=(-DCMAKE_POLICY_VERSION_MINIMUM=3.5)
echo " Detected CMake ${cmake_major}.x; enabling legacy policy compatibility for bundled projects."
fi
# libconfig++
if pkg-config --exists libconfig++ 2>/dev/null || ldconfig -p 2>/dev/null | grep -q libconfig++; then
ok "libconfig++ found"
else
warn "libconfig++ may be missing. If the ZSim build fails, run: sudo apt install libconfig++-dev"
fi
# Python + packages (required for plot.py)
if python3 -c "import pandas, matplotlib" 2>/dev/null; then
ok "Python 3 with pandas and matplotlib"
else
warn "pandas or matplotlib missing. Installing..."
python3 -m pip install --user pandas matplotlib
ok "pandas and matplotlib installed"
fi
# ── 1. Generate .zsim-env ─────────────────────────────────────────────────────
step "Step 2 / 5 — Generating .zsim-env"
"$REPO_ROOT/scripts/setup-env.sh"
if [[ ! -f "$REPO_ROOT/.zsim-env" ]]; then
err ".zsim-env was not created. See scripts/setup-env.sh output above."
fi
# Source it for the remainder of this script
# shellcheck disable=SC1091
source "$REPO_ROOT/.zsim-env"
ok ".zsim-env sourced"
# ── 2. Build memory simulators ───────────────────────────────────────────────
step "Step 3 / 5 — Building memory simulators"
OLD_ABI_CXXFLAG="-D_GLIBCXX_USE_CXX11_ABI=0"
# Ramulator — make libramulator.so in ramulator/ramulator/
RAMULATOR_LIB="$RAMULATORPATH/ramulator/libramulator.so"
if [[ -f "$RAMULATORPATH/ramulator/libramulator.so" ]] && [[ "$REBUILD" == false ]]; then
ok "libramulator.so already built"
else
echo " Building Ramulator..."
[[ "$REBUILD" == true ]] && make -C "$RAMULATORPATH/ramulator" clean 2>/dev/null || true
make -C "$RAMULATORPATH/ramulator" libramulator.so -j"$(nproc)" CXX=g++ CXXFLAGS="-DRAMULATOR -Wall -std=c++11 -w -O3 $OLD_ABI_CXXFLAG"
[[ -f "$RAMULATORPATH/ramulator/libramulator.so" ]] && ok "libramulator.so built" || err "Ramulator build failed."
fi
# DRAMsim3 — cmake build (outputs libdramsim3.so to $DRAMSIM3PATH/, one level above build/)
DRAMSIM3_LIB="$DRAMSIM3PATH/libdramsim3.so"
if [[ -f "$DRAMSIM3_LIB" ]] && [[ "$REBUILD" == false ]]; then
ok "libdramsim3.so already built"
else
echo " Building DRAMsim3..."
[[ "$REBUILD" == true ]] && rm -rf "$DRAMSIM3PATH/build" || true
DRAMSIM3_CMAKE_ARGS=(
-S "$DRAMSIM3PATH"
-B "$DRAMSIM3PATH/build"
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
)
DRAMSIM3_CMAKE_ARGS+=("${CMAKE_COMPAT_ARGS[@]}")
cmake "${DRAMSIM3_CMAKE_ARGS[@]}"
make -C "$DRAMSIM3PATH/build" dramsim3 -j"$(nproc)"
[[ -f "$DRAMSIM3_LIB" ]] && ok "libdramsim3.so built" || err "DRAMsim3 build failed."
fi
# Ramulator2 — cmake build (LIBRARY_OUTPUT_DIRECTORY = PROJECT_SOURCE_DIR, so lib lands in $RAMULATOR2PATH/)
RAMULATOR2_LIB="$RAMULATOR2PATH/libramulator2.so"
if [[ -f "$RAMULATOR2_LIB" ]] && [[ "$REBUILD" == false ]]; then
ok "libramulator2.so already built"
else
echo " Building Ramulator2 from: $RAMULATOR2PATH"
[[ "$REBUILD" == true ]] && rm -rf "$RAMULATOR2PATH/build" || true
RAMULATOR2_CMAKE_ARGS=(
-S "$RAMULATOR2PATH"
-B "$RAMULATOR2PATH/build"
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
)
RAMULATOR2_CMAKE_ARGS+=("${CMAKE_COMPAT_ARGS[@]}")
cmake "${RAMULATOR2_CMAKE_ARGS[@]}"
make -C "$RAMULATOR2PATH/build" ramulator -j"$(nproc)"
[[ -f "$RAMULATOR2_LIB" ]] && ok "libramulator2.so built" || err "Ramulator2 build failed. Expected: $RAMULATOR2_LIB"
fi
# DRAMSys — optional cmake build (static libs in $DRAMSYSPATH/build/lib/)
if [[ -n "${DRAMSYSPATH:-}" ]]; then
DRAMSYS_LIB_DIR="$DRAMSYSPATH/build/lib"
DRAMSYS_LIB="$DRAMSYS_LIB_DIR/libdramsys.a"
DRAMPOWER_LIB="$DRAMSYS_LIB_DIR/libDRAMPower.a"
SYSTEMC_LIB="$DRAMSYS_LIB_DIR/libsystemc.a"
if [[ -f "$DRAMSYS_LIB" && -f "$DRAMPOWER_LIB" && -f "$SYSTEMC_LIB" ]] && [[ "$REBUILD" == false ]]; then
ok "DRAMSys libs and TraceAnalyzer already built"
else
echo " Building DRAMSys from: $DRAMSYSPATH"
[[ "$REBUILD" == true ]] && rm -rf "$DRAMSYSPATH/build" || true
DRAMSYS_CMAKE_ARGS=(
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_CXX_FLAGS="$OLD_ABI_CXXFLAG"
-DDRAMSYS_BUILD_CLI=OFF
-DDRAMSYS_BUILD_TOOLS=OFF
-DDRAMSYS_BUILD_TRACE_ANALYZER=OFF
)
cmake -S "$DRAMSYSPATH" -B "$DRAMSYSPATH/build" \
"${DRAMSYS_CMAKE_ARGS[@]}"
cmake --build "$DRAMSYSPATH/build" -j"$(nproc)"
if [[ -f "$DRAMSYS_LIB" && -f "$DRAMPOWER_LIB" && -f "$SYSTEMC_LIB" ]]; then
ok "DRAMSys libs built (libdramsys.a, libDRAMPower.a, libsystemc.a)"
else
err "DRAMSys build failed. Expected libs under: $DRAMSYS_LIB_DIR"
fi
fi
else
warn "DRAMSYSPATH is not set; skipping optional DRAMSys check/build."
fi
# ── 3. Build ZSim ─────────────────────────────────────────────────────────────
step "Step 4 / 5 — Building ZSim (release)"
ZSIM_DIR="$REPO_ROOT/simulator-source/zsim-bsc"
ZSIM_BIN="$ZSIM_DIR/build/release/zsim"
if [[ -x "$ZSIM_BIN" ]] && [[ "$REBUILD" == false ]]; then
ok "ZSim release binary already exists: $ZSIM_BIN"
echo " To force a rebuild, run: ./setup.sh --rebuild"
else
echo " Building ZSim with $(nproc) parallel jobs. This may take several minutes..."
(
cd "$ZSIM_DIR"
[[ "$REBUILD" == true ]] && scons -c
scons --r -j"$(nproc)"
)
if [[ -x "$ZSIM_BIN" ]]; then
ok "ZSim built: $ZSIM_BIN"
else
err "ZSim build failed. Check the output above."
fi
fi
# ── 3. Build benchmarks ───────────────────────────────────────────────────────
step "Step 5 / 5 — Building benchmarks"
"$REPO_ROOT/scripts/build-benchmarks.sh"
PTR_CHASE="$REPO_ROOT/benchmarks/ptr_chase/ptr_chase"
TRAFFIC_GEN="$REPO_ROOT/benchmarks/traffic_gen/traffic_gen.x"
[[ -x "$PTR_CHASE" ]] && ok "ptr_chase built: $PTR_CHASE" || err "ptr_chase build failed."
[[ -x "$TRAFFIC_GEN" ]] && ok "traffic_gen built: $TRAFFIC_GEN" || err "traffic_gen build failed."
# ── Done ──────────────────────────────────────────────────────────────────────
echo ""
echo -e "${GRN}${BLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GRN}${BLD} Setup complete. The artifact is ready to run.${NC}"
echo -e "${GRN}${BLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo " To run an experiment:"
echo " source .zsim-env"
echo " ./experiments/runner.sh 01-baseline"
echo ""
echo " To compare committed results (no simulation needed):"
echo " ./scripts/compare-results.sh 01-baseline 04-model-correct"
echo ""