diff --git a/runtime/hsa-runtime/core/runtime/runtime.cpp b/runtime/hsa-runtime/core/runtime/runtime.cpp index cbe09cd47b..004a58631c 100644 --- a/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -2063,9 +2063,20 @@ void Runtime::LoadTools() { rocprofiler_register_library_api_table("hsa", &ROCPROFILER_REGISTER_IMPORT_FUNC(hsa), ROCP_REG_VERSION, &profiler_api_table_, 1, &lib_id); - if (rocp_reg_status != ROCP_REG_SUCCESS && flag().report_tool_load_failures()) - fprintf(stderr, "rocprofiler-register failed with error code %i: %s\n", rocp_reg_status, - rocprofiler_register_error_string(rocp_reg_status)); + if (rocp_reg_status != ROCP_REG_SUCCESS && flag().report_tool_load_failures()) { + // hsa-runtime, in non-debug mode, enables reporting tool load failures by default, + // which is good scheme for when tools were only loaded via the HSA_TOOLS_LIB env variable + // but, with automatic detection, this will result in reporting that no tools were available. + // So if no tools were available and flag().report_tool_load_failures() is true, we make + // sure that HSA_TOOLS_REPORT_LOAD_FAILURE was explicitly set and, if not, we suppress + // reporting that no tools were found + if (rocp_reg_status != ROCP_REG_NO_TOOLS || + (rocp_reg_status == ROCP_REG_NO_TOOLS && + flag().report_tool_load_failures_explicitly_set())) { + fprintf(stderr, "[hsa-runtime][%i] rocprofiler-register failed with error code %i: %s\n", + getpid(), rocp_reg_status, rocprofiler_register_error_string(rocp_reg_status)); + } + } bool allow_v1_registration = false; if(os::IsEnvVarSet("HSA_TOOLS_ROCPROFILER_V1_TOOLS")) diff --git a/runtime/hsa-runtime/core/util/flag.h b/runtime/hsa-runtime/core/util/flag.h index 32749b8c61..304b367ffb 100644 --- a/runtime/hsa-runtime/core/util/flag.h +++ b/runtime/hsa-runtime/core/util/flag.h @@ -150,6 +150,7 @@ class Flag { var = os::GetEnvVar("HSA_TOOLS_REPORT_LOAD_FAILURE"); + report_tool_load_failures_explicit_ = (var.empty()) ? false : true; ifdebug { report_tool_load_failures_ = (var == "1") ? true : false; } else { @@ -185,7 +186,7 @@ class Flag { var = os::GetEnvVar("HSA_IGNORE_SRAMECC_MISREPORT"); check_sramecc_validity_ = (var == "1") ? false : true; - + // Legal values are zero "0" or one "1". Any other value will // be interpreted as not defining the env variable. var = os::GetEnvVar("HSA_XNACK"); @@ -248,6 +249,10 @@ class Flag { bool report_tool_load_failures() const { return report_tool_load_failures_; } + bool report_tool_load_failures_explicitly_set() const { + return report_tool_load_failures_explicit_; + } + bool disable_fragment_alloc() const { return disable_fragment_alloc_; } bool rev_copy_dir() const { return rev_copy_dir_; } @@ -334,6 +339,7 @@ class Flag { bool sdma_wait_idle_; bool enable_queue_fault_message_; bool report_tool_load_failures_; + bool report_tool_load_failures_explicit_; bool disable_fragment_alloc_; bool rev_copy_dir_; bool fine_grain_pcie_;