Remove ULT code from runtime

Change-Id: I2faf52070f980d031788fc6946df8534d96c639b
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2018-10-23 09:24:28 +02:00
committed by sys_ocldev
parent 41e77d2fdf
commit a531751001
12 changed files with 51 additions and 81 deletions

View File

@ -97,19 +97,6 @@ void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer &alloc
this->processEviction(osContext);
}
GraphicsAllocation *CommandStreamReceiver::createAllocationAndHandleResidency(const void *address, size_t size, bool addToDefferedDeleteList) {
GraphicsAllocation *graphicsAllocation = getMemoryManager()->allocateGraphicsMemory(size, address);
makeResident(*graphicsAllocation);
if (addToDefferedDeleteList) {
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(graphicsAllocation), TEMPORARY_ALLOCATION);
}
if (!graphicsAllocation->isL3Capable()) {
disableL3Cache = true;
}
return graphicsAllocation;
}
void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gfxAllocation) {
makeResident(*gfxAllocation);
if (!gfxAllocation->isL3Capable()) {

View File

@ -81,7 +81,6 @@ class CommandStreamReceiver {
virtual GmmPageTableMngr *createPageTableManager() { return nullptr; }
GraphicsAllocation *createAllocationAndHandleResidency(const void *address, size_t size, bool addToDefferFreeList = true);
MOCKABLE_VIRTUAL void waitForTaskCountAndCleanAllocationList(uint32_t requiredTaskCount, uint32_t allocationType);
LinearStream &getCS(size_t minRequiredSize = 1024u);

View File

@ -382,7 +382,9 @@ struct AUBSimpleArgNonUniformFixture : public KernelAUBFixture<SimpleArgNonUnifo
kernel->setArgSvm(1, sizeUserMemory, destMemory);
outBuffer = csr->createAllocationAndHandleResidency(destMemory, sizeUserMemory);
outBuffer = csr->getMemoryManager()->allocateGraphicsMemory(sizeUserMemory, destMemory);
csr->makeResidentHostPtrAllocation(outBuffer);
csr->getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(outBuffer), TEMPORARY_ALLOCATION);
ASSERT_NE(nullptr, outBuffer);
outBuffer->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
outBuffer->setMemObjectsAllocationWithWritableFlags(true);

View File

@ -58,7 +58,7 @@ HWTEST_P(AUBReadBuffer, simple) {
cl_event *eventWaitList = nullptr;
cl_event *event = nullptr;
GraphicsAllocation *allocation = pCommandStreamReceiver->createAllocationAndHandleResidency(pDestMemory, sizeof(destMemory));
GraphicsAllocation *allocation = createResidentAllocationAndStoreItInCsr(pDestMemory, sizeof(destMemory));
srcBuffer->forceDisallowCPUCopy = true;
retVal = pCmdQ->enqueueReadBuffer(
@ -138,7 +138,7 @@ HWTEST_F(AUBReadBuffer, reserveCanonicalGpuAddress) {
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
GraphicsAllocation *dstAllocation = pCommandStreamReceiver->createAllocationAndHandleResidency(dstMemory, sizeof(dstMemory));
GraphicsAllocation *dstAllocation = createResidentAllocationAndStoreItInCsr(dstMemory, sizeof(dstMemory));
cl_float *dstGpuAddress = reinterpret_cast<cl_float *>(dstAllocation->getGpuAddress());
AUBCommandStreamFixture::expectMemory<FamilyType>(dstGpuAddress, srcMemory, sizeof(dstMemory));

View File

@ -67,7 +67,7 @@ HWTEST_P(AUBReadBufferRect, simple3D) {
cl_bool blockingRead = CL_TRUE;
pCommandStreamReceiver->createAllocationAndHandleResidency(destMemory, bufferSize);
createResidentAllocationAndStoreItInCsr(destMemory, bufferSize);
size_t bufferOrigin[] = {0, 0, zBuffOffs};
size_t hostOrigin[] = {0, 0, zHostOffs};

View File

@ -135,7 +135,7 @@ HWTEST_P(AUBReadImage, simpleUnalignedMemory) {
// Since we're testing for overwrite, we need to ensure
// the complete memory is made resident for AUB testing.
auto graphicsAllocation = pCommandStreamReceiver->createAllocationAndHandleResidency(dstMemoryUnaligned, (numPixels * elementSize));
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(dstMemoryUnaligned, (numPixels * elementSize));
pCommandStreamReceiver->makeNonResident(*graphicsAllocation);
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat);

View File

@ -72,6 +72,12 @@ class AUBCommandStreamFixture : public CommandStreamFixture {
aubCsr->ppgtt->pageWalk(reinterpret_cast<uintptr_t>(gfxAddress), length, 0, PageTableEntry::nonValidBits, walker, MemoryBanks::BankNotSpecified);
}
GraphicsAllocation *createResidentAllocationAndStoreItInCsr(const void *address, size_t size) {
GraphicsAllocation *graphicsAllocation = pCommandStreamReceiver->getMemoryManager()->allocateGraphicsMemory(size, address);
pCommandStreamReceiver->makeResidentHostPtrAllocation(graphicsAllocation);
pCommandStreamReceiver->getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(graphicsAllocation), TEMPORARY_ALLOCATION);
return graphicsAllocation;
}
CommandStreamReceiver *pCommandStreamReceiver = nullptr;
volatile uint32_t *pTagMemory = nullptr;

View File

@ -95,7 +95,7 @@ TEST_F(AUBcommandstreamTests, makeResident) {
uint8_t buffer[0x10000];
size_t size = sizeof(buffer);
auto &commandStreamReceiver = pDevice->getCommandStreamReceiver();
auto graphicsAllocation = commandStreamReceiver.createAllocationAndHandleResidency(buffer, size);
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(buffer, size);
ResidencyContainer allocationsForResidency = {graphicsAllocation};
commandStreamReceiver.processResidency(allocationsForResidency, *pDevice->getOsContext());
}
@ -103,10 +103,9 @@ TEST_F(AUBcommandstreamTests, makeResident) {
HWTEST_F(AUBcommandstreamTests, expectMemorySingle) {
uint32_t buffer = 0xdeadbeef;
size_t size = sizeof(buffer);
auto &commandStreamReceiver = pDevice->getCommandStreamReceiver();
auto graphicsAllocation = commandStreamReceiver.createAllocationAndHandleResidency(&buffer, size);
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(&buffer, size);
ResidencyContainer allocationsForResidency = {graphicsAllocation};
commandStreamReceiver.processResidency(allocationsForResidency, *pDevice->getOsContext());
pCommandStreamReceiver->processResidency(allocationsForResidency, *pDevice->getOsContext());
AUBCommandStreamFixture::expectMemory<FamilyType>(&buffer, &buffer, size);
}
@ -119,10 +118,9 @@ HWTEST_F(AUBcommandstreamTests, expectMemoryLarge) {
buffer[index] = static_cast<uint8_t>(index);
}
auto &commandStreamReceiver = pDevice->getCommandStreamReceiver();
auto graphicsAllocation = commandStreamReceiver.createAllocationAndHandleResidency(buffer, sizeBuffer);
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(buffer, sizeBuffer);
ResidencyContainer allocationsForResidency = {graphicsAllocation};
commandStreamReceiver.processResidency(allocationsForResidency, *pDevice->getOsContext());
pCommandStreamReceiver->processResidency(allocationsForResidency, *pDevice->getOsContext());
AUBCommandStreamFixture::expectMemory<FamilyType>(buffer, buffer, sizeBuffer);
delete[] buffer;

View File

@ -78,8 +78,7 @@ struct SimpleArgFixture : public FixtureFactory::IndirectHeapFixture,
pKernel->setArg(0, sizeof(int), &argVal);
pKernel->setArgSvm(1, sizeUserMemory, pDestMemory);
auto &commandStreamReceiver = pDevice->getCommandStreamReceiver();
outBuffer = commandStreamReceiver.createAllocationAndHandleResidency(pDestMemory, sizeUserMemory);
outBuffer = AUBCommandStreamFixture::createResidentAllocationAndStoreItInCsr(pDestMemory, sizeUserMemory);
ASSERT_NE(nullptr, outBuffer);
outBuffer->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
outBuffer->setMemObjectsAllocationWithWritableFlags(true);

View File

@ -131,52 +131,34 @@ TEST_F(CommandStreamReceiverTest, givenCommandStreamReceiverWhenGetCSIsCalledThe
EXPECT_EQ(GraphicsAllocation::AllocationType::LINEAR_STREAM, commandStreamAllocation->getAllocationType());
}
TEST_F(CommandStreamReceiverTest, createAllocationAndHandleResidency) {
void *host_ptr = (void *)0x1212341;
auto size = 17262u;
GraphicsAllocation *graphicsAllocation = commandStreamReceiver->createAllocationAndHandleResidency(host_ptr, size);
ASSERT_NE(nullptr, graphicsAllocation);
EXPECT_EQ(host_ptr, graphicsAllocation->getUnderlyingBuffer());
EXPECT_EQ(size, graphicsAllocation->getUnderlyingBufferSize());
}
TEST_F(CommandStreamReceiverTest, givenCommandStreamerWhenAllocationIsNotAddedToListThenCallerMustFreeAllocation) {
void *hostPtr = reinterpret_cast<void *>(0x1212341);
auto size = 17262u;
GraphicsAllocation *graphicsAllocation = commandStreamReceiver->createAllocationAndHandleResidency(hostPtr, size, false);
ASSERT_NE(nullptr, graphicsAllocation);
EXPECT_EQ(hostPtr, graphicsAllocation->getUnderlyingBuffer());
EXPECT_EQ(size, graphicsAllocation->getUnderlyingBufferSize());
commandStreamReceiver->getMemoryManager()->freeGraphicsMemory(graphicsAllocation);
}
HWTEST_F(CommandStreamReceiverTest, givenCommandStreamerWhenPtrAndSizeMeetL3CriteriaThenCsrEnableL3) {
HWTEST_F(CommandStreamReceiverTest, givenPtrAndSizeThatMeetL3CriteriaWhenMakeResidentHostPtrThenCsrEnableL3) {
void *hostPtr = reinterpret_cast<void *>(0xF000);
auto size = 0x2000u;
GraphicsAllocation *graphicsAllocation = commandStreamReceiver->createAllocationAndHandleResidency(hostPtr, size);
auto memoryManager = commandStreamReceiver->getMemoryManager();
GraphicsAllocation *graphicsAllocation = memoryManager->allocateGraphicsMemory(size, hostPtr);
ASSERT_NE(nullptr, graphicsAllocation);
commandStreamReceiver->makeResidentHostPtrAllocation(graphicsAllocation);
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
EXPECT_FALSE(csr.disableL3Cache);
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
HWTEST_F(CommandStreamReceiverTest, givenCommandStreamerWhenPtrAndSizeDoNotMeetL3CriteriaThenCsrDisableL3) {
HWTEST_F(CommandStreamReceiverTest, givenPtrAndSizeThatDoNotMeetL3CriteriaWhenMakeResidentHostPtrThenCsrDisableL3) {
void *hostPtr = reinterpret_cast<void *>(0xF001);
auto size = 0x2001u;
GraphicsAllocation *graphicsAllocation = commandStreamReceiver->createAllocationAndHandleResidency(hostPtr, size);
auto memoryManager = commandStreamReceiver->getMemoryManager();
GraphicsAllocation *graphicsAllocation = memoryManager->allocateGraphicsMemory(size, hostPtr);
ASSERT_NE(nullptr, graphicsAllocation);
commandStreamReceiver->makeResidentHostPtrAllocation(graphicsAllocation);
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
EXPECT_TRUE(csr.disableL3Cache);
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
TEST_F(CommandStreamReceiverTest, memoryManagerHasAccessToCSR) {

View File

@ -891,13 +891,15 @@ TEST_F(EventTests, enqueueReadImageBlockedOnUserEvent) {
TEST_F(EventTests, waitForEventsDestroysTemporaryAllocations) {
auto &csr = pCmdQ->getDevice().getCommandStreamReceiver();
auto memoryManager = pCmdQ->getDevice().getMemoryManager();
//kill some temporary objects that fixture creates.
csr.waitForTaskCountAndCleanAllocationList(-1, TEMPORARY_ALLOCATION);
EXPECT_TRUE(csr.getTemporaryAllocations().peekIsEmpty());
GraphicsAllocation *temporaryAllocation = csr.createAllocationAndHandleResidency((void *)0x1234, 200);
GraphicsAllocation *temporaryAllocation = memoryManager->allocateGraphicsMemory(MemoryConstants::pageSize);
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(temporaryAllocation), TEMPORARY_ALLOCATION);
EXPECT_EQ(temporaryAllocation, csr.getTemporaryAllocations().peekHead());

View File

@ -592,65 +592,58 @@ TEST_F(WddmCommandStreamTest, makeResidentNonResidentMemObj) {
memoryManager->freeGraphicsMemory(gfxAllocation);
}
TEST_F(WddmCommandStreamTest, createAllocationAndMakeResident) {
TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWhenMakeResidentThenAllocationIsInResidencyContainer) {
void *hostPtr = reinterpret_cast<void *>(wddm->virtualAllocAddress + 0x1234);
auto size = 1234u;
WddmAllocation *gfxAllocation = static_cast<WddmAllocation *>(csr->createAllocationAndHandleResidency(hostPtr, size));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(size, hostPtr);
ASSERT_NE(nullptr, gfxAllocation);
EXPECT_EQ(1u, csr->getResidencyAllocations().size());
csr->makeResidentHostPtrAllocation(gfxAllocation);
EXPECT_EQ(1u, csr->getResidencyAllocations().size());
EXPECT_EQ(hostPtr, gfxAllocation->getUnderlyingBuffer());
memoryManager->freeGraphicsMemory(gfxAllocation);
}
TEST_F(WddmCommandStreamTest, givenHostPtrWhenPtrBelowRestrictionThenCreateAllocationAndMakeResident) {
void *hostPtr = reinterpret_cast<void *>(memoryManager->getAlignedMallocRestrictions()->minAddress - 0x1000);
auto size = 0x2000u;
WddmAllocation *gfxAllocation = static_cast<WddmAllocation *>(csr->createAllocationAndHandleResidency(hostPtr, size));
auto gfxAllocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemory(size, hostPtr));
void *expectedReserve = reinterpret_cast<void *>(wddm->virtualAllocAddress);
ASSERT_NE(nullptr, gfxAllocation);
EXPECT_EQ(1u, csr->getResidencyAllocations().size());
csr->makeResidentHostPtrAllocation(gfxAllocation);
EXPECT_EQ(1u, csr->getResidencyAllocations().size());
EXPECT_EQ(hostPtr, gfxAllocation->getUnderlyingBuffer());
EXPECT_EQ(expectedReserve, gfxAllocation->getReservedAddress());
memoryManager->freeGraphicsMemory(gfxAllocation);
}
TEST_F(WddmCommandStreamTest, killAllTemporaryAllocation) {
void *host_ptr = (void *)0x1212341;
auto size = 17262u;
GraphicsAllocation *graphicsAllocation = csr->createAllocationAndHandleResidency(host_ptr, size);
ASSERT_NE(nullptr, graphicsAllocation);
graphicsAllocation->taskCount = 1;
csr->waitForTaskCountAndCleanAllocationList(-1, TEMPORARY_ALLOCATION);
//no memory leaks reported makes this test pass.
}
TEST_F(WddmCommandStreamTest, killCompletedAllocations) {
TEST_F(WddmCommandStreamTest, givenTwoTemporaryAllocationsWhenCleanTemporaryAllocationListThenDestoryOnlyCompletedAllocations) {
void *host_ptr = (void *)0x1212341;
void *host_ptr2 = (void *)0x2212341;
auto size = 17262u;
GraphicsAllocation *graphicsAllocation = csr->createAllocationAndHandleResidency(host_ptr, size);
ASSERT_NE(nullptr, graphicsAllocation);
GraphicsAllocation *graphicsAllocation2 = csr->createAllocationAndHandleResidency(host_ptr2, size);
GraphicsAllocation *graphicsAllocation = memoryManager->allocateGraphicsMemory(size, host_ptr);
GraphicsAllocation *graphicsAllocation2 = memoryManager->allocateGraphicsMemory(size, host_ptr2);
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(graphicsAllocation), TEMPORARY_ALLOCATION);
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(graphicsAllocation2), TEMPORARY_ALLOCATION);
graphicsAllocation->taskCount = 1;
graphicsAllocation2->taskCount = 100;
csr->waitForTaskCountAndCleanAllocationList(1, TEMPORARY_ALLOCATION);
//graphicsAllocation2 still lives
// graphicsAllocation2 still lives
EXPECT_EQ(host_ptr2, graphicsAllocation2->getUnderlyingBuffer());
auto *memoryManager = (WddmMemoryManager *)csr->getMemoryManager();
auto &hostPtrManager = memoryManager->hostPtrManager;
auto alignedPtr = alignDown(host_ptr, MemoryConstants::pageSize);
@ -663,6 +656,8 @@ TEST_F(WddmCommandStreamTest, killCompletedAllocations) {
auto fragment2 = hostPtrManager.getFragment(alignedPtr);
EXPECT_EQ(nullptr, fragment2);
// destroy remaining allocation
csr->waitForTaskCountAndCleanAllocationList(100, TEMPORARY_ALLOCATION);
}
TEST_F(WddmCommandStreamMockGdiTest, FlushCallsWddmMakeResidentForResidencyAllocations) {