-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrungarnet
executable file
·225 lines (202 loc) · 6.52 KB
/
rungarnet
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
#!/usr/bin/env bash
#
# Script for running GarnetStandalone simulations
#
# Usage: ./rungarnet n_cpus n_rows concentration_factor topology_py_file \
# flit_injection_rate synthetic_traffic_type n_cycles
#
# n_cpus: number of cpu's
# n_rows: number of rows in the topology structure
# concentration_factor: number of cpu's per router
# topology_py_file: name of the .py-file in configs/topologies/
# flit_injection_rate: traffic injection rate in packets/node/cycle
# synthetic_traffic_type: uniform_random, tornado, bit_complement, bit_reverse,
# bit_rotation, neighbor, shuffle, transpose
# n_cycles: total number of cycles for which the simulation should run
# Defaults:
HIDEWARNERROR=0 # Bool: hide warnings and errors
HIDESTDOUT=0 # Bool: hide stdout
GARNETDEBUG=0 # Bool: enable Ruby/Garnet2.0 debug printing to `debug.txt`
NVCS=4 # Number of virtual channels (VC) per virtual network
NBUFFERS_PER_DATA_VC=8 # Number of buffers per data VC
NBUFFERS_PER_CTRL_VC=1 # Number of buffers per control VC
LINKWIDTHBITS=512 # Width in bits for all links inside the network
DEADLOCKTHRESHOLD=100000 # Network-level deadlock threshold
INJVNET=-1 # Only inject in this vnet (0, 1 or 2);
# 0 and 1 are 1-flit, 2 is 5-flit;
# set to -1 to inject randomly in all vnets.
CONCENTRATION_FACTOR=4 # Number of cpu's per router
NCPUS=1024 # Number of cpu's
NDIRS=-1 # Number of directory controllers, must <= NCPUS;
# set to -1 to equal the number of routers <= 256.
NROWS=16
TOPOLOGY=Mesh_XY
INJRATE=0.4
SYNTH=uniform_random
NCYCLES=20000
ROUTINGALGORITHM=0 # Routing_algorithm: routing algorithm in network,
# implemented in src/mem/ruby/network/garnet2.0/RoutingUnit.cc:
# 0: Weight-based table (shortest path)
# 1: XY (for Mesh)
# 2: Random (custom)
# 3: Adaptive (not implemented)
# Send between specific router id's. -1: disable
SENDER_ID=-1
DEST_ID=-1
# Get parameter arguments
if [ "$#" -gt 0 ] && [[ $1 =~ ^[0-9]+$ ]]; then
NCPUS=$1
else
# Print help info
sed -n "3,43p" $0
exit
fi
if [ "$#" -gt 1 ]; then
NROWS=$2
fi
if [ "$#" -gt 2 ]; then
CONCENTRATION_FACTOR=$3
fi
if [ "$#" -gt 3 ]; then
TOPOLOGY=$4
fi
if [ "$#" -gt 4 ]; then
INJRATE=$5
fi
if [ "$#" -gt 5 ]; then
SYNTH=$6
fi
if [ "$#" -gt 6 ]; then
NCYCLES=$7
fi
# Set the number of directory controllers, with a maximum of 256
if [ $NDIRS -eq -1 ]; then
NDIRS=$(($NCPUS/$CONCENTRATION_FACTOR))
fi
if [ $NDIRS -gt 256 ]; then
NDIRS=256
fi
# To avoid deadlock in HierarchicalRing topologies with NROWS>4,
# limit NDIRS to NROWS and limit NCPUS to 128
if [ "$TOPOLOGY" == "HierarchicalRing" ] && [ $NCPUS -gt 128 ]; then
echo HierarchicalRing is limited to 128 cores. Exiting...
exit
fi
if [ "$TOPOLOGY" == "HierarchicalRing" ] && [ $NROWS -gt 4 ]; then
NDIRS=$NROWS
fi
USE_ESCAPE_VC=""
# Automatically enable Escape VC's for Ring and disable otherwise
#if [ "$TOPOLOGY" == "Ring" ]; then
# USE_ESCAPE_VC="--escapevc"
#fi
# Recalculate ncols for concentration factor
if [ $CONCENTRATION_FACTOR -gt 1 ]; then
NCOLS=$(($NCPUS/$NROWS/$CONCENTRATION_FACTOR))
CONCENTRATION_STRING=$CONCENTRATION_FACTOR"cpus_per_router-"
CONCENTRATION_FACTOR="--concentration-factor="$CONCENTRATION_FACTOR
else
NCOLS=$(($NCPUS/$NROWS))
CONCENTRATION_STRING=""
CONCENTRATION_FACTOR=""
fi
# Suffix output dir name with routing algorithm : disabled
case "$ROUTINGALGORITHM" in
0) RALGNAME=weighted_table_routing ;;
1) RALGNAME=mesh_xy_routing ;;
2) RALGNAME=random_routing ;;
3) RALGNAME=adaptive_routing ;;
*) RALGNAME=unknown_routing ;;
esac
OUTDIR="m5out/"$TOPOLOGY-$NCPUS"core-"$NROWS"x"$NCOLS-$CONCENTRATION_STRING$SYNTH-$INJRATE"injrate"-$NCYCLES"cycles"
LATENCY_FILE="m5out/"$TOPOLOGY-$NCPUS"core-"$NROWS"x"$NCOLS-$CONCENTRATION_STRING$SYNTH-$NCYCLES"cycles-latency.txt"
# Generate output dir name
if [ -d $OUTDIR ]; then
MAXOUTDIRS=99
for ((i=2;i<=MAXOUTDIRS;i++)); do
NOUTDIR=$OUTDIR"-"$i
if [ ! -d $NOUTDIR ]; then
OUTDIR=$NOUTDIR
break
fi
done
fi
mkdir -p $OUTDIR
# Redirect stdout to file
if [ $GARNETDEBUG -eq 1 ]; then
GARNETDEBUG_FLAGS="--debug-flags=RubyNetwork,GarnetSyntheticTraffic"
GARNETDEBUG_TOFILE="$OUTDIR/debug.txt"
else
GARNETDEBUG_FLAGS=""
GARNETDEBUG_TOFILE=""
GARNETDEBUG_PIPE=""
fi
# Redirect stdout to /dev/null
if [ $HIDESTDOUT -eq 1 ]; then
HIDESTDOUT="-r --stdout-file=/dev/null"
else
HIDESTDOUT=""
fi
# Redirect stderr /dev/null
if [ $HIDEWARNERROR -eq 1 ]; then
HIDEWARNERROR="-e --stderr-file=/dev/null"
else
HIDEWARNERROR=""
fi
SEND_TO_ROUTER_IDS=""
if [ ! $SENDER_ID -eq -1 ]; then
SEND_TO_ROUTER_IDS+="--single-sender-id=$SENDER_ID"
fi
if [ ! $DEST_ID -eq -1 ]; then
SEND_TO_ROUTER_IDS+=" --single-dest-id=$DEST_ID"
fi
# Set environment variable for recognizing simulation type in gem5 source files
export GEM5SIMTYPE=GarnetStandalone
RUNCMD="./build/NULL/gem5.debug -v $HIDEWARNERROR $HIDESTDOUT $GARNETDEBUG_FLAGS \
-d $OUTDIR configs/example/garnet_synth_traffic.py \
--network=garnet2.0 \
--num-cpus=$NCPUS \
--num-dirs=$NDIRS \
--topology=$TOPOLOGY \
--mesh-rows=$NROWS \
--sim-cycles=$NCYCLES \
--injectionrate=$INJRATE \
--synthetic=$SYNTH \
--routing-algorithm=$ROUTINGALGORITHM \
--link-width-bits=$LINKWIDTHBITS \
--vcs-per-vnet=$NVCS \
--buffers-per-data-vc=$NBUFFERS_PER_DATA_VC \
--buffers-per-ctrl-vc=$NBUFFERS_PER_CTRL_VC \
--garnet-deadlock-threshold=$DEADLOCKTHRESHOLD \
--inj-vnet=$INJVNET \
--tikz \
$CONCENTRATION_FACTOR \
$USE_ESCAPE_VC \
$SEND_TO_ROUTER_IDS"
redirect_cmd() {
if [ $GARNETDEBUG -eq 1 ]; then
"$@" > "$GARNETDEBUG_TOFILE"
return $?
else
"$@"
return $?
fi
}
redirect_cmd $RUNCMD
# Simulation output parsing
EXITCODE=$?
if [ $GARNETDEBUG -eq 1 ]; then
python grepdebug.py "$GARNETDEBUG_TOFILE"
fi
if [ $EXITCODE -eq 0 ]; then
# Copy network-related stats to network_stats.txt
python grepnetworkstats.py $OUTDIR
# Plot latency
python plotlatency.py $OUTDIR $LATENCY_FILE $INJRATE
# Generate topology.png from topology.tex
./tex2png $OUTDIR > /dev/null
# Calculate power and area with DSENT
#./rundsent $OUTDIR
else
rmdir $OUTDIR &> /dev/null
fi