From 5a767619601de7db6602d8fdd2f931dbbf5f8452 Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Wed, 8 Jan 2025 15:54:51 -0500 Subject: [PATCH] SWDEV-507019 - Change the function lock to the module lock Multiple functions can be located in the same module. Change-Id: Ia4ca3db64fe5b0822584059d3770c91103665c63 [ROCm/clr commit: 45a12208b652d5e476411f5f00facc47de35d062] --- projects/clr/hipamd/src/hip_fatbin.hpp | 4 ++++ projects/clr/hipamd/src/hip_global.cpp | 2 +- projects/clr/hipamd/src/hip_global.hpp | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/projects/clr/hipamd/src/hip_fatbin.hpp b/projects/clr/hipamd/src/hip_fatbin.hpp index fc1e9b3d1b..ea0ab74aea 100644 --- a/projects/clr/hipamd/src/hip_fatbin.hpp +++ b/projects/clr/hipamd/src/hip_fatbin.hpp @@ -109,6 +109,9 @@ public: return hipSuccess; } + //! Returns the lock for this fatbinary access + amd::Monitor& FatBinaryLock() { return fb_lock_; } + private: std::string fname_; //!< File name amd::Os::FileDesc fdesc_; //!< File descriptor @@ -126,6 +129,7 @@ private: std::vector fatbin_dev_info_; std::shared_ptr ufd_; //!< Unique file descriptor + amd::Monitor fb_lock_{true}; //!< Lock for the fat binary access }; }; // namespace hip diff --git a/projects/clr/hipamd/src/hip_global.cpp b/projects/clr/hipamd/src/hip_global.cpp index 67f007efc0..daa0a0eb41 100644 --- a/projects/clr/hipamd/src/hip_global.cpp +++ b/projects/clr/hipamd/src/hip_global.cpp @@ -162,7 +162,7 @@ hipError_t Function::getStatFunc(hipFunction_t* hfunc, int deviceId) { *hfunc = dFunc_[deviceId]->asHipFunction(); return hipSuccess; } - amd::ScopedLock lock(fc_lock_); + amd::ScopedLock lock((*modules_)->FatBinaryLock()); // Check for the compiled kernel again, to make sure only one thread does compilation if (dFunc_[deviceId] != nullptr) { *hfunc = dFunc_[deviceId]->asHipFunction(); diff --git a/projects/clr/hipamd/src/hip_global.hpp b/projects/clr/hipamd/src/hip_global.hpp index 65ecff6640..dc8fb94132 100644 --- a/projects/clr/hipamd/src/hip_global.hpp +++ b/projects/clr/hipamd/src/hip_global.hpp @@ -96,7 +96,6 @@ private: std::vector dFunc_; //!< DeviceFuncObj per Device std::string name_; //!< name of the func(not unique identifier) FatBinaryInfo** modules_; //!< static module where it is referenced - amd::Monitor fc_lock_{true}; //!< Lock for the function create }; class Var {