From 6de1c81b7186beeb8ae2a6d4629a5ff4553aa3b4 Mon Sep 17 00:00:00 2001 From: Alysa Liu Date: Thu, 29 May 2025 10:30:05 -0400 Subject: [PATCH] rocr: Fix inefficient copy operations Refactor variable assignments to use std::move() where appropriate. Updat function headers to accept parameters by const& where appropriate. Signed-off-by: Alysa Liu [ROCm/ROCR-Runtime commit: f6c8cbd293e5b32446a83e7909277b2aa15c857c] --- .../runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp | 5 ++--- .../runtime/hsa-runtime/core/inc/amd_kfd_driver.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp index 3d6a4c872f..1c05d95f5e 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp @@ -83,7 +83,7 @@ __forceinline uint64_t drm_perm(hsa_access_permission_t perm) { } // namespace -KfdDriver::KfdDriver(std::string& devnode_name) +KfdDriver::KfdDriver(std::string devnode_name) : core::Driver(core::DriverType::KFD, std::move(devnode_name)) {} hsa_status_t KfdDriver::Init() { @@ -128,8 +128,7 @@ hsa_status_t KfdDriver::ShutDown() { } hsa_status_t KfdDriver::DiscoverDriver(std::unique_ptr& driver) { - std::string devnode("/dev/kfd"); - auto tmp_driver = std::unique_ptr(new KfdDriver(devnode)); + auto tmp_driver = std::unique_ptr(new KfdDriver("/dev/kfd")); if (tmp_driver->Open() == HSA_STATUS_SUCCESS) { driver = std::move(tmp_driver); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_kfd_driver.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_kfd_driver.h index 07e3f5f1e6..4579b6e8b0 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_kfd_driver.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_kfd_driver.h @@ -69,7 +69,7 @@ namespace AMD { /// and more. class KfdDriver final : public core::Driver { public: - KfdDriver(std::string& devnode_name); + KfdDriver(std::string devnode_name); /// @brief Determine of the KFD is present on the system and attemp to open it if found. ///