SWDEV-494409 - Fix destructor path for Static and Dynamic CO

1) For Dynamic CO variables, free the device pointer in
   DynCO destructor instead of DeviceVar destructor.
2) For Static CO Remove Fatbinary,
   only call hipFree for valid device Vars instead of all devices.

Change-Id: I84291f5371b2c05d1d0bcdb4f9c6bd122e7c9b21


[ROCm/clr commit: a2d8199402]
Этот коммит содержится в:
Rahul Manocha authored and Rahul Manocha committed 2024-11-19 13:04:44 -05:00
1 родитель ca8ca0bc35
Коммит ee20409853
3 files changed
+32 -4

No files matched your search

+19 -4
Просмотреть файл
@@ -965,6 +965,19 @@ DynCO::~DynCO() {
hipError_t err = ihipFree(elem.second->getManagedVarPtr());
assert(err == hipSuccess);
}
if (elem.second->getVarKind() == Var::DVK_Variable) {
for (auto dev : g_devices) {
DeviceVar* dvar = nullptr;
hipError_t err = elem.second->getDeviceVarPtr(&dvar, dev->deviceId());
assert(err == hipSuccess);
if (dvar != nullptr) {
// free also deletes the device ptr
err = ihipFree(dvar->device_ptr());
assert(err == hipSuccess);
}
}
}
delete elem.second;
}
vars_.clear();
@@ -1179,10 +1192,12 @@ hipError_t StatCO::removeFatBinary(FatBinaryInfo** module) {
hipError_t err;
for (auto dev : g_devices) {
DeviceVar* dvar = nullptr;
IHIP_RETURN_ONFAIL((*it)->getStatDeviceVar(&dvar, dev->deviceId()));
// free also deletes the device ptr
err = ihipFree(dvar->device_ptr());
assert(err == hipSuccess);
IHIP_RETURN_ONFAIL((*it)->getDeviceVarPtr(&dvar, dev->deviceId()));
if (dvar != nullptr) {
// free also deletes the device ptr
err = ihipFree(dvar->device_ptr());
assert(err == hipSuccess);
}
}
err = ihipFree(*(static_cast<void**>((*it)->getManagedVarPtr())));
assert(err == hipSuccess);