Revert "feature: support explicit memory locking"

This reverts commit 27a3307bb0.

Signed-off-by: Young Jin Yoon <young.jin.yoon@intel.com>
This commit is contained in:
Young Jin Yoon
2024-03-25 15:43:50 +00:00
committed by Compute-Runtime-Automation
parent e44ac2a001
commit 068f6a25c6
48 changed files with 108 additions and 623 deletions

View File

@@ -22,12 +22,12 @@ set(NEO_CORE_OS_INTERFACE_TESTS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_mapper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_bindless_heap_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_with_aub_dump_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_impl.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_os_memory_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_pci_speed_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_topology_upstream_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_residency_handler_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_special_heap_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_system_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_tests.cpp
@@ -54,9 +54,9 @@ if(NEO_ENABLE_i915_PRELIM_DETECTION)
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_info_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_debug_surface_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_localmem_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_bind_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_topology_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_residency_handler_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_vm_bind_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_with_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_tests_prelim.cpp

View File

@@ -1,163 +0,0 @@
/*
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/drm_memory_operations_handler_default.h"
#include "shared/test/common/libult/linux/drm_query_mock.h"
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/test_macros/test.h"
#include <memory>
using namespace NEO;
struct MockDrmMemoryOperationsHandlerDefault : public DrmMemoryOperationsHandlerDefault {
using DrmMemoryOperationsHandlerDefault::DrmMemoryOperationsHandlerDefault;
using DrmMemoryOperationsHandlerDefault::residency;
};
struct DrmMemoryOperationsHandlerBaseTest : public ::testing::Test {
void SetUp() override {
executionEnvironment = new ExecutionEnvironment;
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get());
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
executionEnvironment->calculateMaxOsContextCount();
mock = new DrmQueryMock(*executionEnvironment->rootDeviceEnvironments[0]);
mock->setBindAvailable();
drmMemoryOperationsHandler = std::make_unique<MockDrmMemoryOperationsHandlerDefault>(0);
}
void initializeAllocation(int numBos) {
if (!drmAllocation) {
for (auto i = 0; i < numBos; i++) {
mockBos.push_back(new MockBufferObject(0, mock, 3, 0, 0, 1));
}
drmAllocation = new MockDrmAllocation(AllocationType::unknown, MemoryPool::localMemory, mockBos);
for (auto i = 0; i < numBos; i++) {
drmAllocation->storageInfo.memoryBanks[i] = 1;
}
allocationPtr = drmAllocation;
}
}
void TearDown() override {
for (auto i = 0u; i < mockBos.size(); i++) {
delete mockBos[i];
}
mockBos.clear();
delete drmAllocation;
delete mock;
delete executionEnvironment;
}
ExecutionEnvironment *executionEnvironment;
DrmQueryMock *mock;
BufferObjects mockBos;
MockDrmAllocation *drmAllocation = nullptr;
GraphicsAllocation *allocationPtr = nullptr;
std::unique_ptr<MockDrmMemoryOperationsHandlerDefault> drmMemoryOperationsHandler;
};
TEST_F(DrmMemoryOperationsHandlerBaseTest, whenMakingAllocationResidentThenAllocationIsResident) {
initializeAllocation(1);
EXPECT_EQ(1u, drmAllocation->storageInfo.getNumBanks());
EXPECT_EQ(drmMemoryOperationsHandler->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 1u);
EXPECT_TRUE(drmMemoryOperationsHandler->residency.find(allocationPtr) != drmMemoryOperationsHandler->residency.end());
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, *allocationPtr), MemoryOperationsStatus::success);
}
TEST_F(DrmMemoryOperationsHandlerBaseTest, whenEvictingResidentAllocationThenAllocationIsNotResident) {
initializeAllocation(1);
EXPECT_EQ(1u, drmAllocation->storageInfo.getNumBanks());
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
EXPECT_EQ(drmMemoryOperationsHandler->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, *allocationPtr), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 1u);
EXPECT_TRUE(drmMemoryOperationsHandler->residency.find(allocationPtr) != drmMemoryOperationsHandler->residency.end());
EXPECT_EQ(drmMemoryOperationsHandler->evict(nullptr, *allocationPtr), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, *allocationPtr), MemoryOperationsStatus::memoryNotFound);
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
}
TEST_F(DrmMemoryOperationsHandlerBaseTest, whenLockingAllocationThenAllocationIsResident) {
initializeAllocation(2);
EXPECT_EQ(2u, drmAllocation->storageInfo.getNumBanks());
EXPECT_EQ(drmMemoryOperationsHandler->lock(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 1u);
EXPECT_TRUE(drmMemoryOperationsHandler->residency.find(drmAllocation) != drmMemoryOperationsHandler->residency.end());
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, *drmAllocation), MemoryOperationsStatus::success);
EXPECT_TRUE(drmAllocation->isLockedMemory());
EXPECT_TRUE(mockBos[0]->isExplicitLockedMemoryRequired());
EXPECT_TRUE(mockBos[1]->isExplicitLockedMemoryRequired());
}
TEST_F(DrmMemoryOperationsHandlerBaseTest, whenEvictingLockedAllocationThenAllocationIsNotResident) {
initializeAllocation(1);
EXPECT_EQ(1u, drmAllocation->storageInfo.getNumBanks());
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
EXPECT_EQ(drmMemoryOperationsHandler->lock(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, *drmAllocation), MemoryOperationsStatus::success);
EXPECT_TRUE(drmMemoryOperationsHandler->residency.find(drmAllocation) != drmMemoryOperationsHandler->residency.end());
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 1u);
EXPECT_TRUE(drmAllocation->isLockedMemory());
EXPECT_TRUE(mockBos[0]->isExplicitLockedMemoryRequired());
EXPECT_EQ(drmMemoryOperationsHandler->evict(nullptr, *drmAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, *drmAllocation), MemoryOperationsStatus::memoryNotFound);
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
EXPECT_FALSE(drmAllocation->isLockedMemory());
EXPECT_FALSE(mockBos[0]->isExplicitLockedMemoryRequired());
}
TEST_F(DrmMemoryOperationsHandlerBaseTest, whenEvictingLockedAllocationWithMultipleBOsThenAllocationIsNotResident) {
initializeAllocation(2);
EXPECT_EQ(2u, drmAllocation->storageInfo.getNumBanks());
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
EXPECT_EQ(drmMemoryOperationsHandler->lock(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, *drmAllocation), MemoryOperationsStatus::success);
EXPECT_TRUE(drmMemoryOperationsHandler->residency.find(drmAllocation) != drmMemoryOperationsHandler->residency.end());
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 1u);
EXPECT_TRUE(drmAllocation->isLockedMemory());
EXPECT_TRUE(mockBos[0]->isExplicitLockedMemoryRequired());
EXPECT_TRUE(mockBos[1]->isExplicitLockedMemoryRequired());
EXPECT_EQ(drmMemoryOperationsHandler->evict(nullptr, *drmAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, *drmAllocation), MemoryOperationsStatus::memoryNotFound);
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
EXPECT_FALSE(drmAllocation->isLockedMemory());
EXPECT_FALSE(mockBos[0]->isExplicitLockedMemoryRequired());
EXPECT_FALSE(mockBos[1]->isExplicitLockedMemoryRequired());
}
TEST_F(DrmMemoryOperationsHandlerBaseTest, whenEvictingLockedAllocationWithChunkedThenAllocationIsNotResident) {
initializeAllocation(1);
EXPECT_EQ(1u, drmAllocation->storageInfo.getNumBanks());
drmAllocation->storageInfo.isChunked = true;
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
EXPECT_EQ(drmMemoryOperationsHandler->lock(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, *drmAllocation), MemoryOperationsStatus::success);
EXPECT_TRUE(drmMemoryOperationsHandler->residency.find(drmAllocation) != drmMemoryOperationsHandler->residency.end());
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 1u);
EXPECT_TRUE(drmAllocation->isLockedMemory());
EXPECT_TRUE(mockBos[0]->isExplicitLockedMemoryRequired());
EXPECT_EQ(drmMemoryOperationsHandler->evict(nullptr, *drmAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, *drmAllocation), MemoryOperationsStatus::memoryNotFound);
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
EXPECT_FALSE(drmAllocation->isLockedMemory());
EXPECT_FALSE(mockBos[0]->isExplicitLockedMemoryRequired());
}

View File

@@ -9,8 +9,6 @@
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/linux/drm_memory_operations_handler_default.h"
#include "shared/source/os_interface/linux/drm_memory_operations_handler_with_aub_dump.h"
#include "shared/test/common/libult/linux/drm_query_mock.h"
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
#include "shared/test/common/mocks/mock_aub_memory_operations_handler.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
@@ -61,55 +59,17 @@ TEST_F(DrmMemoryOperationsHandlerWithAubDumpTest, whenMakingAllocationResidentTh
}
TEST_F(DrmMemoryOperationsHandlerWithAubDumpTest, whenEvictingResidentAllocationThenAllocationIsNotResident) {
auto mock = new DrmQueryMock(*device->executionEnvironment->rootDeviceEnvironments[0]);
mock->setBindAvailable();
BufferObjects bos;
MockBufferObject mockBo(0, mock, 3, 0, 0, 1);
mockBo.setSize(1024);
bos.push_back(&mockBo);
GraphicsAllocation *mockDrmAllocation = new MockDrmAllocation(AllocationType::unknown, MemoryPool::localMemory, bos);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->residency.size(), 0u);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&mockDrmAllocation, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, *mockDrmAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, graphicsAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->residency.size(), 1u);
EXPECT_TRUE(drmMemoryOperationsHandlerWithAubDumpMock->residency.find(mockDrmAllocation) != drmMemoryOperationsHandlerWithAubDumpMock->residency.end());
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->evict(nullptr, *mockDrmAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, *mockDrmAllocation), MemoryOperationsStatus::memoryNotFound);
EXPECT_TRUE(drmMemoryOperationsHandlerWithAubDumpMock->residency.find(allocationPtr) != drmMemoryOperationsHandlerWithAubDumpMock->residency.end());
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->evict(nullptr, graphicsAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, graphicsAllocation), MemoryOperationsStatus::memoryNotFound);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->residency.size(), 0u);
EXPECT_TRUE(mockAubMemoryOperationsHandler->makeResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->isResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->evictCalled);
delete mockDrmAllocation;
delete mock;
}
TEST_F(DrmMemoryOperationsHandlerWithAubDumpTest, whenEvictingLockedAllocationThenAllocationIsNotResident) {
auto mock = new DrmQueryMock(*device->executionEnvironment->rootDeviceEnvironments[0]);
mock->setBindAvailable();
BufferObjects bos;
MockBufferObject mockBo(0, mock, 3, 0, 0, 1);
mockBo.setSize(1024);
bos.push_back(&mockBo);
GraphicsAllocation *mockDrmAllocation = new MockDrmAllocation(AllocationType::unknown, MemoryPool::localMemory, bos);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->residency.size(), 0u);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->lock(nullptr, ArrayRef<GraphicsAllocation *>(&mockDrmAllocation, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, *mockDrmAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->residency.size(), 1u);
EXPECT_TRUE(drmMemoryOperationsHandlerWithAubDumpMock->residency.find(mockDrmAllocation) != drmMemoryOperationsHandlerWithAubDumpMock->residency.end());
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->evict(nullptr, *mockDrmAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, *mockDrmAllocation), MemoryOperationsStatus::memoryNotFound);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->residency.size(), 0u);
EXPECT_TRUE(mockAubMemoryOperationsHandler->makeResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->isResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->evictCalled);
delete mockDrmAllocation;
delete mock;
}
TEST_F(DrmMemoryOperationsHandlerWithAubDumpTest, whenConstructingDrmMemoryOperationsHandlerWithAubDumpWithoutAubCenterThenAubCenterIsInitialized) {

View File

@@ -1324,91 +1324,6 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenClosEnabledAndAllocationToBeCach
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryOperationsHandlerBindTest, whenIoctlFailDuringLockingThenOutOfMemoryIsThrown) {
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
mock->context.vmBindReturn = -1;
EXPECT_EQ(operationHandler->isResident(device, *allocation), MemoryOperationsStatus::memoryNotFound);
EXPECT_EQ(operationHandler->lock(device, ArrayRef<GraphicsAllocation *>(&allocation, 1)), MemoryOperationsStatus::outOfMemory);
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryOperationsHandlerBindTest, whenLockingDrmAllocationThenBosRequireExplicitLockedMemory) {
BufferObjects bos;
MockBufferObject mockBo1(0, mock, 3, 0, 0, 1), mockBo2(0, mock, 3, 0, 0, 1);
mockBo1.setSize(1024);
mockBo2.setSize(1024);
bos.push_back(&mockBo1);
bos.push_back(&mockBo2);
GraphicsAllocation *mockDrmAllocation = new MockDrmAllocation(AllocationType::unknown, MemoryPool::localMemory, bos);
mockDrmAllocation->storageInfo.memoryBanks = 3;
EXPECT_EQ(2u, mockDrmAllocation->storageInfo.getNumBanks());
mock->context.vmBindReturn = 0;
EXPECT_EQ(operationHandler->isResident(device, *mockDrmAllocation), MemoryOperationsStatus::memoryNotFound);
EXPECT_EQ(operationHandler->lock(device, ArrayRef<GraphicsAllocation *>(&mockDrmAllocation, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(operationHandler->isResident(device, *mockDrmAllocation), MemoryOperationsStatus::success);
EXPECT_TRUE(mockDrmAllocation->isLockedMemory());
EXPECT_TRUE(mockBo1.isExplicitLockedMemoryRequired());
EXPECT_TRUE(mockBo2.isExplicitLockedMemoryRequired());
delete mockDrmAllocation;
}
TEST_F(DrmMemoryOperationsHandlerBindTest, givenPreviouslyLockedMemoryWhenCallingResidentMemoryThenBosDoNotRequireExplicitLockedMemory) {
BufferObjects bos;
MockBufferObject mockBo(0, mock, 3, 0, 0, 1);
mockBo.setSize(1024);
bos.push_back(&mockBo);
GraphicsAllocation *mockDrmAllocation = new MockDrmAllocation(AllocationType::unknown, MemoryPool::localMemory, bos);
mock->context.vmBindReturn = 0;
mock->context.vmUnbindReturn = 0;
EXPECT_EQ(operationHandler->isResident(device, *mockDrmAllocation), MemoryOperationsStatus::memoryNotFound);
EXPECT_EQ(operationHandler->lock(device, ArrayRef<GraphicsAllocation *>(&mockDrmAllocation, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(operationHandler->isResident(device, *mockDrmAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(operationHandler->evict(device, *mockDrmAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(operationHandler->isResident(device, *mockDrmAllocation), MemoryOperationsStatus::memoryNotFound);
EXPECT_FALSE(mockDrmAllocation->isLockedMemory());
EXPECT_EQ(operationHandler->makeResident(device, ArrayRef<GraphicsAllocation *>(&mockDrmAllocation, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(operationHandler->isResident(device, *mockDrmAllocation), MemoryOperationsStatus::success);
EXPECT_FALSE(mockDrmAllocation->isLockedMemory());
EXPECT_FALSE(mockBo.isExplicitLockedMemoryRequired());
delete mockDrmAllocation;
}
TEST_F(DrmMemoryOperationsHandlerBindTest, givenLockedAndResidentAllocationsWhenCallingEvictUnusedMemoryThenBothAllocationsAreNotEvicted) {
auto allocation1 = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
auto allocation2 = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
EXPECT_EQ(operationHandler->isResident(device, *allocation1), MemoryOperationsStatus::memoryNotFound);
EXPECT_EQ(operationHandler->isResident(device, *allocation2), MemoryOperationsStatus::memoryNotFound);
EXPECT_EQ(operationHandler->lock(device, ArrayRef<GraphicsAllocation *>(&allocation1, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(operationHandler->isResident(device, *allocation1), MemoryOperationsStatus::success);
EXPECT_EQ(operationHandler->makeResident(device, ArrayRef<GraphicsAllocation *>(&allocation2, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(operationHandler->isResident(device, *allocation2), MemoryOperationsStatus::success);
operationHandler->useBaseEvictUnused = true;
EXPECT_EQ(operationHandler->evictUnusedCalled, 0u);
EXPECT_EQ(operationHandler->evictUnusedAllocations(false, true), MemoryOperationsStatus::success);
EXPECT_EQ(operationHandler->evictUnusedCalled, 1u);
EXPECT_EQ(operationHandler->isResident(device, *allocation1), MemoryOperationsStatus::success);
EXPECT_EQ(operationHandler->isResident(device, *allocation2), MemoryOperationsStatus::success);
memoryManager->freeGraphicsMemory(allocation2);
memoryManager->freeGraphicsMemory(allocation1);
}
using DrmResidencyHandlerTests = ::testing::Test;
HWTEST2_F(DrmResidencyHandlerTests, givenClosIndexAndMemoryTypeWhenAskingForPatIndexThenReturnCorrectValue, IsWithinXeGfxFamily) {

View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/drm_memory_operations_handler_default.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/test_macros/test.h"
#include <memory>
using namespace NEO;
struct MockDrmMemoryOperationsHandlerDefault : public DrmMemoryOperationsHandlerDefault {
using DrmMemoryOperationsHandlerDefault::DrmMemoryOperationsHandlerDefault;
using DrmMemoryOperationsHandlerDefault::residency;
};
struct DrmMemoryOperationsHandlerBaseTest : public ::testing::Test {
void SetUp() override {
drmMemoryOperationsHandler = std::make_unique<MockDrmMemoryOperationsHandlerDefault>(0);
allocationPtr = &graphicsAllocation;
}
MockGraphicsAllocation graphicsAllocation;
GraphicsAllocation *allocationPtr;
std::unique_ptr<MockDrmMemoryOperationsHandlerDefault> drmMemoryOperationsHandler;
};
TEST_F(DrmMemoryOperationsHandlerBaseTest, whenMakingAllocationResidentThenAllocationIsResident) {
EXPECT_EQ(drmMemoryOperationsHandler->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 1u);
EXPECT_TRUE(drmMemoryOperationsHandler->residency.find(allocationPtr) != drmMemoryOperationsHandler->residency.end());
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, graphicsAllocation), MemoryOperationsStatus::success);
}
TEST_F(DrmMemoryOperationsHandlerBaseTest, whenEvictingResidentAllocationThenAllocationIsNotResident) {
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
EXPECT_EQ(drmMemoryOperationsHandler->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, graphicsAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 1u);
EXPECT_TRUE(drmMemoryOperationsHandler->residency.find(allocationPtr) != drmMemoryOperationsHandler->residency.end());
EXPECT_EQ(drmMemoryOperationsHandler->evict(nullptr, graphicsAllocation), MemoryOperationsStatus::success);
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, graphicsAllocation), MemoryOperationsStatus::memoryNotFound);
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
}

View File

@@ -266,23 +266,20 @@ TEST_F(IoctlPrelimHelperTests, whenGettingFlagsForVmBindThenProperValuesAreRetur
for (auto &bindCapture : ::testing::Bool()) {
for (auto &bindImmediate : ::testing::Bool()) {
for (auto &bindMakeResident : ::testing::Bool()) {
for (auto &bindLockedMemory : ::testing::Bool()) {
auto flags = ioctlHelper.getFlagsForVmBind(bindCapture, bindImmediate, bindMakeResident, bindLockedMemory);
if (bindCapture) {
EXPECT_EQ(PRELIM_I915_GEM_VM_BIND_CAPTURE, (flags & PRELIM_I915_GEM_VM_BIND_CAPTURE));
}
if (bindImmediate) {
EXPECT_EQ(PRELIM_I915_GEM_VM_BIND_IMMEDIATE, (flags & PRELIM_I915_GEM_VM_BIND_IMMEDIATE));
}
if (bindMakeResident || bindLockedMemory) {
EXPECT_EQ(PRELIM_I915_GEM_VM_BIND_MAKE_RESIDENT, (flags & PRELIM_I915_GEM_VM_BIND_MAKE_RESIDENT));
}
if (flags == 0) {
EXPECT_FALSE(bindCapture);
EXPECT_FALSE(bindImmediate);
EXPECT_FALSE(bindMakeResident);
EXPECT_FALSE(bindLockedMemory);
}
auto flags = ioctlHelper.getFlagsForVmBind(bindCapture, bindImmediate, bindMakeResident);
if (bindCapture) {
EXPECT_EQ(PRELIM_I915_GEM_VM_BIND_CAPTURE, (flags & PRELIM_I915_GEM_VM_BIND_CAPTURE));
}
if (bindImmediate) {
EXPECT_EQ(PRELIM_I915_GEM_VM_BIND_IMMEDIATE, (flags & PRELIM_I915_GEM_VM_BIND_IMMEDIATE));
}
if (bindMakeResident) {
EXPECT_EQ(PRELIM_I915_GEM_VM_BIND_MAKE_RESIDENT, (flags & PRELIM_I915_GEM_VM_BIND_MAKE_RESIDENT));
}
if (flags == 0) {
EXPECT_FALSE(bindCapture);
EXPECT_FALSE(bindImmediate);
EXPECT_FALSE(bindMakeResident);
}
}
}

View File

@@ -318,10 +318,8 @@ TEST(IoctlHelperUpstreamTest, whenGettingFlagsForVmBindThenZeroIsReturned) {
for (auto &bindCapture : ::testing::Bool()) {
for (auto &bindImmediate : ::testing::Bool()) {
for (auto &bindMakeResident : ::testing::Bool()) {
for (auto &bindLock : ::testing::Bool()) {
auto flags = ioctlHelper.getFlagsForVmBind(bindCapture, bindImmediate, bindMakeResident, bindLock);
EXPECT_EQ(0u, flags);
}
auto flags = ioctlHelper.getFlagsForVmBind(bindCapture, bindImmediate, bindMakeResident);
EXPECT_EQ(0u, flags);
}
}
}

View File

@@ -7,7 +7,6 @@
set(NEO_CORE_OS_INTERFACE_TESTS_LINUX_XE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/${BRANCH_TYPE}/ioctl_helper_xe_vm_bind_flag_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe_vm_export_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe_perf_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe_tests.h

View File

@@ -260,7 +260,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsRe
EXPECT_EQ(0u, xeIoctlHelper->getDirectSubmissionFlag());
EXPECT_EQ(0u, xeIoctlHelper->getFlagsForVmBind(false, false, false, false));
EXPECT_EQ(0u, xeIoctlHelper->getFlagsForVmBind(false, false, false));
std::vector<QueryItem> queryItems;
std::vector<DistanceInfo> distanceInfos;
@@ -401,6 +401,11 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsRe
XE_NEO_VMCREATE_USEVMBIND_FLAG),
xeIoctlHelper->getFlagsForVmCreate(true, true, true));
EXPECT_EQ(static_cast<uint64_t>(XE_NEO_BIND_CAPTURE_FLAG |
XE_NEO_BIND_IMMEDIATE_FLAG |
XE_NEO_BIND_MAKERESIDENT_FLAG),
xeIoctlHelper->getFlagsForVmBind(true, true, true));
uint32_t fabricId = 0, latency = 0, bandwidth = 0;
EXPECT_FALSE(xeIoctlHelper->getFabricLatency(fabricId, latency, bandwidth));
}

View File

@@ -1,41 +0,0 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h"
using namespace NEO;
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetFlagsForVmBindThenExpectedValueIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
ASSERT_NE(nullptr, xeIoctlHelper);
for (auto &bindCapture : ::testing::Bool()) {
for (auto &bindImmediate : ::testing::Bool()) {
for (auto &bindMakeResident : ::testing::Bool()) {
for (auto &bindLockedMemory : ::testing::Bool()) {
auto flags = xeIoctlHelper->getFlagsForVmBind(bindCapture, bindImmediate, bindMakeResident, bindLockedMemory);
if (bindCapture) {
EXPECT_EQ(static_cast<uint32_t>(XE_NEO_BIND_CAPTURE_FLAG), (flags & XE_NEO_BIND_CAPTURE_FLAG));
}
if (bindImmediate) {
EXPECT_EQ(static_cast<uint32_t>(DRM_XE_VM_BIND_FLAG_IMMEDIATE), (flags & DRM_XE_VM_BIND_FLAG_IMMEDIATE));
}
if (bindMakeResident) {
EXPECT_EQ(static_cast<uint32_t>(XE_NEO_BIND_MAKERESIDENT_FLAG), (flags & XE_NEO_BIND_MAKERESIDENT_FLAG));
}
if (flags == 0) {
EXPECT_FALSE(bindCapture);
EXPECT_FALSE(bindImmediate);
EXPECT_FALSE(bindMakeResident);
}
}
}
}
}
}