From f6dcfa4246b68c96ba1f600457b1b44c73294e6d Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Thu, 5 Aug 2021 14:44:08 -0500 Subject: [PATCH] Register the default queue error handler for all internal queues. Also make failure to handle queue errors fatal. Motivation is to improve detection of queue error conditions that currently appear as application hangs. Change-Id: I655643616dc0bd303d7df3ce8aca2c099bec3d46 [ROCm/ROCR-Runtime commit: 907679c989e44057ee1c6331b30c57b4ca293296] --- .../runtime/hsa-runtime/core/inc/amd_gpu_agent.h | 12 ++++++++++-- .../hsa-runtime/core/runtime/amd_gpu_agent.cpp | 6 ++++-- .../runtime/hsa-runtime/core/runtime/queue.cpp | 1 + 3 files changed, 15 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 18ef156c39..c1b26495c4 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 @@ -332,8 +332,16 @@ class GpuAgent : public GpuAgentInt { static const uint32_t minAqlSize_ = 0x1000; // 4KB min static const uint32_t maxAqlSize_ = 0x20000; // 8MB max - // @brief Create a queue through HSA API to allow tools to intercept. - core::Queue* CreateInterceptibleQueue(); + // @brief Create an internal queue allowing tools to be notified. + core::Queue* CreateInterceptibleQueue() { + return CreateInterceptibleQueue(core::Queue::DefaultErrorHandler, nullptr); + } + + // @brief // @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); // @brief Create SDMA blit object. // 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 fe757c2446..b7cad75df0 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 @@ -533,10 +533,12 @@ hsa_status_t GpuAgent::VisitRegion( return HSA_STATUS_SUCCESS; } -core::Queue* GpuAgent::CreateInterceptibleQueue() { +core::Queue* GpuAgent::CreateInterceptibleQueue(void (*callback)(hsa_status_t status, + hsa_queue_t* source, void* data), + void* data) { // Disabled intercept of internal queues pending tools updates. core::Queue* queue = nullptr; - QueueCreate(minAqlSize_, HSA_QUEUE_TYPE_MULTI, NULL, NULL, 0, 0, &queue); + QueueCreate(minAqlSize_, HSA_QUEUE_TYPE_MULTI, callback, data, 0, 0, &queue); if (queue != nullptr) core::Runtime::runtime_singleton_->InternalQueueCreateNotify(core::Queue::Convert(queue), this->public_handle()); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/queue.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/queue.cpp index a86bbf8158..9a9bea819d 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/queue.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/queue.cpp @@ -54,6 +54,7 @@ void Queue::DefaultErrorHandler(hsa_status_t status, hsa_queue_t* source, void* const char* msg = "UNKNOWN ERROR"; HSA::hsa_status_string(status, &msg); fprintf(stderr, "Queue at %p inactivated due to async error:\n\t%s\n", source, msg); + abort(); } }