Files
TheRock/rocm-systems/projects/rocprofiler-sdk/external/ptl/.scripts/gperf_cpu_profile.sh
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

73 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
set -o errexit
: ${N:=0}
: ${CPUPROFILE:=""}
: ${CPUPROFBASE:=gperf.cpu.prof}
: ${PPROF_ARGS:=""}
: ${MALLOCSTATS:=1}
: ${CPUPROFILE_FREQUENCY:=250}
: ${INTERACTIVE:=0}
while [ -z "${CPUPROFILE}" ]
do
TEST_FILE=${CPUPROFBASE}.${N}
if [ ! -f "${TEST_FILE}" ]; then
CPUPROFILE=${TEST_FILE}
fi
N=$((${N}+1))
done
export CPUPROFILE
export MALLOCSTATS
export CPUPROFILE_FREQUENCY
echo -e "\n\t--> Outputting profile to '${CPUPROFILE}'...\n"
# remove profile file if unsucessful execution
cleanup-failure() { set +v ; rm -f ${CPUPROFILE}; }
trap cleanup-failure SIGHUP SIGINT SIGQUIT SIGILL SIGABRT SIGKILL
# configure pre-loading of profiler library
LIBS=$(find $PWD | grep libptl | egrep -v '\.a$|\.dSYM')
LIBS=$(echo ${LIBS} | sed 's/ /:/g')
if [ "$(uname)" = "Darwin" ]; then
for i in $(otool -L ${1} | egrep 'profiler' | awk '{print $1}')
do
LIBS=${LIBS}:${i}
done
LIBS=$(echo ${LIBS} | sed 's/^://g')
if [ -n "${LIBS}" ]; then
export DYLD_FORCE_FLAT_NAMESPACE=1
export DYLD_INSERT_LIBRARIES=${LIBS}
echo "DYLD_INSERT_LIBRARIES=${DYLD_INSERT_LIBRARIES}"
fi
else
for i in $(ldd ${1} | egrep 'profiler' | awk '{print $(NF-1)}')
do
LIBS=${LIBS}:${i}
done
LIBS=$(echo ${LIBS} | sed 's/^://g')
if [ -n "${LIB}" ]; then
export LD_PRELOAD=${LIBS}
echo "LD_PRELOAD=${LD_PRELOAD}"
fi
fi
# run the application
eval $@ | tee ${CPU_PROFILE}.log
# generate the results
EXT=so
if [ "$(uname)" = "Darwin" ]; then EXT=dylib; fi
if [ -f "${CPUPROFILE}" ]; then
: ${PPROF:=$(which pprof)}
if [ -n "${PPROF}" ]; then
pprof --text --add_lib=libptl.${EXT} ${PPROF_ARGS} ${1} ${CPUPROFILE} | egrep -v ' 0x[0-9]' &> ${CPUPROFILE}.txt
pprof --text --cum --add_lib=libptl.${EXT} ${PPROF_ARGS} ${1} ${CPUPROFILE} | egrep -v ' 0x[0-9]' &> ${CPUPROFILE}.cum.txt
if [ "${INTERACTIVE}" -gt 0 ]; then
pprof --add_lib=libptl.${EXT} ${PPROF_ARGS} ${1} ${CPUPROFILE}
fi
fi
fi