Reconfigure DrmMemoryManager tests to use non-default root device index

pass rootDeviceIndex to TestedDrmCommandStreamReceiver

Related-To: NEO-4512

Change-Id: I7257e5b9f63a1b6e5bba9b6ca48583e95deae606
Signed-off-by: Jablonski, Mateusz <mateusz.jablonski@intel.com>
This commit is contained in:
Jablonski, Mateusz 2020-03-26 09:30:46 +01:00 committed by sys_ocldev
parent 49d3c39fae
commit 0c67b0cb57
6 changed files with 47 additions and 43 deletions

View File

@ -22,8 +22,8 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiver<GfxFamily
TestedDrmCommandStreamReceiver(gemCloseWorkerMode mode, ExecutionEnvironment &executionEnvironment)
: DrmCommandStreamReceiver<GfxFamily>(executionEnvironment, 0, mode) {
}
TestedDrmCommandStreamReceiver(ExecutionEnvironment &executionEnvironment)
: DrmCommandStreamReceiver<GfxFamily>(executionEnvironment, 0, gemCloseWorkerMode::gemCloseWorkerInactive) {
TestedDrmCommandStreamReceiver(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex)
: DrmCommandStreamReceiver<GfxFamily>(executionEnvironment, rootDeviceIndex, gemCloseWorkerMode::gemCloseWorkerInactive) {
}
void overrideDispatchPolicy(DispatchMode overrideValue) {

View File

@ -53,7 +53,11 @@ void TestedDrmMemoryManager::injectPinBB(BufferObject *newPinBB) {
}
DrmGemCloseWorker *TestedDrmMemoryManager::getgemCloseWorker() { return this->gemCloseWorker.get(); }
void TestedDrmMemoryManager::forceLimitedRangeAllocator(uint64_t range) { getGfxPartition(0)->init(range, getSizeToReserve(), 0, 1); }
void TestedDrmMemoryManager::forceLimitedRangeAllocator(uint64_t range) {
for (auto &gfxPartition : gfxPartitions) {
gfxPartition->init(range, getSizeToReserve(), 0, 1);
}
}
void TestedDrmMemoryManager::overrideGfxPartition(GfxPartition *newGfxPartition) { gfxPartitions[0].reset(newGfxPartition); }
DrmAllocation *TestedDrmMemoryManager::allocate32BitGraphicsMemory(uint32_t rootDeviceIndex, size_t size, const void *ptr, GraphicsAllocation::AllocationType allocationType) {

View File

@ -85,6 +85,7 @@ class DrmCommandStreamEnhancedTest : public ::testing::Test {
MockExecutionEnvironment *executionEnvironment;
DrmMockCustom *mock;
CommandStreamReceiver *csr = nullptr;
const uint32_t rootDeviceIndex = 0u;
DrmMemoryManager *mm = nullptr;
std::unique_ptr<MockDevice> device;
@ -99,10 +100,10 @@ class DrmCommandStreamEnhancedTest : public ::testing::Test {
DebugManager.flags.EnableForcePin.set(false);
mock = new DrmMockCustom();
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock);
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setDrm(mock);
csr = new TestedDrmCommandStreamReceiver<GfxFamily>(*executionEnvironment);
csr = new TestedDrmCommandStreamReceiver<GfxFamily>(*executionEnvironment, rootDeviceIndex);
ASSERT_NE(nullptr, csr);
mm = new DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerInactive,
DebugManager.flags.EnableForcePin.get(),
@ -110,7 +111,7 @@ class DrmCommandStreamEnhancedTest : public ::testing::Test {
*executionEnvironment);
ASSERT_NE(nullptr, mm);
executionEnvironment->memoryManager.reset(mm);
device.reset(MockDevice::create<MockDevice>(executionEnvironment, 0u));
device.reset(MockDevice::create<MockDevice>(executionEnvironment, rootDeviceIndex));
device->resetCommandStreamReceiver(csr);
ASSERT_NE(nullptr, device);
}

View File

@ -593,23 +593,19 @@ TEST_F(DrmMemoryManagerTest, BoWaitFailure) {
}
TEST_F(DrmMemoryManagerTest, NullOsHandleStorageAskedForPopulationReturnsFilledPointer) {
mock->ioctl_expected.gemUserptr = 0;
mock->ioctl_expected.gemWait = 0;
mock->ioctl_expected.gemClose = 0;
nonDefaultDrm->ioctl_expected.gemUserptr = 1;
nonDefaultDrm->ioctl_expected.gemWait = 1;
nonDefaultDrm->ioctl_expected.gemClose = 1;
mock->ioctl_expected.gemUserptr = 1;
mock->ioctl_expected.gemWait = 1;
mock->ioctl_expected.gemClose = 1;
OsHandleStorage storage;
storage.fragmentStorageData[0].cpuPtr = reinterpret_cast<void *>(0x1000);
storage.fragmentStorageData[0].fragmentSize = 1;
memoryManager->populateOsHandles(storage, nonDefaultRootDeviceIndex);
memoryManager->populateOsHandles(storage, rootDeviceIndex);
EXPECT_NE(nullptr, storage.fragmentStorageData[0].osHandleStorage);
EXPECT_EQ(nullptr, storage.fragmentStorageData[1].osHandleStorage);
EXPECT_EQ(nullptr, storage.fragmentStorageData[2].osHandleStorage);
storage.fragmentStorageData[0].freeTheFragment = true;
memoryManager->cleanOsHandles(storage, nonDefaultRootDeviceIndex);
memoryManager->cleanOsHandles(storage, rootDeviceIndex);
}
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValidationWhenReadOnlyPointerCausesPinningFailWithEfaultThenPopulateOsHandlesReturnsInvalidHostPointerError) {
@ -2054,7 +2050,7 @@ TEST_F(DrmMemoryManagerTest, givenSharedHandleWhenAllocationIsCreatedAndIoctlPri
}
TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferObjectWhenTheyAreMadeResidentThenOnlyOneBoIsPassedToExec) {
auto testedCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment);
auto testedCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment, rootDeviceIndex);
device->resetCommandStreamReceiver(testedCsr);
mock->reset();
@ -2090,7 +2086,7 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBuf
mock->testIoctls();
auto testedCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment);
auto testedCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment, rootDeviceIndex);
device->resetCommandStreamReceiver(testedCsr);
mock->reset();

