From a6b2294b93a614082df0f77f3a31c1d2a88f5d2a Mon Sep 17 00:00:00 2001 From: Satyanvesh Dittakavi Date: Thu, 23 Dec 2021 06:09:08 +0000 Subject: [PATCH] Revert "SWDEV-304151 - Reset file descriptor after Module Load" This reverts commit 3b157b3d5f1eeb6cfd6cdb9ee2b329b867fb7718. Reason for revert: To address SWDEV-316216 Change-Id: Ib8e6ac4b87c5e52757cd8f45958f39f012823c60 --- hipamd/src/hip_code_object.cpp | 3 --- hipamd/src/hip_fatbin.cpp | 15 ++++++++++++++- hipamd/src/hip_fatbin.hpp | 18 ------------------ 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/hipamd/src/hip_code_object.cpp b/hipamd/src/hip_code_object.cpp index d36ad9e9e6..c719a68024 100644 --- a/hipamd/src/hip_code_object.cpp +++ b/hipamd/src/hip_code_object.cpp @@ -509,9 +509,6 @@ hipError_t DynCO::loadCodeObject(const char* fname, const void* image) { // Define Global functions IHIP_RETURN_ONFAIL(populateDynGlobalFuncs()); - // Resets the file info such as desc, size and name - // as they are not necessary once the code object is loaded - fb_info_->ResetFileInfo(); return hipSuccess; } diff --git a/hipamd/src/hip_fatbin.cpp b/hipamd/src/hip_fatbin.cpp index c36609730f..2c7f46973f 100644 --- a/hipamd/src/hip_fatbin.cpp +++ b/hipamd/src/hip_fatbin.cpp @@ -30,7 +30,20 @@ FatBinaryInfo::~FatBinaryInfo() { delete fbd; } - ResetFileInfo(); + if (fdesc_ > 0) { + if (fsize_ && !amd::Os::MemoryUnmapFile(image_, fsize_)) { + guarantee(false, "Cannot unmap file"); + } + if (!amd::Os::CloseFileHandle(fdesc_)) { + guarantee(false, "Cannot close file"); + } + } + + fname_ = std::string(); + fdesc_ = amd::Os::FDescInit(); + fsize_ = 0; + image_ = nullptr; + uri_ = std::string(); } hipError_t FatBinaryInfo::ExtractFatBinary(const std::vector& devices) { diff --git a/hipamd/src/hip_fatbin.hpp b/hipamd/src/hip_fatbin.hpp index 4692f4d247..219a96e802 100644 --- a/hipamd/src/hip_fatbin.hpp +++ b/hipamd/src/hip_fatbin.hpp @@ -67,24 +67,6 @@ public: return hipSuccess; } - // Resets the file information - void ResetFileInfo() { - if (fdesc_ > 0) { - if (fsize_ && !amd::Os::MemoryUnmapFile(image_, fsize_)) { - guarantee(false, "Cannot unmap file"); - } - if (!amd::Os::CloseFileHandle(fdesc_)) { - guarantee(false, "Cannot close file"); - } - } - - fname_ = std::string(); - fdesc_ = amd::Os::FDescInit(); - fsize_ = 0; - image_ = nullptr; - uri_ = std::string(); - } - private: std::string fname_; // File name amd::Os::FileDesc fdesc_; // File descriptor