diff --git a/projects/roctracer/src/util/hsa_rsrc_factory.cpp b/projects/roctracer/src/util/hsa_rsrc_factory.cpp index e1ef92683e..cf172cae11 100644 --- a/projects/roctracer/src/util/hsa_rsrc_factory.cpp +++ b/projects/roctracer/src/util/hsa_rsrc_factory.cpp @@ -742,6 +742,19 @@ hsa_status_t HsaRsrcFactory::hsa_executable_freeze_interceptor(hsa_executable_t return hsa_api_.hsa_executable_freeze(executable, options);; } +void HsaRsrcFactory::DumpHandles(FILE* file) { + auto beg = agent_map_.begin(); + auto end = agent_map_.end(); + for (auto it = beg; it != end; ++it) { + const AgentInfo* agent_info = it->second; + fprintf(file, "0x%lx agent %s\n", agent_info->dev_id.handle, (agent_info->dev_type == HSA_DEVICE_TYPE_CPU) ? "cpu" : "gpu"); + if (agent_info->cpu_pool.handle != 0) fprintf(file, "0x%lx pool cpu\n", agent_info->cpu_pool.handle); + if (agent_info->kern_arg_pool.handle != 0) fprintf(file, "0x%lx pool cpu kernarg\n", agent_info->kern_arg_pool.handle); + if (agent_info->gpu_pool.handle != 0) fprintf(file, "0x%lx pool gpu\n", agent_info->gpu_pool.handle); + } + fflush(file); +} + std::atomic HsaRsrcFactory::instance_{}; HsaRsrcFactory::mutex_t HsaRsrcFactory::mutex_; HsaRsrcFactory::timestamp_t HsaRsrcFactory::timeout_ns_ = HsaTimer::TIMESTAMP_MAX; diff --git a/projects/roctracer/src/util/hsa_rsrc_factory.h b/projects/roctracer/src/util/hsa_rsrc_factory.h index 466ccf1f95..3bfeda68c1 100644 --- a/projects/roctracer/src/util/hsa_rsrc_factory.h +++ b/projects/roctracer/src/util/hsa_rsrc_factory.h @@ -439,6 +439,8 @@ class HsaRsrcFactory { return HSA_STATUS_SUCCESS; } + void DumpHandles(FILE* output_file); + private: // System agents iterating callback static hsa_status_t GetHsaAgentsCallback(hsa_agent_t agent, void* data); diff --git a/projects/roctracer/test/CMakeLists.txt b/projects/roctracer/test/CMakeLists.txt index 148c60b0b0..a7511789c9 100644 --- a/projects/roctracer/test/CMakeLists.txt +++ b/projects/roctracer/test/CMakeLists.txt @@ -44,7 +44,7 @@ endif () ## Path to HSA test set ( HSA_TEST_DIR "${TEST_DIR}/hsa/test" ) -set ( HSA_REV "19b1191" ) +set ( HSA_REV "a4fcdae" ) ## test run script set ( RUN_SCRIPT "${TEST_DIR}/run.sh" ) diff --git a/projects/roctracer/test/tool/tracer_tool.cpp b/projects/roctracer/test/tool/tracer_tool.cpp index 1aeb75a301..218652e98a 100644 --- a/projects/roctracer/test/tool/tracer_tool.cpp +++ b/projects/roctracer/test/tool/tracer_tool.cpp @@ -1127,6 +1127,11 @@ extern "C" PUBLIC_API bool OnLoad(HsaApiTable* table, uint64_t runtime_version, ROCTRACER_CALL(roctracer_enable_op_activity(ACTIVITY_DOMAIN_HSA_OPS, HSA_OP_ID_RESERVED1)); } + // Dumping HSA handles for agents and pools + FILE* handles_file_handle = open_output_file(output_prefix, "hsa_handles.txt"); + HsaRsrcFactory::Instance().DumpHandles(handles_file_handle); + close_output_file(handles_file_handle); + ONLOAD_TRACE_END(); return true; }