View File

@ -24,22 +24,24 @@ using AllocationData = TestedDrmMemoryManager::AllocationData;
class DrmMemoryManagerBasic : public ::testing::Test {
public:
DrmMemoryManagerBasic() : executionEnvironment(defaultHwInfo.get()){};
DrmMemoryManagerBasic() : executionEnvironment(defaultHwInfo.get(), false, numRootDevices){};
void SetUp() override {
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
for (auto i = 0u; i < numRootDevices; i++) {
executionEnvironment.rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
executionEnvironment.rootDeviceEnvironments[i]->osInterface->get()->setDrm(Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[i]));
executionEnvironment.rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
}
}
const uint32_t rootDeviceIndex = 0u;
const uint32_t rootDeviceIndex = 1u;
const uint32_t numRootDevices = 2u;
MockExecutionEnvironment executionEnvironment;
};
class DrmMemoryManagerFixture : public MemoryManagementFixture {
public:
DrmMockCustom *mock;
DrmMockCustom *nonDefaultDrm = nullptr;
const uint32_t nonDefaultRootDeviceIndex = 1u;
const uint32_t rootDeviceIndex = 0u;
DrmMockCustom *mock = nullptr;
const uint32_t rootDeviceIndex = 1u;
const uint32_t numRootDevices = 2u;
TestedDrmMemoryManager *memoryManager = nullptr;
MockClDevice *device = nullptr;
@ -51,16 +53,16 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture {
void SetUp(DrmMockCustom *mock, bool localMemoryEnabled) {
allocationData.rootDeviceIndex = rootDeviceIndex;
this->mock = mock;
executionEnvironment = new MockExecutionEnvironment(defaultHwInfo.get(), false, nonDefaultRootDeviceIndex + 1);
executionEnvironment = new MockExecutionEnvironment(defaultHwInfo.get(), false, numRootDevices);
executionEnvironment->incRefInternal();
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->get()->setDrm(mock);
for (auto i = 0u; i < numRootDevices; i++) {
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[i].get();
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->get()->setDrm(new DrmMockCustom());
}
nonDefaultDrm = new DrmMockCustom();
auto nonDefaultRootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[nonDefaultRootDeviceIndex].get();
nonDefaultRootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
nonDefaultRootDeviceEnvironment->osInterface->get()->setDrm(nonDefaultDrm);
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex].get();
rootDeviceEnvironment->osInterface->get()->setDrm(mock);
memoryManager = new (std::nothrow) TestedDrmMemoryManager(localMemoryEnabled, false, false, *executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager);
@ -69,7 +71,7 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture {
if (memoryManager->getgemCloseWorker()) {
memoryManager->getgemCloseWorker()->close(true);
}
device = new MockClDevice{MockDevice::create<MockDevice>(executionEnvironment, 0)};
device = new MockClDevice{MockDevice::create<MockDevice>(executionEnvironment, rootDeviceIndex)};
mock->reset();
}

View File

@ -24,9 +24,9 @@ struct clCreateCommandQueueWithPropertiesLinux : public UltCommandStreamReceiver
executionEnvironment->prepareRootDeviceEnvironments(1);
auto osInterface = new OSInterface();
osInterface->get()->setDrm(drm);
executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(osInterface);
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface.reset(osInterface);
executionEnvironment->memoryManager.reset(new TestedDrmMemoryManager(*executionEnvironment));
mdevice = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0u));
mdevice = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, rootDeviceIndex));
clDevice = mdevice.get();
retVal = CL_SUCCESS;
@ -38,8 +38,9 @@ struct clCreateCommandQueueWithPropertiesLinux : public UltCommandStreamReceiver
DrmMock *drm = new DrmMock();
std::unique_ptr<MockClDevice> mdevice = nullptr;
std::unique_ptr<Context> context;
cl_device_id clDevice;
cl_int retVal;
cl_device_id clDevice = nullptr;
cl_int retVal = 0;
const uint32_t rootDeviceIndex = 0u;
};
namespace ULT {
@ -110,7 +111,7 @@ HWTEST_F(clCreateCommandQueueWithPropertiesLinux, givenPropertiesWithClQueueSlic
cl_queue_properties properties[] = {CL_QUEUE_SLICE_COUNT_INTEL, newSliceCount, 0};
auto mockCsr = new TestedDrmCommandStreamReceiver<FamilyType>(*mdevice->executionEnvironment);
auto mockCsr = new TestedDrmCommandStreamReceiver<FamilyType>(*mdevice->executionEnvironment, rootDeviceIndex);
mdevice->resetCommandStreamReceiver(mockCsr);
cl_command_queue cmdQ = clCreateCommandQueueWithProperties(context.get(), clDevice, properties, &retVal);
@ -154,7 +155,7 @@ HWTEST_F(clCreateCommandQueueWithPropertiesLinux, givenSameSliceCountAsRecentlyS
cl_queue_properties properties[] = {CL_QUEUE_SLICE_COUNT_INTEL, newSliceCount, 0};
auto mockCsr = new TestedDrmCommandStreamReceiver<FamilyType>(*mdevice->executionEnvironment);
auto mockCsr = new TestedDrmCommandStreamReceiver<FamilyType>(*mdevice->executionEnvironment, rootDeviceIndex);
mdevice->resetCommandStreamReceiver(mockCsr);
cl_command_queue cmdQ = clCreateCommandQueueWithProperties(context.get(), clDevice, properties, &retVal);
@ -197,7 +198,7 @@ HWTEST_F(clCreateCommandQueueWithPropertiesLinux, givenPropertiesWithClQueueSlic
cl_queue_properties properties[] = {CL_QUEUE_SLICE_COUNT_INTEL, newSliceCount, 0};
auto mockCsr = new TestedDrmCommandStreamReceiver<FamilyType>(*mdevice->executionEnvironment);
auto mockCsr = new TestedDrmCommandStreamReceiver<FamilyType>(*mdevice->executionEnvironment, rootDeviceIndex);
mdevice->resetCommandStreamReceiver(mockCsr);
cl_command_queue cmdQ = clCreateCommandQueueWithProperties(context.get(), clDevice, properties, &retVal);