Don't use global platform in cl device
Related-To: NEO-4207 Change-Id: I5e478a9aa8e0acab925cd0159db1ec36a28dd729 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
parent
6cc9b9d125
commit
c7ed76a169
|
@ -49,7 +49,8 @@ unsigned int ClDevice::getSupportedClVersion() const { return device.getSupporte
|
|||
|
||||
void ClDevice::retainApi() {
|
||||
if (device.isReleasable()) {
|
||||
platform()->getClDevice(device.getRootDeviceIndex())->incRefInternal();
|
||||
auto pPlatform = castToObject<Platform>(platformId);
|
||||
pPlatform->getClDevice(device.getRootDeviceIndex())->incRefInternal();
|
||||
this->incRefApi();
|
||||
}
|
||||
};
|
||||
|
@ -57,7 +58,8 @@ unique_ptr_if_unused<ClDevice> ClDevice::releaseApi() {
|
|||
if (!device.isReleasable()) {
|
||||
return unique_ptr_if_unused<ClDevice>(this, false);
|
||||
}
|
||||
platform()->getClDevice(device.getRootDeviceIndex())->decRefInternal();
|
||||
auto pPlatform = castToObject<Platform>(platformId);
|
||||
pPlatform->getClDevice(device.getRootDeviceIndex())->decRefInternal();
|
||||
return this->decRefApi();
|
||||
}
|
||||
|
||||
|
@ -113,5 +115,4 @@ void ClDeviceVector::toDeviceIDs(std::vector<cl_device_id> &devIDs) {
|
|||
const std::string &ClDevice::peekCompilerExtensions() const {
|
||||
return compilerExtensions;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
|
|
@ -54,25 +54,34 @@ TEST(SubDevicesTest, givenDeviceWithSubDevicesWhenSubDeviceRefcountsAreChangedTh
|
|||
DebugManager.flags.CreateMultipleSubDevices.set(2);
|
||||
VariableBackup<bool> mockDeviceFlagBackup(&MockDevice::createSingleDevice, false);
|
||||
constructPlatform()->initialize();
|
||||
auto device = platform()->getClDevice(0);
|
||||
auto nonDefaultPlatform = std::make_unique<Platform>();
|
||||
nonDefaultPlatform->initialize();
|
||||
auto device = nonDefaultPlatform->getClDevice(0);
|
||||
auto defaultDevice = platform()->getClDevice(0);
|
||||
|
||||
auto subDevice = device->getDeviceById(1);
|
||||
auto baseDeviceApiRefCount = device->getRefApiCount();
|
||||
auto baseDeviceInternalRefCount = device->getRefInternalCount();
|
||||
auto baseSubDeviceApiRefCount = subDevice->getRefApiCount();
|
||||
auto baseSubDeviceInternalRefCount = subDevice->getRefInternalCount();
|
||||
auto baseDefaultDeviceApiRefCount = defaultDevice->getRefApiCount();
|
||||
auto baseDefaultDeviceInternalRefCount = defaultDevice->getRefInternalCount();
|
||||
|
||||
subDevice->retainApi();
|
||||
EXPECT_EQ(baseDeviceApiRefCount, device->getRefApiCount());
|
||||
EXPECT_EQ(baseDeviceInternalRefCount + 1, device->getRefInternalCount());
|
||||
EXPECT_EQ(baseSubDeviceApiRefCount + 1, subDevice->getRefApiCount());
|
||||
EXPECT_EQ(baseSubDeviceInternalRefCount + 1, subDevice->getRefInternalCount());
|
||||
EXPECT_EQ(baseDefaultDeviceApiRefCount, defaultDevice->getRefApiCount());
|
||||
EXPECT_EQ(baseDefaultDeviceInternalRefCount, defaultDevice->getRefInternalCount());
|
||||
|
||||
subDevice->releaseApi();
|
||||
EXPECT_EQ(baseDeviceApiRefCount, device->getRefApiCount());
|
||||
EXPECT_EQ(baseDeviceInternalRefCount, device->getRefInternalCount());
|
||||
EXPECT_EQ(baseSubDeviceApiRefCount, subDevice->getRefApiCount());
|
||||
EXPECT_EQ(baseSubDeviceInternalRefCount, subDevice->getRefInternalCount());
|
||||
EXPECT_EQ(baseDefaultDeviceApiRefCount, defaultDevice->getRefApiCount());
|
||||
EXPECT_EQ(baseDefaultDeviceInternalRefCount, defaultDevice->getRefInternalCount());
|
||||
}
|
||||
|
||||
TEST(SubDevicesTest, givenDeviceWithSubDevicesWhenSubDeviceCreationFailThenWholeDeviceIsDestroyed) {
|
||||
|
|
Loading…
Reference in New Issue