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 {