From 76c28f38c452aa61313980c3b6853b4ebdb320a1 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Sat, 4 Nov 2017 04:09:20 -0500 Subject: [PATCH] Fix bad casts in tools. Also virtualize queue profiling enable. Change-Id: I761b41269be3df7eb64a5914ee9951ed6b51bb04 [ROCm/ROCR-Runtime commit: 6455a69b03f7009d225ef5fb34939ad3538d9e3c] --- .../runtime/hsa-runtime/core/inc/amd_gpu_agent.h | 2 +- .../runtime/hsa-runtime/core/inc/intercept_queue.h | 1 + projects/rocr-runtime/runtime/hsa-runtime/core/inc/queue.h | 5 +++++ .../runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp | 4 +--- .../runtime/hsa-runtime/core/runtime/intercept_queue.cpp | 1 + 5 files changed, 9 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 6e9ef909a3..58a70a2cb9 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 @@ -297,7 +297,7 @@ class GpuAgent : public GpuAgentInt { return regions_; } - // @brief OVerride from core::Agent. + // @brief Override from core::Agent. const core::Isa* isa() const override { return isa_; } // @brief Override from amd::GpuAgentInt. diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/intercept_queue.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/intercept_queue.h index 762e888135..82ec222fe4 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/intercept_queue.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/intercept_queue.h @@ -116,6 +116,7 @@ class QueueWrapper : public Queue { void ExecutePM4(uint32_t* cmd_data, size_t cmd_size_b) override { wrapped->ExecutePM4(cmd_data, cmd_size_b); } + void SetProfiling(bool enabled) override { wrapped->SetProfiling(enabled); } protected: void do_set_public_handle(hsa_queue_t* handle) { diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/queue.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/queue.h index 98824ed5d4..d5fc232095 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/queue.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/queue.h @@ -294,6 +294,11 @@ class Queue : public Checked<0xFA3906A679F9DB49>, private LocalQueue { // @brief Submits a block of PM4 and waits until it has been executed. virtual void ExecutePM4(uint32_t* cmd_data, size_t cmd_size_b) = 0; + virtual void SetProfiling(bool enabled) { + AMD_HSA_BITS_SET(amd_queue_.queue_properties, AMD_QUEUE_PROPERTIES_ENABLE_PROFILING, + (enabled != 0)); + } + /// @ brief Reports async queue errors to stderr if no other error handler was registered. static void DefaultErrorHandler(hsa_status_t status, hsa_queue_t* source, void* data); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp index 7e8458f295..f13e06b727 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp @@ -266,11 +266,9 @@ hsa_status_t hsa_amd_profiling_set_profiler_enabled(hsa_queue_t* queue, int enab IS_OPEN(); core::Queue* cmd_queue = core::Queue::Convert(queue); - IS_VALID(cmd_queue); - AMD_HSA_BITS_SET(cmd_queue->amd_queue_.queue_properties, - AMD_QUEUE_PROPERTIES_ENABLE_PROFILING, (enable != 0)); + cmd_queue->SetProfiling(enable); return HSA_STATUS_SUCCESS; CATCH; 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 707effdad4..0beaddab0d 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 @@ -235,6 +235,7 @@ void InterceptQueue::StoreRelaxed(hsa_signal_value_t value) { next_packet_ = i; Cursor.queue = nullptr; + atomic::Store(&amd_queue_.read_dispatch_id, next_packet_, std::memory_order_release); } } // namespace core