Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#endif

#include <atomic>
#include <cassert>
#include <cstring>

#include "core/inc/amd_xdna_driver.h"
Expand All @@ -73,18 +74,16 @@ AieAqlQueue::AieAqlQueue(core::SharedQueue* shared_queue, AieAgent* agent, size_
agent_(*agent),
active_(false) {
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.");
throw 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);

if (!ring_buf_) {
throw AMD::hsa_exception(
HSA_STATUS_ERROR_INVALID_QUEUE_CREATION,
"Could not allocate a ring buffer for an AIE queue.");
throw hsa_exception(HSA_STATUS_ERROR_INVALID_QUEUE_CREATION,
"Could not allocate a ring buffer for an AIE queue.");
}

// Populate hsa_queue_t fields.
Expand All @@ -107,7 +106,7 @@ AieAqlQueue::AieAqlQueue(core::SharedQueue* shared_queue, AieAgent* agent, size_
agent_.driver().CreateQueue(node_id, HSA_QUEUE_COMPUTE_AQL, 0, HSA_QUEUE_PRIORITY_NORMAL, 0,
nullptr, queue_size_bytes_, nullptr, queue_resource);
if (status != HSA_STATUS_SUCCESS) {
throw AMD::hsa_exception(status, "Failed to create a hardware context for an AIE queue.");
throw hsa_exception(status, "Failed to create a hardware context for an AIE queue.");
}

queue_id_ = queue_resource.QueueId;
Expand Down Expand Up @@ -226,7 +225,7 @@ void AieAqlQueue::SubmitPackets() {
// Get the packet header information
if (pkt->header.header != HSA_PACKET_TYPE_VENDOR_SPECIFIC ||
pkt->header.AmdFormat != HSA_AMD_PACKET_TYPE_AIE_ERT) {
assert(false && "Invalid packet header");
throw hsa_exception(HSA_STATUS_ERROR_INVALID_PACKET_FORMAT, "Invalid packet header");
}

// Get the payload information
Expand All @@ -248,7 +247,7 @@ void AieAqlQueue::SubmitPackets() {
hsa_status_t status = driver.SubmitCmdChain(pkt, num_cont_start_cu_pkts, queue_id_,
agent_.properties().NumNeuralCores);
if (status != HSA_STATUS_SUCCESS) {
assert(false && "Could not submit packets");
throw hsa_exception(status, "Could not submit packets");
}

cur_id += num_cont_start_cu_pkts;
Expand Down