mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-10 07:08:04 +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
@@ -11,6 +11,7 @@
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/device/sub_device.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/gfx_core_helper.h"
|
||||
@@ -87,7 +88,7 @@ unique_ptr_if_unused<ClDevice> ClDevice::decRefInternal() {
|
||||
|
||||
void ClDevice::retainApi() {
|
||||
auto parentDeviceId = deviceInfo.parentDevice;
|
||||
if (parentDeviceId) {
|
||||
if ((parentDeviceId && !getExecutionEnvironment()->isExposingSubDevicesAsDevices())) {
|
||||
auto pParentClDevice = static_cast<ClDevice *>(parentDeviceId);
|
||||
pParentClDevice->incRefInternal();
|
||||
this->incRefApi();
|
||||
@@ -95,7 +96,7 @@ void ClDevice::retainApi() {
|
||||
};
|
||||
unique_ptr_if_unused<ClDevice> ClDevice::releaseApi() {
|
||||
auto parentDeviceId = deviceInfo.parentDevice;
|
||||
if (!parentDeviceId) {
|
||||
if (!parentDeviceId || getExecutionEnvironment()->isExposingSubDevicesAsDevices()) {
|
||||
return unique_ptr_if_unused<ClDevice>(this, false);
|
||||
}
|
||||
auto pParentClDevice = static_cast<ClDevice *>(parentDeviceId);
|
||||
|
||||
@@ -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