Skip to content

Commit 48bc65e

Browse files
committed
add valgrind test, reformat stdout, and colorize output
1 parent 79a7855 commit 48bc65e

File tree

13 files changed

+607
-136
lines changed

13 files changed

+607
-136
lines changed

ODIN_II/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ cppcheck:
9494
cppcheck . 1> /dev/null
9595

9696
test:
97-
./verify_odin.sh --test pre_commit --nb_of_process $(NB_OF_PROCESS) --limit_ressource
97+
./verify_odin.sh --test pre_commit --nb_of_process $(NB_OF_PROCESS) --limit_ressource --colorize
9898

9999
large_test:
100-
./verify_odin.sh --test pre_merge --nb_of_process $(NB_OF_PROCESS) --limit_ressource
100+
./verify_odin.sh --test pre_merge --nb_of_process $(NB_OF_PROCESS) --limit_ressource --colorize

ODIN_II/log.txt

Lines changed: 384 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--simulate
1+
--arch_list small_sweep
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--no_threading --simulate
1+
--no_threading
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--arch_list small_sweep --simulate
1+
--arch_list full_sweep
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
--arch_list memories --no_threading --simulate
1+
--arch_list memories
2+
--no_threading
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
--arch_list memories --no_threading
1+
--arch_list memories
2+
--no_threading
3+
--disable_simulation
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--arch_list small_sweep --simulate
1+
--arch_list small_sweep
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--arch_list small_sweep --simulate
1+
--arch_list small_sweep
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--simulate
1+
--arch_list small_sweep
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--arch_list small_sweep
2+
--disable_simulation
3+
--source ../operators
4+
--valgrind

ODIN_II/verify_odin.sh

Lines changed: 89 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ NEW_RUN_DIR="${REGRESSION_DIR}/run001/"
2626
##############################################
2727
# Arch Sweep Arrays to use during benchmarking
2828
DEFAULT_ARCH="${VTR_ROOT_DIR}/libs/libarchfpga/arch/sample_arch.xml"
29-
MEM_ARCH="${VTR_ROOT_DIR}/vtr_flow/arch/timing/k6_N10_mem32K_40nm.xml"
30-
SMALL_ARCH_SWEEP="${DEFAULT_ARCH} ${MEM_ARCH}"
31-
FULL_ARCH_SWEEP=$(find ${VTR_ROOT_DIR}/vtr_flow/arch/timing -maxdepth 1 | grep xml)
29+
MEM_ARCH="${VTR_ROOT_DIR}/vtr_flow/arch/timing/k6_frac_N10_frac_chain_mem32K_40nm.xml"
30+
SMALL_ARCH_SWEEP="no_arch ${DEFAULT_ARCH} ${MEM_ARCH}"
31+
FULL_ARCH_SWEEP=$(find ${VTR_ROOT_DIR}/vtr_flow/arch/timing -maxdepth 1 | grep xml | grep mem)
3232

3333
##############################################
3434
# Include more generic names here for better vector generation
@@ -42,7 +42,7 @@ _TEST=""
4242
_NUMBER_OF_PROCESS="1"
4343
_SIM_THREADS="1"
4444
_VECTORS="100"
45-
_TIMEOUT="1200"
45+
_TIMEOUT="1200s"
4646
_ADDER_DEF="default"
4747
_SIM_COUNT="1"
4848
_RUN_DIR_OVERRIDE=""
@@ -55,6 +55,7 @@ _BEST_COVERAGE_OFF="on"
5555
_BATCH_SIM="off"
5656
_USE_PERF="off"
5757
_FORCE_SIM="off"
58+
_COLORIZE="off"
5859

