rocr: Remove KMT usage from AMD ext

Use the core Driver in AMD's HSA extension API to make it
agnostic to the underlying OS and kernel-mode driver.


[ROCm/ROCR-Runtime commit: d3a4dc9687]
This commit is contained in:
Tony Gutierrez
2025-02-05 15:24:04 -08:00
committed by Yat Sin, David
parent b42578b070
commit 3b30b8a975
7 changed files with 79 additions and 13 deletions
@@ -301,7 +301,7 @@ class Agent : public Checked<0xF6BC25EB17E6F917> {
__forceinline uint32_t node_id() const { return node_id_; }
// @brief Returns the driver associated with this agent.
__forceinline Driver &driver() { return *driver_; }
__forceinline Driver& driver() const { return *driver_; }
// @brief Getter for profiling_enabled_.
__forceinline bool profiling_enabled() const { return profiling_enabled_; }
@@ -109,7 +109,13 @@ public:
size_t size) override;
hsa_status_t ReleaseShareableHandle(core::ShareableHandle &handle) override;
private:
hsa_status_t SPMAcquire(uint32_t preferred_node_id) const override;
hsa_status_t SPMRelease(uint32_t preferred_node_id) const override;
hsa_status_t SPMSetDestBuffer(uint32_t preferred_node_id, uint32_t size_bytes, uint32_t* timeout,
uint32_t* size_copied, void* dest_mem_addr,
bool* is_spm_data_loss) const override;
private:
/// @brief Allocate agent accessible memory (system / local memory).
static void *AllocateKfdMemory(const HsaMemFlags &flags, uint32_t node_id,
size_t size);
@@ -174,10 +174,16 @@ public:
size_t size) override;
hsa_status_t ReleaseShareableHandle(core::ShareableHandle &handle) override;
// @brief Submits num_pkts packets in a command chain to the XDNA driver
/// @brief Submits num_pkts packets in a command chain to the XDNA driver
hsa_status_t SubmitCmdChain(hsa_amd_aie_ert_packet_t* first_pkt, uint32_t num_pkts,
uint32_t num_operands, uint32_t hw_ctx_handle);
hsa_status_t SPMAcquire(uint32_t preferred_node_id) const override;
hsa_status_t SPMRelease(uint32_t preferred_node_id) const override;
hsa_status_t SPMSetDestBuffer(uint32_t preferred_node_id, uint32_t size_bytes, uint32_t* timeout,
uint32_t* size_copied, void* dest_mem_addr,
bool* is_spm_data_loss) const override;
private:
hsa_status_t QueryDriverVersion();
/// @brief Allocate device accesible heap space.
@@ -193,6 +193,24 @@ public:
virtual hsa_status_t
ReleaseShareableHandle(core::ShareableHandle &handle) = 0;
/// @brief Acquire a streaming performance monitor on an agent.
/// @param[in] preferred_node_id Node ID of the preferred agent.
virtual hsa_status_t SPMAcquire(uint32_t preferred_node_id) const = 0;
/// @brief Release a streaming performance monitor on an agent.
/// @param[in] preferred_node_id Node ID of the preferred agent.
virtual hsa_status_t SPMRelease(uint32_t preferred_node_id) const = 0;
/// @brief Setup the destination user-mode buffer for streaming performance monitor data.
/// @param[in] preferred_node_id Node ID of the preferred agent.
/// @param[in] size_bytes Size of the destination buffer in bytes.
/// @param[in, out] timeout Timeout in milliseconds.
/// @param[out] size_copied Size of data copied in bytes.
/// @param[in] dest_mem_addr Destination address for streaming performance data. Set to NULL to
/// stop copy on previous buffer.
/// @param[out] is_spm_data_loss Data was lost if true.
virtual hsa_status_t SPMSetDestBuffer(uint32_t preferred_node_id, uint32_t size_bytes,
uint32_t* timeout, uint32_t* size_copied,
void* dest_mem_addr, bool* is_spm_data_loss) const = 0;
/// Unique identifier for supported kernel-mode drivers.
const DriverType kernel_driver_type_;