Collision avoidance on 36 bit address space

Signed-off-by: Andrzej Koska <andrzej.koska@intel.com>

Related-To: NEO-5356
This commit is contained in:
Andrzej Koska 2021-05-06 14:15:19 +00:00 committed by Compute-Runtime-Automation
parent adcf685824
commit c59f44ecdf
15 changed files with 256 additions and 24 deletions

View File

@ -52,6 +52,9 @@ class TestedMemoryManager : public OsAgnosticMemoryManager {
TEST(BufferTests, WhenBufferIsCreatedThenPinIsSet) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
std::unique_ptr<TestedMemoryManager> mm(new MemoryManagerCreate<TestedMemoryManager>(false, false, executionEnvironment));
if (mm->isLimitedGPU(0)) {
GTEST_SKIP();
}
{
MockContext context;
auto size = MemoryConstants::pageSize * 32;
@ -75,6 +78,10 @@ TEST(BufferTests, WhenBufferIsCreatedThenPinIsSet) {
TEST(BufferTests, GivenHostPtrWhenBufferIsCreatedThenPinIsSet) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
std::unique_ptr<TestedMemoryManager> mm(new TestedMemoryManager(executionEnvironment));
if (mm->isLimitedGPU(0)) {
GTEST_SKIP();
}
{
MockContext context;
auto retVal = CL_INVALID_OPERATION;

View File

@ -674,6 +674,49 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenForce32bitallocationI
EXPECT_TRUE(memoryManager.peekForce32BitAllocations());
}
class MyOsAgnosticMemoryManager : public OsAgnosticMemoryManager {
public:
bool peek32bit() override {
return is32bit;
}
MyOsAgnosticMemoryManager(bool, ExecutionEnvironment &executionEnvironment) : OsAgnosticMemoryManager(false, executionEnvironment) {}
MyOsAgnosticMemoryManager(ExecutionEnvironment &executionEnvironment) : MyOsAgnosticMemoryManager(false, executionEnvironment) {}
bool is32bit = false;
};
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenIsLimitedGPUIsCalledThenCorrectValueIsReturned) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MyOsAgnosticMemoryManager memoryManager(executionEnvironment);
memoryManager.is32bit = false;
EXPECT_FALSE(memoryManager.isLimitedGPU(mockRootDeviceIndex));
memoryManager.is32bit = true;
if (executionEnvironment.rootDeviceEnvironments[mockRootDeviceIndex]->isFullRangeSvm()) {
EXPECT_FALSE(memoryManager.isLimitedGPU(mockRootDeviceIndex));
} else {
EXPECT_TRUE(memoryManager.isLimitedGPU(mockRootDeviceIndex));
}
}
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenIsLimitedGPUOnTypeIsCalledThenCorrectValueIsReturned) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MyOsAgnosticMemoryManager memoryManager(executionEnvironment);
memoryManager.is32bit = false;
EXPECT_FALSE(memoryManager.isLimitedGPUOnType(mockRootDeviceIndex, GraphicsAllocation::AllocationType::BUFFER));
EXPECT_FALSE(memoryManager.isLimitedGPUOnType(mockRootDeviceIndex, GraphicsAllocation::AllocationType::IMAGE));
EXPECT_FALSE(memoryManager.isLimitedGPUOnType(mockRootDeviceIndex, GraphicsAllocation::AllocationType::MAP_ALLOCATION));
memoryManager.is32bit = true;
if (executionEnvironment.rootDeviceEnvironments[mockRootDeviceIndex]->isFullRangeSvm()) {
EXPECT_FALSE(memoryManager.isLimitedGPUOnType(mockRootDeviceIndex, GraphicsAllocation::AllocationType::BUFFER));
EXPECT_FALSE(memoryManager.isLimitedGPUOnType(mockRootDeviceIndex, GraphicsAllocation::AllocationType::IMAGE));
EXPECT_FALSE(memoryManager.isLimitedGPUOnType(mockRootDeviceIndex, GraphicsAllocation::AllocationType::MAP_ALLOCATION));
} else {
EXPECT_TRUE(memoryManager.isLimitedGPUOnType(mockRootDeviceIndex, GraphicsAllocation::AllocationType::BUFFER));
EXPECT_FALSE(memoryManager.isLimitedGPUOnType(mockRootDeviceIndex, GraphicsAllocation::AllocationType::IMAGE));
EXPECT_FALSE(memoryManager.isLimitedGPUOnType(mockRootDeviceIndex, GraphicsAllocation::AllocationType::MAP_ALLOCATION));
}
}
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAskedFor32BitAllocationWhenLimitedAllocationIsEnabledThenGpuRangeFromExternalHeapIsAllocatiedAndBaseAddressIsSet) {
if (is32bit) {
GTEST_SKIP();
@ -903,6 +946,9 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerAndUnifiedAuxCapableAlloc
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocateGraphicsMemoryIsCalledThenMemoryPoolIsSystem4KBPages) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
if (memoryManager.isLimitedGPU(0)) {
GTEST_SKIP();
}
auto size = 4096u;
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{0, size});
@ -945,6 +991,9 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesEnabledWhenAllocate
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocateGraphicsMemoryWithPtrIsCalledThenMemoryPoolIsSystem4KBPages) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
if (memoryManager.isLimitedGPU(0)) {
GTEST_SKIP();
}
void *ptr = reinterpret_cast<void *>(0x1001);
auto size = MemoryConstants::pageSize;
@ -988,6 +1037,9 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesEnabledWhenAllocate
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
executionEnvironment.initGmm();
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(true, false, executionEnvironment);
if (memoryManager.isLimitedGPU(0)) {
GTEST_SKIP();
}
auto svmAllocation = memoryManager.allocateGraphicsMemoryWithProperties({mockRootDeviceIndex, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SVM_ZERO_COPY, mockDeviceBitfield});
EXPECT_NE(nullptr, svmAllocation);
EXPECT_EQ(MemoryPool::System64KBPages, svmAllocation->getMemoryPool());
@ -998,6 +1050,9 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesDisabledWhenAllocat
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
executionEnvironment.initGmm();
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
if (memoryManager.isLimitedGPU(0)) {
GTEST_SKIP();
}
auto svmAllocation = memoryManager.allocateGraphicsMemoryWithProperties({mockRootDeviceIndex, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SVM_ZERO_COPY, mockDeviceBitfield});
EXPECT_EQ(MemoryPool::System4KBPages, svmAllocation->getMemoryPool());
memoryManager.freeGraphicsMemory(svmAllocation);
@ -1309,6 +1364,9 @@ TEST(OsAgnosticMemoryManager, GivenEnabled64kbPagesWhenHostMemoryAllocationIsCre
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
executionEnvironment.initGmm();
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(true, false, executionEnvironment);
if (memoryManager.isLimitedGPU(0)) {
GTEST_SKIP();
}
GraphicsAllocation *galloc = memoryManager.allocateGraphicsMemoryWithProperties({mockRootDeviceIndex, MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, mockDeviceBitfield});
EXPECT_NE(nullptr, galloc);
@ -1373,7 +1431,7 @@ TEST_P(OsAgnosticMemoryManagerWithParams, givenFullGpuAddressSpaceWhenAllocateGr
bool requiresL3Flush = GetParam();
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
if ((!executionEnvironment.rootDeviceEnvironments[0]->isFullRangeSvm() && !is32bit) || !defaultHwInfo->capabilityTable.hostPtrTrackingEnabled) {
if ((!executionEnvironment.rootDeviceEnvironments[0]->isFullRangeSvm()) || !defaultHwInfo->capabilityTable.hostPtrTrackingEnabled) {
GTEST_SKIP();
}
OsAgnosticMemoryManager memoryManager(executionEnvironment);
@ -1473,6 +1531,9 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenVerifyHandleThenRe
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenGpuAddressIsSetThenAllocationWithSpecifiedGpuAddressInSystemMemoryIsCreated) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
auto memoryManager = new OsAgnosticMemoryManager(executionEnvironment);
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
DeviceBitfield deviceBitfield(1);
std::unique_ptr<CommandStreamReceiver> csr(createCommandStream(executionEnvironment, 0u, deviceBitfield));
executionEnvironment.memoryManager.reset(memoryManager);
@ -1557,6 +1618,42 @@ TEST(MemoryManager, givenSharedResourceCopyWhenAllocatingGraphicsMemoryThenAlloc
memoryManager.freeGraphicsMemory(imageAllocation);
}
TEST(MemoryManager, givenImageAndLimitedGPUWhenAllocatingGraphicsMemoryThenAllocate32BitGraphicsMemoryImplIsNotCalled) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
MockMemoryManager memoryManager(false, true, *executionEnvironment);
memoryManager.limitedGPU = true;
cl_image_desc imgDesc = {};
imgDesc.image_width = 1;
imgDesc.image_height = 1;
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
AllocationData allocationData;
allocationData.imgInfo = &imgInfo;
allocationData.type = GraphicsAllocation::AllocationType::IMAGE;
auto imageAllocation = memoryManager.allocateGraphicsMemory(allocationData);
EXPECT_NE(nullptr, imageAllocation);
EXPECT_TRUE(memoryManager.allocateForImageCalled);
EXPECT_FALSE(memoryManager.allocate32BitGraphicsMemoryImplCalled);
memoryManager.freeGraphicsMemory(imageAllocation);
}
TEST(MemoryManager, givenBufferAndLimitedGPUWhenAllocatingGraphicsMemoryThenAllocate32BitGraphicsMemoryImplIsCalled) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
MockMemoryManager memoryManager(false, true, *executionEnvironment);
memoryManager.limitedGPU = true;
AllocationData allocationData;
allocationData.size = 4096u;
allocationData.type = GraphicsAllocation::AllocationType::BUFFER;
auto bufferAllocation = memoryManager.allocateGraphicsMemory(allocationData);
EXPECT_NE(nullptr, bufferAllocation);
EXPECT_FALSE(memoryManager.allocateForImageCalled);
EXPECT_TRUE(memoryManager.allocate32BitGraphicsMemoryImplCalled);
memoryManager.freeGraphicsMemory(bufferAllocation);
}
TEST(MemoryManager, givenShareableWhenAllocatingGraphicsMemoryThenAllocateShareableIsCalled) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
MockMemoryManager memoryManager(false, true, *executionEnvironment);

