Handle user input if first PMC line is empty
Change-Id: I456fd9360a4a8506fadcc975e71da112a26b07ae
[ROCm/rocprofiler commit: c6729adaed]
This commit is contained in:
@@ -226,6 +226,7 @@ Rocprofiler for ROCm 5.7 added support for counter collection (PMC) and advanced
|
||||
- ATT analysis will not run by default. For ATT to have the same behaviour as 5.5, use --plugin att <as.s> --mode network
|
||||
### Optimized
|
||||
- ATT json filesizes
|
||||
- Now profiler autocorrects user input errors for pmc and throws exception for wrong input with this message:"Bad input metric. usage --> pmc: [counter1] [counter2]"
|
||||
### Added
|
||||
- Every API trace in V2 reported synchronously will have two records, one for Enter phase and for Exit phase
|
||||
- File Plugin now reports the HSA OPS operation kind as part of the output text
|
||||
|
||||
@@ -256,6 +256,10 @@ PMC_LINES=()
|
||||
if [ -n "$COUNTERS_PATH" ]; then
|
||||
input=$COUNTERS_PATH
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
#skip empty lines
|
||||
if [[ -z "$line" ]]; then
|
||||
continue
|
||||
fi
|
||||
# if in att mode, only add the first line
|
||||
if [[ ! -n "$PMC_LINES" ]] || [[ ! -n "$ATT_ARGV" ]]; then
|
||||
PMC_LINES+=( "$line" )
|
||||
|
||||
@@ -36,14 +36,16 @@ class Exception : public std::runtime_error {
|
||||
Exception() = delete;
|
||||
|
||||
explicit Exception(rocprofiler_status_t status, const char* what_arg = "")
|
||||
: std::runtime_error(std::string(rocprofiler_error_str(status)) + " " +
|
||||
what_arg),
|
||||
: std::runtime_error(std::string(rocprofiler_error_str(status)) + " " + what_arg),
|
||||
status_(status) {}
|
||||
|
||||
rocprofiler_status_t status() const noexcept { return status_; }
|
||||
|
||||
explicit Exception(const std::string& message) : std::runtime_error(message) { message_ = message; }
|
||||
const char* what() const noexcept override { return message_.c_str(); }
|
||||
|
||||
protected:
|
||||
const rocprofiler_status_t status_;
|
||||
rocprofiler_status_t status_;
|
||||
std::string message_;
|
||||
};
|
||||
|
||||
}; // namespace rocprofiler
|
||||
|
||||
@@ -144,7 +144,6 @@ std::string string_printf(const char* format, ...) {
|
||||
#endif /* defined (ENABLE_BACKTRACE) */
|
||||
|
||||
std::string errmsg("ROCProfiler: fatal error: " + message);
|
||||
fputs(errmsg.c_str(), stderr);
|
||||
|
||||
std::cerr << errmsg << std::endl;
|
||||
abort();
|
||||
@@ -251,7 +250,7 @@ void trim(std::string& str) {
|
||||
// replace unsuported specail chars with space
|
||||
static void handle_special_chars(std::string& str) {
|
||||
std::set<char> specialChars = {'!', '@', '#', '$', '%', '&', '(', ')', ',', '*', '+', '-', '.',
|
||||
'/', ';', '<', '=', '>', '?', '@', '{', '}', '^', '`', '~', '|'};
|
||||
'/', ';', '<', '=', '>', '?', '@', '{', '}', '^', '`', '~', '|', ':'};
|
||||
|
||||
// Iterate over the string and replace any special characters with a space.
|
||||
for (unsigned int i = 0; i < str.length(); i++) {
|
||||
@@ -277,6 +276,14 @@ void validate_counters_format(std::vector<std::string>& counters, std::string li
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// raise exception with correct usage if user still managed to corrupt input
|
||||
for(const auto &itr: counters)
|
||||
{
|
||||
if(!has_counter_format(itr)){
|
||||
rocprofiler::fatal("Bad input metric. usage --> pmc: <counter1> <counter2>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace rocprofiler
|
||||
|
||||
Reference in New Issue
Block a user