5960
##############################################
6061
# Exit Functions
@@ -117,7 +118,7 @@ printf "Called program with $INPUT
117118
-j|--nb_of_process < N > $(_prt_cur_arg ${_NUMBER_OF_PROCESS}) Number of process requested to be used
118119
-s|--sim_threads < N > $(_prt_cur_arg ${_SIM_THREADS}) Use multithreaded simulation using N threads
119120
-V|--vectors < N > $(_prt_cur_arg ${_VECTORS}) Use N vectors to generate per simulation
120-
-T|--timeout < N sec > $(_prt_cur_arg ${_TIMEOUT}) Timeout a simulation/synthesis after N seconds
121+
-T|--timeout < N[s|m|h] > $(_prt_cur_arg ${_TIMEOUT}) Timeout a simulation/synthesis after N seconds
121122
-a|--adder_def < /abs/path > $(_prt_cur_arg ${_ADDER_DEF}) Use template to build adders
122123
-n|--simulation_count < N > $(_prt_cur_arg ${_SIM_COUNT}) Allow to run the simulation N times to benchmark the simulator
123124
-d|--output_dir < /abs/path > $(_prt_cur_arg ${_RUN_DIR_OVERRIDE}) Change the run directory output
@@ -132,6 +133,7 @@ printf "Called program with $INPUT
132133
-b|--batch_sim $(_prt_cur_arg ${_BATCH_SIM}) Use Batch mode multithreaded simulation
133134
-p|--perf $(_prt_cur_arg ${_USE_PERF}) Use Perf for monitoring execution
134135
-f|--force_simulate $(_prt_cur_arg ${_FORCE_SIM}) Force the simulation to be executed regardless of the config
136+
-C|--colorize $(_prt_cur_arg ${_COLORIZE}) Turn on pretty print for stdout
135137
136138
"
137139
}
@@ -145,8 +147,9 @@ printf "
145147
*small_sweep use a small set of timing architecture
146148
*full_sweep sweep the whole vtr directory *** WILL FAIL ***
147149
*default use the sample_arch.xml
148-
--simulate request simulation to be ran
150+
--disable_simulation request simulation NOT to be ran
149151
--no_threading do not use multithreading for this test ** useful if you have large test **
152+
--source [relative_path] change where the benchmark files are, (relative to this config file) <default: ./>
150153
"
151154
}
152155

@@ -287,38 +290,16 @@ function flag_is_number() {
287290
esac
288291
}
289292

290-
291-
# boolean type flags
292-
_low_ressource_flag=""
293-
_valgrind_flag=""
294-
_batch_sim_flag=""
295-
_use_best_coverage_flag=""
296-
_perf_flag=""
297-
298-
# number type flags
299-
_vector_flag=""
300-
_timeout_flag=""
301-
_simulation_threads_flag=""
302-
303-
_adder_definition_flag=""
304-
305293
function _set_if() {
306294
[ "$1" == "on" ] && echo "$2" || echo ""
307295
}
308296

309-
function _set_flag() {
310-
_low_ressource_flag=$(_set_if ${_LIMIT_RESSOURCE} "--limit_ressource")
311-
_valgrind_flag=$(_set_if ${_VALGRIND} "--tool valgrind")
312-
_batch_sim_flag=$(_set_if ${_BATCH_SIM} "--batch")
313-
_use_best_coverage_flag=$(_set_if ${_BEST_COVERAGE_OFF} "--best_coverage")
314-
_perf_flag=$(_set_if ${_USE_PERF} "--tool perf")
315-
316-
_vector_flag="-g ${_VECTORS}"
317-
_timeout_flag="--time_limit ${_TIMEOUT}s"
318-
_simulation_threads_flag=$([ "${_SIM_THREADS}" != "1" ] && echo "-j ${_SIM_THREADS}")
319-
320-
_adder_definition_flag="--adder_type ${_ADDER_DEF}"
297+
function _echo_args() {
298+
echo $@ | tr '\n' ' ' | tr -s ' '
299+
}
321300

301+
function _cat_args() {
302+
_echo_args "$(cat $1)"
322303
}
323304

324305
function parse_args() {
@@ -409,6 +390,10 @@ function parse_args() {
409390
shift
410391

411392
# Boolean flags
393+
;;-C|--colorize)
394+
_COLORIZE="on"
395+
echo "colorizing the output"
396+
412397
;;-g|--generate_bench)
413398
_GENERATE_BENCH="on"
414399
echo "generating output vector for test given predefined input"
@@ -463,10 +448,30 @@ function sim() {
463448
arch_list="no_arch"
464449
with_sim="0"
465450
threads=${_NUMBER_OF_PROCESS}
466-
DEFAULT_CMD_PARAM="${_adder_definition_flag} ${_simulation_threads_flag} ${_batch_sim_flag}"
451+
test_src="./"
452+
453+
# default flags
454+
_low_ressource_flag="--limit_ressource"
455+
_valgrind_flag="--tool valgrind"
456+
_batch_sim_flag="--batch"
457+
_best_coverage_flag="--best_coverage"
458+
_perf_flag="--tool perf"
459+
_colorize_flag="--colorize"
460+
461+
use_timeout="--time_limit ${_TIMEOUT}"
462+
use_valgrind=$(_set_if ${_VALGRIND} ${_valgrind_flag})
463+
use_low_ressource=$(_set_if ${_LIMIT_RESSOURCE} ${_low_ressource_flag})
464+
use_batch_sim=$(_set_if ${_BATCH_SIM} ${_batch_sim_flag})
465+
use_best_coverage=$(_set_if ${_BEST_COVERAGE_OFF} ${_best_coverage_flag})
466+
use_perf=$(_set_if ${_USE_PERF} ${_perf_flag})
467+
use_color=$(_set_if ${_COLORIZE} ${_colorize_flag})
468+
469+
_vector_flag="-g ${_VECTORS}"
470+
_simulation_threads_flag=$([ "${_SIM_THREADS}" != "1" ] && echo "-j ${_SIM_THREADS}")
471+
_adder_definition_flag="--adder_type ${_ADDER_DEF}"
467472

468473
_SYNTHESIS="on"
469-
_SIMULATE=${_FORCE_SIM}
474+
_SIMULATE="on"
470475

471476
if [ ! -d "$1" ]
472477
then
@@ -479,6 +484,11 @@ function sim() {
479484
while [[ "$#" > 0 ]]
480485
do
481486
case $1 in
487+
--source)
488+
test_src=$2
489+
shift
490+
;;
491+
482492
--custom_args_file)
483493
with_custom_args=1
484494
;;
@@ -506,15 +516,20 @@ function sim() {
506516
shift
507517
;;
508518

509-
--simulate)
510-
_SIMULATE="on"
519+
--disable_simulation)
520+
_SIMULATE=${_FORCE_SIM}
511521
;;
512522

