Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions scripts/convert_pftrace_to_json.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
OUTPUT_JSON_PATH=""
INPUT_PFTRACE_PATH=""
TRACECONV=""

log() {
local message="$1"
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
echo "[${timestamp}] ${message}" 2>&1
}

usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -f, --pftrace PFTRACE_PATH Path to the merged pftrace file to convert to JSON"
echo " -o, --output OUTPUT_PATH Path to the output JSON file"
echo " -h, --help Print this help message and exit"
exit 1
}

for arg in "$@"; do
shift
case "$arg" in
--pftrace) set -- "$@" "-f" ;;
--output) set -- "$@" "-o" ;;
--help) set -- "$@" "-h" ;;
*) set -- "$@" "$arg";;
esac
done

download_traceconv() {
log "Downloading traceconv binary..."
curl -LO https://get.perfetto.dev/traceconv
chmod u+x ./traceconv
TRACECONV=$(realpath ./traceconv)
log "traceconv saved to $TRACECONV"
}

while getopts "f:o:h-:" opt; do
case $opt in
f)
INPUT_PFTRACE_PATH="$OPTARG"
;;
o)
OUTPUT_JSON_PATH="$OPTARG"
;;
h)
usage
;;
-)
echo "Invalid option: --$OPTARG" >&2
usage
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
;;
esac
done

assert_input_file_present() {
if [ -z "$INPUT_PFTRACE_PATH" ]; then
log "Empty pftrace path. Exiting"
exit 1
fi
if [ ! -f "$INPUT_PFTRACE_PATH" ]; then
log "Invalid pftrace filepath. Exiting"
exit 1
fi
}

main() {
assert_input_file_present
download_traceconv
log "Generating JSON from $INPUT_PFTRACE_PATH..."
"$TRACECONV" json "$INPUT_PFTRACE_PATH" "$OUTPUT_JSON_PATH"
log "Generated JSON. Saved to $OUTPUT_JSON_PATH."
}

main
2 changes: 1 addition & 1 deletion scripts/rocprof_capture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fi

export PYTHONPATH="${REPO_ROOT}/src:${PYTHONPATH:-}"

rocprofv3 "${ROC_PROF_ARGS[@]}" -d "${RUN_DIR}" -- \
rocprofv3 "${ROC_PROF_ARGS[@]}" -d "${RUN_DIR}" --output-format pftrace -- \
torchrun \
--standalone \
--nproc_per_node "${GPU_COUNT}" \
Expand Down