1f4cf1aa39
* Srnagara/tool counters collect (#331) * Adding counter collection capability to tools * Adding counter collection feature to tools * Adding counter collection capability to tools * Fixing merge down issues * Small tool fixes for build + prevent profile realloc * Reproducing the counter name query issue in buffered callback * Minor fix for init order + sample that directly uses sdk-tool for debug purposes * Adding a temporary fix to print the counter names * Fixing the output file name and reverting the changes of caching the profile config * Fixing SGPR_Count value * cleaning up debug prints * Adding header to counter collection file * Adding kernel filtering support * Remove threading * Cleaning up the code * Removing redundant prints * Revert "Remove threading" This reverts commit 05c58fb9de826e92cf8d2e3d1c31d5578525dcb4. * Revert "Cleaning up the code" This reverts commit 1d964882bf2396dee8ad020cbb6c83b36e0674e9. * Changing the tools code to align with init-order fix * cmake formatting (cmake-format) (#335) Co-authored-by: SrirakshaNag <SrirakshaNag@users.noreply.github.com> * source formatting (clang-format v11) (#336) Co-authored-by: SrirakshaNag <SrirakshaNag@users.noreply.github.com> * Adding support for async memory copy * source formatting (clang-format v11) (#391) Co-authored-by: SrirakshaNag <SrirakshaNag@users.noreply.github.com> * Fixing header typo * Fixing tool_fini * Replaceing the direction and kind fields values with description * Update lib/rocprofiler-sdk-tool/helper.cpp - Remove use of VLA * Update lib/rocprofiler-sdk-tool/tool.cpp - Formatting * Migrate common/config.* to rocprofiler-sdk-tool * Update lib/rocprofiler-sdk-tool/tool.cpp - fix clang-tidy issues * source formatting (clang-format v11) (#392) Co-authored-by: jrmadsen <jrmadsen@users.noreply.github.com> * Update lib/common/mpl.hpp - is_string_type / is_string_type_impl for deducing if type is a string type * Update include/rocprofiler-sdk/fwd.h - ROCPROFILER_BUFFER_TRACING_MEMORY_COPY_NONE starts at zero * Update lib/rocprofiler-sdk/hsa/async_copy.* - functions for operation ids and names * Update lib/rocprofiler-sdk/buffer_tracing.cpp - support iterating and getting names for ROCPROFILER_BUFFER_TRACING_MEMORY_COPY * Update lib/rocprofiler-sdk-tool/config.* - env ROCPROFILER_ prefix -> ROCPROF_ prefix - add support for memory copy tracing, counter collection, etc. * Update lib/rocprofiler-sdk-tool/helper.* - removed TracerFlushRecord - removed cxa_demangle (use one in common library) - removed GetCounterNames (handled in config) - removed GetKernelNames (handled in config) * Add lib/rocprofiler-sdk-tool/output_file.* - separate out get_output_stream function and output_file struct from tool.cpp * Add lib/rocprofiler-sdk-tool/csv.hpp - write_csv_entry automatically quotes strings - csv_encoder struct enforces correct number of columns * Update lib/rocprofiler-sdk-tool/CMakeLists.txt - add new files * Update lib/rocprofiler-sdk-tool/tool.cpp - update construction of output_file class - add kernel_symbol_data for serializing kernel trace data - use config instead of env lookups - optimize counter collection profile config lookup/creation * Update bin/rocprofv3 - rocprofv3 --help exits with 0 (as it should) - command-line arg for memory copy tracing - command-line arg for mangled kernels - command-line arg for truncated kernels - env ROCPROFILER_ prefix -> env ROCPROF_ prefix * Update tests/async-copy-tracing/validate.py - update test_async_copy_direction to new enum values * Update tests/kernel-tracing/validate.py - update test_async_copy_direction to new enum values * Update tests/tools/json-tool.cpp - add ROCPROFILER_BUFFER_TRACING_MEMORY_COPY to supported buffer_name_info * Update samples/counter_collection/{CMakeLists.txt,main.cpp} - remove counter-collection-sdk-tool * Update .github/workflows/docs.yml - fix paths triggering running the workflow --------- Co-authored-by: Benjamin Welton <bewelton@amd.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: SrirakshaNag <SrirakshaNag@users.noreply.github.com> Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com> Co-authored-by: jrmadsen <jrmadsen@users.noreply.github.com> * adding counter collection support * Adding counter collection test * changing directory structure of counter collection tests * Fixing test path for rocprofv3 * Adding hsa-tracing basic test * cmake formatting (cmake-format) (#362) Co-authored-by: bgopesh <bgopesh@users.noreply.github.com> * counter collection tests drop2 * fixing hsa-trace test for rocprofv3 path * python formatting (black) (#371) Co-authored-by: bgopesh <bgopesh@users.noreply.github.com> * both counter colleciton and tracing should work together * Fixing rocprofv3 path * Attempt to fix Segfault with AddressSanitizer * fixing sanitizer segfault * Update rocprofv3 * Update lib/rocprofiler-sdk-tool/README.md - update env variables * Update lib/rocprofiler-sdk/buffer_tracing.cpp - return ROCPROFILER_STATUS_BUFFER_NOT_FOUND if buffer tracing service is configured with invalid buffer * Update lib/rocprofiler-sdk-tool/tool.cpp - designated hsa API trace buffer * Update tests/hsa-tracing/CMakeLists.txt - Fix environment * Update rocprofv3 - do not override HSA_TOOLS_LIB - support ROCPROF_PRELOAD - LD_PRELOAD librocprofiler-sdk.so * Restructure tests directory - move all rocprofv3 integration tests into subfolder * Update cmake/Templates/rocprofiler-sdk/config.cmake.in - create rocprofiler-sdk::rocprofv3 cmake target * Update tests/rocprofv3/hsa-tracing - improve validate.py - convert input to dict via csv.DictReader * Update tests/apps/CMakeLists.txt - fix build rpath for simple-transpose * Update cmake/rocprofiler_memcheck.cmake - prefer libtsan.so.0 * Update tests/rocprofv3/hsa-tracing - move to tests/rocprofv3/tracing - include kernel tracing and memory copy tracing * Update lib/rocprofiler-sdk-tool/tool.cpp - normalize "_ID" vs. "_Id" in CSV column names (use "_Id") * Update lib/rocprofiler-sdk/buffer.{hpp,cpp} - change signature of buffer::get_buffers() - buffer::get_buffers() uses static_object * Update lib/rocprofiler-sdk/context/context.cpp - update usage of buffer::get_buffers() - now returns pointer * Update lib/rocprofiler-sdk/tests/buffer.cpp - update to change for signature of buffer::get_buffers() * Update tests/rocprofv3/tracing/CMakeLists.txt - use %argt% with -d argument * Update lib/rocprofiler-sdk-tool/tool.cpp - use atexit for finalization * Update tests/rocprofv3/tracing/CMakeLists.txt - tweaked name of tests * Update lib/rocprofiler-sdk/hsa/async_copy.* - async_copy_fini + reference counting signals * Update lib/rocprofiler-sdk/registration.cpp - invoke hsa::async_copy_fini() to prevent data race on signals --------- Co-authored-by: SrirakshaNag <104580803+SrirakshaNag@users.noreply.github.com> Co-authored-by: Benjamin Welton <bewelton@amd.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: SrirakshaNag <SrirakshaNag@users.noreply.github.com> Co-authored-by: gobhardw <gopesh.bhardwaj@amd.com> Co-authored-by: bgopesh <bgopesh@users.noreply.github.com>
145 라인
4.6 KiB
Bash
실행 파일
145 라인
4.6 KiB
Bash
실행 파일
#!/bin/bash -e
|
|
|
|
set -eo pipefail
|
|
|
|
ROCPROFV3_DIR=$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")
|
|
ROCM_DIR=$(dirname -- "${ROCPROFV3_DIR}")
|
|
|
|
: ${HSA_TOOLS_LIB:="${ROCM_DIR}/lib/librocprofiler-sdk.so"}
|
|
|
|
export HSA_TOOLS_LIB
|
|
|
|
# Define color codes
|
|
GREEN='\033[0;32m'
|
|
GREY='\033[0;90m'
|
|
RESET='\033[0m'
|
|
|
|
usage() {
|
|
local EC=${1}
|
|
if [ -z "${EC}" ]; then EC=1; fi
|
|
echo -e "${RESET}ROCProfilerV3 Run Script Usage:"
|
|
echo -e "${GREEN}-h | --help ${RESET} For showing this message"
|
|
echo -e "${GREEN}-i | --input ${RESET} For adding counters file path (every line in the text file represents a counter)"
|
|
echo -e "${GREEN}--hsa-trace ${RESET} For Collecting HSA API Traces"
|
|
echo -e "${GREEN}--kernel-trace ${RESET} For Collecting Kernel Dispatch Traces"
|
|
echo -e "${GREEN}--memory-copy-trace ${RESET} For Collecting Memory Copy Traces"
|
|
echo -e "${GREEN}-o | --output-file ${RESET} For the output file name"
|
|
echo -e "\t#${GREY} usage e.g:(with current dir): rocprofv3 --hsa-trace -o <file_name> <executable>"
|
|
echo -e "\t#${GREY} usage e.g:(with custom dir): rocprofv3 --hsa-trace -d <out_dir> -o <file_name> <executable>${RESET}\n"
|
|
echo -e "${GREEN}-d | --output-directory ${RESET} For adding output path where the output files will be saved"
|
|
echo -e "\t#${GREY} usage e.g:(with custom dir): rocprofv3 --hsa-trace -d <out_dir> <executable>${RESET}"
|
|
echo -e "${GREEN}-M | --mangled-kernels ${RESET} Do not demangle the kernel names"
|
|
echo -e "${GREEN}-T | --truncate-kernels ${RESET} Truncate the demangled kernel names"
|
|
echo -e ""
|
|
exit ${EC}
|
|
}
|
|
|
|
if [ -z "$1" ]; then
|
|
usage 1
|
|
fi
|
|
|
|
: ${ROCPROF_OUTPUT_PATH:="."}
|
|
: ${ROCPROF_OUTPUT_PATH_INTERNAL:="."}
|
|
: ${ROCPROF_OUTPUT_FILE_NAME:=""}
|
|
: ${ROCPROF_COUNTERS_PATH:=""}
|
|
: ${ROCPROF_PRELOAD:=""}
|
|
|
|
while true; do
|
|
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
|
usage 0
|
|
elif [[ "$1" == "-M" || "$1" == "--mangled-kernels" ]]; then
|
|
export ROCPROF_DEMANGLE_KERNELS=0
|
|
shift
|
|
elif [[ "$1" == "-T" || "$1" == "--truncate-kernels" ]]; then
|
|
export ROCPROF_TRUNCATE_KERNELS=1
|
|
shift
|
|
elif [[ "$1" == "-i" || "$1" == "--input" ]]; then
|
|
if [ "$2" ] && [ -n "$2" ] && [ -r "$2" ]; then
|
|
export ROCPROF_COUNTERS_PATH=$2
|
|
export ROCPROF_COUNTER_COLLECTION=1
|
|
else
|
|
echo -e "Error: input file \"$2\" doesn't exist!"
|
|
usage 1
|
|
fi
|
|
shift
|
|
shift
|
|
elif [[ "$1" == "-o" || "$1" == "--output-file-name" ]]; then
|
|
if [ "$2" ]; then
|
|
export ROCPROF_OUTPUT_FILE_NAME=$2
|
|
else
|
|
usage 1
|
|
fi
|
|
shift
|
|
shift
|
|
elif [[ "$1" == "-d" || "$1" == "--output-directory" ]]; then
|
|
if [ "$2" ]; then
|
|
ROCPROF_OUTPUT_PATH_INTERNAL=$2
|
|
export ROCPROF_OUTPUT_PATH=$ROCPROF_OUTPUT_PATH_INTERNAL
|
|
else
|
|
usage 1
|
|
fi
|
|
shift
|
|
shift
|
|
elif [ "$1" == "--hsa-trace" ]; then
|
|
export ROCPROF_HSA_API_TRACE=1
|
|
shift
|
|
elif [ "$1" == "--kernel-trace" ]; then
|
|
export ROCPROF_KERNEL_TRACE=1
|
|
shift
|
|
elif [ "$1" == "--memory-copy-trace" ]; then
|
|
export ROCPROF_MEMORY_COPY_TRACE=1
|
|
shift
|
|
elif [ "$1" == "--" ]; then
|
|
shift
|
|
break
|
|
elif [[ "$1" == "-"* || "$1" == "--"* ]]; then
|
|
echo -e "Wrong option \"$1\", Please use the following options:\n"
|
|
usage 1
|
|
else
|
|
break
|
|
fi
|
|
done
|
|
|
|
# read input counter file
|
|
PMC_LINES=()
|
|
if [ -n "$ROCPROF_COUNTERS_PATH" ]; then
|
|
input=$ROCPROF_COUNTERS_PATH
|
|
while IFS= read -r line || [[ -n "$line" ]]; do
|
|
#skip empty lines
|
|
if [[ -z "$line" ]]; then
|
|
continue
|
|
fi
|
|
PMC_LINES+=("$line")
|
|
done <"$input"
|
|
fi
|
|
|
|
if [ -n "${PMC_LINES:-}" ]; then
|
|
#for counter collection
|
|
COUNTER=1
|
|
for i in "${!PMC_LINES[@]}"; do
|
|
export ROCPROF_COUNTERS="${PMC_LINES[$i]}"
|
|
if [[ ! ${PMC_LINES[$i]} =~ "pmc" ]]; then
|
|
continue
|
|
fi
|
|
|
|
RESULT_PATH="$ROCPROF_OUTPUT_PATH_INTERNAL/pmc_$COUNTER"
|
|
if [ -n "$ROCPROF_OUTPUT_FILE_NAME" ] || [ -n "$ROCPROF_OUTPUT_PATH" ]; then
|
|
export ROCPROF_OUTPUT_PATH=$RESULT_PATH
|
|
fi
|
|
((COUNTER++))
|
|
ROCP_TOOL_LIBRARIES="${ROCM_DIR}/lib/rocprofiler-sdk/librocprofiler-sdk-tool.so" \
|
|
LD_LIBRARY_PATH=${ROCM_DIR}/lib:${LD_LIBRARY_PATH} \
|
|
LD_PRELOAD="${ROCPROF_PRELOAD}:${ROCM_DIR}/lib/librocprofiler-sdk.so" \
|
|
"${@}"
|
|
if [ -n "$ROCPROF_OUTPUT_PATH" ]; then
|
|
echo -e "\nThe output path for the following counters: $ROCPROF_OUTPUT_PATH"
|
|
fi
|
|
done
|
|
else
|
|
# for non counter collection. e.g: tracing
|
|
ROCP_TOOL_LIBRARIES="${ROCM_DIR}/lib/rocprofiler-sdk/librocprofiler-sdk-tool.so" \
|
|
LD_LIBRARY_PATH=${ROCM_DIR}/lib:${LD_LIBRARY_PATH} \
|
|
LD_PRELOAD="${ROCPROF_PRELOAD}:${ROCM_DIR}/lib/librocprofiler-sdk.so" \
|
|
"${@}"
|
|
fi
|