From 924e11ba7f1ed4d95736f68c307617a6f4fe0fc5 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Thu, 5 Sep 2024 17:50:49 +0000 Subject: [PATCH] rocr: Increase queue size for co-op queues Increase queue-size for co-op queues to 16K to improve performance on some workloads Change-Id: I4d3bf0ecbd30ebb648b68d9c5fdabadc670a386c --- runtime/hsa-runtime/core/inc/amd_gpu_agent.h | 9 ++++----- runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 10 +++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/runtime/hsa-runtime/core/inc/amd_gpu_agent.h b/runtime/hsa-runtime/core/inc/amd_gpu_agent.h index 7f2f965177..608017c114 100644 --- a/runtime/hsa-runtime/core/inc/amd_gpu_agent.h +++ b/runtime/hsa-runtime/core/inc/amd_gpu_agent.h @@ -464,15 +464,14 @@ class GpuAgent : public GpuAgentInt { static const uint32_t maxAqlSize_ = 0x20000; // 8MB max // @brief Create an internal queue allowing tools to be notified. - core::Queue* CreateInterceptibleQueue() { - return CreateInterceptibleQueue(core::Queue::DefaultErrorHandler, nullptr); + core::Queue* CreateInterceptibleQueue(const uint32_t size = 0) { + return CreateInterceptibleQueue(core::Queue::DefaultErrorHandler, nullptr, size); } // @brief Create an internal queue, with a custom error handler, allowing tools to be // notified. - core::Queue* CreateInterceptibleQueue(void (*callback)(hsa_status_t status, hsa_queue_t* source, - void* data), - void* data); + core::Queue* CreateInterceptibleQueue(void (*callback)(hsa_status_t status, hsa_queue_t* source, void* data), + void* data, const uint32_t size); // @brief Create SDMA blit object. // diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index 496115f92d..0101553fd7 100644 --- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -716,10 +716,13 @@ hsa_status_t GpuAgent::VisitRegion( core::Queue* GpuAgent::CreateInterceptibleQueue(void (*callback)(hsa_status_t status, hsa_queue_t* source, void* data), - void* data) { + void* data, const uint32_t in_size) { // Disabled intercept of internal queues pending tools updates. core::Queue* queue = nullptr; - QueueCreate(minAqlSize_, HSA_QUEUE_TYPE_MULTI, callback, data, 0, 0, &queue); + uint32_t size = std::max(in_size, minAqlSize_); + size = std::min(size, maxAqlSize_); + + QueueCreate(size, HSA_QUEUE_TYPE_MULTI, callback, data, 0, 0, &queue); if (queue != nullptr) core::Runtime::runtime_singleton_->InternalQueueCreateNotify(core::Queue::Convert(queue), this->public_handle()); @@ -894,7 +897,8 @@ void GpuAgent::InitDma() { void GpuAgent::InitGWS() { gws_queue_.queue_.reset([this]() { if (properties_.NumGws == 0) return (core::Queue*)nullptr; - std::unique_ptr queue(CreateInterceptibleQueue()); + const uint32_t defaultGWSQueueSize = 0x4000; // 16KB + std::unique_ptr queue(CreateInterceptibleQueue(defaultGWSQueueSize)); if (queue == nullptr) throw AMD::hsa_exception(HSA_STATUS_ERROR_OUT_OF_RESOURCES, "Internal queue creation failed.");