From f100ae36794a253fe186c0ba124dabdb35d1dbfb Mon Sep 17 00:00:00 2001 From: Christophe Paquot Date: Tue, 12 May 2020 15:51:52 -0700 Subject: [PATCH] Add lock to addFatBinary and removeFatBinary In case hipModule(Un)Load is called from different thread as hipInit we need to grab the lock as both are going to modify modules_ Also add some logging for __hipExtractCodeObjectFromFatBinary in case binary isn't found for GPU SWDEV-236032 Change-Id: Icbd72b412502df80d5066cea42a4fbcd5b0b8a98 --- rocclr/hip_internal.hpp | 2 ++ rocclr/hip_platform.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rocclr/hip_internal.hpp b/rocclr/hip_internal.hpp index 643a43341b..4cc0dadd8a 100755 --- a/rocclr/hip_internal.hpp +++ b/rocclr/hip_internal.hpp @@ -212,6 +212,7 @@ public: void init(); std::vector>* addFatBinary(const void*data) { + amd::ScopedLock lock(lock_); if (initialized_) { digestFatBinary(data, modules_[data]); } @@ -219,6 +220,7 @@ public: } void removeFatBinary(std::vector>* module) { + amd::ScopedLock lock(lock_); for (auto& mod : modules_) { if (&mod.second == module) { modules_.erase(&mod); diff --git a/rocclr/hip_platform.cpp b/rocclr/hip_platform.cpp index 1378a697e0..4b94d01045 100755 --- a/rocclr/hip_platform.cpp +++ b/rocclr/hip_platform.cpp @@ -122,10 +122,12 @@ hipError_t __hipExtractCodeObjectFromFatBinary(const void* data, num_code_objs++; } } - if (num_code_objs == devices.size()) + if (num_code_objs == devices.size()) { return hipSuccess; - else + } else { + DevLogError("hipErrorNoBinaryForGpu: Coudn't find binary for current devices!"); return hipErrorNoBinaryForGpu; + } } extern "C" std::vector>* __hipRegisterFatBinary(const void* data)