From c3142d6b6dfb3e20e0f658229b730e4fba04f80c Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Thu, 8 Oct 2020 15:33:43 -0500 Subject: [PATCH] Initialize intercept queue packets properly. Change-Id: I0ff1540940665409a9ade3a517dd576a8f334c7b [ROCm/ROCR-Runtime commit: 9192dfe1b0f585d7a5251c6fa4ee6bf790d3bf33] --- .../runtime/hsa-runtime/core/runtime/intercept_queue.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/intercept_queue.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/intercept_queue.cpp index 3ad278920c..766bd15843 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/intercept_queue.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/intercept_queue.cpp @@ -79,6 +79,12 @@ InterceptQueue::InterceptQueue(std::unique_ptr queue) buffer_ = SharedArray(wrapped->amd_queue_.hsa_queue.size); amd_queue_.hsa_queue.base_address = reinterpret_cast(&buffer_[0]); + // Fill the ring buffer with invalid packet headers. + // Leave packet content uninitialized to help trigger application errors. + for (uint32_t pkt_id = 0; pkt_id < wrapped->amd_queue_.hsa_queue.size; ++pkt_id) { + buffer_[pkt_id].dispatch.header = HSA_PACKET_TYPE_INVALID; + } + // Match the queue's signal ABI block to async_doorbell_'s // This allows us to use the queue's signal ABI block from devices to trigger async_doorbell while // host side use jumps directly to the queue's signal implementation.