hsakmt: Initial Commit for the HSA KMT Model

The over arching goal it so provide an API that pre-silicon models can latch into for software bring up.# Please enter the commit message for your changes. Lines starting


[ROCm/ROCR-Runtime commit: d4b85b6bf5]
This commit is contained in:
jordans
2025-03-11 16:56:02 -04:00
committed by Stratton, Jordan
parent 9e8859636e
commit 938b34da24
20 changed files with 1104 additions and 28 deletions
@@ -214,13 +214,21 @@ GpuAgent::GpuAgent(HSAuint32 node, const HsaNodeProperties& node_props, bool xna
#if !defined(__linux__)
wallclock_frequency_ = 0;
#else
// Get wallclock freq from libdrm.
amdgpu_gpu_info info;
if (amdgpu_query_gpu_info(ldrm_dev_, &info) < 0)
throw AMD::hsa_exception(HSA_STATUS_ERROR, "Agent creation failed.\nlibdrm query failed.\n");
bool model_enabled;
hsa_status_t status = driver().IsModelEnabled(&model_enabled);
assert(status == HSA_STATUS_SUCCESS && "IsModelEnabled failed");
if (model_enabled) {
wallclock_frequency_ = 0;
} else {
// Get wallclock freq from libdrm.
amdgpu_gpu_info info;
if (amdgpu_query_gpu_info(ldrm_dev_, &info) < 0)
throw AMD::hsa_exception(HSA_STATUS_ERROR, "Agent creation failed.\nlibdrm query failed.\n");
// Reported by libdrm in KHz.
wallclock_frequency_ = uint64_t(info.gpu_counter_freq) * 1000ull;
}
// Reported by libdrm in KHz.
wallclock_frequency_ = uint64_t(info.gpu_counter_freq) * 1000ull;
#endif
auto& firstCpu = core::Runtime::runtime_singleton_->cpu_agents()[0];
@@ -425,6 +425,9 @@ bool Load() {
if (core::Runtime::runtime_singleton_->AgentDrivers().empty()) return false;
for (auto& d : core::Runtime::runtime_singleton_->AgentDrivers()) {
bool is_model_enabled = false;
d->IsModelEnabled(&is_model_enabled);
if (is_model_enabled) continue;
if (!InitializeDriver(d)) return false;
}