[Samples] update polybench dse and dnn ablation scripts

This commit is contained in:
Hanchen Ye 2021-03-29 23:56:35 -05:00
parent affa783242
commit 6dc5b6785e
5 changed files with 41 additions and 26 deletions

View File

@ -601,7 +601,8 @@ Resource ScaleHLSEstimator::estimateResource(Block &block, int64_t interval) {
});
auto noShareDspNum = totalFadd * 2 + totalFmul * 3;
dsp = staticDspNum + max(shareDspNum, noShareDspNum / interval);
// max(shareDspNum, noShareDspNum / interval);
dsp = staticDspNum + noShareDspNum / interval;
// Annotate dsp utilization with & without resource sharing.
auto parentOp = block.getParentOp();

View File

@ -1,11 +1,21 @@
#!/bin/bash
# Please run: source ablation_test_run.sh -m resnet18 -n 19 -c 0
# Please run: source ablation_test_run.sh -m resnet18 -n 17 -c 0
# cd samples/onnx-mlir/ && source ablation_test_run.sh -m lenet -n 19 -c 0
# cd samples/onnx-mlir/ && source ablation_test_run.sh -m mobilenetv2 -n 19 -c 0
# cd samples/onnx-mlir/ && source ablation_test_run.sh -m resnet18 -n 19 -c 0
# cd samples/onnx-mlir/ && source ablation_test_run.sh -m vgg16 -n 19 -c 0
# cd samples/onnx-mlir-1/ && source ablation_test_run.sh -m lenet -n 17 -c 0
# cd samples/onnx-mlir-1/ && source ablation_test_run.sh -m mobilenetv2 -n 17 -c 0
# cd samples/onnx-mlir-1/ && source ablation_test_run.sh -m resnet18 -n 17 -c 0
# cd samples/onnx-mlir-1/ && source ablation_test_run.sh -m vgg16 -n 17 -c 0
# cd samples/onnx-mlir-2/ && source ablation_test_run.sh -m lenet -n 17 -c 0
# cd samples/onnx-mlir-2/ && source ablation_test_run.sh -m mobilenetv2 -n 17 -c 0
# cd samples/onnx-mlir-2/ && source ablation_test_run.sh -m resnet18 -n 17 -c 0
# cd samples/onnx-mlir-2/ && source ablation_test_run.sh -m vgg16 -n 17 -c 0
# cd samples/onnx-mlir-3/ && source ablation_test_run.sh -m lenet -n 17 -c 0
# cd samples/onnx-mlir-3/ && source ablation_test_run.sh -m mobilenetv2 -n 17 -c 0
# cd samples/onnx-mlir-3/ && source ablation_test_run.sh -m resnet18 -n 17 -c 0
# cd samples/onnx-mlir-3/ && source ablation_test_run.sh -m vgg16 -n 17 -c 0
# Script options.
while getopts 'm:n:c:' opt
@ -38,7 +48,7 @@ graph_O3=-legalize-dataflow="min-gran=6 insert-copy=true"
graph_O4=-legalize-dataflow="min-gran=5 insert-copy=true"
graph_O5=-legalize-dataflow="min-gran=4 insert-copy=true"
graph_O6=-legalize-dataflow="min-gran=3 insert-copy=true"
graph_O7=-legalize-dataflow="min-gran=2 insert-copy=true"
# graph_O7=-legalize-dataflow="min-gran=2 insert-copy=true"
# Split and canonicalize function.
split="-split-function -convert-linalg-to-affine-loops -canonicalize"
@ -56,7 +66,7 @@ loop_O3=-partial-affine-loop-tile="tile-size=4 apply-order-opt=true apply-pipeli
loop_O4=-partial-affine-loop-tile="tile-size=8 apply-order-opt=true apply-pipeline=true"
loop_O5=-partial-affine-loop-tile="tile-size=16 apply-order-opt=true apply-pipeline=true"
loop_O6=-partial-affine-loop-tile="tile-size=32 apply-order-opt=true apply-pipeline=true"
loop_O7=-partial-affine-loop-tile="tile-size=64 apply-order-opt=true apply-pipeline=true"
# loop_O7=-partial-affine-loop-tile="tile-size=64 apply-order-opt=true apply-pipeline=true"
# Loop pipelining.
pipeline="-loop-pipelining"
@ -86,24 +96,25 @@ do
4) scalehls-opt $file $legalize "$graph_O6" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
## Ablation study of loop opt.
# Graph (level 6) + loop (level 1 to 7) + directive opt.
# Graph (level 6) + loop (level 1 to 6) + directive opt.
5) scalehls-opt $file $legalize "$graph_O6" $split $hlscpp $perfect $loop_O1 $direct | scalehls-translate -emit-hlscpp -o $output ;;
6) scalehls-opt $file $legalize "$graph_O6" $split $hlscpp $perfect "$loop_O2" $direct | scalehls-translate -emit-hlscpp -o $output ;;
7) scalehls-opt $file $legalize "$graph_O6" $split $hlscpp $perfect "$loop_O3" $direct | scalehls-translate -emit-hlscpp -o $output ;;
8) scalehls-opt $file $legalize "$graph_O6" $split $hlscpp $perfect "$loop_O4" $direct | scalehls-translate -emit-hlscpp -o $output ;;
9) scalehls-opt $file $legalize "$graph_O6" $split $hlscpp $perfect "$loop_O5" $direct | scalehls-translate -emit-hlscpp -o $output ;;
10) scalehls-opt $file $legalize "$graph_O6" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
11) scalehls-opt $file $legalize "$graph_O6" $split $hlscpp $perfect "$loop_O7" $direct | scalehls-translate -emit-hlscpp -o $output ;;
## Ablation study of graph opt.
# Graph (from level 1 to 7) + loop (level 6) + directive opt.
12) scalehls-opt $file $legalize "$graph_O1" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
13) scalehls-opt $file $legalize "$graph_O2" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
14) scalehls-opt $file $legalize "$graph_O3" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
15) scalehls-opt $file $legalize "$graph_O4" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
16) scalehls-opt $file $legalize "$graph_O5" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
17) scalehls-opt $file $legalize "$graph_O6" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
18) scalehls-opt $file $legalize "$graph_O7" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
# Graph (from level 1 to 6) + loop (level 6) + directive opt.
11) scalehls-opt $file $legalize "$graph_O1" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
12) scalehls-opt $file $legalize "$graph_O2" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
13) scalehls-opt $file $legalize "$graph_O3" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
14) scalehls-opt $file $legalize "$graph_O4" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
15) scalehls-opt $file $legalize "$graph_O5" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
16) scalehls-opt $file $legalize "$graph_O6" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
# 17) scalehls-opt $file $legalize "$graph_O6" $split $hlscpp $perfect "$loop_O7" $direct | scalehls-translate -emit-hlscpp -o $output ;;
# 18) scalehls-opt $file $legalize "$graph_O7" $split $hlscpp $perfect "$loop_O6" $direct | scalehls-translate -emit-hlscpp -o $output ;;
esac
if [ $n -ge $rerun_csynth_from ]