513523
--no_threading)
514524
echo "This test will not be multithreaded"
515525
threads="1"
516526
;;
517527

528+
--valgrind)
529+
echo "This test will be ran with valgrind"
530+
use_valgrind=${_valgrind_flag}
531+
;;
532+
518533
*)
519534
echo "Unknown internal parameter passed: $1"
520535
config_help
@@ -526,9 +541,23 @@ function sim() {
526541

527542
###########################################
528543
# run custom benchmark
529-
bench_type=${benchmark_dir##*/}
544+
real_bench="${benchmark_dir}"
545+
benchmark_dir="${benchmark_dir}/${test_src}"
546+
if [ "_${benchmark_dir}" == "_" ] || [ ! -d ${benchmark_dir} ]; then
547+
echo "invalid benchmark directory parameter passed: ${benchmark_dir} from ${test_src}"
548+
ctrl_c
549+
fi
550+
551+
benchmark_dir=$(readlink -f "${benchmark_dir}")
552+
bench_type=${real_bench##*/}
530553
echo " BENCHMARK IS: ${bench_type}"
531554

555+
556+
##########################################
557+
# setup defaults
558+
DEFAULT_CMD_PARAM="${_adder_definition_flag} ${_simulation_threads_flag} ${_batch_sim_flag}"
559+
DEFAULT_WRAPPER_CMD="${use_timeout} ${use_low_ressource} ${use_valgrind} ${use_perf} ${use_color}"
560+
532561
if [ "_${with_custom_args}" == "_1" ]
533562
then
534563

@@ -550,21 +579,14 @@ function sim() {
550579
--log_file ${DIR}/odin.log
551580
--test_name ${TEST_FULL_REF}
552581
--failure_log ${global_odin_failure}.log
553-
${_timeout_flag}
554-
${_low_ressource_flag}
555-
${_valgrind_flag}"
556-
557-
if [ "${_USE_PERF}" == "on" ]
558-
then
559-
wrapper_odin_command="${wrapper_odin_command} ${_perf_flag} ${DIR}/perf.data"
560-
fi
582+
${DEFAULT_WRAPPER_CMD}"
561583

562584
odin_command="${DEFAULT_CMD_PARAM}
563-
$(cat ${dir}/odin.args | tr '\n' ' ')
585+
$( _cat_args "${dir}/odin.args" )
564586
-o ${blif_file}
565587
-sim_dir ${DIR}"
566588

567-
echo $(echo "${wrapper_odin_command} ${odin_command}" | tr '\n' ' ' | tr -s ' ' ) > ${DIR}/odin_param
589+
_echo_args "${wrapper_odin_command} ${odin_command}" > ${DIR}/odin_param
568590
fi
569591
done
570592

@@ -587,12 +609,9 @@ function sim() {
587609
basename=""
588610
case "${benchmark}" in
589611
*.v)
590-
_SYNTHESIS="on"
591612
basename=${benchmark%.v}
592613
;;
593614
*.blif)
594-
# this is a blif file
595-
_SYNTHESIS="off"
596615
basename=${benchmark%.blif}
597616
;;
598617
*)
@@ -620,7 +639,19 @@ function sim() {
620639
TEST_FULL_REF="${bench_type}/${test_name}/${arch_name}"
621640

622641
DIR="${NEW_RUN_DIR}/${TEST_FULL_REF}"
623-
blif_file="${DIR}/odin.blif"
642+
blif_file=""
643+
644+
case "${benchmark}" in
645+
*.v)
646+
_SYNTHESIS="on"
647+
blif_file="${DIR}/odin.blif"
648+
;;
649+
*.blif)
650+
# this is a blif file
651+
_SYNTHESIS="off"
652+
blif_file=${benchmark}
653+
;;
654+
esac
624655

625656

626657
#build commands
@@ -634,22 +665,15 @@ function sim() {
634665
--log_file ${DIR}/synthesis.log
635666
--test_name ${TEST_FULL_REF}
636667
--failure_log ${global_synthesis_failure}.log
637-
${_timeout_flag}
638-
${_low_ressource_flag}
639-
${_valgrind_flag}"
640-
641-
if [ "${_USE_PERF}" == "on" ]
642-
then
643-
wrapper_synthesis_command="${wrapper_synthesis_command} ${_perf_flag} ${DIR}/perf.data"
644-
fi
668+
${DEFAULT_WRAPPER_CMD}"
645669

646670
synthesis_command="${DEFAULT_CMD_PARAM}
647671
${arch_cmd}
648672
-V ${benchmark}
649673
-o ${blif_file}
650674
-sim_dir ${DIR}"
651675

652-
echo $(echo "${wrapper_synthesis_command} ${synthesis_command}" | tr '\n' ' ' | tr -s ' ') > ${DIR}/cmd_param
676+
_echo_args "${wrapper_synthesis_command} ${synthesis_command}" > ${DIR}/cmd_param
653677
fi
654678

655679
if [ "${_SIMULATE}" == "on" ]
@@ -658,14 +682,7 @@ function sim() {
658682
--log_file ${DIR}/simulation.log
659683
--test_name ${TEST_FULL_REF}
660684
--failure_log ${global_simulation_failure}.log
661-
${_timeout_flag}
662-
${_low_ressource_flag}
663-
${_valgrind_flag}"
664-
665-
if [ "${_USE_PERF}" == "on" ]
666-
then
667-
wrapper_simulation_command="${wrapper_simulation_command} ${_perf_flag} ${DIR}/perf.data"
668-
fi
685+
${DEFAULT_WRAPPER_CMD}"
669686

670687
simulation_command="${DEFAULT_CMD_PARAM}
671688
${arch_cmd}
@@ -675,7 +692,7 @@ function sim() {
675692

676693
if [ "${_GENERATE_BENCH}" == "on" ] || [ ! -f ${input_vector_file} ]
677694
then
678-
simulation_command="${simulation_command} ${_use_best_coverage_flag} ${_vector_flag}"
695+
simulation_command="${simulation_command} ${use_best_coverage} ${_vector_flag}"
679696
else
680697
simulation_command="${simulation_command} -t ${input_vector_file}"
681698
if [ "${_GENERATE_OUTPUT}" == "off" ] && [ -f ${output_vector_file} ]
@@ -684,7 +701,7 @@ function sim() {
684701
fi
685702
fi
686703

687-
echo $(echo "${wrapper_simulation_command} ${simulation_command}" | tr '\n' ' ' | tr -s ' ') > ${DIR}/sim_param
704+
_echo_args "${wrapper_simulation_command} ${simulation_command}" > ${DIR}/sim_param
688705
fi
689706

690707
done
@@ -872,7 +889,7 @@ function run_sim_on_directory() {
872889
config_help
873890
else
874891
create_temp
875-
sim ${BENCHMARK_DIR}/${test_dir} $(cat ${BENCHMARK_DIR}/${test_dir}/config.txt)
892+
sim "${BENCHMARK_DIR}/${test_dir}" $(_cat_args "${BENCHMARK_DIR}/${test_dir}/config.txt")
876893
fi
877894
}
878895

@@ -907,7 +924,6 @@ START=`get_current_time`
907924
init_temp
908925

909926
parse_args $INPUT
910-
_set_flag
911927

912928
if [ "_${_TEST}" == "_" ]
913929
then

0 commit comments

Comments
 (0)