From 0e96cb895fd3b70f0fa78b75fa4fdc0ad2538758 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Sun, 16 Jan 2022 08:24:50 -0600 Subject: [PATCH] Correct queue minimum size enforcement. Minimum queue size was not enforced at the Agent level. Minimum size should be one page to give unifority across all asics. Change-Id: I26394f79458d09fbceb79fc8aaf495e2c26a8ff3 [ROCm/ROCR-Runtime commit: a6742209f7bdf07811d6d084e14dea6cc19374e3] --- .../runtime/hsa-runtime/core/inc/amd_gpu_agent.h | 5 +++-- .../runtime/hsa-runtime/core/runtime/amd_aql_queue.cpp | 4 ++-- .../runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_gpu_agent.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_gpu_agent.h index 8d1544987c..ed64d5be3e 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_gpu_agent.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_gpu_agent.h @@ -336,7 +336,8 @@ class GpuAgent : public GpuAgentInt { const std::function& system_deallocator() const { return system_deallocator_; } protected: - static const uint32_t minAqlSize_ = 0x1000; // 4KB min + // Sizes are in packets. + static const uint32_t minAqlSize_ = 0x40; // 4KB min static const uint32_t maxAqlSize_ = 0x20000; // 8MB max // @brief Create an internal queue allowing tools to be notified. @@ -344,7 +345,7 @@ class GpuAgent : public GpuAgentInt { return CreateInterceptibleQueue(core::Queue::DefaultErrorHandler, nullptr); } - // @brief // @brief Create an internal queue, with a custom error handler, allowing tools to be + // @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), diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_aql_queue.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_aql_queue.cpp index ac452a34e1..2981205a76 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_aql_queue.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_aql_queue.cpp @@ -671,8 +671,8 @@ void AqlQueue::AllocRegisteredRingBuffer(uint32_t queue_size_pkts) { #endif } else { // Allocate storage for the ring buffer. - ring_buf_alloc_bytes_ = AlignUp( - queue_size_pkts * sizeof(core::AqlPacket), 4096); + ring_buf_alloc_bytes_ = queue_size_pkts * sizeof(core::AqlPacket); + assert(IsMultipleOf(ring_buf_alloc_bytes_, 4096) && "Ring buffer sizes must be 4KiB aligned."); ring_buf_ = agent_->system_allocator()( ring_buf_alloc_bytes_, 0x1000, diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index 1f8b70ab9e..2230b96fcf 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -1055,6 +1055,11 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, return HSA_STATUS_ERROR_OUT_OF_RESOURCES; } + // Enforce min size + if (size < minAqlSize_) { + return HSA_STATUS_ERROR_INVALID_ARGUMENT; + } + // Allocate scratch memory ScratchInfo scratch = {0}; if (private_segment_size == UINT_MAX) {