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
Этот коммит содержится в:
коммит произвёл
Rahul Manocha
родитель
e2eeb20c00
Коммит
a2d8199402
@@ -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