View File

@ -131,6 +131,7 @@ GraphicsAllocation *MockMemoryManager::allocate32BitGraphicsMemory(uint32_t root
}
GraphicsAllocation *MockMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) {
allocate32BitGraphicsMemoryImplCalled = true;
if (failAllocate32Bit) {
return nullptr;
}

View File

@ -133,6 +133,9 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
GraphicsAllocation *allocate32BitGraphicsMemory(uint32_t rootDeviceIndex, size_t size, const void *ptr, GraphicsAllocation::AllocationType allocationType);
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override;
bool isLimitedGPU(uint32_t rootDeviceIndex) override {
return limitedGPU;
}
void forceLimitedRangeAllocator(uint32_t rootDeviceIndex, uint64_t range) { getGfxPartition(rootDeviceIndex)->init(range, 0, 0, gfxPartitions.size()); }
uint32_t freeGraphicsMemoryCalled = 0u;
@ -155,6 +158,7 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
bool failInAllocateWithSizeAndAlignment = false;
bool preferRenderCompressedFlagPassed = false;
bool allocateForImageCalled = false;
bool allocate32BitGraphicsMemoryImplCalled = false;
bool allocateForShareableCalled = false;
bool failReserveAddress = false;
bool failAllocateSystemMemory = false;
@ -165,6 +169,7 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
bool forceFailureInAllocationWithHostPointer = false;
bool isMockHostMemoryManager = false;
bool isMockEventPoolCreateMemoryManager = false;
bool limitedGPU = false;
std::unique_ptr<MockExecutionEnvironment> mockExecutionEnvironment;
DeviceBitfield recentlyPassedDeviceBitfield{};
std::unique_ptr<MultiGraphicsAllocation> waitAllocations = nullptr;

View File

@ -659,6 +659,9 @@ TEST_F(WddmCommandStreamTest, WhenMakingResidentAndNonResidentThenAllocationIsMo
}
TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWhenMakeResidentThenAllocationIsInResidencyContainer) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
void *hostPtr = reinterpret_cast<void *>(wddm->virtualAllocAddress + 0x1234);
auto size = 1234u;
@ -675,6 +678,9 @@ TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWhenMakeResidentThenAllocat
}
TEST_F(WddmCommandStreamTest, givenHostPtrAllocationWhenMapFailsThenFragmentsAreClearedAndNullptrIsReturned) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
this->wddm->callBaseMapGpuVa = false;
this->wddm->mapGpuVaStatus = false;
void *hostPtr = reinterpret_cast<void *>(wddm->virtualAllocAddress + 0x1234);
@ -691,6 +697,9 @@ TEST_F(WddmCommandStreamTest, givenHostPtrAllocationWhenMapFailsThenFragmentsAre
}
TEST_F(WddmCommandStreamTest, givenAddressWithHighestBitSetWhenItIsMappedThenProperAddressIsPassed) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
uintptr_t address = 0xffff0000;
void *faultyAddress = reinterpret_cast<void *>(address);
@ -709,6 +718,9 @@ TEST_F(WddmCommandStreamTest, givenAddressWithHighestBitSetWhenItIsMappedThenPro
}
TEST_F(WddmCommandStreamTest, givenHostPtrWhenPtrBelowRestrictionThenCreateAllocationAndMakeResident) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
void *hostPtr = reinterpret_cast<void *>(memoryManager->getAlignedMallocRestrictions()->minAddress - 0x1000);
auto size = 0x2000u;
@ -728,6 +740,9 @@ TEST_F(WddmCommandStreamTest, givenHostPtrWhenPtrBelowRestrictionThenCreateAlloc
}
TEST_F(WddmCommandStreamTest, givenTwoTemporaryAllocationsWhenCleanTemporaryAllocationListThenDestoryOnlyCompletedAllocations) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
void *host_ptr = (void *)0x1212341;
void *host_ptr2 = (void *)0x2212341;
auto size = 17262u;

