rocr/aie: Throw exception for malformed packets and packet submission errors (#2528)
此提交包含在:
@@ -54,6 +54,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "core/inc/amd_xdna_driver.h"
|
#include "core/inc/amd_xdna_driver.h"
|
||||||
@@ -73,8 +74,7 @@ AieAqlQueue::AieAqlQueue(core::SharedQueue* shared_queue, AieAgent* agent, size_
|
|||||||
agent_(*agent),
|
agent_(*agent),
|
||||||
active_(false) {
|
active_(false) {
|
||||||
if (agent_.device_type() != core::Agent::DeviceType::kAmdAieDevice) {
|
if (agent_.device_type() != core::Agent::DeviceType::kAmdAieDevice) {
|
||||||
throw AMD::hsa_exception(
|
throw hsa_exception(HSA_STATUS_ERROR_INVALID_AGENT,
|
||||||
HSA_STATUS_ERROR_INVALID_AGENT,
|
|
||||||
"Attempting to create an AIE queue on a non-AIE agent.");
|
"Attempting to create an AIE queue on a non-AIE agent.");
|
||||||
}
|
}
|
||||||
queue_size_bytes_ = req_size_pkts * sizeof(core::AqlPacket);
|
queue_size_bytes_ = req_size_pkts * sizeof(core::AqlPacket);
|
||||||
@@ -82,8 +82,7 @@ AieAqlQueue::AieAqlQueue(core::SharedQueue* shared_queue, AieAgent* agent, size_
|
|||||||
core::MemoryRegion::AllocateNoFlags);
|
core::MemoryRegion::AllocateNoFlags);
|
||||||
|
|
||||||
if (!ring_buf_) {
|
if (!ring_buf_) {
|
||||||
throw AMD::hsa_exception(
|
throw hsa_exception(HSA_STATUS_ERROR_INVALID_QUEUE_CREATION,
|
||||||
HSA_STATUS_ERROR_INVALID_QUEUE_CREATION,
|
|
||||||
"Could not allocate a ring buffer for an AIE queue.");
|
"Could not allocate a ring buffer for an AIE queue.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +106,7 @@ AieAqlQueue::AieAqlQueue(core::SharedQueue* shared_queue, AieAgent* agent, size_
|
|||||||
agent_.driver().CreateQueue(node_id, HSA_QUEUE_COMPUTE_AQL, 0, rocr::HSA::HSA_AMD_QUEUE_PRIORITY_NORMAL, 0,
|
agent_.driver().CreateQueue(node_id, HSA_QUEUE_COMPUTE_AQL, 0, rocr::HSA::HSA_AMD_QUEUE_PRIORITY_NORMAL, 0,
|
||||||
nullptr, queue_size_bytes_, nullptr, queue_resource);
|
nullptr, queue_size_bytes_, nullptr, queue_resource);
|
||||||
if (status != HSA_STATUS_SUCCESS) {
|
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;
|
queue_id_ = queue_resource.QueueId;
|
||||||
@@ -226,7 +225,7 @@ void AieAqlQueue::SubmitPackets() {
|
|||||||
// Get the packet header information
|
// Get the packet header information
|
||||||
if (pkt->header.header != HSA_PACKET_TYPE_VENDOR_SPECIFIC ||
|
if (pkt->header.header != HSA_PACKET_TYPE_VENDOR_SPECIFIC ||
|
||||||
pkt->header.AmdFormat != HSA_AMD_PACKET_TYPE_AIE_ERT) {
|
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
|
// Get the payload information
|
||||||
@@ -248,7 +247,7 @@ void AieAqlQueue::SubmitPackets() {
|
|||||||
hsa_status_t status = driver.SubmitCmdChain(pkt, num_cont_start_cu_pkts, queue_id_,
|
hsa_status_t status = driver.SubmitCmdChain(pkt, num_cont_start_cu_pkts, queue_id_,
|
||||||
agent_.properties().NumNeuralCores);
|
agent_.properties().NumNeuralCores);
|
||||||
if (status != HSA_STATUS_SUCCESS) {
|
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;
|
cur_id += num_cont_start_cu_pkts;
|
||||||
|
|||||||
新增問題並參考
封鎖使用者