View File

@ -6,8 +6,8 @@ open_project $proj
set_top $name
add_files $file
open_solution $name
set_part {xc7z020-clg400-1} -tool vivado
create_clock -period 10 -name default
set_part {xcvu9p-flga2104-2L-e} -tool vivado
create_clock -period 5 -name default
#csim_design
csynth_design
#cosim_design

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Please run: source dse_test_run.sh -c 0
# Please run: source dse_test_run.sh -m gemm -c 0
# cd samples/polybench/ && source dse_test_run.sh -m atax -c 0
# cd samples/polybench/ && source dse_test_run.sh -m bicg -c 0
@ -55,7 +55,7 @@ do
done
# Run Vivado HLS and collect results.
echo -e "Name\tBRAM\tDSP\tLUT\tCycles\tInterval" > ${model_name}/${model_name}_result.log
echo -e "Name\tBRAM\tDSP\tLUT\tCycles\tEstiDSP\tEstiCycles" > ${model_name}/${model_name}_result.log
n=0
for file in ${model_name}/cpp_src/*
do
@ -76,9 +76,12 @@ do
dsp=$(awk '/<\/*DSP48E>/{gsub(/<\/*DSP48E>/,"");print $0;exit;}' $csynth_xml)
lut=$(awk '/<\/*LUT>/{gsub(/<\/*LUT>/,"");print $0;exit;}' $csynth_xml)
cycles=$(awk '/<\/*Best-caseLatency>/{gsub(/<\/*Best-caseLatency>/,"");print $0}' $csynth_xml)
interval=$(awk '/<\/*Interval-min>/{gsub(/<\/*Interval-min>/,"");print $0}' $csynth_xml)
# interval=$(awk '/<\/*Interval-min>/{gsub(/<\/*Interval-min>/,"");print $0}' $csynth_xml)
echo -e "${cpp_name}\t$bram\t$dsp\t$lut\t$cycles\t$interval" >> ${model_name}/${model_name}_result.log
esti_dsp=$(awk '/\/* DSP=/{gsub(/\/* DSP=/,"");print $0}' ${model_name}/cpp_src/${cpp_name}.cpp)
esti_cycles=$(awk '/\/* Latency=/{gsub(/\/* Latency=/,"");print $0}' ${model_name}/cpp_src/${cpp_name}.cpp)
echo -e "${cpp_name}\t$bram\t$dsp\t$lut\t$cycles\t${esti_dsp}\t${esti_cycles}" >> ${model_name}/${model_name}_result.log
let n++
done

View File

@ -6,7 +6,7 @@
#set1 = affine_set<(d0) : (d0 == 0)>
module {
// CHECK-LABEL: func @test_syrk(
// CHECK-SAME: %arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, #map0, 1>, %arg3: memref<16x16xf32, #map1, 1>) attributes {bram = 3 : i64, dataflow = false, dsp = 11 : i64, ff = 0 : i64, latency = 4117 : i64, lut = 0 : i64, top_function = true} {
// CHECK-SAME: %arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, #map0, 1>, %arg3: memref<16x16xf32, #map1, 1>) attributes {bram = 3 : i64, dataflow = false, dsp = 9 : i64, ff = 0 : i64, latency = 4117 : i64, lut = 0 : i64, top_function = true} {
func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, #map0, 1>, %arg3: memref<16x16xf32, #map1, 1>) attributes {dataflow = false, top_function = true} {
affine.for %arg4 = 0 to 16 step 2 {
affine.for %arg5 = 0 to 16 {
@ -32,7 +32,7 @@ module {
affine.store %12, %arg3[%arg5, %arg6] : memref<16x16xf32, #map1, 1>
}
// CHECK: } {bram = 0 : i64, dep_ii = 2 : i64, dsp = 11 : i64, ff = 0 : i64, flatten = false, flatten_trip_count = 16 : i64, ii = 2 : i64, iter_latency = 21 : i64, latency = 51 : i64, lut = 0 : i64, noshare_dsp = 19 : i64, parallel = true, pipeline = true, res_ii = 2 : i64, schedule_begin = 0 : i64, schedule_end = 53 : i64, share_dsp = 11 : i64, target_ii = 1 : i64, trip_count = 16 : i64}
// CHECK: } {bram = 0 : i64, dep_ii = 2 : i64, dsp = 9 : i64, ff = 0 : i64, flatten = false, flatten_trip_count = 16 : i64, ii = 2 : i64, iter_latency = 21 : i64, latency = 51 : i64, lut = 0 : i64, noshare_dsp = 19 : i64, parallel = true, pipeline = true, res_ii = 2 : i64, schedule_begin = 0 : i64, schedule_end = 53 : i64, share_dsp = 11 : i64, target_ii = 1 : i64, trip_count = 16 : i64}
} {flatten = false, parallel = true, pipeline = true, target_ii = 1 : i64}
} {flatten = true, parallel = true, pipeline = false}
} {flatten = true, parallel = false, pipeline = false}