View File

@ -146,6 +146,9 @@ TEST(WddmMemoryManagerWithDeferredDeleterTest, givenWmmWhenAsyncDeleterIsEnabled
TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocateGraphicsMemoryIsCalledThenMemoryPoolIsSystem4KBPages) {
memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment));
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
EXPECT_NE(nullptr, allocation);
@ -191,6 +194,9 @@ TEST_F(WddmMemoryManagerSimpleTest, givenAllocationDataWithFlagsWhenAllocateGrap
TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocateGraphicsMemoryWithPtrIsCalledThenMemoryPoolIsSystem4KBPages) {
memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment));
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
void *ptr = reinterpret_cast<void *>(0x1001);
auto size = 4096u;
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), false, size}, ptr);
@ -218,6 +224,9 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocate32BitGraphicsM
TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWith64KBPagesDisabledWhenAllocateGraphicsMemoryForSVMThen4KBGraphicsAllocationIsReturned) {
memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment));
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
auto size = MemoryConstants::pageSize;
auto svmAllocation = memoryManager->allocateGraphicsMemoryWithProperties({csr->getRootDeviceIndex(), size, GraphicsAllocation::AllocationType::SVM_ZERO_COPY, mockDeviceBitfield});
@ -229,6 +238,9 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWith64KBPagesDisabledWhenA
TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWith64KBPagesEnabledWhenAllocateGraphicsMemoryForSVMThenMemoryPoolIsSystem64KBPages) {
memoryManager.reset(new MockWddmMemoryManager(true, false, *executionEnvironment));
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
auto size = MemoryConstants::pageSize;
auto svmAllocation = memoryManager->allocateGraphicsMemoryWithProperties({csr->getRootDeviceIndex(), size, GraphicsAllocation::AllocationType::SVM_ZERO_COPY, mockDeviceBitfield});
@ -692,6 +704,9 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenAllocateGraphicsMemory
rootDeviceEnvironment->setHwInfo(&hwInfo);
auto memoryManager = std::make_unique<MockWddmMemoryManager>(true, false, *executionEnvironment);
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
memoryManager->allocateGraphicsMemoryInNonDevicePool = true;
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{mockRootDeviceIndex, true, size, GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, mockDeviceBitfield}, ptr);
@ -886,6 +901,9 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenNonTiledImgWithMipCountN
}
TEST_F(WddmMemoryManagerTest, GivenOffsetsWhenAllocatingGpuMemHostThenAllocatedOnlyIfInBounds) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
MockWddmAllocation alloc, allocOffseted;
// three pages
void *ptr = alignedMalloc(4 * 4096, 4096);
@ -939,6 +957,9 @@ TEST_F(WddmMemoryManagerTest, GivenOffsetsWhenAllocatingGpuMemHostThenAllocatedO
}
TEST_F(WddmMemoryManagerTest, WhenAllocatingGpuMemThenOsInternalStorageIsPopulatedCorrectly) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
MockWddmAllocation allocation;
// three pages
void *ptr = alignedMalloc(3 * 4096, 4096);
@ -1106,6 +1127,9 @@ TEST_F(WddmMemoryManagerTest, givenDefaultWddmMemoryManagerWhenAskedForAlignedMa
}
TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCpuMemNotMeetRestrictionsThenReserveMemRangeForMap) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
void *cpuPtr = reinterpret_cast<void *>(memoryManager->getAlignedMallocRestrictions()->minAddress - 0x1000);
size_t size = 0x1000;
@ -1243,6 +1267,9 @@ TEST_F(BufferWithWddmMemory, GivenNullOsHandleStorageWhenPopulatingThenFilledPoi
}
TEST_F(BufferWithWddmMemory, GivenMisalignedHostPtrAndMultiplePagesSizeWhenAskedForGraphicsAllocationThenItContainsAllFragmentsWithProperGpuAdrresses) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
auto ptr = reinterpret_cast<void *>(wddm->virtualAllocAddress + 0x1001);
auto size = MemoryConstants::pageSize * 10;
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{context.getDevice(0)->getRootDeviceIndex(), false, size, context.getDevice(0)->getDeviceBitfield()}, ptr);
@ -1517,6 +1544,9 @@ TEST_F(MockWddmMemoryManagerTest, givenEnabled64kbpagesWhenCreatingGraphicsMemor
wddm->init();
DebugManager.flags.Enable64kbpages.set(true);
MemoryManagerCreate<WddmMemoryManager> memoryManager64k(true, false, *executionEnvironment);
if (memoryManager64k.isLimitedGPU(0)) {
GTEST_SKIP();
}
EXPECT_EQ(0, wddm->createAllocationResult.called);
GraphicsAllocation *galloc = memoryManager64k.allocateGraphicsMemoryWithProperties({rootDeviceIndex, MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, mockDeviceBitfield});
@ -1577,6 +1607,9 @@ TEST_F(MockWddmMemoryManagerTest, givenAllocateGraphicsMemoryForBufferAndRequest
DebugManager.flags.Enable64kbpages.set(true);
MemoryManagerCreate<MockWddmMemoryManager> memoryManager(true, false, *executionEnvironment);
if (memoryManager.isLimitedGPU(0)) {
GTEST_SKIP();
}
EXPECT_EQ(0, wddm->createAllocationResult.called);
memoryManager.hugeGfxMemoryChunkSize = MemoryConstants::pageSize64k - MemoryConstants::pageSize;
@ -1604,6 +1637,9 @@ TEST_F(MockWddmMemoryManagerTest, givenAllocateGraphicsMemoryForHostBufferAndReq
DebugManager.flags.Enable64kbpages.set(true);
MemoryManagerCreate<MockWddmMemoryManager> memoryManager(true, false, *executionEnvironment);
if (memoryManager.isLimitedGPU(0)) {
GTEST_SKIP();
}
EXPECT_EQ(0, wddm->createAllocationResult.called);
memoryManager.hugeGfxMemoryChunkSize = MemoryConstants::pageSize64k - MemoryConstants::pageSize;
@ -2021,6 +2057,10 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMultiHandleAllocationAndPreferredGpuVaI
}
TEST_F(WddmMemoryManagerSimpleTest, givenSvmCpuAllocationWhenSizeAndAlignmentProvidedThenAllocateMemoryReserveGpuVa) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
size_t size = 2 * MemoryConstants::megaByte;
MockAllocationProperties properties{csr->getRootDeviceIndex(), true, size, GraphicsAllocation::AllocationType::SVM_CPU, mockDeviceBitfield};
properties.alignment = size;
@ -2074,8 +2114,8 @@ TEST_F(WddmMemoryManagerSimpleTest, givenDebugVariableWhenCreatingWddmMemoryMana
}
}
TEST_F(WddmMemoryManagerSimpleTest, givenBufferHostMemoryAllocationAndLimitedRangeAnd32BitThenAllocationGoesToSvmHeap) {
if (executionEnvironment->rootDeviceEnvironments[0]->isFullRangeSvm()) {
TEST_F(WddmMemoryManagerSimpleTest, givenBufferHostMemoryAllocationAndLimitedRangeAnd32BitThenAllocationGoesToExternalHeap) {
if (executionEnvironment->rootDeviceEnvironments[0]->isFullRangeSvm() || !is32bit) {
GTEST_SKIP();
}
@ -2085,12 +2125,12 @@ TEST_F(WddmMemoryManagerSimpleTest, givenBufferHostMemoryAllocationAndLimitedRan
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(size, allocation->getUnderlyingBufferSize());
EXPECT_NE(nullptr, allocation->getUnderlyingBuffer());
EXPECT_NE(nullptr, reinterpret_cast<void *>(allocation->getGpuAddress()));
uint64_t gpuAddress = allocation->getGpuAddress();
EXPECT_NE(0ULL, gpuAddress);
EXPECT_EQ(0ULL, gpuAddress & 0xffFFffF000000000);
auto heap = is32bit ? HeapIndex::HEAP_SVM : HeapIndex::HEAP_STANDARD;
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(heap)), allocation->getGpuAddress());
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(heap)), allocation->getGpuAddress());
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAddress);
memoryManager->freeGraphicsMemory(allocation);
}

