-
Notifications
You must be signed in to change notification settings - Fork 408
/
Copy pathverify_odin.sh
executable file
·1658 lines (1384 loc) · 46.4 KB
/
verify_odin.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
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
SHELL=$(type -P bash)
FAILURE=0
THIS_SCRIPT_PATH=$(readlink -f "$0")
THIS_DIR=$(dirname "${THIS_SCRIPT_PATH}")
VTR_DIR=$(readlink -f "${THIS_DIR}/..")
REGRESSION_DIR="${THIS_DIR}/regression_test"
REG_LIB="${REGRESSION_DIR}/.library"
PARSER_DIR="${REGRESSION_DIR}/parse_result"
PARSER_EXEC="${PARSER_DIR}/parse_result.py"
source "${REG_LIB}/handle_exit.sh"
source "${REG_LIB}/helper.sh"
source "${REG_LIB}/conf_generate.sh"
export EXIT_NAME="$0"
##############################################
# grab the input args
INPUT="$*"
# disable stdin
exec 0<&-
WRAPPER_EXEC="${THIS_DIR}/exec_wrapper.sh"
ODIN_EXEC="${THIS_DIR}/odin_ii"
BENCHMARK_DIR="${REGRESSION_DIR}/benchmark"
VTR_REG_PREFIX="vtr::"
VTR_REG_DIR="${VTR_DIR}/vtr_flow/tasks/regression_tests"
SUITE_DIR="${BENCHMARK_DIR}/suite"
RELAPATH_SUITE_DIR=$(realapath_from "${SUITE_DIR}" "${PWD}")
TASK_DIR="${BENCHMARK_DIR}/task"
RELAPATH_TASK_DIR=$(realapath_from "${TASK_DIR}" "${PWD}")
RTL_REG_PREFIX="rtl_reg"
PREVIOUS_RUN_DIR=""
NEW_RUN_DIR="${REGRESSION_DIR}/run001/"
global_failure="test_failures.log"
##############
# defaults
_TEST_INPUT_LIST=()
_SUBTEST_LIST=()
_NUMBER_OF_PROCESS="1"
_RUN_DIR_OVERRIDE=""
_EXTRA_CONFIG=""
_OVERRIDE_CONFIG="off"
_GENERATE_BENCH="off"
_GENERATE_OUTPUT="off"
_GENERATE_CONFIG="off"
_FORCE_SIM="off"
_DRY_RUN="off"
_RANDOM_DRY_RUN="off"
_REGENERATE_EXPECTATION="off"
_GENERATE_EXPECTATION="off"
_CONTINUE="off"
_REPORT="on"
_STATUS_ONLY="off"
##############################################
# Exit Functions
function exit_program() {
FAIL_COUNT="0"
if [ -f "${NEW_RUN_DIR}/${global_failure}" ]; then
FAIL_COUNT=$(wc -l "${NEW_RUN_DIR}/${global_failure}" | cut -d ' ' -f 1)
fi
FAILURE=$(( FAIL_COUNT ))
if [ "_${_REPORT}" == "_on" ]
then
if [ "_${FAILURE}" != "_0" ]
then
echo "Failed ${FAILURE} benchmarks"
echo ""
cat "${NEW_RUN_DIR}/${global_failure}"
echo ""
echo "View Failure log in ${NEW_RUN_DIR}/${global_failure}"
else
echo "no run failure!"
fi
fi
exit ${FAILURE}
}
##############################################
# Help Print helper
_prt_cur_arg() {
arg="[ $1 ]"
line=" "
printf "%s%s" "${arg}" "${line:${#arg}}"
}
function help() {
printf "Called program with $INPUT
Usage:
$0 [ OPTIONS / FLAGS ] [ SUBTEST_LIST ... ]
SUBTEST_LIST
should be a list of the form < task_name/test_file_name/architecture_file_name >
passing this in will limit a task to a subset of test
current: $(_prt_cur_arg ${_SUBTEST_LIST[*]})
FLAGS
-g|--generate_bench $(_prt_cur_arg ${_GENERATE_BENCH}) Generate input and output vector for test
-o|--generate_output $(_prt_cur_arg ${_GENERATE_OUTPUT}) Generate output vector for test given its input vector
-b|--build_config $(_prt_cur_arg ${_GENERATE_CONFIG}) Generate a config file for a given directory
-c|--clean $(_prt_cur_arg off ) Clean temporary directory
-f|--force_simulate $(_prt_cur_arg ${_FORCE_SIM}) Force the simulation to be executed regardless of the config
--override $(_prt_cur_arg ${_OVERRIDE_CONFIG}) if a config file is passed in, override arguments rather than append
--dry_run $(_prt_cur_arg ${_DRY_RUN}) performs a dry run to check the validity of the task and flow
--randomize $(_prt_cur_arg ${_RANDOM_DRY_RUN}) performs a dry run randomly to check the validity of the task and flow
--regenerate_expectation $(_prt_cur_arg ${_REGENERATE_EXPECTATION}) regenerate the expectation and overrides the expected value mismatches only
--generate_expectation $(_prt_cur_arg ${_GENERATE_EXPECTATION}) generate the expectation and overrides the expectation file
--continue $(_prt_cur_arg ${_CONTINUE}) continue running test in the same directory as the last run
--no_report printing report is: $(_prt_cur_arg ${_REPORT})
--status_only $(_prt_cur_arg ${_STATUS_ONLY}) print the report and exit
OPTIONS
-h|--help $(_prt_cur_arg off) print this
-j|--nb_of_process < N > $(_prt_cur_arg ${_NUMBER_OF_PROCESS}) Number of process requested to be used
-d|--output_dir < /abs/path > $(_prt_cur_arg ${_RUN_DIR_OVERRIDE}) Change the run directory output
-C|--config <path/to/config> $(_prt_cur_arg ${_EXTRA_CONFIG}) Add a config file to append to the config for the tests
-t|--test < test name > $(_prt_cur_arg ${_TEST_INPUT_LIST[*]}) Test name is either a absolute or relative path to
a directory containing a task.conf, task_list.conf
(see CONFIG FILE HELP) or one of the following predefined test
AVAILABLE_TEST:
"
printf "\n\t\t%s\n" "${RELAPATH_SUITE_DIR}/"
for bm in "${SUITE_DIR}"/*; do printf "\t\t\t%s\n" "$(basename "${bm}")"; done
printf "\n\t\t%s\n" "${RELAPATH_TASK_DIR}/"
for bm in "${TASK_DIR}"/*; do printf "\t\t\t%s\n" "$(basename "${bm}")"; done
printf "\n\t\t%s\n" "${VTR_REG_PREFIX}"
for bm in "${VTR_REG_DIR}/${VTR_REG_PREFIX}"*; do printf "\t\t\t%s\n" "$(basename "${bm}" | sed "s+${VTR_REG_PREFIX}++g")"; done
printf "\n\t\t%s\n" "${RTL_REG_PREFIX}"
echo "CONFIG FILE HELP:"
config_help
}
###############################################
# Time Helper Functions
function get_current_time() {
date +%s%3N
}
# needs start time $1
function print_time_since() {
BEGIN="$1"
NOW=$(get_current_time)
TIME_TO_RUN=$(( NOW - BEGIN ))
Mili=$(( TIME_TO_RUN %1000 ))
Sec=$(( ( TIME_TO_RUN /1000 ) %60 ))
Min=$(( ( ( TIME_TO_RUN /1000 ) /60 ) %60 ))
Hour=$(( ( ( TIME_TO_RUN /1000 ) /60 ) /60 ))
echo "ran test in: $Hour:$Min:$Sec.$Mili"
}
TMP_BENCH_FIND_ARRAY=()
function find_in_bench() {
# sort the output alphabeticaly
mapfile -t TMP_BENCH_FIND_ARRAY < <(echo "$1"/*/*/"$2" | tr -s '[:space:]' '\n' | sort)
if [ "_${TMP_BENCH_FIND_ARRAY[*]}" == "_" ] \
|| [ "_${TMP_BENCH_FIND_ARRAY[0]}" == "_" ]\
|| [ ! -f "${TMP_BENCH_FIND_ARRAY[0]}" ]
then
TMP_BENCH_FIND_ARRAY=()
fi
}
################################################
# Init Directories and cleanup
function init_temp() {
OUTPUT_DIRECTORY=${REGRESSION_DIR}
if [ "_${_RUN_DIR_OVERRIDE}" != "_" ] && [ -d "${_RUN_DIR_OVERRIDE}" ]
then
OUTPUT_DIRECTORY=${_RUN_DIR_OVERRIDE}
fi
PREVIOUS_RUN_DIR=$(find ${OUTPUT_DIRECTORY}/run* -maxdepth 0 -type d 2>/dev/null | tail -1 )
n="1"
if [ "_${PREVIOUS_RUN_DIR}" != "_" ]
then
n=$(echo "${PREVIOUS_RUN_DIR##${OUTPUT_DIRECTORY}/run}" | awk '{print $0 + 1}')
if [ "_${_CONTINUE}" == "_on" ]
then
n=$(( n - 1 ))
fi
fi
NEW_RUN_DIR=${OUTPUT_DIRECTORY}/run$(printf "%03d" "${n}")
echo "Benchmark result location: ${NEW_RUN_DIR}"
}
function create_temp() {
if [ ! -d "${NEW_RUN_DIR}" ]; then
mkdir -p "${NEW_RUN_DIR}"
unlink "${REGRESSION_DIR}/latest" &> /dev/null || /bin/true
rm -Rf "${REGRESSION_DIR}/latest" || /bin/true
ln -s "${NEW_RUN_DIR}" "${REGRESSION_DIR}/latest"
# put in the passed parameter for keepsake
echo "${_TEST_INPUT_LIST[@]}" | xargs -n 1 -I {} echo {} > "${NEW_RUN_DIR}/cmd.task"
echo "========="
echo "$0 ${INPUT}" >> "${NEW_RUN_DIR}/cmd.task"
fi
}
function cleanup_temp() {
OUTPUT_DIRECTORY=${REGRESSION_DIR}
if [ "_${_RUN_DIR_OVERRIDE}" != "_" ]
then
OUTPUT_DIRECTORY=${_RUN_DIR_OVERRIDE}
fi
for runs in "${OUTPUT_DIRECTORY}"/run*
do
rm -Rf "${runs}"
done
if [ -e "${REGRESSION_DIR}/latest" ]; then
unlink "${REGRESSION_DIR}/latest" || /bin/true
rm -Rf "${REGRESSION_DIR}/latest" || /bin/true
fi
}
function disable_failed_bm() {
failed_dir=$1
bench_name="$2"
if [ "_${failed_dir}" != "_" ] && [ "_${bench_name}" != "_" ]
then
find_in_bench "${NEW_RUN_DIR}/${bench_name}" "failure"
for failed_benchmark in "${TMP_BENCH_FIND_ARRAY[@]}"
do
failed_benchmark="$(dirname "${failed_benchmark}")"
for cmd_params in "${failed_benchmark}"/*_wrapper_*
do
[ "_${cmd_params}" != "_" ] && [ -f "${cmd_params}" ] && mv "${cmd_params}" "${cmd_params}_disabled"
done
failed_benchmark_relapath="$(realapath_from "${failed_benchmark}" "${NEW_RUN_DIR}")"
target="${failed_dir}/${failed_benchmark_relapath}"
target_dir=$(dirname "${target}")
if [ ! -L "${target}" ]
then
mkdir -p "${target_dir}"
ln -s "${failed_benchmark}" "${target}"
fi
done
fi
}
function parse_args() {
PARSE_SUBTEST="off"
while [ "_$*" != "_" ]
do
if [ ${PARSE_SUBTEST} == "on" ];
then
# parse subtest
_SUBTEST_LIST+=( "$1" )
shift
else
# parse [ OPTIONS / FLAGS ]
case $1 in
# Help Desk
-h|--help)
echo "Printing Help information"
help
_exit_with_code "0"
## directory in benchmark
;;-t|--test)
# this is handled down stream
if [ "_$2" == "_" ]
then
echo "empty argument for $1"
_exit_with_code "-1"
fi
# concat tests
_TEST_INPUT_LIST+=( "$2" )
shift
;;-d|--output_dir)
if [ "_$2" == "_" ]
then
echo "empty argument for $1"
_exit_with_code "-1"
fi
_RUN_DIR_OVERRIDE=$2
if [ ! -d "${_RUN_DIR_OVERRIDE}" ]
then
echo "Directory ${_RUN_DIR_OVERRIDE} does not exist"
_exit_with_code "-1"
fi
shift
;;-C|--config)
if [ "_$2" == "_" ]
then
echo "empty argument for $1"
_exit_with_code "-1"
fi
_EXTRA_CONFIG=$2
echo "Reading extra config directive from ${_EXTRA_CONFIG}"
shift
## number
;;-j|--nb_of_process)
_NUMBER_OF_PROCESS=$(_flag_is_number "$1" "$2")
echo "Using [$2] processors for this benchmarking suite"
shift
# Boolean flags
;;-g|--generate_bench)
_GENERATE_BENCH="on"
echo "generating output vector for test given predefined input"
;;-o|--generate_output)
_GENERATE_OUTPUT="on"
echo "generating input and output vector for test"
;;-b|--build_config)
_GENERATE_CONFIG="on"
echo "generating a config file for test directory"
;;-c|--clean)
echo "Cleaning temporary run in directory"
cleanup_temp
;;-f|--force_simulate)
_FORCE_SIM="on"
echo "Forcing Simulation"
;;--override)
_OVERRIDE_CONFIG="on"
echo "Forcing override of config"
;;--dry_run)
_DRY_RUN="on"
echo "Performing a dry run"
;;--randomize)
_RANDOM_DRY_RUN="on"
echo "random dry run"
;;--regenerate_expectation)
_REGENERATE_EXPECTATION="on"
echo "regenerating expected values for changes outside the defined ranges"
;;--generate_expectation)
_GENERATE_EXPECTATION="on"
echo "generating new expected values"
;;--no_report)
_REPORT="off"
echo "don't generate the report at the end"
;;--continue)
_CONTINUE="on"
echo "run this test in the same directory as the previous test"
;;--status_only)
_STATUS_ONLY="on"
_CONTINUE="on"
echo "print the previous test report"
;;*)
PARSE_SUBTEST="on"
esac
# keep the subtest in case we caught the end of options and flags
[ ${PARSE_SUBTEST} != "on" ] && shift
fi
done
}
function format_line() {
echo "$@" \
| cut -d '#' -f 1 `# trim the # signs` \
| sed 's/\s+/ /g' `# trim duplicate whitespace` \
| sed 's/\s*$//g' `# trim the tail end whitespace` \
| sed 's/^\s*//g' `# trim the front white space`
}
function warn_is_defined() {
[ "_$1" != "_" ] && echo "Specifying more than one ${2} in config file"
}
_regression_params=""
_script_synthesis_params=""
_script_techmap_params=""
_script_simulation_params=""
_synthesis_parse_file=""
_techmap_parse_file=""
_simulation_parse_file=""
_synthesis_params=""
_techmap_params=""
_simulation_params=""
_circuit_list=()
_arch_list=()
function config_help() {
printf "
*.conf is a list of key=value set
'#' are used for comments
the following key=value, ... are available:
circuits_dir = < path/to/circuit/dir >
circuit_list_add = < circuit file path relative to [circuits_dir] >
archs_dir = < path/to/arch/dir >
arch_list_add = < architecture file path relative to [archs_dir] >
synthesis_parse_file = < path/to/parse/file >
techmap_parse_file = < path/to/parse/file >
simulation_parse_file = < path/to/parse/file >
script_synthesis_params = [see exec_wrapper.sh options]
script_techmap_params = [see exec_wrapper.sh options]
script_simulation_params = [see exec_wrapper.sh options]
synthesis_params = [see Odin options]
techmap_params = [see Odin options]
simulation_params = [see Odin options]
regression_params =
{
--verbose # display error logs after batch of tests
--concat_circuit_list # concatenate the circuit list and pass it straight through to odin
--generate_bench # generate input and output vectors from scratch
--generate_output # generate output vectors only if input vectors already exist
--enable_techmap # enable the technology mapping for this task (only coarsen blif files should pass)
--disable_simulation # disable the simulation for this task
--disable_parallel_jobs # disable running circuit/task pairs in parralel
--include_default_arch # run odin also without architecture file
}
"
}
init_args_for_test() {
_regression_params=""
_script_synthesis_params=""
_script_techmap_params=""
_script_simulation_params=""
_synthesis_parse_file=""
_techmap_parse_file=""
_simulation_parse_file=""
_synthesis_params=""
_techmap_params=""
_simulation_params=""
_circuit_list=()
_arch_list=()
}
function populate_arg_from_file() {
_circuits_dir=""
_archs_dir=""
_circuit_list_add=()
_arch_list_add=()
_local_synthesis_parse_file=""
_local_techmap_parse_file=""
_local_simulation_parse_file=""
_local_script_synthesis_params=""
_local_script_techmap_params=""
_local_script_simulation_params=""
_local_synthesis_params=""
_local_techmap_params=""
_local_simulation_params=""
_local_regression_params=""
if [ "_$1" == "_" ] || [ ! -f "$1" ]
then
echo "Config file $1 does not exist"
else
OLD_IFS=${IFS}
while IFS="" read -r current_line || [ -n "${current_line}" ]
do
formatted_line=$(format_line "${current_line}")
_key="$(echo "${formatted_line}" | cut -d '=' -f1 )"
_value="$(echo "${formatted_line}" | cut -d '=' -f2 )"
if [ "_${_key}" != "_" ] && [ "_${_value}" == "_" ]
then
echo "Specifying empty value for ${_key}, skipping assignment"
elif [ "_${_key}" == "_" ] && [ "_${_value}" != "_" ]
then
echo "Specifying empty key for value: ${_value}, skipping assignment"
elif [ "_${_key}" != "_" ] && [ "_${_value}" != "_" ]
then
case _${_key} in
_circuits_dir)
if [ ! -d "${_value}" ]
then
_value=${THIS_DIR}/${_value}
fi
_circuits_dir="${_value}"
;;_circuit_list_add)
# glob the value
_circuit_list_add+=( "${_circuits_dir}"/${_value} )
;;_archs_dir)
if [ ! -d "${_value}" ]
then
_value=${THIS_DIR}/${_value}
fi
_archs_dir="${_value}"
;;_arch_list_add)
# glob the value
_arch_list_add+=( "${_archs_dir}"/${_value} )
;;_script_synthesis_params)
_local_script_synthesis_params="${_local_script_synthesis_params} ${_value}"
;;_script_techmap_params)
_local_script_techmap_params="${_local_script_techmap_params} ${_value}"
;;_script_simulation_params)
_local_script_simulation_params="${_local_script_simulation_params} ${_value}"
;;_simulation_parse_file)
_local_simulation_parse_file="${_value}"
;;_techmap_parse_file)
_local_techmap_parse_file="${_value}"
;;_synthesis_parse_file)
_local_synthesis_parse_file="${_value}"
;;_synthesis_params)
_local_synthesis_params="${_local_synthesis_params} ${_value}"
;;_techmap_params)
_local_techmap_params="${_local_techmap_params} ${_value}"
;;_simulation_params)
_local_simulation_params="${_local_simulation_params} ${_value}"
;;_regression_params)
_local_regression_params="${_local_regression_params} ${_value}"
;;_)
echo "skip" > /dev/null
;;*)
echo "Unsupported value: ${_key} ${_value}, skipping"
esac
fi
done < "$1"
IFS=${OLD_IFS}
fi
if [ "${_OVERRIDE_CONFIG}" == "on" ];
then
_regression_params="${_local_regression_params}"
_script_simulation_params="${_local_script_simulation_params}"
_script_techmap_params="${_local_script_techmap_params}"
_script_synthesis_params="${_local_script_synthesis_params}"
_synthesis_params="${_local_synthesis_params}"
_techmap_params="${_local_techmap_params}"
_simulation_params="${_local_simulation_params}"
else
_regression_params="${_local_regression_params} ${_regression_params}"
_script_simulation_params="${_local_script_simulation_params} ${_script_simulation_params}"
_script_techmap_params="${_local_script_techmap_params} ${_script_techmap_params}"
_script_synthesis_params="${_local_script_synthesis_params} ${_script_synthesis_params}"
_synthesis_params="${_local_synthesis_params} ${_synthesis_params}"
_techmap_params="${_local_techmap_params} ${_techmap_params}"
_simulation_params="${_local_simulation_params} ${_simulation_params}"
fi
if [ "_${_local_synthesis_parse_file}" != "_" ]
then
if [ ! -f "${_local_synthesis_parse_file}" ]
then
_local_synthesis_parse_file="${THIS_DIR}/${_local_synthesis_parse_file}"
fi
fi
if [ "_${_local_synthesis_parse_file}" != "_" ]
then
if [ ! -f "${_local_synthesis_parse_file}" ]
then
echo "file ${_local_synthesis_parse_file} not found, skipping"
else
_synthesis_parse_file="${_local_synthesis_parse_file}"
fi
fi
if [ "_${_local_techmap_parse_file}" != "_" ]
then
if [ ! -f "${_local_techmap_parse_file}" ]
then
_local_techmap_parse_file="${THIS_DIR}/${_local_techmap_parse_file}"
fi
fi
if [ "_${_local_techmap_parse_file}" != "_" ]
then
if [ ! -f "${_local_techmap_parse_file}" ]
then
echo "file ${_local_techmap_parse_file} not found, skipping"
else
_techmap_parse_file="${_local_techmap_parse_file}"
fi
fi
if [ "_${_local_simulation_parse_file}" != "_" ]
then
if [ ! -f "${_local_simulation_parse_file}" ]
then
_local_simulation_parse_file="${THIS_DIR}/${_local_simulation_parse_file}"
fi
fi
if [ "_${_local_simulation_parse_file}" != "_" ]
then
if [ ! -f "${_local_simulation_parse_file}" ]
then
echo "file ${_local_simulation_parse_file} not found, skipping"
else
_simulation_parse_file="${_local_simulation_parse_file}"
fi
fi
for circuit_list_item in "${_circuit_list_add[@]}"
do
if [ ! -f "${circuit_list_item}" ]
then
echo "file ${circuit_list_item} not found, skipping"
else
_circuit_list+=( "${circuit_list_item}" )
fi
done
if [ "_${#_circuit_list[*]}" == "_" ]
then
echo "Passed a config file with no circuit to test"
_exit_with_code "-1"
fi
for arch_list_item in "${_arch_list_add[@]}"
do
if [ ! -f "${arch_list_item}" ]
then
echo "file ${arch_list_item} not found, skipping"
else
_arch_list+=( "${arch_list_item}" )
fi
done
if [ "_${#_arch_list[*]}" == "_" ]
then
echo "Passed a config file with no architecture, defaulting to no_arch"
_arch_list+=( "no_arch" )
fi
}
function odin_file_type_arg() {
###############################
# return Odin-II arg specified
# by the input file extension
basename=$(basename "$1")
extension=$(echo ${basename##*.} | tr '[:upper:]' '[:lower:]')
case ${extension} in
v|vh)
echo "-v"
;;sv|svh)
echo "-s"
;;blif)
echo "-b"
;;*)
echo "Invalid input file type (${extenstion}), supported file types are { .v .vh .sv .svh .blif }"
_exit_with_code "-1"
esac
}
function header() {
echo " ========= $*"
}
function run_cmd_file_in_parallel() {
hdr="$1"
thread_count="$2"
cmd_list=( "${@:3}" )
if (( ${#cmd_list[@]} > 0 ))
then
header "${hdr}"
#run the simulation in parallel
echo "${cmd_list[@]}" | xargs -n1 | sort | xargs -P"${thread_count}" -I{} "${SHELL}" -c '$(cat {})'
fi
}
function move_vector() {
file_dir="$1"
file_name="$2"
replacement_suffix="$3"
find_in_bench "${file_dir}" "${file_name}"
# move the output vectors
for sim_vectors in "${TMP_BENCH_FIND_ARRAY[@]}"
do
[ -d "${file_dir}/vectors" ] || mkdir -p "${file_dir}/vectors"
BM_DIR=$(dirname "${sim_vectors}")
BM_NAME="$(basename "$(readlink -f "${BM_DIR}/..")")${replacement_suffix}"
cp "${sim_vectors}" "${file_dir}/vectors/${BM_NAME}"
mv "${sim_vectors}" "${BM_DIR}/${BM_NAME}"
done
}
function sim() {
benchmark_dir="$1"
###########################################
# find the benchmark
if [ "_${benchmark_dir}" == "_" ] || [ ! -d "${benchmark_dir}" ]
then
echo "invalid benchmark directory parameter passed: ${benchmark_dir}"
_exit_with_code "-1"
elif [ ! -f "${benchmark_dir}/task.conf" ]
then
echo "invalid benchmark directory parameter passed: ${benchmark_dir}, contains no task.conf file, see CONFIG_HELP in --help"
_exit_with_code "-1"
fi
benchmark_dir=$(readlink -f "${benchmark_dir}")
bench_name=$(basename "${benchmark_dir}")
##########################################
# check if we only run some subtask
run_subtest_only=""
if [ "_${_SUBTEST_LIST[*]}" != "_" ];
then
run_subtest_only="--subset"
fi
echo "Task is: ${bench_name}"
##########################################
# setup the parameters
init_args_for_test
populate_arg_from_file "${benchmark_dir}/task.conf"
##########################################
# use the overrides from the user
if [ "_${_EXTRA_CONFIG}" != "_" ]
then
_EXTRA_CONFIG=$(readlink -f "${_EXTRA_CONFIG}")
if [ ! -f "${_EXTRA_CONFIG}" ]
then
echo "Passed in an invalid global configuration file ${_EXTRA_CONFIG}"
_exit_with_code "-1"
else
populate_arg_from_file "${_EXTRA_CONFIG}"
fi
fi
####################################
# parse the function commands passed
_threads=${_NUMBER_OF_PROCESS}
_generate_bench="${_GENERATE_BENCH}"
_generate_output="${_GENERATE_OUTPUT}"
_concat_circuit_list="off"
_synthesis="on"
_techmap="off"
_simulation="on"
_verbose_failures="off"
_disable_color=""
##########################################
# populate the wrapper command using the configs
for _regression_param in ${_regression_params}
do
case ${_regression_param} in
--concat_circuit_list)
_concat_circuit_list="on"
;;
--generate_bench)
echo "This test will have the input and output regenerated"
_generate_bench="on"
;;
--generate_output)
echo "This test will have the output regenerated"
_generate_output="on"
;;
--enable_techmap)
echo "This test will only be technology mapped"
_techmap="on"
_synthesis="off"
;;
--disable_simulation)
echo "This test will not be simulated"
if [ "_${_FORCE_SIM}" == "_on" ]
then
echo "WARNING: This test will be forcefully simulated, unexpected results may occur"
_simulation="on"
else
_simulation="off"
fi
;;
--no_color)
_disable_color="${_regression_param}"
;;
--verbose)
_verbose_failures="on"
;;
--disable_parallel_jobs)
echo "This test will not be multithreaded"
_threads="1"
;;
--include_default_arch)
_arch_list+=( "no_arch" )
;;
*)
echo "Unknown internal parameter passed: ${_regression_param}, see CONFIG_HELP in --help"
_exit_with_code "-1"
;;
esac
done
##########################################
# setup defaults
# synthesis
synthesis_failure_name="synthesis_failures"
synthesis_parse_result_file_name="synthesis_result.json"
synthesis_params_file_name="synthesis_params"
synthesis_wrapper_file_name="synthesis_wrapper_params"
synthesis_log_file_name="synthesis.log"
synthesis_failure="${NEW_RUN_DIR}/${bench_name}/${synthesis_failure_name}"
synthesis_golden_result_file="${benchmark_dir}/${synthesis_parse_result_file_name}"
synthesis_failure_log_file="${synthesis_failure}.log"
synthesis_result_failure_log_file="${synthesis_failure}_result.log"
# techmap
techmap_pass="true"
techmap_failure_name="techmap_failures"
techmap_parse_result_file_name="techmap_result.json"
techmap_params_file_name="techmap_params"
techmap_wrapper_file_name="techmap_wrapper_params"
techmap_log_file_name="techmap.log"
techmap_failure="${NEW_RUN_DIR}/${bench_name}/${techmap_failure_name}"
techmap_golden_result_file="${benchmark_dir}/${techmap_parse_result_file_name}"
techmap_failure_log_file="${techmap_failure}.log"
techmap_result_failure_log_file="${techmap_failure}_result.log"
# simulation
simulation_failure_name="simulation_failures"
simulation_parse_result_file_name="simulation_result.json"
simulation_params_file_name="simulation_params"
simulation_wrapper_generate_io_file_name="simulation_wrapper_generate_io_params"
simulation_wrapper_generate_output_file_name="simulation_wrapper_generate_output_params"
simulation_wrapper_predefined_io_file_name="simulation_wrapper_predefined_io_params"
simulation_log_file_name="simulation.log"
simulation_failure="${NEW_RUN_DIR}/${bench_name}/${simulation_failure_name}"
simulation_golden_result_file="${benchmark_dir}/${simulation_parse_result_file_name}"
simulation_failure_log_file="${simulation_failure}.log"
simulation_result_failure_log_file="${simulation_failure}_result.log"
circuit_list_temp=""
if [ ${_concat_circuit_list} == "on" ]
then
circuit_list_temp="${_circuit_list[*]}"
_circuit_list=( "${bench_name}" )
fi
for circuit in "${_circuit_list[@]}"
do
circuits_dir=$(dirname "${circuit}")
circuit_file=$(basename "${circuit}")
input_file=""
generated_blif_file=""
case "${circuit_file}" in
*.blif)
# disable synthesis for blif files
_synthesis="off"
case "${circuit_file}" in
# disable techmap for generated blif files
*_generated.blif)
techmap_pass="false"
;;
*)
input_file="${circuit}"
techmap_pass="true"
;;
esac
;;
*)
_synthesis="on"
if [ ${_concat_circuit_list} == "on" ]
then
input_file="${circuit_list_temp}"
else
input_file="${circuit}"
fi
;;
esac
circuit_name="${circuit_file%.*}"
# lookup for input and output vector files to do comparison
input_vector_file="${circuits_dir}/${circuit_name}_odin_input"
output_vector_file="${circuits_dir}/${circuit_name}_odin_output"
for arches in "${_arch_list[@]}"
do
arch_cmd=""
if [ -e "${arches}" ]
then
arch_cmd="-a ${arches}"
fi
arch_name=$(basename "${arches%.*}")
TEST_FULL_REF="${bench_name}/${circuit_name}/${arch_name}"
run_this_test="on"
if [ "_${_SUBTEST_LIST[*]}" != "_" ]
then
run_this_test="off"
for subtest in "${_SUBTEST_LIST[@]}";
do
if echo "_${TEST_FULL_REF}" | grep -E "${subtest}" &> /dev/null
then
run_this_test="on"
break;
fi
done
fi
if [ -d "${NEW_RUN_DIR}/${TEST_FULL_REF}" ]
then
# skip duplicate tests
run_this_test="off"
fi
if [ "${run_this_test}" == "on" ];