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:
committed by
Stratton, Jordan
parent
9e8859636e
commit
938b34da24
@@ -520,5 +520,14 @@ bool KfdDriver::BindXnackMode() {
|
||||
return (mode != Flag::XNACK_DISABLE);
|
||||
}
|
||||
|
||||
hsa_status_t KfdDriver::IsModelEnabled(bool* enable) const {
|
||||
// AIE does not support streaming performance monitor.
|
||||
HSAKMT_STATUS status = HSAKMT_STATUS_ERROR;
|
||||
status = hsaKmtModelEnabled(enable);
|
||||
if (status != HSAKMT_STATUS_SUCCESS) {
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace AMD
|
||||
} // namespace rocr
|
||||
|
||||
@@ -688,5 +688,11 @@ hsa_status_t XdnaDriver::SPMSetDestBuffer(uint32_t preferred_node_id, uint32_t s
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
|
||||
hsa_status_t XdnaDriver::IsModelEnabled(bool* enable) const {
|
||||
// AIE does not support streaming performance monitor.
|
||||
*enable = false;
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace AMD
|
||||
} // namespace rocr
|
||||
|
||||
@@ -115,6 +115,8 @@ public:
|
||||
uint32_t* size_copied, void* dest_mem_addr,
|
||||
bool* is_spm_data_loss) const override;
|
||||
|
||||
hsa_status_t IsModelEnabled(bool* enable) const override;
|
||||
|
||||
private:
|
||||
/// @brief Allocate agent accessible memory (system / local memory).
|
||||
static void *AllocateKfdMemory(const HsaMemFlags &flags, uint32_t node_id,
|
||||
|
||||
@@ -184,6 +184,8 @@ public:
|
||||
uint32_t* size_copied, void* dest_mem_addr,
|
||||
bool* is_spm_data_loss) const override;
|
||||
|
||||
hsa_status_t IsModelEnabled(bool* enable) const override;
|
||||
|
||||
private:
|
||||
hsa_status_t QueryDriverVersion();
|
||||
/// @brief Allocate device accesible heap space.
|
||||
|
||||
@@ -211,6 +211,10 @@ public:
|
||||
uint32_t* timeout, uint32_t* size_copied,
|
||||
void* dest_mem_addr, bool* is_spm_data_loss) const = 0;
|
||||
|
||||
/// @brief Check if the HSA KMT Model is enabled
|
||||
/// @param[out] enable True if the model is enabled, false otherwise
|
||||
virtual hsa_status_t IsModelEnabled(bool* enable) const = 0;
|
||||
|
||||
/// Unique identifier for supported kernel-mode drivers.
|
||||
const DriverType kernel_driver_type_;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user