Add hsa_amd_queue_set_priority extension function

Controls dispatch and wavefront scheduling arbitration across quees.

Change-Id: I498f4898b544f79b8fb8514bf7e789ca9da29462
Этот коммит содержится в:
Jay Cornwall committed 2018-06-19 19:41:28 -05:00
1 родитель 6df6ef778d
Коммит e388a23344
12 files changed
+111 -4

No files matched your search

+16 -4
Просмотреть файл
@@ -93,7 +93,9 @@ AqlQueue::AqlQueue(GpuAgent* agent, size_t req_size_pkts, HSAuint32 node_id, Scr
is_kv_queue_(is_kv),
pm4_ib_buf_(nullptr),
pm4_ib_size_b_(0x1000),
dynamicScratchState(0) {
dynamicScratchState(0),
suspended_(false),
priority_(HSA_QUEUE_PRIORITY_NORMAL) {
// When queue_full_workaround_ is set to 1, the ring buffer is internally
// doubled in size. Virtual addresses in the upper half of the ring allocation
// are mapped to the same set of pages backing the lower half.
@@ -150,8 +152,7 @@ AqlQueue::AqlQueue(GpuAgent* agent, size_t req_size_pkts, HSAuint32 node_id, Scr
}
HSAKMT_STATUS kmt_status;
kmt_status = hsaKmtCreateQueue(node_id, HSA_QUEUE_COMPUTE_AQL, 100,
HSA_QUEUE_PRIORITY_NORMAL, ring_buf_,
kmt_status = hsaKmtCreateQueue(node_id, HSA_QUEUE_COMPUTE_AQL, 100, priority_, ring_buf_,
ring_buf_alloc_bytes_, NULL, &queue_rsrc);
if (kmt_status != HSAKMT_STATUS_SUCCESS)
throw AMD::hsa_exception(HSA_STATUS_ERROR_OUT_OF_RESOURCES,
@@ -686,7 +687,8 @@ int AqlQueue::CreateRingBufferFD(const char* ring_buf_shm_path,
}
void AqlQueue::Suspend() {
auto err = hsaKmtUpdateQueue(queue_id_, 0, HSA_QUEUE_PRIORITY_NORMAL, NULL, 0, NULL);
suspended_ = true;
auto err = hsaKmtUpdateQueue(queue_id_, 0, priority_, NULL, 0, NULL);
assert(err == HSAKMT_STATUS_SUCCESS && "hsaKmtUpdateQueue failed.");
}
@@ -700,6 +702,16 @@ hsa_status_t AqlQueue::Inactivate() {
return HSA_STATUS_SUCCESS;
}
hsa_status_t AqlQueue::SetPriority(HSA_QUEUE_PRIORITY priority) {
if (suspended_) {
return HSA_STATUS_ERROR_INVALID_QUEUE;
}
priority_ = priority;
auto err = hsaKmtUpdateQueue(queue_id_, 100, priority_, ring_buf_, ring_buf_alloc_bytes_, NULL);
return (err == HSAKMT_STATUS_SUCCESS ? HSA_STATUS_SUCCESS : HSA_STATUS_ERROR_OUT_OF_RESOURCES);
}
bool AqlQueue::DynamicScratchHandler(hsa_signal_value_t error_code, void* arg) {
AqlQueue* queue = (AqlQueue*)arg;
hsa_status_t errorCode = HSA_STATUS_SUCCESS;
+1
Просмотреть файл
@@ -380,6 +380,7 @@ void HsaApiTable::UpdateAmdExts() {
amd_ext_api.hsa_amd_register_system_event_handler_fn = AMD::hsa_amd_register_system_event_handler;
amd_ext_api.hsa_amd_queue_intercept_create_fn = AMD::hsa_amd_queue_intercept_create;
amd_ext_api.hsa_amd_queue_intercept_register_fn = AMD::hsa_amd_queue_intercept_register;
amd_ext_api.hsa_amd_queue_set_priority_fn = AMD::hsa_amd_queue_set_priority;
}
class Init {
+25
Просмотреть файл
@@ -46,6 +46,7 @@
#include <set>
#include <utility>
#include <memory>
#include <map>
#include "core/inc/runtime.h"
#include "core/inc/agent.h"
@@ -852,4 +853,28 @@ hsa_status_t hsa_amd_register_system_event_handler(hsa_amd_system_event_callback
CATCH;
}
hsa_status_t HSA_API hsa_amd_queue_set_priority(hsa_queue_t* queue,
hsa_amd_queue_priority_t priority) {
TRY;
IS_OPEN();
IS_BAD_PTR(queue);
core::Queue* cmd_queue = core::Queue::Convert(queue);
IS_VALID(cmd_queue);
static std::map<hsa_amd_queue_priority_t, HSA_QUEUE_PRIORITY> ext_kmt_priomap = {
{HSA_AMD_QUEUE_PRIORITY_LOW, HSA_QUEUE_PRIORITY_MINIMUM},
{HSA_AMD_QUEUE_PRIORITY_NORMAL, HSA_QUEUE_PRIORITY_NORMAL},
{HSA_AMD_QUEUE_PRIORITY_HIGH, HSA_QUEUE_PRIORITY_MAXIMUM},
};
auto priority_it = ext_kmt_priomap.find(priority);
if (priority_it == ext_kmt_priomap.end()) {
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
}
return cmd_queue->SetPriority(priority_it->second);
CATCH;
}
} // end of AMD namespace