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) {