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]
This commit is contained in:
کامیت شده توسط
Rahul Manocha
والد
ca8ca0bc35
کامیت
ee20409853
@@ -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);
|
||||
|
||||
مرجع در شماره جدید
Block a user