From c03356b41adda97cf8c807df9e134be2ff8d2e69 Mon Sep 17 00:00:00 2001 From: Jaydeep Patel Date: Wed, 16 Oct 2024 09:19:25 +0000 Subject: [PATCH] SWDEV-491409 - Handle DynCO path to delete DeviceVars. Change-Id: I757185e9c7c12f236e266219b67daf5836d2a122 [ROCm/clr commit: c24bc05caceaa0fb582401ad496fc0b39d634809] --- projects/clr/hipamd/src/hip_global.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/projects/clr/hipamd/src/hip_global.cpp b/projects/clr/hipamd/src/hip_global.cpp index c6878c8574..0e5abed174 100644 --- a/projects/clr/hipamd/src/hip_global.cpp +++ b/projects/clr/hipamd/src/hip_global.cpp @@ -90,8 +90,13 @@ DeviceVar::DeviceVar(std::string name, DeviceVar::~DeviceVar() { // device_ptr_ is being removed and its amd:Memory obj is being released/deleted during - // ihipFree in hip::StatCO::removeFatBinary. - assert(amd::MemObjMap::FindMemObj(device_ptr_) == nullptr); + // ihipFree in hip::StatCO::removeFatBinary however in DynCO path, it seems to bypass + // ihipFree and hence it needs to be removed+released here. In order to avoid issue with + // StatCO, It is better to check if mem obj is found. + if (amd::MemObjMap::FindMemObj(device_ptr_) != nullptr && amd_mem_obj_ != nullptr) { + amd::MemObjMap::RemoveMemObj(device_ptr_); + amd_mem_obj_->release(); + } if (shadowVptr != nullptr) { textureReference* texRef = reinterpret_cast(shadowVptr); hipError_t err = ihipUnbindTexture(texRef);