From 27eb0516bb25b2ea770a30970ba389bd183bd829 Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Fri, 1 Dec 2023 15:18:09 -0600 Subject: [PATCH] rocprofiler-register updates - fix logic for using HSA_TOOLS_LIB when rocprofiler-register support is enabled - report tool load failure for rocprofiler-register Change-Id: Ife23aa3e6ed19174376cd694764583b73f8976cd --- runtime/hsa-runtime/core/runtime/runtime.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/runtime/hsa-runtime/core/runtime/runtime.cpp b/runtime/hsa-runtime/core/runtime/runtime.cpp index 3ea2a7e74b..264590ab68 100644 --- a/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -1742,10 +1742,14 @@ void Runtime::LoadTools() { #if defined(HSA_ROCPROFILER_REGISTER) && HSA_ROCPROFILER_REGISTER > 0 auto* profiler_api_table_ = static_cast(&hsa_api_table_); auto lib_id = rocprofiler_register_library_indentifier_t{}; - auto success = + auto rocp_reg_status = 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)); + bool allow_v1_registration = false; if(os::IsEnvVarSet("HSA_TOOLS_ROCPROFILER_V1_TOOLS")) { @@ -1764,9 +1768,9 @@ void Runtime::LoadTools() { } } - // if rocprofiler library supports registration and v1 support not explicitly requested, do not - // use old method - if (success != 0 && !allow_v1_registration) return; + // if rocprofiler library supports registration and v1 support not explicitly requested, + // do not use old method + if (rocp_reg_status == ROCP_REG_SUCCESS && !allow_v1_registration) return; #endif std::vector failed; @@ -1800,7 +1804,7 @@ void Runtime::LoadTools() { os::CloseLib(handle); } } - + // Load env var tools. env_count=0; for (auto& name : names) { @@ -1842,7 +1846,7 @@ void Runtime::LoadTools() { sorted.sort([](const lib_t& lhs, const lib_t& rhs) { return lhs.order_ < rhs.order_; }); - + for(auto& lib : sorted) { auto& tool = lib.lib_;