From 6416434d3b3a31c04b6c4feeb2fba013b3beb4e7 Mon Sep 17 00:00:00 2001 From: Laurent Morichetti Date: Fri, 30 Sep 2022 11:02:27 -0700 Subject: [PATCH] Fix a profiling data corrupted error Using rocprof with ROCP_MCOPY_DATA=1 while tracing HSA produces the following error: tblextr.py: Memcpy args "(0x7feb16a00000, 123handle=28593376125, 0x7feb12a00010, 123handle=27558560125, 4194304, 0, 0, 123handle=140661639440000125) = 1" cannot be identified Profiling data corrupted: ' ./out/rpl_data_220930_143009_1826700/input_results_220930_143009/results.txt' There are two issues: 1) The hsa_agent_t handle argument is misprinted: "123handle=...125" Instead of printing '{' and '}', it prints '123' and '125'. The wrong operator<<(unsigned char) is used and an integer value is printed instead of a char. Use std::operator<< instead of hsa_support::detail::operator<< to print '{' and '}' 2) The result value is unitialized and in some cases printed as a negative integer value. The leading '-' is not matched by the mem_manager regular expresion for HSA api calls. Correctly capture the HSA function's return value. Change-Id: If13a1e62eeb4e598447c4b90d53d1b2e3b408696 --- script/gen_ostream_ops.py | 4 ++-- script/hsaap.py | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/script/gen_ostream_ops.py b/script/gen_ostream_ops.py index aacbd7ce37..b9a52a302b 100755 --- a/script/gen_ostream_ops.py +++ b/script/gen_ostream_ops.py @@ -191,7 +191,7 @@ def gen_cppheader(infilepath, outfilepath, rank): if len(cppHeader.classes[c]["properties"]["public"]) != 0: output_filename_h.write("inline static std::ostream& operator<<(std::ostream& out, const " + c + "& v)\n") output_filename_h.write("{\n") - output_filename_h.write(" roctracer::" + apiname.lower() + "_support::detail::operator<<(out, '{');\n") + output_filename_h.write(" std::operator<<(out, '{');\n") output_filename_h.write(" " + apiname.upper() + "_depth_max_cnt++;\n") output_filename_h.write(" if (" + apiname.upper() + "_depth_max == -1 || " + apiname.upper() + "_depth_max_cnt <= " + apiname.upper() + "_depth_max" + ") {\n" ) process_struct(output_filename_h, c, cppHeader, "", apiname) @@ -200,7 +200,7 @@ def gen_cppheader(infilepath, outfilepath, rank): output_filename_h.write(global_str) output_filename_h.write(" };\n") output_filename_h.write(" " + apiname.upper() + "_depth_max_cnt--;\n") - output_filename_h.write(" roctracer::" + apiname.lower() + "_support::detail::operator<<(out, '}');\n") + output_filename_h.write(" std::operator<<(out, '}');\n") output_filename_h.write(" return out;\n") output_filename_h.write("}\n") global_str = '' diff --git a/script/hsaap.py b/script/hsaap.py index 2aa0742c8f..7d5813c7f0 100755 --- a/script/hsaap.py +++ b/script/hsaap.py @@ -441,8 +441,7 @@ class API_DescrParser: content += '\n' if ret_type != 'void': - # FIXME: we should capture the return value and store it in the api_data - content += ' ' + ret_type + ' ret =' + content += ' trace_data.api_data.' + ret_type + '_retval = ' content += ' ' + name + '_saved_before_cb.' + call + '_fn(' + ', '.join(struct['alst']) + ');\n' content += '\n' @@ -450,8 +449,7 @@ class API_DescrParser: content += ' trace_data.phase_exit(' + call_id + ', &trace_data);\n' if ret_type != 'void': - content += '\n' - content += ' return ret;\n' + content += ' return trace_data.api_data.' + ret_type + '_retval;\n' content += '}\n' return content