rocr/aie: Allocate AIE queue's ring buf

Change-Id: I799a8223d695ec5c0ea2eaea012bc1b5d877e103


[ROCm/ROCR-Runtime commit: 54a459c05c]
Šī revīzija ir iekļauta:
Tony Gutierrez
2024-08-19 15:50:47 +00:00
revīziju iesūtīja David Yat Sin
vecāks 7e130369db
revīzija f58a06c656
2 mainīti faili ar 37 papildinājumiem un 41 dzēšanām
@@ -43,6 +43,8 @@
#ifndef HSA_RUNTIME_CORE_INC_AMD_HW_AQL_AIE_COMMAND_PROCESSOR_H_
#define HSA_RUNTIME_CORE_INC_AMD_HW_AQL_AIE_COMMAND_PROCESSOR_H_
#include <limits>
#include "core/inc/amd_aie_agent.h"
#include "core/inc/queue.h"
#include "core/inc/runtime.h"
@@ -114,29 +116,21 @@ public:
hsa_fence_scope_t releaseFence = HSA_FENCE_SCOPE_NONE,
hsa_signal_t *signal = NULL) override;
core::SharedQueue *shared_queue_;
core::SharedSignal *shared_signal_;
/// ID of the queue used in communication with the AMD AIR driver.
uint32_t queue_id_;
/// ID of the doorbell used in communication with the AMD AIR driver.
uint32_t doorbell_id_;
/// Pointer to the hardware doorbell for this queue.
uint64_t *hardware_doorbell_ptr_;
/// ID of AIE device on which this queue has been mapped.
uint32_t node_id_;
/// Queue size in bytes.
uint32_t queue_size_bytes_;
uint32_t queue_id_ = INVALID_QUEUEID;
/// @brief ID of AIE device on which this queue has been mapped.
uint32_t node_id_ = std::numeric_limits<uint32_t>::max();
/// @brief Queue size in bytes.
uint32_t queue_size_bytes_ = std::numeric_limits<uint32_t>::max();
protected:
bool _IsA(Queue::rtti_t id) const override { return id == &rtti_id_; }
private:
core::SharedQueue *CreateSharedQueue(AieAgent *agent, size_t req_size_pkts,
uint32_t node_id);
core::SharedSignal *CreateSharedSignal(AieAgent *agent);
AieAgent &agent_;
/// @brief Base of the queue's ring buffer storage.
void *ring_buf_ = nullptr;
/// @brief Handle for an application context on the AIE device.
///
/// Each user queue will have an associated context. This handle is assigned
@@ -147,7 +141,8 @@ private:
/// that multiple workloads with different core tile configurations can
/// execute on the AIE agent at the same time.
uint32_t hw_ctx_handle_ = std::numeric_limits<uint32_t>::max();
/// Indicates if queue is active.
/// @brief Indicates if queue is active.
std::atomic<bool> active_;
static int rtti_id_;
};
@@ -72,11 +72,32 @@ AieAqlQueue::AieAqlQueue(AieAgent *agent, size_t req_size_pkts,
uint32_t node_id)
: Queue(0, 0), LocalSignal(0, false), DoorbellSignal(signal()),
agent_(*agent), active_(false) {
amd_queue_.hsa_queue.doorbell_signal = Signal::Convert(this);
amd_queue_.hsa_queue.size = 0x40;
if (agent_.device_type() != core::Agent::DeviceType::kAmdAieDevice) {
throw AMD::hsa_exception(
HSA_STATUS_ERROR_INVALID_AGENT,
"Attempting to create an AIE queue on a non-AIE agent.");
}
queue_size_bytes_ = req_size_pkts * sizeof(core::AqlPacket);
ring_buf_ = agent_.system_allocator()(queue_size_bytes_, 4096,
core::MemoryRegion::AllocateNoFlags);
signal_.hardware_doorbell_ptr =
reinterpret_cast<volatile uint64_t *>(hardware_doorbell_ptr_);
if (!ring_buf_) {
throw AMD::hsa_exception(
HSA_STATUS_ERROR_INVALID_QUEUE_CREATION,
"Could not allocate a ring buffer for an AIE queue.");
}
// Populate hsa_queue_t fields.
amd_queue_.hsa_queue.type = HSA_QUEUE_TYPE_SINGLE;
amd_queue_.hsa_queue.id = INVALID_QUEUEID;
amd_queue_.hsa_queue.doorbell_signal = Signal::Convert(this);
amd_queue_.hsa_queue.size = req_size_pkts;
amd_queue_.hsa_queue.base_address = ring_buf_;
// Populate AMD queue fields.
amd_queue_.write_dispatch_id = 0;
amd_queue_.read_dispatch_id = 0;
signal_.hardware_doorbell_ptr = nullptr;
signal_.kind = AMD_SIGNAL_KIND_DOORBELL;
signal_.queue_ptr = &amd_queue_;
active_ = true;
@@ -200,26 +221,6 @@ hsa_status_t AieAqlQueue::GetInfo(hsa_queue_info_attribute_t attribute,
return HSA_STATUS_SUCCESS;
}
core::SharedQueue *AieAqlQueue::CreateSharedQueue(AieAgent *agent,
size_t req_size_pkts,
uint32_t node_id) {
queue_size_bytes_ = req_size_pkts * sizeof(core::AqlPacket);
if (!IsPowerOfTwo(queue_size_bytes_)) {
throw AMD::hsa_exception(
HSA_STATUS_ERROR_INVALID_QUEUE_CREATION,
"Requested queue with non-power of two packet capacity.\n");
}
node_id_ = node_id;
return nullptr;
}
core::SharedSignal *AieAqlQueue::CreateSharedSignal(AieAgent *agent) {
return nullptr;
}
hsa_status_t AieAqlQueue::GetCUMasking(uint32_t num_cu_mask_count,
uint32_t *cu_mask) {
assert(false && "AIE AQL queue does not support CU masking.");