View File

@ -555,6 +555,9 @@ TEST_F(WddmResidencyControllerWithGdiTest, givenOneUsedAllocationFromPreviousPer
}
TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, givenTripleAllocationWithUsedAndUnusedFragmentsSincePreviousTrimWhenTrimResidencyPeriodicTrimIsCalledThenProperFragmentsAreEvictedAndMarked) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
D3DKMT_TRIMNOTIFICATION trimNotification = {0};
trimNotification.Flags.PeriodicTrim = 1;
trimNotification.NumBytesToTrim = 0;
@ -788,6 +791,9 @@ TEST_F(WddmResidencyControllerWithGdiTest, GivenLastFenceIsGreaterThanMonitoredW
}
TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, WhenTrimmingToBudgetThenOnlyDoneFragmentsAreEvicted) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
gdi->setNonZeroNumBytesToTrimInEvict();
void *ptr = reinterpret_cast<void *>(wddm->virtualAllocAddress + 0x1000);
WddmAllocation allocation1(0, GraphicsAllocation::AllocationType::UNKNOWN, ptr, 0x1000, nullptr, MemoryPool::MemoryNull, 0u, 1u);
@ -937,6 +943,9 @@ TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, WhenMakingResidentRes
}
TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, GivenTripleAllocationsWhenMakingResidentResidencyAllocationsThenAllAllocationsAreMarkedResident) {
if (executionEnvironment->memoryManager.get()->isLimitedGPU(0)) {
GTEST_SKIP();
}
MockWddmAllocation allocation1, allocation2;
void *ptr = reinterpret_cast<void *>(wddm->virtualAllocAddress + 0x1500);

View File

@ -92,6 +92,9 @@ TEST(KernelInfoTest, givenKernelInfoWhenCreateKernelAllocationAndCannotAllocateM
KernelInfo kernelInfo;
auto executionEnvironment = new MockExecutionEnvironment(defaultHwInfo.get());
executionEnvironment->memoryManager.reset(new MyMemoryManager(*executionEnvironment));
if (executionEnvironment->memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
auto device = std::unique_ptr<Device>(Device::create<RootDevice>(executionEnvironment, mockRootDeviceIndex));
auto retVal = kernelInfo.createKernelAllocation(*device, false);
EXPECT_FALSE(retVal);

View File

@ -77,6 +77,9 @@ struct EnqueueBufferWindowsTest : public HardwareParse,
};
HWTEST_F(EnqueueBufferWindowsTest, givenMisalignedHostPtrWhenEnqueueReadBufferCalledThenStateBaseAddressAddressIsAlignedAndMatchesKernelDispatchInfoParams) {
if (executionEnvironment->memoryManager.get()->isLimitedGPU(0)) {
GTEST_SKIP();
}
initializeFixture<FamilyType>();
if (device->areSharedSystemAllocationsAllowed()) {
GTEST_SKIP();

View File

@ -505,7 +505,8 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData &
}
bool use32Allocator = heapAssigner.use32BitHeap(allocationData.type);
if (use32Allocator ||
bool isAllocationOnLimitedGPU = isLimitedGPUOnType(allocationData.rootDeviceIndex, allocationData.type);
if (use32Allocator || isAllocationOnLimitedGPU ||
(force32bitAllocations && allocationData.flags.allow32Bit && is64bit)) {
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
bool useLocalMem = heapAssigner.useExternal32BitHeap(allocationData.type) ? HwHelper::get(hwInfo->platform.eRenderCoreFamily).heapInLocalMem(*hwInfo) : false;

View File

@ -94,6 +94,17 @@ class MemoryManager {
void *lockResource(GraphicsAllocation *graphicsAllocation);
void unlockResource(GraphicsAllocation *graphicsAllocation);
MOCKABLE_VIRTUAL bool peek32bit() {
return is32bit;
}
MOCKABLE_VIRTUAL bool isLimitedGPU(uint32_t rootDeviceIndex) {
return peek32bit() && !peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->isFullRangeSvm();
}
MOCKABLE_VIRTUAL bool isLimitedGPUOnType(uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType type) {
return isLimitedGPU(rootDeviceIndex) &&
(type != GraphicsAllocation::AllocationType::MAP_ALLOCATION) &&
(type != GraphicsAllocation::AllocationType::IMAGE);
}
void cleanGraphicsMemoryCreatedFromHostPtr(GraphicsAllocation *);
GraphicsAllocation *createGraphicsAllocationWithPadding(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding);

View File

@ -216,6 +216,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const
mapPtr = alignUp(mapPtr, newAlignment);
}
mapPtr = isLimitedGPU(allocationData.rootDeviceIndex) ? nullptr : mapPtr;
if (!createWddmAllocation(wddmAllocation.get(), mapPtr)) {
delete gmm;
freeSystemMemory(pSysMem);

View File

@ -14,7 +14,7 @@ if(WIN32)
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_gdi_gfx_partition.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi_gfx_partition.cpp
${DEF_FILE}
)

View File

@ -10,20 +10,56 @@
#include "mock_gdi.h"
extern ADAPTER_INFO gAdapterInfo;
extern uint64_t gGpuAddressSpace;
void InitGfxPartition() {
gAdapterInfo.GfxPartition.Standard.Base = 0x0000800400000000;
gAdapterInfo.GfxPartition.Standard.Limit = 0x0000eeffffffffff;
gAdapterInfo.GfxPartition.Standard64KB.Base = 0x0000b80200000000;
gAdapterInfo.GfxPartition.Standard64KB.Limit = 0x0000efffffffffff;
gAdapterInfo.GfxPartition.SVM.Base = 0;
gAdapterInfo.GfxPartition.SVM.Limit = MemoryConstants::maxSvmAddress;
gAdapterInfo.GfxPartition.Heap32[0].Base = 0x0000800000000000;
gAdapterInfo.GfxPartition.Heap32[0].Limit = 0x00008000ffffefff;
gAdapterInfo.GfxPartition.Heap32[1].Base = 0x0000800100000000;
gAdapterInfo.GfxPartition.Heap32[1].Limit = 0x00008001ffffefff;
gAdapterInfo.GfxPartition.Heap32[2].Base = 0x0000800200000000;
gAdapterInfo.GfxPartition.Heap32[2].Limit = 0x00008002ffffefff;
gAdapterInfo.GfxPartition.Heap32[3].Base = 0x0000800300000000;
gAdapterInfo.GfxPartition.Heap32[3].Limit = 0x00008003ffffefff;
if (gGpuAddressSpace >= maxNBitValue(48)) {
// Full-range SVM 48 bit
gAdapterInfo.GfxPartition.Standard.Base = 0x0000800400000000;
gAdapterInfo.GfxPartition.Standard.Limit = 0x0000b801ffffffff;
gAdapterInfo.GfxPartition.Standard64KB.Base = 0x0000b80200000000;
gAdapterInfo.GfxPartition.Standard64KB.Limit = 0x0000efffffffffff;
gAdapterInfo.GfxPartition.SVM.Base = 0;
gAdapterInfo.GfxPartition.SVM.Limit = MemoryConstants::maxSvmAddress;
gAdapterInfo.GfxPartition.Heap32[0].Base = 0x0000800000000000;
gAdapterInfo.GfxPartition.Heap32[0].Limit = 0x00008000ffffefff;
gAdapterInfo.GfxPartition.Heap32[1].Base = 0x0000800100000000;
gAdapterInfo.GfxPartition.Heap32[1].Limit = 0x00008001ffffefff;
gAdapterInfo.GfxPartition.Heap32[2].Base = 0x0000800200000000;
gAdapterInfo.GfxPartition.Heap32[2].Limit = 0x00008002ffffefff;
gAdapterInfo.GfxPartition.Heap32[3].Base = 0x0000800300000000;
gAdapterInfo.GfxPartition.Heap32[3].Limit = 0x00008003ffffefff;
} else if (gGpuAddressSpace == maxNBitValue(47)) {
// Full-range SVM 47 bit
gAdapterInfo.GfxPartition.Standard.Base = 0x000001c98a320000;
gAdapterInfo.GfxPartition.Standard.Limit = 0x000005c98a31ffff;
gAdapterInfo.GfxPartition.Standard64KB.Base = 0x000005ce00000000;
gAdapterInfo.GfxPartition.Standard64KB.Limit = 0x000009cdffffffff;
gAdapterInfo.GfxPartition.SVM.Base = 0;
gAdapterInfo.GfxPartition.SVM.Limit = MemoryConstants::maxSvmAddress;
gAdapterInfo.GfxPartition.Heap32[0].Base = 0x000005ca00000000;
gAdapterInfo.GfxPartition.Heap32[0].Limit = 0x000005caffffefff;
gAdapterInfo.GfxPartition.Heap32[1].Base = 0x000005cb00000000;
gAdapterInfo.GfxPartition.Heap32[1].Limit = 0x000005cbffffefff;
gAdapterInfo.GfxPartition.Heap32[2].Base = 0x000005cc00000000;
gAdapterInfo.GfxPartition.Heap32[2].Limit = 0x000005ccffffefff;
gAdapterInfo.GfxPartition.Heap32[3].Base = 0x000005cd00000000;
gAdapterInfo.GfxPartition.Heap32[3].Limit = 0x000005cdffffefff;
} else {
// Limited range
gAdapterInfo.GfxPartition.Standard.Base = 0x0000000100000000;
gAdapterInfo.GfxPartition.Standard.Limit = 0x0000000FFFFFFFFF;
gAdapterInfo.GfxPartition.Standard64KB.Base = 0x0000000100000000;
gAdapterInfo.GfxPartition.Standard64KB.Limit = 0x0000000FFFFFFFFF;
gAdapterInfo.GfxPartition.SVM.Base = 0x0;
gAdapterInfo.GfxPartition.SVM.Limit = 0x0;
gAdapterInfo.GfxPartition.Heap32[0].Base = 0x00001000;
gAdapterInfo.GfxPartition.Heap32[0].Limit = 0xFFFFEFFF;
gAdapterInfo.GfxPartition.Heap32[1].Base = 0x00001000;
gAdapterInfo.GfxPartition.Heap32[1].Limit = 0xFFFFEFFF;
gAdapterInfo.GfxPartition.Heap32[2].Base = 0x00001000;
gAdapterInfo.GfxPartition.Heap32[2].Limit = 0xFFFFEFFF;
gAdapterInfo.GfxPartition.Heap32[3].Base = 0x00001000;
gAdapterInfo.GfxPartition.Heap32[3].Limit = 0xFFFFEFFF;
}
}

View File

@ -277,6 +277,9 @@ HWTEST_F(MidThreadPreemptionTests, givenMidThreadPreemptionWhenFailingOnCsrSurfa
};
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
executionEnvironment->memoryManager = std::make_unique<FailingMemoryManager>(*executionEnvironment);
if (executionEnvironment->memoryManager.get()->isLimitedGPU(0)) {
GTEST_SKIP();
}
std::unique_ptr<MockDevice> mockDevice(MockDevice::create<MockDevice>(executionEnvironment, 0));
EXPECT_EQ(nullptr, mockDevice.get());