From bdf4b84f82e7b0e864aaa06010a438fbe63a3f3c Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Thu, 18 Apr 2019 19:59:16 -0500 Subject: [PATCH] Don't create blits when copy profiling is enabled. Change-Id: I879827133957ee610c3381ea30c536ec7d10ffab [ROCm/ROCR-Runtime commit: 1251842900e5927a615a66bd0d286328eb25ec94] --- .../hsa-runtime/core/runtime/amd_gpu_agent.cpp | 2 +- .../hsa-runtime/core/runtime/hsa_ext_amd.cpp | 13 +++++++------ .../runtime/hsa-runtime/core/util/lazy_ptr.h | 5 ++++- 3 files changed, 12 insertions(+), 8 deletions(-) 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 d3dc21cc87..245bc4d64a 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 @@ -676,7 +676,7 @@ hsa_status_t GpuAgent::EnableDmaProfiling(bool enable) { } for (int i = 0; i < BlitCount; ++i) { - if (blits_[i] != NULL) { + if (blits_[i].created()) { const hsa_status_t stat = blits_[i]->EnableProfiling(enable); if (stat != HSA_STATUS_SUCCESS) { return stat; 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 b4fd546431..d804d81558 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 @@ -328,12 +328,13 @@ hsa_status_t hsa_amd_profiling_async_copy_enable(bool enable) { TRY; IS_OPEN(); - return core::Runtime::runtime_singleton_->IterateAgent( - [](hsa_agent_t agent_handle, void* data) -> hsa_status_t { - const bool enable = *(reinterpret_cast(data)); - return core::Agent::Convert(agent_handle)->profiling_enabled(enable); - }, - reinterpret_cast(&enable)); + hsa_status_t ret = HSA_STATUS_SUCCESS; + for (core::Agent* agent : core::Runtime::runtime_singleton_->gpu_agents()) { + hsa_status_t err = agent->profiling_enabled(enable); + if (err != HSA_STATUS_SUCCESS) ret = err; + } + return ret; + CATCH; } diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/util/lazy_ptr.h b/projects/rocr-runtime/runtime/hsa-runtime/core/util/lazy_ptr.h index 7837200d89..3e00b74db3 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/util/lazy_ptr.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/util/lazy_ptr.h @@ -88,10 +88,13 @@ template class lazy_ptr { /* * Ensures that the object is created or is being created. - * This is useful when early consruction of the object is required. + * This is useful when early construction of the object is required. */ void touch() const { make(false); } + // Tells if the lazy object has been constructed or not. + bool created() const { return obj != nullptr; } + private: mutable std::unique_ptr obj; mutable std::function func;