diff --git a/fud2/scripts/profiler.rhai b/fud2/scripts/profiler.rhai index c1a953ba2..41e1a6602 100644 --- a/fud2/scripts/profiler.rhai +++ b/fud2/scripts/profiler.rhai @@ -26,7 +26,8 @@ fn profiling_setup(e) { e.rule("parse-vcd", "python3 $parse-vcd-script $in $cells dot-out $out flame-out"); e.config_var("flamegraph-script", "flamegraph.script"); - e.rule("produce-flame-graph", "$flamegraph-script $in > $out"); + e.var_("flamegraph-utility-script", "$calyx-base/tools/profiler/convert-all-flames.sh"); + e.rule("produce-flame-graph", "bash $flamegraph-utility-script $flamegraph-script flame-out $in $out"); // Standalone Verilog testbench. copied from testbench e.rsrc("tb.sv"); diff --git a/tools/profiler/convert-all-flames.sh b/tools/profiler/convert-all-flames.sh new file mode 100644 index 000000000..478d18215 --- /dev/null +++ b/tools/profiler/convert-all-flames.sh @@ -0,0 +1,25 @@ +# Utility script for fud2 to produce flame graphs from produced .folded files + +if [ $# -lt 4 ]; then + echo "USAGE: bash $0 FLAME_GRAPH_SCRIPT FOLDED_DIR REPR_IN" + exit +fi + +SCRIPT_DIR=$( cd $( dirname $0 ) && pwd ) + +FLAME_GRAPH_SCRIPT=$1 +FOLDED_DIR=$2 +REPR_IN=$3 +REPR_OUT=$4 + +for folded in $( ls ${FOLDED_DIR}/*.folded ); do + base_name=$( echo "${folded}" | rev | cut -d. -f2- | rev ) + if [[ "${base_name}" == *"scaled"* ]]; then + ${FLAME_GRAPH_SCRIPT} --countname="cycles" ${folded} > ${base_name}-original.svg + python3 ${SCRIPT_DIR}/finagle-with-svg.py ${base_name}-original.svg > ${base_name}.svg + else + ${FLAME_GRAPH_SCRIPT} --countname="cycles" ${folded} > ${base_name}.svg + fi +done + +${FLAME_GRAPH_SCRIPT} ${REPR_IN} > ${REPR_OUT}