mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
Use correct Heap32 index for local memory allocations
Change-Id: I068f712ab2b05ee3d5a9716b21de685a7fee3a02 Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
4076d3e294
commit
6dd07bd3bc
@@ -53,7 +53,7 @@ void CommandQueueHw<gfxCoreFamily>::programGeneralStateBaseAddress(uint64_t gsba
|
||||
gsba,
|
||||
true,
|
||||
(device->getMOCS(true, false) >> 1),
|
||||
neoDevice->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex()),
|
||||
neoDevice->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), false),
|
||||
true,
|
||||
neoDevice->getGmmHelper(),
|
||||
false);
|
||||
|
||||
@@ -124,7 +124,7 @@ using CommandQueueSBASupport = IsWithinProducts<IGFX_SKYLAKE, IGFX_TIGERLAKE_LP>
|
||||
|
||||
struct MockMemoryManagerCommandQueueSBA : public MemoryManagerMock {
|
||||
MockMemoryManagerCommandQueueSBA(NEO::ExecutionEnvironment &executionEnvironment) : MemoryManagerMock(const_cast<NEO::ExecutionEnvironment &>(executionEnvironment)) {}
|
||||
MOCK_METHOD1(getInternalHeapBaseAddress, uint64_t(uint32_t rootDeviceIndex));
|
||||
MOCK_METHOD2(getInternalHeapBaseAddress, uint64_t(uint32_t rootDeviceIndex, bool useLocalMemory));
|
||||
};
|
||||
|
||||
struct CommandQueueProgramSBATest : public ::testing::Test {
|
||||
@@ -169,7 +169,7 @@ HWTEST2_F(CommandQueueProgramSBATest, whenCreatingCommandQueueThenItIsInitialize
|
||||
uint32_t alignedSize = 4096u;
|
||||
NEO::LinearStream child(commandQueue->commandStream->getSpace(alignedSize), alignedSize);
|
||||
|
||||
EXPECT_CALL(*memoryManager, getInternalHeapBaseAddress(rootDeviceIndex))
|
||||
EXPECT_CALL(*memoryManager, getInternalHeapBaseAddress(rootDeviceIndex, false))
|
||||
.Times(1);
|
||||
|
||||
commandQueue->programGeneralStateBaseAddress(0u, child);
|
||||
|
||||
@@ -102,8 +102,9 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(const Al
|
||||
return memoryAllocation;
|
||||
}
|
||||
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) {
|
||||
auto heap = useInternal32BitAllocator(allocationData.type) ? HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_EXTERNAL;
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) {
|
||||
auto heap = useInternal32BitAllocator(allocationData.type) ? selectInternalHeap(useLocalMemory)
|
||||
: selectExternalHeap(useLocalMemory);
|
||||
auto gfxPartition = getGfxPartition(allocationData.rootDeviceIndex);
|
||||
if (allocationData.hostPtr) {
|
||||
auto allocationSize = alignSizeWholePage(allocationData.hostPtr, allocationData.size);
|
||||
|
||||
@@ -89,7 +89,7 @@ class OsAgnosticMemoryManager : public MemoryManager {
|
||||
|
||||
void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) override { return graphicsAllocation.getUnderlyingBuffer(); }
|
||||
void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override {}
|
||||
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override;
|
||||
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override;
|
||||
MemoryAllocation *createMemoryAllocation(GraphicsAllocation::AllocationType allocationType, void *driverAllocatedCpuPointer, void *pMem, uint64_t gpuAddress, size_t memSize,
|
||||
uint64_t count, MemoryPool::Type pool, uint32_t rootDeviceIndex, bool uncacheable, bool flushL3Required, bool requireSpecificBitness);
|
||||
|
||||
@@ -222,7 +222,7 @@ HWTEST_F(EnqueueCopyBufferRectTest, WhenCopyingBufferRect2DThenL3ProgrammingIsCo
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueCopyBufferRectTest, When2DEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueCopyBufferRect2D<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ HWTEST_F(EnqueueCopyBufferRectTest, WhenCopyingBufferRect3DThenL3ProgrammingIsCo
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueCopyBufferRectTest, When3DEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueCopyBufferRect3D<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ HWTEST_F(EnqueueCopyBufferTest, WhenCopyingBufferThenL3ProgrammingIsCorrect) {
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueCopyBufferTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueCopyBufferAndParse<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ HWTEST_F(EnqueueCopyBufferToImageTest, WhenCopyingBufferToImageThenL3Programming
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueCopyBufferToImageTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueCopyBufferToImage<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ HWTEST_F(EnqueueCopyImageTest, WhenCopyingImageThenL3ProgrammingIsCorrect) {
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueCopyImageTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueCopyImage<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ HWTEST_F(EnqueueCopyImageToBufferTest, WhenCopyingImageToBufferThenL3Programming
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueCopyImageToBufferTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueCopyImageToBuffer<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, WhenFillingBufferThenL3ProgrammingIsCorrect)
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueFillBufferCmdTests, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueFillBuffer<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ HWTEST_F(EnqueueFillImageTest, WhenFillingImageThenL3ProgrammingIsCorrect) {
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueFillImageTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueFillImage<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -186,9 +186,9 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueWorkItemTestsWithLimitedParamSet, LoadRegiste
|
||||
HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueWorkItemTestsWithLimitedParamSet, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueKernel<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList,
|
||||
context->getMemoryManager()->peekForce32BitAllocations() ? context->getMemoryManager()->getExternalHeapBaseAddress(ultCsr.rootDeviceIndex) : 0llu);
|
||||
context->getMemoryManager()->peekForce32BitAllocations() ? context->getMemoryManager()->getExternalHeapBaseAddress(ultCsr.rootDeviceIndex, false) : 0llu);
|
||||
}
|
||||
|
||||
HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueWorkItemTestsWithLimitedParamSet, MediaInterfaceDescriptorLoad) {
|
||||
@@ -510,7 +510,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueKernelWithScratch, givenDeviceForcing32bitAll
|
||||
|
||||
auto GSHaddress = sba->getGeneralStateBaseAddress();
|
||||
|
||||
EXPECT_EQ(memoryManager->getExternalHeapBaseAddress(graphicsAllocation->getRootDeviceIndex()), GSHaddress);
|
||||
EXPECT_EQ(memoryManager->getExternalHeapBaseAddress(graphicsAllocation->getRootDeviceIndex(), graphicsAllocation->isAllocatedInLocalMemoryPool()), GSHaddress);
|
||||
|
||||
//now re-try to see if SBA is not programmed
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ HWTEST_F(EnqueueReadBufferRectTest, WhenReadingBufferThenL3ProgrammingIsCorrect)
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueReadBufferRectTest, When2DEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueReadBufferRect2D<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueReadBufferTypeTest, WhenEnqueueIsDoneThenStat
|
||||
srcBuffer->forceDisallowCPUCopy = true;
|
||||
enqueueReadBuffer<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ HWTEST_F(EnqueueReadImageTest, WhenReadingImageThenL3ProgrammingIsCorrect) {
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueReadImageTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueReadImage<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, WhenWritingBufferThenL3ProgrammingIsCorrect
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueWriteBufferRectTest, When2DEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueWriteBufferRect2D<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueWriteBufferTypeTest, WhenEnqueueIsDoneThenSta
|
||||
srcBuffer->forceDisallowCPUCopy = true;
|
||||
enqueueWriteBuffer<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ HWTEST_F(EnqueueWriteImageTest, WhenWritingImageThenL3ProgrammingIsCorrect) {
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueWriteImageTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) {
|
||||
enqueueWriteImage<FamilyType>();
|
||||
auto &ultCsr = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex),
|
||||
validateStateBaseAddress<FamilyType>(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu);
|
||||
}
|
||||
|
||||
|
||||
@@ -457,7 +457,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, stateBaseAddressProgrammingShouldM
|
||||
auto &cmd = *reinterpret_cast<STATE_BASE_ADDRESS *>(cmdStateBaseAddress);
|
||||
|
||||
EXPECT_EQ(dsh.getCpuBase(), reinterpret_cast<void *>(cmd.getDynamicStateBaseAddress()));
|
||||
EXPECT_EQ(commandStreamReceiver.getMemoryManager()->getInternalHeapBaseAddress(commandStreamReceiver.rootDeviceIndex), cmd.getInstructionBaseAddress());
|
||||
EXPECT_EQ(commandStreamReceiver.getMemoryManager()->getInternalHeapBaseAddress(commandStreamReceiver.rootDeviceIndex, ioh.getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), cmd.getInstructionBaseAddress());
|
||||
EXPECT_EQ(ioh.getCpuBase(), reinterpret_cast<void *>(cmd.getIndirectObjectBaseAddress()));
|
||||
EXPECT_EQ(ssh.getCpuBase(), reinterpret_cast<void *>(cmd.getSurfaceStateBaseAddress()));
|
||||
|
||||
|
||||
@@ -638,7 +638,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenTwoConsecu
|
||||
}
|
||||
|
||||
if (sharedDeviceInfo.force32BitAddressess) {
|
||||
EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(graphicsAllocationScratch->getRootDeviceIndex()), GSHaddress);
|
||||
EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(graphicsAllocationScratch->getRootDeviceIndex(), false), GSHaddress);
|
||||
} else {
|
||||
if (is64bit) {
|
||||
EXPECT_EQ(graphicsAddress - ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, GSHaddress);
|
||||
@@ -752,7 +752,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNDRangeKer
|
||||
EXPECT_EQ(highPartGraphicsAddress, scratchBaseHighPart);
|
||||
|
||||
if (sharedDeviceInfo.force32BitAddressess) {
|
||||
EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(graphicsAllocationScratch->getRootDeviceIndex()), GSHaddress);
|
||||
EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(graphicsAllocationScratch->getRootDeviceIndex(), false), GSHaddress);
|
||||
} else {
|
||||
if (is64bit) {
|
||||
EXPECT_EQ(graphicsAddress - ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, GSHaddress);
|
||||
|
||||
@@ -76,6 +76,14 @@ TEST(MemoryManagerTest, givenDebugVariableWhenCreatingMemoryManagerThenSetSuppor
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenLocalMemoryRequiredWhenSelectingHeapThenPickDeviceHeapIndex) {
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, MemoryManager::selectInternalHeap(true));
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL, MemoryManager::selectInternalHeap(false));
|
||||
|
||||
EXPECT_EQ(HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY, MemoryManager::selectExternalHeap(true));
|
||||
EXPECT_EQ(HeapIndex::HEAP_EXTERNAL, MemoryManager::selectExternalHeap(false));
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, whenCreatingAllocPropertiesForMultiStorageResourceThenMultiStorageResourcesFlagIsSetToTrue) {
|
||||
AllocationProperties properties{0, false, 0u, GraphicsAllocation::AllocationType::SCRATCH_SURFACE, false, true, 0};
|
||||
EXPECT_TRUE(properties.multiStorageResource);
|
||||
@@ -649,7 +657,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAskedFor32BitAllocationWhenL
|
||||
auto gfxAllocation = memoryManager.allocateGraphicsMemoryWithAlignment(allocationData);
|
||||
ASSERT_NE(gfxAllocation, nullptr);
|
||||
EXPECT_NE(gfxAllocation->getGpuBaseAddress(), 0ull);
|
||||
EXPECT_EQ(gfxAllocation->getGpuBaseAddress(), memoryManager.getExternalHeapBaseAddress(gfxAllocation->getRootDeviceIndex()));
|
||||
EXPECT_EQ(gfxAllocation->getGpuBaseAddress(), memoryManager.getExternalHeapBaseAddress(gfxAllocation->getRootDeviceIndex(), gfxAllocation->isAllocatedInLocalMemoryPool()));
|
||||
memoryManager.freeGraphicsMemory(gfxAllocation);
|
||||
}
|
||||
|
||||
@@ -2029,19 +2037,19 @@ TEST(MemoryManagerTest, givenForcedLinearImages3DImageAndProperDescriptorValuesW
|
||||
TEST(HeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
|
||||
GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::KERNEL_ISA, nullptr, 0, 0, 0, MemoryPool::MemoryNull};
|
||||
allocation.set32BitAllocation(true);
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, MemoryManager::selectHeap(&allocation, false, false));
|
||||
EXPECT_EQ(MemoryManager::selectInternalHeap(allocation.isAllocatedInLocalMemoryPool()), MemoryManager::selectHeap(&allocation, false, false));
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, givenNon32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
|
||||
GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::KERNEL_ISA, nullptr, 0, 0, 0, MemoryPool::MemoryNull};
|
||||
allocation.set32BitAllocation(false);
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, MemoryManager::selectHeap(&allocation, false, false));
|
||||
EXPECT_EQ(MemoryManager::selectInternalHeap(allocation.isAllocatedInLocalMemoryPool()), MemoryManager::selectHeap(&allocation, false, false));
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExternalHeapIsUsed) {
|
||||
GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull};
|
||||
allocation.set32BitAllocation(true);
|
||||
EXPECT_EQ(HeapIndex::HEAP_EXTERNAL, MemoryManager::selectHeap(&allocation, false, false));
|
||||
EXPECT_EQ(MemoryManager::selectExternalHeap(allocation.isAllocatedInLocalMemoryPool()), MemoryManager::selectHeap(&allocation, false, false));
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForExternalAllocationThenStandardHeapIsUsed) {
|
||||
|
||||
@@ -69,7 +69,8 @@ DrmAllocation *TestedDrmMemoryManager::allocate32BitGraphicsMemory(uint32_t root
|
||||
AllocationData allocationData;
|
||||
MockAllocationProperties properties(rootDeviceIndex, allocateMemory, size, allocationType);
|
||||
getAllocationData(allocationData, properties, ptr, createStorageInfoFromProperties(properties));
|
||||
return allocate32BitGraphicsMemoryImpl(allocationData);
|
||||
bool useLocalMemory = !allocationData.flags.useSystemMemory && this->localMemorySupported[rootDeviceIndex];
|
||||
return allocate32BitGraphicsMemoryImpl(allocationData, useLocalMemory);
|
||||
}
|
||||
TestedDrmMemoryManager::~TestedDrmMemoryManager() {
|
||||
DrmMemoryManager::commonCleanup();
|
||||
|
||||
@@ -102,14 +102,15 @@ GraphicsAllocation *MockMemoryManager::allocate32BitGraphicsMemory(uint32_t root
|
||||
AllocationData allocationData{};
|
||||
MockAllocationProperties properties(rootDeviceIndex, allocateMemory, size, allocationType);
|
||||
getAllocationData(allocationData, properties, ptr, createStorageInfoFromProperties(properties));
|
||||
return allocate32BitGraphicsMemoryImpl(allocationData);
|
||||
bool useLocalMemory = !allocationData.flags.useSystemMemory && this->localMemorySupported[rootDeviceIndex];
|
||||
return allocate32BitGraphicsMemoryImpl(allocationData, useLocalMemory);
|
||||
}
|
||||
|
||||
GraphicsAllocation *MockMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) {
|
||||
GraphicsAllocation *MockMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) {
|
||||
if (failAllocate32Bit) {
|
||||
return nullptr;
|
||||
}
|
||||
return OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(allocationData);
|
||||
return OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(allocationData, useLocalMemory);
|
||||
}
|
||||
|
||||
FailMemoryManager::FailMemoryManager(int32_t failedAllocationsCount, ExecutionEnvironment &executionEnvironment) : MockMemoryManager(executionEnvironment) {
|
||||
|
||||
@@ -107,7 +107,7 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
|
||||
bool isCpuCopyRequired(const void *ptr) override { return cpuCopyRequired; }
|
||||
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(uint32_t rootDeviceIndex, size_t size, const void *ptr, GraphicsAllocation::AllocationType allocationType);
|
||||
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override;
|
||||
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override;
|
||||
|
||||
void forceLimitedRangeAllocator(uint32_t rootDeviceIndex, uint64_t range) { getGfxPartition(rootDeviceIndex)->init(range, 0, 0, gfxPartitions.size()); }
|
||||
|
||||
@@ -186,7 +186,7 @@ class FailMemoryManager : public MockMemoryManager {
|
||||
GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties, const void *ptr) override {
|
||||
return nullptr;
|
||||
}
|
||||
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override {
|
||||
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override {
|
||||
return nullptr;
|
||||
}
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness) override {
|
||||
|
||||
@@ -926,7 +926,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationThen32
|
||||
EXPECT_LT(address64bit, MemoryConstants::max32BitAddress);
|
||||
EXPECT_TRUE(allocation->is32BitAllocation());
|
||||
|
||||
EXPECT_EQ(GmmHelper::canonize(memoryManager->getExternalHeapBaseAddress(allocation->getRootDeviceIndex())), allocation->getGpuBaseAddress());
|
||||
EXPECT_EQ(GmmHelper::canonize(memoryManager->getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), allocation->isAllocatedInLocalMemoryPool())), allocation->getGpuBaseAddress());
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
@@ -2029,7 +2029,7 @@ TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleAndBi
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
EXPECT_TRUE(graphicsAllocation->is32BitAllocation());
|
||||
EXPECT_EQ(1, lseekCalledCount);
|
||||
EXPECT_EQ(GmmHelper::canonize(memoryManager->getExternalHeapBaseAddress(graphicsAllocation->getRootDeviceIndex())), drmAllocation->getGpuBaseAddress());
|
||||
EXPECT_EQ(GmmHelper::canonize(memoryManager->getExternalHeapBaseAddress(graphicsAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool())), drmAllocation->getGpuBaseAddress());
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
|
||||
@@ -2482,7 +2482,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit
|
||||
|
||||
auto gpuPtr = drmAllocation->getGpuAddress();
|
||||
|
||||
auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex()));
|
||||
auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool()));
|
||||
auto heapSize = 4 * GB;
|
||||
|
||||
EXPECT_GE(gpuPtr, heapBase);
|
||||
@@ -2515,7 +2515,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForInternalAlloc
|
||||
|
||||
auto gpuPtr = drmAllocation->getGpuAddress();
|
||||
|
||||
auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex()));
|
||||
auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool()));
|
||||
auto heapSize = 4 * GB;
|
||||
|
||||
EXPECT_GE(gpuPtr, heapBase);
|
||||
@@ -2572,7 +2572,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit
|
||||
|
||||
auto gpuPtr = drmAllocation->getGpuAddress();
|
||||
|
||||
auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex()));
|
||||
auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool()));
|
||||
auto heapSize = 4 * GB;
|
||||
|
||||
EXPECT_GE(gpuPtr, heapBase);
|
||||
@@ -2689,7 +2689,7 @@ TEST_F(DrmMemoryManagerBasic, givenDefaultDrmMemoryManagerWhenItIsQueriedForInte
|
||||
true,
|
||||
executionEnvironment));
|
||||
auto heapBase = memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY);
|
||||
EXPECT_EQ(heapBase, memoryManager->getInternalHeapBaseAddress(rootDeviceIndex));
|
||||
EXPECT_EQ(heapBase, memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, true));
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerBasic, givenMemoryManagerWithEnabledHostMemoryValidationWhenFeatureIsQueriedThenTrueIsReturned) {
|
||||
|
||||
@@ -52,7 +52,8 @@ class MockWddmMemoryManager : public MemoryManagerCreate<WddmMemoryManager> {
|
||||
AllocationData allocationData;
|
||||
MockAllocationProperties properties(rootDeviceIndex, allocateMemory, size, allocationType);
|
||||
getAllocationData(allocationData, properties, ptr, createStorageInfoFromProperties(properties));
|
||||
return allocate32BitGraphicsMemoryImpl(allocationData);
|
||||
bool useLocalMemory = !allocationData.flags.useSystemMemory && this->localMemorySupported[rootDeviceIndex];
|
||||
return allocate32BitGraphicsMemoryImpl(allocationData, useLocalMemory);
|
||||
}
|
||||
|
||||
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override {
|
||||
|
||||
@@ -122,7 +122,7 @@ TEST(WddmMemoryManagerExternalHeapTest, WhenExternalHeapIsCreatedThenItHasCorrec
|
||||
|
||||
std::unique_ptr<WddmMemoryManager> memoryManager = std::unique_ptr<WddmMemoryManager>(new WddmMemoryManager(*executionEnvironment));
|
||||
|
||||
EXPECT_EQ(base, memoryManager->getExternalHeapBaseAddress(0));
|
||||
EXPECT_EQ(base, memoryManager->getExternalHeapBaseAddress(0, false));
|
||||
}
|
||||
|
||||
TEST(WddmMemoryManagerWithDeferredDeleterTest, givenWmmWhenAsyncDeleterIsEnabledAndWaitForDeletionsIsCalledThenDeleterInWddmIsSetToNullptr) {
|
||||
@@ -566,7 +566,7 @@ TEST_F(WddmMemoryManagerTest, GivenForce32bitAddressingAndRequireSpecificBitness
|
||||
if (is64bit) {
|
||||
EXPECT_TRUE(gpuAllocation->is32BitAllocation());
|
||||
|
||||
uint64_t base = memoryManager->getExternalHeapBaseAddress(gpuAllocation->getRootDeviceIndex());
|
||||
uint64_t base = memoryManager->getExternalHeapBaseAddress(gpuAllocation->getRootDeviceIndex(), gpuAllocation->isAllocatedInLocalMemoryPool());
|
||||
EXPECT_EQ(GmmHelper::canonize(base), gpuAllocation->getGpuBaseAddress());
|
||||
}
|
||||
|
||||
@@ -970,7 +970,7 @@ TEST_F(WddmMemoryManagerTest, WhenAllocating32BitMemoryThenGpuBaseAddressIsCanno
|
||||
|
||||
ASSERT_NE(nullptr, gpuAllocation);
|
||||
|
||||
uint64_t cannonizedAddress = GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL));
|
||||
uint64_t cannonizedAddress = GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(MemoryManager::selectExternalHeap(gpuAllocation->isAllocatedInLocalMemoryPool())));
|
||||
EXPECT_EQ(cannonizedAddress, gpuAllocation->getGpuBaseAddress());
|
||||
|
||||
memoryManager->freeGraphicsMemory(gpuAllocation);
|
||||
@@ -1087,12 +1087,12 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstAnd
|
||||
TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocationWhenCallIsMadeThenAllocationIsCreatedIn32BitHeapInternal) {
|
||||
auto wddmAllocation = static_cast<WddmAllocation *>(memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, MemoryConstants::pageSize, nullptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP));
|
||||
ASSERT_NE(nullptr, wddmAllocation);
|
||||
EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(wddmAllocation->getRootDeviceIndex())));
|
||||
EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(wddmAllocation->getRootDeviceIndex(), wddmAllocation->isAllocatedInLocalMemoryPool())));
|
||||
EXPECT_NE(nullptr, wddmAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress());
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex));
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY));
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, wddmAllocation->isAllocatedInLocalMemoryPool()));
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(MemoryManager::selectInternalHeap(wddmAllocation->isAllocatedInLocalMemoryPool())));
|
||||
|
||||
EXPECT_GT(wddmAllocation->getGpuAddress(), cannonizedHeapBase);
|
||||
EXPECT_LT(wddmAllocation->getGpuAddress() + wddmAllocation->getUnderlyingBufferSize(), cannonizedHeapEnd);
|
||||
@@ -1106,12 +1106,12 @@ TEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationWhe
|
||||
auto ptr = reinterpret_cast<void *>(0x1000000);
|
||||
auto wddmAllocation = static_cast<WddmAllocation *>(memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, MemoryConstants::pageSize, ptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP));
|
||||
ASSERT_NE(nullptr, wddmAllocation);
|
||||
EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex)));
|
||||
EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, wddmAllocation->isAllocatedInLocalMemoryPool())));
|
||||
EXPECT_EQ(ptr, wddmAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress());
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex));
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY));
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, wddmAllocation->isAllocatedInLocalMemoryPool()));
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(MemoryManager::selectInternalHeap(wddmAllocation->isAllocatedInLocalMemoryPool())));
|
||||
|
||||
EXPECT_GT(wddmAllocation->getGpuAddress(), cannonizedHeapBase);
|
||||
EXPECT_LT(wddmAllocation->getGpuAddress() + wddmAllocation->getUnderlyingBufferSize(), cannonizedHeapEnd);
|
||||
@@ -1386,7 +1386,7 @@ TEST(WddmMemoryManagerDefaults, givenDefaultWddmMemoryManagerWhenItIsQueriedForI
|
||||
wddm->init();
|
||||
MockWddmMemoryManager memoryManager(*executionEnvironment);
|
||||
auto heapBase = wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Base;
|
||||
EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress(0));
|
||||
EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress(0, true));
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenValidateAllocationFunctionWhenItIsCalledWithTripleAllocationThenSuccessIsReturned) {
|
||||
|
||||
@@ -128,7 +128,7 @@ TEST(KernelInfoTest, givenKernelInfoWhenCreateKernelAllocationThenCopyWholeKerne
|
||||
class MyMemoryManager : public OsAgnosticMemoryManager {
|
||||
public:
|
||||
using OsAgnosticMemoryManager::OsAgnosticMemoryManager;
|
||||
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override { return nullptr; }
|
||||
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override { return nullptr; }
|
||||
};
|
||||
|
||||
TEST(KernelInfoTest, givenKernelInfoWhenCreateKernelAllocationAndCannotAllocateMemoryThenReturnsFalse) {
|
||||
|
||||
@@ -652,7 +652,7 @@ TEST_P(ProgramFromBinaryTest, givenProgramWhenItIsBeingBuildThenItContainsGraphi
|
||||
EXPECT_NE(kernelInfo->heapInfo.pKernelHeap, kernelIsa);
|
||||
EXPECT_EQ(0, memcmp(kernelIsa, kernelInfo->heapInfo.pKernelHeap, kernelInfo->heapInfo.KernelHeapSize));
|
||||
auto rootDeviceIndex = graphicsAllocation->getRootDeviceIndex();
|
||||
EXPECT_EQ(GmmHelper::decanonize(graphicsAllocation->getGpuBaseAddress()), pProgram->getDevice().getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex));
|
||||
EXPECT_EQ(GmmHelper::decanonize(graphicsAllocation->getGpuBaseAddress()), pProgram->getDevice().getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, graphicsAllocation->isAllocatedInLocalMemoryPool()));
|
||||
}
|
||||
|
||||
TEST_P(ProgramFromBinaryTest, whenProgramIsBeingRebuildThenOutdatedGlobalBuffersAreFreed) {
|
||||
|
||||
@@ -82,7 +82,7 @@ bool CommandContainer::initialize(Device *device) {
|
||||
indirectHeaps[i] = std::make_unique<IndirectHeap>(allocationIndirectHeaps[i], requireInternalHeap);
|
||||
}
|
||||
|
||||
instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex());
|
||||
instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), allocationIndirectHeaps[IndirectHeap::Type::INDIRECT_OBJECT]->isAllocatedInLocalMemoryPool());
|
||||
|
||||
iddBlock = nullptr;
|
||||
nextIddInBlock = this->getNumIddPerBlock();
|
||||
|
||||
@@ -350,7 +350,8 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
|
||||
if (is64bit && scratchSpaceController->getScratchSpaceAllocation() && !force32BitAllocations) {
|
||||
newGSHbase = scratchSpaceController->calculateNewGSH();
|
||||
} else if (is64bit && force32BitAllocations && dispatchFlags.gsba32BitRequired) {
|
||||
newGSHbase = getMemoryManager()->getExternalHeapBaseAddress(rootDeviceIndex);
|
||||
bool useLocalMemory = scratchSpaceController->getScratchSpaceAllocation() ? scratchSpaceController->getScratchSpaceAllocation()->isAllocatedInLocalMemoryPool() : false;
|
||||
newGSHbase = getMemoryManager()->getExternalHeapBaseAddress(rootDeviceIndex, useLocalMemory);
|
||||
GSBAFor32BitProgrammed = true;
|
||||
}
|
||||
|
||||
@@ -364,7 +365,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
|
||||
newGSHbase,
|
||||
true,
|
||||
mocsIndex,
|
||||
getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex),
|
||||
getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, ioh.getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
|
||||
true,
|
||||
device.getGmmHelper(),
|
||||
isMultiOsContextCapable());
|
||||
|
||||
@@ -233,6 +233,8 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
||||
|
||||
uint32_t getUsedPageSize() const;
|
||||
|
||||
bool isAllocatedInLocalMemoryPool() const { return (this->memoryPool == MemoryPool::LocalMemory); }
|
||||
|
||||
OsHandleStorage fragmentsStorage;
|
||||
StorageInfo storageInfo = {};
|
||||
|
||||
|
||||
@@ -401,7 +401,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData &
|
||||
}
|
||||
if (useInternal32BitAllocator(allocationData.type) ||
|
||||
(force32bitAllocations && allocationData.flags.allow32Bit && is64bit)) {
|
||||
return allocate32BitGraphicsMemoryImpl(allocationData);
|
||||
return allocate32BitGraphicsMemoryImpl(allocationData, false);
|
||||
}
|
||||
if (allocationData.hostPtr) {
|
||||
return allocateGraphicsMemoryWithHostPtr(allocationData);
|
||||
@@ -480,10 +480,10 @@ void MemoryManager::unlockResource(GraphicsAllocation *graphicsAllocation) {
|
||||
HeapIndex MemoryManager::selectHeap(const GraphicsAllocation *allocation, bool hasPointer, bool isFullRangeSVM) {
|
||||
if (allocation) {
|
||||
if (useInternal32BitAllocator(allocation->getAllocationType())) {
|
||||
return HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY;
|
||||
return selectInternalHeap(allocation->isAllocatedInLocalMemoryPool());
|
||||
}
|
||||
if (allocation->is32BitAllocation()) {
|
||||
return HeapIndex::HEAP_EXTERNAL;
|
||||
return selectExternalHeap(allocation->isAllocatedInLocalMemoryPool());
|
||||
}
|
||||
}
|
||||
if (isFullRangeSVM) {
|
||||
|
||||
@@ -98,8 +98,8 @@ class MemoryManager {
|
||||
virtual uint64_t getLocalMemorySize(uint32_t rootDeviceIndex) = 0;
|
||||
|
||||
uint64_t getMaxApplicationAddress() { return is64bit ? MemoryConstants::max64BitAppAddress : MemoryConstants::max32BitAppAddress; };
|
||||
MOCKABLE_VIRTUAL uint64_t getInternalHeapBaseAddress(uint32_t rootDeviceIndex) { return getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY); }
|
||||
uint64_t getExternalHeapBaseAddress(uint32_t rootDeviceIndex) { return getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_EXTERNAL); }
|
||||
MOCKABLE_VIRTUAL uint64_t getInternalHeapBaseAddress(uint32_t rootDeviceIndex, bool useLocalMemory) { return getGfxPartition(rootDeviceIndex)->getHeapBase(selectInternalHeap(useLocalMemory)); }
|
||||
uint64_t getExternalHeapBaseAddress(uint32_t rootDeviceIndex, bool useLocalMemory) { return getGfxPartition(rootDeviceIndex)->getHeapBase(selectExternalHeap(useLocalMemory)); }
|
||||
|
||||
bool isLimitedRange(uint32_t rootDeviceIndex) { return getGfxPartition(rootDeviceIndex)->isLimitedRange(); }
|
||||
|
||||
@@ -162,6 +162,8 @@ class MemoryManager {
|
||||
virtual void releaseReservedCpuAddressRange(void *reserved, size_t size, uint32_t rootDeviceIndex){};
|
||||
void *getReservedMemory(size_t size, size_t alignment);
|
||||
GfxPartition *getGfxPartition(uint32_t rootDeviceIndex) { return gfxPartitions.at(rootDeviceIndex).get(); }
|
||||
static HeapIndex selectInternalHeap(bool useLocalMemory) { return useLocalMemory ? HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_INTERNAL; }
|
||||
static HeapIndex selectExternalHeap(bool useLocalMemory) { return useLocalMemory ? HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_EXTERNAL; }
|
||||
|
||||
static uint32_t maxOsContextCount;
|
||||
virtual void commonCleanup(){};
|
||||
@@ -174,6 +176,7 @@ class MemoryManager {
|
||||
return allocationType == GraphicsAllocation::AllocationType::KERNEL_ISA ||
|
||||
allocationType == GraphicsAllocation::AllocationType::INTERNAL_HEAP;
|
||||
}
|
||||
|
||||
static bool isCopyRequired(ImageInfo &imgInfo, const void *hostPtr);
|
||||
|
||||
bool useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType allocationType, uint32_t rootDeviceIndex);
|
||||
@@ -185,7 +188,7 @@ class MemoryManager {
|
||||
virtual GraphicsAllocation *allocateGraphicsMemoryWithHostPtr(const AllocationData &allocationData);
|
||||
virtual GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) = 0;
|
||||
virtual GraphicsAllocation *allocateGraphicsMemory64kb(const AllocationData &allocationData) = 0;
|
||||
virtual GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) = 0;
|
||||
virtual GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) = 0;
|
||||
virtual GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) = 0;
|
||||
GraphicsAllocation *allocateGraphicsMemoryForImageFromHostPtr(const AllocationData &allocationData);
|
||||
MOCKABLE_VIRTUAL GraphicsAllocation *allocateGraphicsMemoryForImage(const AllocationData &allocationData);
|
||||
|
||||
@@ -357,9 +357,9 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A
|
||||
return allocation;
|
||||
}
|
||||
|
||||
DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) {
|
||||
DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) {
|
||||
auto internal = useInternal32BitAllocator(allocationData.type);
|
||||
auto allocatorToUse = internal ? HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_EXTERNAL;
|
||||
auto allocatorToUse = internal ? selectInternalHeap(useLocalMemory) : selectExternalHeap(useLocalMemory);
|
||||
|
||||
if (allocationData.hostPtr) {
|
||||
uintptr_t inputPtr = reinterpret_cast<uintptr_t>(allocationData.hostPtr);
|
||||
@@ -490,7 +490,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||
|
||||
if (requireSpecificBitness && this->force32bitAllocations) {
|
||||
drmAllocation->set32BitAllocation(true);
|
||||
drmAllocation->setGpuBaseAddress(GmmHelper::canonize(getExternalHeapBaseAddress(properties.rootDeviceIndex)));
|
||||
drmAllocation->setGpuBaseAddress(GmmHelper::canonize(getExternalHeapBaseAddress(properties.rootDeviceIndex, drmAllocation->isAllocatedInLocalMemoryPool())));
|
||||
}
|
||||
|
||||
if (properties.imgInfo) {
|
||||
|
||||
@@ -81,7 +81,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
MOCKABLE_VIRTUAL void *lockResourceInLocalMemoryImpl(BufferObject *bo);
|
||||
MOCKABLE_VIRTUAL void unlockResourceInLocalMemoryImpl(BufferObject *bo);
|
||||
void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override;
|
||||
DrmAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override;
|
||||
DrmAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override;
|
||||
|
||||
Drm &getDrm(uint32_t rootDeviceIndex) const;
|
||||
|
||||
@@ -170,7 +170,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
|
||||
allocation->setCpuPtrAndGpuAddress(cpuAddress, gpuAddress);
|
||||
}
|
||||
if (useInternal32BitAllocator(allocationData.type)) {
|
||||
allocation->setGpuBaseAddress(GmmHelper::canonize(getInternalHeapBaseAddress(allocationData.rootDeviceIndex)));
|
||||
allocation->setGpuBaseAddress(GmmHelper::canonize(getInternalHeapBaseAddress(allocationData.rootDeviceIndex, true)));
|
||||
}
|
||||
|
||||
status = AllocationStatus::Success;
|
||||
|
||||
@@ -250,7 +250,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithHostPtr(const A
|
||||
return MemoryManager::allocateGraphicsMemoryWithHostPtr(allocationData);
|
||||
}
|
||||
|
||||
GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) {
|
||||
GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) {
|
||||
Gmm *gmm = nullptr;
|
||||
const void *ptrAligned = nullptr;
|
||||
size_t sizeAligned = allocationData.size;
|
||||
@@ -285,7 +285,8 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto baseAddress = useInternal32BitAllocator(allocationData.type) ? getInternalHeapBaseAddress(allocationData.rootDeviceIndex) : getExternalHeapBaseAddress(allocationData.rootDeviceIndex);
|
||||
auto baseAddress = useInternal32BitAllocator(allocationData.type) ? getInternalHeapBaseAddress(allocationData.rootDeviceIndex, useLocalMemory)
|
||||
: getExternalHeapBaseAddress(allocationData.rootDeviceIndex, useLocalMemory);
|
||||
wddmAllocation->setGpuBaseAddress(GmmHelper::canonize(baseAddress));
|
||||
|
||||
return wddmAllocation.release();
|
||||
@@ -313,7 +314,7 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl
|
||||
allocation->setReservedAddressRange(ptr, size);
|
||||
} else if (requireSpecificBitness && this->force32bitAllocations) {
|
||||
allocation->set32BitAllocation(true);
|
||||
allocation->setGpuBaseAddress(GmmHelper::canonize(getExternalHeapBaseAddress(allocation->getRootDeviceIndex())));
|
||||
allocation->setGpuBaseAddress(GmmHelper::canonize(getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), false)));
|
||||
}
|
||||
status = mapGpuVirtualAddress(allocation.get(), allocation->getReservedAddressPtr());
|
||||
DEBUG_BREAK_IF(!status);
|
||||
|
||||
@@ -73,7 +73,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||
void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) override;
|
||||
void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override;
|
||||
void freeAssociatedResourceImpl(GraphicsAllocation &graphicsAllocation) override;
|
||||
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override;
|
||||
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override;
|
||||
|
||||
MOCKABLE_VIRTUAL size_t getHugeGfxMemoryChunkSize() const { return 4 * MemoryConstants::gigaByte - MemoryConstants::pageSize64k; }
|
||||
|
||||
@@ -114,7 +114,8 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeThenEverythingIs
|
||||
auto heapAllocation = cmdContainer.getIndirectHeapAllocation(static_cast<HeapType>(i));
|
||||
EXPECT_EQ(indirectHeap->getGraphicsAllocation(), heapAllocation);
|
||||
}
|
||||
EXPECT_EQ(cmdContainer.getInstructionHeapBaseAddress(), pDevice->getMemoryManager()->getInternalHeapBaseAddress(0));
|
||||
EXPECT_EQ(cmdContainer.getInstructionHeapBaseAddress(),
|
||||
pDevice->getMemoryManager()->getInternalHeapBaseAddress(0, cmdContainer.getIndirectHeap(HeapType::INDIRECT_OBJECT)->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()));
|
||||
}
|
||||
|
||||
TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeWithoutDeviceThenReturnedFalse) {
|
||||
@@ -445,12 +446,14 @@ TEST_F(CommandContainerHeaps, givenCommandContainerForDifferentRootDevicesThenIn
|
||||
|
||||
CommandContainer cmdContainer0;
|
||||
cmdContainer0.initialize(device0.get());
|
||||
uint64_t baseAddressHeapDevice0 = device0.get()->getMemoryManager()->getInternalHeapBaseAddress(device0->getRootDeviceIndex());
|
||||
bool useLocalMemory0 = cmdContainer0.getIndirectHeap(HeapType::INDIRECT_OBJECT)->getGraphicsAllocation()->isAllocatedInLocalMemoryPool();
|
||||
uint64_t baseAddressHeapDevice0 = device0.get()->getMemoryManager()->getInternalHeapBaseAddress(device0->getRootDeviceIndex(), useLocalMemory0);
|
||||
EXPECT_EQ(cmdContainer0.getInstructionHeapBaseAddress(), baseAddressHeapDevice0);
|
||||
|
||||
CommandContainer cmdContainer1;
|
||||
cmdContainer1.initialize(device1.get());
|
||||
uint64_t baseAddressHeapDevice1 = device1.get()->getMemoryManager()->getInternalHeapBaseAddress(device1->getRootDeviceIndex());
|
||||
bool useLocalMemory1 = cmdContainer0.getIndirectHeap(HeapType::INDIRECT_OBJECT)->getGraphicsAllocation()->isAllocatedInLocalMemoryPool();
|
||||
uint64_t baseAddressHeapDevice1 = device1.get()->getMemoryManager()->getInternalHeapBaseAddress(device1->getRootDeviceIndex(), useLocalMemory1);
|
||||
EXPECT_EQ(cmdContainer1.getInstructionHeapBaseAddress(), baseAddressHeapDevice1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user