Skip to content

Commit

Permalink
Updating fud2 to support new flame graph rig
Browse files Browse the repository at this point in the history
  • Loading branch information
ayakayorihiro committed Dec 4, 2024
1 parent fa5a7b5 commit e4bdc2a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fud2/scripts/profiler.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
25 changes: 25 additions & 0 deletions tools/profiler/convert-all-flames.sh
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit e4bdc2a

Please sign in to comment.