Adding queue information queries

New hsa_amd_queue_get_info API to support:

- HSA_AMD_QUEUE_INFO_AGENT: Agent that owns the underlying HW queue

- HSA_AMD_QUEUE_INFO_DOORBELL_ID: KFD doorbell ID of the queue
completion signal.

Change-Id: I98842131bcbdd08552649791a5d43e578a615808
This commit is contained in:
David Yat Sin
2023-12-08 00:14:12 +00:00
parent 3443fdf665
commit d6d5786051
14 changed files with 90 additions and 4 deletions
@@ -535,6 +535,25 @@ void AqlQueue::StoreRelease(hsa_signal_value_t value) {
StoreRelaxed(value);
}
hsa_status_t AqlQueue::GetInfo(hsa_queue_info_attribute_t attribute, void* value) {
switch (attribute) {
case HSA_AMD_QUEUE_INFO_AGENT:
*(reinterpret_cast<hsa_agent_t*>(value)) = agent_->public_handle();
break;
case HSA_AMD_QUEUE_INFO_DOORBELL_ID:
if (doorbell_type_ == 2)
// Hardware doorbell supports AQL semantics.
*(reinterpret_cast<uint64_t*>(value)) =
reinterpret_cast<uint64_t>(signal_.hardware_doorbell_ptr);
else
return HSA_STATUS_ERROR_INVALID_QUEUE;
break;
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
}
return HSA_STATUS_SUCCESS;
}
uint32_t AqlQueue::ComputeRingBufferMinPkts() {
// From CP_HQD_PQ_CONTROL.QUEUE_SIZE specification:
// Size of the primary queue (PQ) will be: 2^(HQD_QUEUE_SIZE+1) DWs.
@@ -80,7 +80,7 @@ void HsaApiTable::Init() {
// they can add preprocessor macros on the new functions
constexpr size_t expected_core_api_table_size = 1016;
constexpr size_t expected_amd_ext_table_size = 560;
constexpr size_t expected_amd_ext_table_size = 568;
constexpr size_t expected_image_ext_table_size = 120;
constexpr size_t expected_finalizer_ext_table_size = 64;
constexpr size_t expected_tools_table_size = 64;
@@ -464,6 +464,7 @@ void HsaApiTable::UpdateAmdExts() {
amd_ext_api.hsa_amd_vmem_get_alloc_properties_from_handle_fn =
AMD::hsa_amd_vmem_get_alloc_properties_from_handle;
amd_ext_api.hsa_amd_agent_set_async_scratch_limit_fn = AMD::hsa_amd_agent_set_async_scratch_limit;
amd_ext_api.hsa_amd_queue_get_info_fn = AMD::hsa_amd_queue_get_info;
}
void HsaApiTable::UpdateTools() {
@@ -1388,5 +1388,17 @@ hsa_status_t HSA_API hsa_amd_agent_set_async_scratch_limit(hsa_agent_t _agent, s
CATCH;
}
hsa_status_t HSA_API hsa_amd_queue_get_info(hsa_queue_t* _queue,
hsa_queue_info_attribute_t attribute, void* value) {
TRY;
IS_OPEN();
core::Queue* queue = core::Queue::Convert(_queue);
IS_VALID(queue);
return queue->GetInfo(attribute, value);
CATCH;
}
} // namespace amd
} // namespace rocr
@@ -41,6 +41,7 @@
////////////////////////////////////////////////////////////////////////////////
#include "core/inc/intercept_queue.h"
#include "core/inc/amd_aql_queue.h"
#include "core/util/utils.h"
#include "inc/hsa_api_trace.h"
@@ -386,5 +387,18 @@ void InterceptQueue::StoreRelaxed(hsa_signal_value_t value) {
atomic::Store(&amd_queue_.read_dispatch_id, next_packet_, std::memory_order_release);
}
hsa_status_t InterceptQueue::GetInfo(hsa_queue_info_attribute_t attribute, void* value) {
switch (attribute) {
case HSA_AMD_QUEUE_INFO_AGENT:
case HSA_AMD_QUEUE_INFO_DOORBELL_ID: {
if (!AMD::AqlQueue::IsType(wrapped.get())) return HSA_STATUS_ERROR_INVALID_QUEUE;
AMD::AqlQueue* aqlQueue = static_cast<AMD::AqlQueue*>(wrapped.get());
return aqlQueue->GetInfo(attribute, value);
}
}
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
}
} // namespace core
} // namespace rocr