shellcheck and minor bug fix (#347)
* shellcheck and minor bug fix * source formatting (clang-format v11) (#348) Co-authored-by: bgopesh <bgopesh@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bgopesh <bgopesh@users.noreply.github.com>
This commit is contained in:
+11
-16
@@ -1,14 +1,13 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
set -eo pipefail
|
set -eou pipefail
|
||||||
|
|
||||||
CURRENT_DIR="$( dirname -- "$0"; )";
|
ROCPROFV2_DIR=$(dirname -- "$(realpath "${BASH_SOURCE[0]}")");
|
||||||
ROCPROFV2_DIR=$(dirname -- $(realpath ${BASH_SOURCE[0]}));
|
|
||||||
ROCM_DIR=$( dirname -- "${ROCPROFV2_DIR}"; )
|
ROCM_DIR=$( dirname -- "${ROCPROFV2_DIR}"; )
|
||||||
|
|
||||||
export HSA_TOOLS_LIB=${ROCM_DIR}/lib/librocprofiler-sdk.so.0
|
export HSA_TOOLS_LIB=${ROCM_DIR}/lib/librocprofiler-sdk.so.0
|
||||||
|
|
||||||
# Define color code
|
# Define color codes
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
GREY='\033[0;90m'
|
GREY='\033[0;90m'
|
||||||
RESET='\033[0m'
|
RESET='\033[0m'
|
||||||
@@ -19,39 +18,36 @@ usage() {
|
|||||||
echo -e "${GREEN}--hsa-trace ${RESET} For Collecting HSA API Traces"
|
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}--kernel-trace ${RESET} For Collecting Kernel Dispatch Traces"
|
||||||
echo -e "${GREEN}-o | --output-file ${RESET} For the output file name"
|
echo -e "${GREEN}-o | --output-file ${RESET} For the output file name"
|
||||||
echo -e "\t#${GREY} usage e.g:(with current dir): rocprofv3 --hip-trace -o <file_name> <executable>"
|
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 --hip-trace -d <out_dir> -o <file_name> <executable>${RESET}\n"
|
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 "${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 --hip-trace -d <out_dir> <executable>${RESET}\n"
|
echo -e "\t#${GREY} usage e.g:(with custom dir): rocprofv3 --hsa-trace -d <out_dir> <executable>${RESET}\n"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
usage
|
usage
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
: ${ROCPROFILER_OUTPUT_PATH:="."}
|
: "${ROCPROFILER_OUTPUT_PATH:="."}"
|
||||||
|
: "${ROCPROFILER_OUTPUT_FILE_NAME:=""}"
|
||||||
|
|
||||||
while [ 1 ]; do
|
while true; do
|
||||||
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
||||||
usage
|
usage
|
||||||
exit 1
|
|
||||||
elif [[ "$1" == "-o" || "$1" == "--output-file-name" ]]; then
|
elif [[ "$1" == "-o" || "$1" == "--output-file-name" ]]; then
|
||||||
if [ $2 ]; then
|
if [ "$2" ]; then
|
||||||
export ROCPROFILER_OUTPUT_FILE_NAME=$2
|
export ROCPROFILER_OUTPUT_FILE_NAME=$2
|
||||||
else
|
else
|
||||||
usage
|
usage
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
elif [[ "$1" == "-d" || "$1" == "--output-directory" ]]; then
|
elif [[ "$1" == "-d" || "$1" == "--output-directory" ]]; then
|
||||||
if [ $2 ]; then
|
if [ "$2" ]; then
|
||||||
ROCPROFILER_OUTPUT_PATH=$2
|
ROCPROFILER_OUTPUT_PATH=$2
|
||||||
else
|
else
|
||||||
usage
|
usage
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
@@ -67,7 +63,6 @@ while [ 1 ]; do
|
|||||||
elif [[ "$1" == "-"* || "$1" == "--"* ]]; then
|
elif [[ "$1" == "-"* || "$1" == "--"* ]]; then
|
||||||
echo -e "Wrong option \"$1\", Please use the following options:\n"
|
echo -e "Wrong option \"$1\", Please use the following options:\n"
|
||||||
usage
|
usage
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ auto context_id = rocprofiler_context_id_t{};
|
|||||||
auto output_path =
|
auto output_path =
|
||||||
fs::path{common::get_env<std::string>("ROCPROFILER_OUTPUT_PATH", fs::current_path().string())};
|
fs::path{common::get_env<std::string>("ROCPROFILER_OUTPUT_PATH", fs::current_path().string())};
|
||||||
auto output_file_name =
|
auto output_file_name =
|
||||||
common::get_env<std::string>("ROCPROFILER_OUTPUT_FILE_NAME", std::to_string(getpid()) + "-");
|
common::get_env<std::string>("ROCPROFILER_OUTPUT_FILE_NAME", std::to_string(getpid()));
|
||||||
|
|
||||||
std::pair<std::ostream*, void (*)(std::ostream*&)>
|
std::pair<std::ostream*, void (*)(std::ostream*&)>
|
||||||
get_output_stream(const std::string& fname, const std::string& ext = ".csv")
|
get_output_stream(const std::string& fname, const std::string& ext = ".csv")
|
||||||
@@ -64,7 +64,7 @@ get_output_stream(const std::string& fname, const std::string& ext = ".csv")
|
|||||||
output_path.string())};
|
output_path.string())};
|
||||||
if(!fs::exists(output_path)) fs::create_directories(output_path);
|
if(!fs::exists(output_path)) fs::create_directories(output_path);
|
||||||
|
|
||||||
auto output_file = output_path / (output_file_name + fname + ext);
|
auto output_file = output_path / (output_file_name + "_" + fname + ext);
|
||||||
auto* _ofs = new std::ofstream{output_file};
|
auto* _ofs = new std::ofstream{output_file};
|
||||||
if(!_ofs && !*_ofs)
|
if(!_ofs && !*_ofs)
|
||||||
throw std::runtime_error{fmt::format("Failed to open {} for output", output_file.string())};
|
throw std::runtime_error{fmt::format("Failed to open {} for output", output_file.string())};
|
||||||
|
|||||||
مرجع در شماره جدید
Block a user