SWDEV-413890 and formatting changes
Change-Id: Icea4ddf9dbdb6181bd8affdec9072738fcfa215e
[ROCm/rocprofiler commit: 0ecf3cb2e1]
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#!/bin/bash
|
||||
CURRENT_DIR="$( dirname -- "$0"; )";
|
||||
ROCPROFV2_DIR=$(dirname -- $(realpath ${BASH_SOURCE[0]}));
|
||||
ROCM_DIR=$( dirname -- "$ROCPROFV2_DIR"; )
|
||||
set -eo pipefail
|
||||
CURRENT_DIR="$(dirname -- "$0")"
|
||||
ROCPROFV2_DIR=$(dirname -- $(realpath ${BASH_SOURCE[0]}))
|
||||
ROCM_DIR=$(dirname -- "$ROCPROFV2_DIR")
|
||||
PLUGIN_LIST=("ctf" "perfetto" "file" "att")
|
||||
RUN_FROM_BUILD=0
|
||||
if [[ $ROCPROFV2_DIR == *"/build"* ]]; then
|
||||
@@ -32,51 +33,51 @@ usage() {
|
||||
echo -e "${GREEN}--roctx-trace ${RESET} For Collecting ROCTx Traces"
|
||||
echo -e "${GREEN}--kernel-trace ${RESET} For Collecting Kernel dispatch Traces"
|
||||
echo -e "${GREEN}--sys-trace ${RESET} For Collecting HIP and HSA APIs and their Activities Traces along ROCTX and Kernel Dispatch traces\n"
|
||||
echo -e "\t#${GREY}usage e.g: rocprofv2 --[hip-trace|hsa-trace|roctx-trace|kernel-trace|sys-trace] <executable>\n"${RESET}
|
||||
echo -e "\t#${GREY}usage e.g: rocprofv2 --[hip-trace|hsa-trace|roctx-trace|kernel-trace|sys-trace] <executable>\n"${RESET}
|
||||
|
||||
echo -e "${GREEN}--plugin ${RESET} PLUGIN_NAME For enabling a plugin (file/perfetto/att/ctf)"
|
||||
echo -e "\t#${GREY} usage(file/perfetto/ctf) e.g: rocprofv2 -i pmc.txt --plugin [file/perfetto/ctf] -d out_dir <executable>"
|
||||
echo -e "\t# usage(att): rocprofv2 <rocprofv2_params> --plugin att <ISA_file> <att_parameters> <executable>"
|
||||
echo -e "\t# use \"rocprofv2 --plugin att --help\" for ATT-specific parameters help.${RESET}\n"
|
||||
echo -e "\t#${GREY} usage(file/perfetto/ctf) e.g: rocprofv2 -i pmc.txt --plugin [file/perfetto/ctf] -d out_dir <executable>"
|
||||
echo -e "\t# usage(att): rocprofv2 <rocprofv2_params> --plugin att <ISA_file> <att_parameters> <executable>"
|
||||
echo -e "\t# use \"rocprofv2 --plugin att --help\" for ATT-specific parameters help.${RESET}\n"
|
||||
echo -e "${GREEN}-i | --input ${RESET} For adding counters file path (every line in the text file represents a counter)"
|
||||
echo -e "\t#${GREY} usage: rocprofv2 -i pmc.txt -d <executable>${RESET}\n"
|
||||
echo -e "\t#${GREY} usage: rocprofv2 -i pmc.txt -d <executable>${RESET}\n"
|
||||
echo -e "${GREEN}-o | --output-file ${RESET} For the output file name"
|
||||
echo -e "\t#${GREY} usage e.g:(with current dir): rocprofv2 --hip-trace -o <file_name> <executable>"
|
||||
echo -e "\t#${GREY} usage e.g:(with custom dir): rocprofv2 --hip-trace -d <out_dir> -o <file_name> <executable>${RESET}\n"
|
||||
echo -e "\t#${GREY} usage e.g:(with current dir): rocprofv2 --hip-trace -o <file_name> <executable>"
|
||||
echo -e "\t#${GREY} usage e.g:(with custom dir): rocprofv2 --hip-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): rocprofv2 --hip-trace -d <out_dir> <executable>${RESET}\n"
|
||||
echo -e "\t#${GREY} usage e.g:(with custom dir): rocprofv2 --hip-trace -d <out_dir> <executable>${RESET}\n"
|
||||
echo -e "${GREEN}-fi | --flush-interval ${RESET} For adding a flush interval in milliseconds, every \"flush interval\" the buffers will be flushed"
|
||||
echo -e "\t#${GREY} usage e.g: rocprofv2 --hip-trace -fi 1000 <executable>${RESET}\n"
|
||||
echo -e "\t#${GREY} usage e.g: rocprofv2 --hip-trace -fi 1000 <executable>${RESET}\n"
|
||||
echo -e "${GREEN}-tp | --trace-period ${RESET} Specifies a trace period in milliseconds, with format \"-tp <DELAY>:<ACTIVE_TIME>:<LOOP_RESET_TIME>\"."
|
||||
echo -e "\t#${GREY} usage e.g: rocprofv2 --hip-trace -tp 1000:2000:4000 <executable>${RESET}\n"
|
||||
echo -e "\t#${GREY} usage e.g: rocprofv2 --hip-trace -tp 1000:2000:4000 <executable>${RESET}\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ -z "$1" ] ; then
|
||||
if [ -z "$1" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while [ 1 ] ; do
|
||||
if [[ "$1" = "-h" || "$1" = "--help" ]] ; then
|
||||
while [ 1 ]; do
|
||||
if [[ "$1" = "-h" || "$1" = "--help" ]]; then
|
||||
usage
|
||||
exit 1
|
||||
elif [[ "$1" = "-t" || "$1" = "--test" ]] ; then
|
||||
elif [[ "$1" = "-t" || "$1" = "--test" ]]; then
|
||||
if [ $RUN_FROM_BUILD == 1 ]; then
|
||||
./run_tests.sh
|
||||
exit 1
|
||||
fi
|
||||
elif [[ "$1" = "-mt" || "$1" = "--mem-test" ]] ; then
|
||||
elif [[ "$1" = "-mt" || "$1" = "--mem-test" ]]; then
|
||||
if [ $RUN_FROM_BUILD == 1 ]; then
|
||||
$ROCM_DIR/tests-v2/memorytests/run_asan_tests.sh $ROCM_DIR/tests-v2/featuretests/profiler/apps/hip_vectoradd $ROCM_DIR/memleaks.log
|
||||
exit 1
|
||||
fi
|
||||
elif [[ "$1" = "--list-counters" ]] ; then
|
||||
elif [[ "$1" = "--list-counters" ]]; then
|
||||
export LD_PRELOAD=$LD_PRELOAD:$ROCM_DIR/lib/rocprofiler/librocprofiler_tool.so
|
||||
eval $ROCM_DIR/libexec/rocprofiler/ctrl
|
||||
exit 1
|
||||
elif [[ "$1" = "-i" || "$1" = "--input" ]] ; then
|
||||
if [ $2 ] && [ -n $2 ] && [ -r $2 ] ; then
|
||||
elif [[ "$1" = "-i" || "$1" = "--input" ]]; then
|
||||
if [ $2 ] && [ -n $2 ] && [ -r $2 ]; then
|
||||
export COUNTERS_PATH=$2
|
||||
else
|
||||
echo -e "Error: \"$2\" doesn't exist!"
|
||||
@@ -85,8 +86,8 @@ while [ 1 ] ; do
|
||||
fi
|
||||
shift
|
||||
shift
|
||||
elif [[ "$1" = "-o" || "$1" = "--output-file-name" ]] ; then
|
||||
if [ $2 ] ; then
|
||||
elif [[ "$1" = "-o" || "$1" = "--output-file-name" ]]; then
|
||||
if [ $2 ]; then
|
||||
export OUT_FILE_NAME=$2
|
||||
else
|
||||
usage
|
||||
@@ -94,8 +95,8 @@ while [ 1 ] ; do
|
||||
fi
|
||||
shift
|
||||
shift
|
||||
elif [[ "$1" = "-d" || "$1" = "--output-directory" ]] ; then
|
||||
if [ $2 ] ; then
|
||||
elif [[ "$1" = "-d" || "$1" = "--output-directory" ]]; then
|
||||
if [ $2 ]; then
|
||||
OUTPUT_PATH_INTERNAL=$2
|
||||
MPI_RANK_INTERNAL=""
|
||||
if [ -n "$MPI_RANK" ]; then
|
||||
@@ -117,8 +118,8 @@ while [ 1 ] ; do
|
||||
fi
|
||||
shift
|
||||
shift
|
||||
elif [[ "$1" = "-fi" || "$1" = "--flush-interval" ]] ; then
|
||||
if [ $2 ] && [ $2 -gt 0 ] ; then
|
||||
elif [[ "$1" = "-fi" || "$1" = "--flush-interval" ]]; then
|
||||
if [ $2 ] && [ $2 -gt 0 ]; then
|
||||
export ROCPROFILER_FLUSH_INTERVAL=$2
|
||||
else
|
||||
echo -e "Wrong input \"$2\" for flush interval, it needs to be integer greater than zero!"
|
||||
@@ -127,8 +128,8 @@ while [ 1 ] ; do
|
||||
fi
|
||||
shift
|
||||
shift
|
||||
elif [[ "$1" = "-tp" || "$1" = "--trace-period" ]] ; then
|
||||
if [ $2 ] && [[ "$2" == *":"* ]] ; then
|
||||
elif [[ "$1" = "-tp" || "$1" = "--trace-period" ]]; then
|
||||
if [ $2 ] && [[ "$2" == *":"* ]]; then
|
||||
export ROCPROFILER_TRACE_PERIOD=$2
|
||||
else
|
||||
echo -e "Wrong input \"$2\" for trace period!"
|
||||
@@ -137,44 +138,44 @@ while [ 1 ] ; do
|
||||
fi
|
||||
shift
|
||||
shift
|
||||
elif [ "$1" = "--hip-api" ] ; then
|
||||
elif [ "$1" = "--hip-api" ]; then
|
||||
export ROCPROFILER_HIP_API_TRACE=1
|
||||
shift
|
||||
elif [[ "$1" = "--hip-activity" || "$1" = "--hip-trace" ]] ; then
|
||||
elif [[ "$1" = "--hip-activity" || "$1" = "--hip-trace" ]]; then
|
||||
export ROCPROFILER_HIP_API_TRACE=1
|
||||
export ROCPROFILER_HIP_ACTIVITY_TRACE=1
|
||||
shift
|
||||
elif [ "$1" = "--hsa-api" ] ; then
|
||||
elif [ "$1" = "--hsa-api" ]; then
|
||||
export ROCPROFILER_HSA_API_TRACE=1
|
||||
shift
|
||||
elif [[ "$1" = "--hsa-activity" || "$1" = "--hsa-trace" ]] ; then
|
||||
elif [[ "$1" = "--hsa-activity" || "$1" = "--hsa-trace" ]]; then
|
||||
export ROCPROFILER_HSA_API_TRACE=1
|
||||
export ROCPROFILER_HSA_ACTIVITY_TRACE=1
|
||||
shift
|
||||
elif [ "$1" = "--roctx-trace" ] ; then
|
||||
elif [ "$1" = "--roctx-trace" ]; then
|
||||
export ROCPROFILER_ROCTX_TRACE=1
|
||||
shift
|
||||
elif [ "$1" = "--kernel-trace" ] ; then
|
||||
elif [ "$1" = "--kernel-trace" ]; then
|
||||
export ROCPROFILER_KERNEL_TRACE=1
|
||||
shift
|
||||
elif [ "$1" = "--sys-trace" ] ; then
|
||||
elif [ "$1" = "--sys-trace" ]; then
|
||||
export ROCPROFILER_HIP_API_TRACE=1
|
||||
export ROCPROFILER_HIP_ACTIVITY_TRACE=1
|
||||
export ROCPROFILER_HSA_API_TRACE=1
|
||||
export ROCPROFILER_HSA_ACTIVITY_TRACE=1
|
||||
export ROCPROFILER_ROCTX_TRACE=1
|
||||
shift
|
||||
elif [ "$1" = "--roc-sys" ] ; then
|
||||
elif [ "$1" = "--roc-sys" ]; then
|
||||
export ROCPROFILER_ENABLE_AMDSYS=$2
|
||||
shift
|
||||
shift
|
||||
elif [ "$1" = "--plugin" ] ; then
|
||||
if [ -n $2 ] ; then
|
||||
elif [ "$1" = "--plugin" ]; then
|
||||
if [ -n $2 ]; then
|
||||
PLUGIN=$2
|
||||
if [[ ! "${PLUGIN_LIST[*]}" =~ $PLUGIN ]]; then
|
||||
echo -e "Wrong input \"$2\" for plugin!"
|
||||
usage
|
||||
exit 1
|
||||
echo -e "Wrong input \"$2\" for plugin!"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
export ROCPROFILER_PLUGIN_LIB=lib${PLUGIN}_plugin.so
|
||||
else
|
||||
@@ -182,7 +183,7 @@ while [ 1 ] ; do
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
if [ "$2" = "att" ] ; then
|
||||
if [ "$2" = "att" ]; then
|
||||
if [ $RUN_FROM_BUILD == 1 ]; then
|
||||
ATT_PATH=$ROCM_DIR/plugin/att/att/att.py
|
||||
else
|
||||
@@ -203,7 +204,7 @@ while [ 1 ] ; do
|
||||
ATT_PYTHON3_ARG="mpirun -np $4 python3 "
|
||||
shift
|
||||
shift
|
||||
elif [[ "$3" = "--mode" || "$3" = "--ports" || "$3" = "--genasm" || "$3" == "--att_kernel" || "$3" == "--depth" ]]; then
|
||||
elif [[ "$3" = "--mode" || "$3" = "--ports" || "$3" = "--genasm" || "$3" == "--att_kernel" || "$3" == "--depth" ]]; then
|
||||
ATT_ARGV="$ATT_ARGV $3 $4"
|
||||
shift
|
||||
shift
|
||||
@@ -214,7 +215,7 @@ while [ 1 ] ; do
|
||||
fi
|
||||
shift
|
||||
shift
|
||||
elif [[ "$1" = "-"* || "$1" = "--"* ]] ; then
|
||||
elif [[ "$1" = "-"* || "$1" = "--"* ]]; then
|
||||
echo -e "Wrong option \"$1\", Please use the following options:\n"
|
||||
usage
|
||||
exit 1
|
||||
@@ -229,13 +230,13 @@ if [ -n "$COUNTERS_PATH" ]; then
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
#skip empty lines
|
||||
if [[ -z "$line" ]]; then
|
||||
continue
|
||||
continue
|
||||
fi
|
||||
# if in att mode, only add the first line
|
||||
if [[ ! -n "$PMC_LINES" ]] || [[ ! -n "$ATT_ARGV" ]]; then
|
||||
PMC_LINES+=( "$line" )
|
||||
PMC_LINES+=("$line")
|
||||
fi
|
||||
done < $input
|
||||
done <$input
|
||||
fi
|
||||
|
||||
COUNTERS_PMC_DIRS=""
|
||||
@@ -257,7 +258,7 @@ if [ -n "$PMC_LINES" ]; then
|
||||
fi
|
||||
echo -e "\nThe output path for the following counters: $FINAL_PATH"
|
||||
mkdir -p $FINAL_PATH
|
||||
echo $ROCPROFILER_COUNTERS > $FINAL_PATH/pmc.txt
|
||||
echo $ROCPROFILER_COUNTERS >$FINAL_PATH/pmc.txt
|
||||
export OUTPUT_PATH=$FINAL_PATH
|
||||
let COUNTER=COUNTER+1
|
||||
fi
|
||||
@@ -267,8 +268,8 @@ elif [ ! -n "$ATT_ARGV" ]; then
|
||||
LD_PRELOAD=$LD_PRELOAD:$ROCM_DIR/lib/rocprofiler/librocprofiler_tool.so $*
|
||||
fi
|
||||
|
||||
get_pmc_results_txt_path(){
|
||||
for file_name in `ls $1` ; do
|
||||
get_pmc_results_txt_path() {
|
||||
for file_name in $(ls $1); do
|
||||
if [[ $file_name == *results.txt ]]; then
|
||||
echo "$1/$file_name"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user