mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-11 16:45:25 +08:00
fix: Taking into account variable ReturnSubDevicesAsApiDevices
Taking into account variable ReturnSubDevicesAsApiDevices during Retain and Release Device Related-To: NEO-8161 Signed-off-by: Andrzej Koska <andrzej.koska@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
81d037f59b
commit
0a3b135673
@@ -130,6 +130,24 @@ TEST_F(ClCreateSubDevicesTests, GivenValidInputWhenCreatingSubDevicesThenDeviceA
|
||||
EXPECT_EQ(2, device->getSubDevice(1)->getRefApiCount());
|
||||
}
|
||||
|
||||
TEST_F(ClCreateSubDevicesTests, GivenValidInputAndReturnSubDevicesAsApiDevicesIsSetWhenCreatingSubDevicesThenDeviceApiReferenceCountIsNotIncreased) {
|
||||
DebugManager.flags.ReturnSubDevicesAsApiDevices.set(1);
|
||||
setup(2);
|
||||
|
||||
EXPECT_EQ(0, device->getSubDevice(0)->getRefApiCount());
|
||||
EXPECT_EQ(0, device->getSubDevice(1)->getRefApiCount());
|
||||
|
||||
auto retVal = clCreateSubDevices(device.get(), properties, outDevicesCount, outDevices, nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, device->getSubDevice(0)->getRefApiCount());
|
||||
EXPECT_EQ(0, device->getSubDevice(1)->getRefApiCount());
|
||||
|
||||
retVal = clCreateSubDevices(device.get(), properties, outDevicesCount, outDevices, nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, device->getSubDevice(0)->getRefApiCount());
|
||||
EXPECT_EQ(0, device->getSubDevice(1)->getRefApiCount());
|
||||
}
|
||||
|
||||
struct ClCreateSubDevicesDeviceInfoTests : ClCreateSubDevicesTests {
|
||||
void setup(int numberOfDevices) {
|
||||
ClCreateSubDevicesTests::setup(numberOfDevices);
|
||||
|
||||
@@ -100,6 +100,42 @@ TEST(SubDevicesTest, givenDeviceWithSubDevicesWhenSubDeviceApiRefCountsAreChange
|
||||
EXPECT_EQ(baseDefaultDeviceInternalRefCount, defaultDevice->getRefInternalCount());
|
||||
}
|
||||
|
||||
TEST(SubDevicesTest, givenDeviceWithSubDevicesAndSubDevicesAsDevicesIsSetWhenSubDeviceApiRefCountsAreChangedThenChangeIsNotPropagatedToRootDevice) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(2);
|
||||
VariableBackup<bool> mockDeviceFlagBackup(&MockDevice::createSingleDevice, false);
|
||||
initPlatform();
|
||||
platform()->peekExecutionEnvironment()->setExposeSubDevicesAsDevices(1);
|
||||
auto nonDefaultPlatform = std::make_unique<MockPlatform>(*platform()->peekExecutionEnvironment());
|
||||
nonDefaultPlatform->initializeWithNewDevices();
|
||||
auto device = nonDefaultPlatform->getClDevice(0);
|
||||
auto defaultDevice = platform()->getClDevice(0);
|
||||
|
||||
auto subDevice = device->getSubDevice(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, device->getRefInternalCount());
|
||||
EXPECT_EQ(baseSubDeviceApiRefCount, subDevice->getRefApiCount());
|
||||
EXPECT_EQ(baseSubDeviceInternalRefCount, 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, givenDeviceWithSubDevicesWhenSubDeviceInternalRefCountsAreChangedThenChangeIsPropagatedToRootDevice) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(2);
|
||||
|
||||
Reference in New Issue
Block a user