-
Notifications
You must be signed in to change notification settings - Fork 10
/
72tops_dse.sh
149 lines (138 loc) · 6.21 KB
/
72tops_dse.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
# Design Space Experiment of 72TOPS
# Script Usage: ./dse.sh [output_folder]
# Execute `stschedule` once.
# Usage: search $mm $nn $xx $yy $ss $bb $rr $ff $xcut $ycut $_serdes_lane $_DRAM_bw $_NoC_bw $_mac_num $_ul3 $TOPS result.log out.log err.log search.log
search(){
start=$(date +%s)
echo "$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} ${14} ${15} ${16}" | ./build/stschedule ${17} > ${18} 2> ${19}
end=$(date +%s)
iter_time=$(( end - start ))
printf "INPUT(%1d %2d %3d %3d %3d %3d %3d %2d %3d %3d %3d %8d %3d %4d %4d %8d) ITERATION_TIME(%5d)seconds\n" $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} ${14} ${15} ${16} $iter_time >> ${20}
return $iter_time
}
experiment() {
echo '************************* Start Experiment *************************'
echo "[PROMPT] Check the output in dir $output_path."
network_range=(11)
DRAM_bw_range=(`expr $TOPS / 2` $TOPS `expr $TOPS \* 2` `expr $TOPS \* 4`)
NoC_bw_range=(8 16 32 64)
ul3_range=(256 512 1024 2048 4096)
mac_num_range=(512 1024 2048 4096)
start_time=$(date +%s)
for nn in ${network_range[*]}
do
temp_path0=$output_path/${network[$nn]}
mkdir $temp_path0
for _DRAM_bw in ${DRAM_bw_range[*]}
do
temp_path1=$temp_path0/DRAM_bw_${_DRAM_bw}
mkdir $temp_path1
for _NoC_bw in ${NoC_bw_range[*]}
do
temp_path2=$temp_path1/NoC_bw_${_NoC_bw}
mkdir $temp_path2
for _ul3 in ${ul3_range[*]}
do
{
temp_path3=$temp_path2/ul3_${_ul3}
mkdir $temp_path3
for _serdes_lane in `expr $_NoC_bw / 2` $_NoC_bw
do
temp_path4=$temp_path3/NoP_bw_${_serdes_lane}
mkdir $temp_path4
for _mac_num in ${mac_num_range[*]}
do
temp_path5=$temp_path4/mac_num_${_mac_num}
mkdir $temp_path5
x2=`expr $TOPS / 2 / $_mac_num`
# xx >= yy
xx=$(echo "sqrt($x2)" | bc)
if [ `expr $xx \* $xx` -eq $x2 ]; then
# x2 is an even power of 2.
yy=$xx
else
# x2 is an odd power of 2.
x2=`expr $x2 / 2`
yy=$(echo "sqrt($x2)" | bc)
xx=`expr 2 \* $yy`
fi
ss=`expr $xx / 2`
for cut_idx in `seq 0 1 $(( ${#cut_long[*]} - 1))`
do
if [ $xx -gt $yy ]; then
xcut=${cut_long[$cut_idx]}
ycut=${cut_short[$cut_idx]}
else
ycut=${cut_long[$cut_idx]}
xcut=${cut_short[$cut_idx]}
fi
# Abandon invalid chiplet partition schemes.
if [ `expr $xx % $xcut` -ne 0 -o `expr $yy % $ycut` -ne 0 ]; then continue; fi
if [ `expr $xcut \* $ycut` -eq 1 -a $_serdes_lane -ne $_NoC_bw ]; then continue; fi
temp_path_innerest=$temp_path5/xcut_${xcut}_ycut_${ycut}
mkdir $temp_path_innerest
touch $temp_path_innerest/$search_log
touch $temp_path_innerest/$err_log
touch $temp_path_innerest/$output_point_file
touch $temp_path_innerest/$output_struct_file
search $mm $nn $xx $yy $ss $bb $rr $ff $xcut $ycut $_serdes_lane $_DRAM_bw $_NoC_bw $_mac_num $_ul3 $TOPS "$temp_path_innerest/$output_point_file" "$temp_path_innerest/$output_struct_file" "$temp_path_innerest/$err_log" "$temp_path_innerest/$search_log"
done
done
done
} &
done
done
done
done
wait
# Print experiment time.
end_time=$(date +%s)
search_time=$(( end_time - start_time ))
_second=`expr $search_time % 60`
_minute=`expr $search_time / 60`
_hour=`expr $_minute / 60`
_minute=`expr $_minute % 60`
echo "[PROMPT] Experiment time: $_hour h $_minute m $_second s ($search_time)seconds."
echo '************************ Finish Experiment *************************'
}
# *************************** Output File ****************************
output_point_file="result.log"
output_struct_file="out.log"
err_log="err.log"
search_log="search.log"
# Make output dir and files.
temp_date=$(date "+%Y_%m_%d_%H_%M_%S")
if [ $# -lt 1 ]; then
if [ ! -d "dse_log" ]; then
mkdir "dse_log"
fi
output_path=`pwd`/dse_log/${temp_date}
else
output_path=`readlink -f $1`
fi
mkdir $output_path
# The max depth of output dir.
max_dir_depth=16
# ************************* Other Parameters *************************
network=(darknet19 vgg resnet50 googlenet resnet101 densenet ires gnmt lstm zfnet transformer transformer_cell pnasnet resnext50 resnet152)
# chiplet number : 1 2 4 9 18 36
cut_long=(1 2 2 3 6 6)
cut_short=(1 1 2 3 3 6)
mm=0
TOPS=`expr 72 \* 1024`
rr=150
bb=64
ff=1
# ************************ Execute Experiment ************************
echo "******************** 72TOPS DSE Start ********************"
echo "[INFO] Check output in dir $output_path."
echo "[INFO] DSE running..."
experiment > $output_path/dse.log 2> $output_path/dse.err.log
# Summarize the experiment result.
echo "[INFO] Summarizing experiment results..."
./summary.sh $output_path $max_dir_depth
echo "[INFO] Summary at $output_path/result.xlsx"
echo "[INFO] Summary accomplished."
echo "[INFO] Best Arch found."
python3 pyscripts/best_arch.py $output_path/result.csv $output_path/best_arch.txt
echo "******************** 72TOPS DSE Finish *******************"