mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-06 10:26:29 +08:00
Change type of residency task count to uint32_t
Move definitions of objectNotUsed and objectNotResident to GraphicsAllocation Change-Id: I2aec604a865cc6c975e9d1121028cbdd35c0b18a Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
bd4ea652ec
commit
66492a53a4
@@ -58,7 +58,7 @@ HWTEST_F(AsyncGPUoperations, MapBufferAfterWriteBuffer) {
|
||||
}
|
||||
t.join();
|
||||
|
||||
srcBuffer->getGraphicsAllocation()->updateTaskCount(ObjectNotUsed, 0);
|
||||
srcBuffer->getGraphicsAllocation()->updateTaskCount(0u, 0u);
|
||||
|
||||
alignedFree(ptrMemory);
|
||||
}
|
||||
|
||||
@@ -201,26 +201,26 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC
|
||||
|
||||
// First makeResident marks the allocation resident
|
||||
aubCsr->makeResident(*gfxAllocation);
|
||||
EXPECT_NE(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(gfxAllocation->isResident(0u));
|
||||
EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getTaskCount(0));
|
||||
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(1u, aubCsr->getResidencyAllocations().size());
|
||||
|
||||
// Second makeResident should have no impact
|
||||
aubCsr->makeResident(*gfxAllocation);
|
||||
EXPECT_NE(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(gfxAllocation->isResident(0u));
|
||||
EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getTaskCount(0));
|
||||
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(1u, aubCsr->getResidencyAllocations().size());
|
||||
|
||||
// First makeNonResident marks the allocation as nonresident
|
||||
aubCsr->makeNonResident(*gfxAllocation);
|
||||
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(gfxAllocation->isResident(0u));
|
||||
EXPECT_EQ(1u, aubCsr->getEvictionAllocations().size());
|
||||
|
||||
// Second makeNonResident should have no impact
|
||||
aubCsr->makeNonResident(*gfxAllocation);
|
||||
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(gfxAllocation->isResident(0u));
|
||||
EXPECT_EQ(1u, aubCsr->getEvictionAllocations().size());
|
||||
|
||||
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
|
||||
@@ -430,17 +430,17 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
auto engineType = OCLRT::ENGINE_RCS;
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(commandBuffer->isResident(0u));
|
||||
|
||||
aubCsr->overrideDispatchPolicy(DispatchMode::ImmediateDispatch);
|
||||
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext());
|
||||
|
||||
EXPECT_NE(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(commandBuffer->isResident(0u));
|
||||
EXPECT_EQ(aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u));
|
||||
|
||||
aubCsr->makeSurfacePackNonResident(aubCsr->getResidencyAllocations(), *pDevice->getOsContext());
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(commandBuffer->isResident(0u));
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnCommandBufferAllocation) {
|
||||
@@ -452,11 +452,11 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
auto engineType = OCLRT::ENGINE_RCS;
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, aubExecutionEnvironment->commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(aubExecutionEnvironment->commandBuffer->isResident(0u));
|
||||
|
||||
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext());
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, aubExecutionEnvironment->commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(aubExecutionEnvironment->commandBuffer->isResident(0u));
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnResidencyAllocations) {
|
||||
@@ -473,22 +473,22 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
|
||||
auto engineType = OCLRT::ENGINE_RCS;
|
||||
ResidencyContainer allocationsForResidency = {gfxAllocation};
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(gfxAllocation->isResident(0u));
|
||||
EXPECT_FALSE(commandBuffer->isResident(0u));
|
||||
|
||||
aubCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
|
||||
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext());
|
||||
|
||||
EXPECT_NE(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(gfxAllocation->isResident(0u));
|
||||
EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
|
||||
|
||||
EXPECT_NE(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(commandBuffer->isResident(0u));
|
||||
EXPECT_EQ(aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u));
|
||||
|
||||
aubCsr->makeSurfacePackNonResident(allocationsForResidency, *pDevice->getOsContext());
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(gfxAllocation->isResident(0u));
|
||||
EXPECT_FALSE(commandBuffer->isResident(0u));
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
}
|
||||
@@ -506,15 +506,15 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
|
||||
auto engineType = OCLRT::ENGINE_RCS;
|
||||
ResidencyContainer allocationsForResidency = {gfxAllocation};
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(gfxAllocation->isResident(0u));
|
||||
EXPECT_FALSE(commandBuffer->isResident(0u));
|
||||
|
||||
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext());
|
||||
|
||||
EXPECT_NE(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(gfxAllocation->isResident(0u));
|
||||
EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(commandBuffer->isResident(0u));
|
||||
|
||||
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
|
||||
}
|
||||
@@ -544,22 +544,22 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
|
||||
auto engineType = OCLRT::ENGINE_RCS;
|
||||
ResidencyContainer allocationsForResidency = {gfxAllocation};
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(gfxAllocation->isResident(0u));
|
||||
EXPECT_FALSE(commandBuffer->isResident(0u));
|
||||
|
||||
aubCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
|
||||
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext());
|
||||
|
||||
EXPECT_NE(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(gfxAllocation->isResident(0u));
|
||||
EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
|
||||
|
||||
EXPECT_NE(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(commandBuffer->isResident(0u));
|
||||
EXPECT_EQ(aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u));
|
||||
|
||||
aubCsr->makeSurfacePackNonResident(allocationsForResidency, *pDevice->getOsContext());
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(gfxAllocation->isResident(0u));
|
||||
EXPECT_FALSE(commandBuffer->isResident(0u));
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenRecorded
|
||||
|
||||
for (auto &graphicsAllocation : residentSurfaces) {
|
||||
EXPECT_TRUE(graphicsAllocation->isResident(0u));
|
||||
EXPECT_EQ(1, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(1u, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
}
|
||||
|
||||
mockCsr->flushBatchedSubmissions();
|
||||
|
||||
@@ -177,7 +177,7 @@ HWTEST_F(CommandStreamReceiverTest, whenStoreAllocationThenStoredAllocationHasTa
|
||||
void *host_ptr = (void *)0x1234;
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(1, host_ptr);
|
||||
|
||||
EXPECT_EQ(ObjectNotUsed, allocation->getTaskCount(0));
|
||||
EXPECT_FALSE(allocation->isUsed());
|
||||
|
||||
csr.taskCount = 2u;
|
||||
|
||||
@@ -363,14 +363,14 @@ TEST(CommandStreamReceiverMultiContextTests, givenMultipleCsrsWhenSameResourcesA
|
||||
EXPECT_EQ(1u, commandStreamReceiver0.getResidencyAllocations().size());
|
||||
EXPECT_EQ(1u, commandStreamReceiver1.getResidencyAllocations().size());
|
||||
|
||||
EXPECT_EQ(1, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(1, graphicsAllocation->getResidencyTaskCount(1u));
|
||||
EXPECT_EQ(1u, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(1u, graphicsAllocation->getResidencyTaskCount(1u));
|
||||
|
||||
commandStreamReceiver0.makeNonResident(*graphicsAllocation);
|
||||
commandStreamReceiver1.makeNonResident(*graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(1u));
|
||||
EXPECT_FALSE(graphicsAllocation->isResident(0u));
|
||||
EXPECT_FALSE(graphicsAllocation->isResident(1u));
|
||||
|
||||
EXPECT_EQ(1u, commandStreamReceiver0.getEvictionAllocations().size());
|
||||
EXPECT_EQ(1u, commandStreamReceiver1.getEvictionAllocations().size());
|
||||
|
||||
@@ -227,13 +227,13 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidenc
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(graphicsAllocation->isResident(0u));
|
||||
|
||||
ResidencyContainer allocationsForResidency = {graphicsAllocation};
|
||||
tbxCsr->processResidency(allocationsForResidency, *pDevice->getOsContext());
|
||||
|
||||
EXPECT_NE(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(graphicsAllocation->isResident(0u));
|
||||
EXPECT_EQ(tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
@@ -246,13 +246,13 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidenc
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(graphicsAllocation->isResident(0u));
|
||||
|
||||
ResidencyContainer allocationsForResidency = {graphicsAllocation};
|
||||
tbxCsr->processResidency(allocationsForResidency, *pDevice->getOsContext());
|
||||
|
||||
EXPECT_NE(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(graphicsAllocation->isResident(0u));
|
||||
EXPECT_EQ(tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
@@ -273,12 +273,12 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledTh
|
||||
auto engineType = OCLRT::ENGINE_RCS;
|
||||
ResidencyContainer allocationsForResidency = {graphicsAllocation};
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(graphicsAllocation->isResident(0u));
|
||||
|
||||
tbxCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext());
|
||||
|
||||
EXPECT_NE(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(graphicsAllocation->isResident(0u));
|
||||
EXPECT_EQ(tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u));
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
|
||||
@@ -894,9 +894,6 @@ 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 = memoryManager->allocateGraphicsMemory(MemoryConstants::pageSize);
|
||||
|
||||
@@ -115,7 +115,7 @@ HWTEST_P(ParentKernelEnqueueTest, GivenParentKernelWithPrivateSurfaceWhenEnqueue
|
||||
pKernel->getProgram()->getBlockKernelManager()->pushPrivateSurface(privateSurface, 0);
|
||||
pCmdQ->enqueueKernel(pKernel, 1, offset, gws, gws, 0, nullptr, nullptr);
|
||||
|
||||
EXPECT_NE(ObjectNotResident, privateSurface->getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(privateSurface->isResident(0u));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "runtime/memory_manager/graphics_allocation.h"
|
||||
#include "unit_tests/mocks/mock_graphics_allocation.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
@@ -14,64 +14,64 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenIsCreatedThenTaskCountsA
|
||||
GraphicsAllocation graphicsAllocation1(nullptr, 0u, 0u, 0u);
|
||||
GraphicsAllocation graphicsAllocation2(nullptr, 0u, 0u);
|
||||
for (auto i = 0u; i < maxOsContextCount; i++) {
|
||||
EXPECT_EQ(ObjectNotUsed, graphicsAllocation1.getTaskCount(i));
|
||||
EXPECT_EQ(ObjectNotUsed, graphicsAllocation2.getTaskCount(i));
|
||||
EXPECT_EQ(ObjectNotResident, graphicsAllocation1.getResidencyTaskCount(i));
|
||||
EXPECT_EQ(ObjectNotResident, graphicsAllocation2.getResidencyTaskCount(i));
|
||||
EXPECT_EQ(MockGraphicsAllocation::objectNotUsed, graphicsAllocation1.getTaskCount(i));
|
||||
EXPECT_EQ(MockGraphicsAllocation::objectNotUsed, graphicsAllocation2.getTaskCount(i));
|
||||
EXPECT_EQ(MockGraphicsAllocation::objectNotResident, graphicsAllocation1.getResidencyTaskCount(i));
|
||||
EXPECT_EQ(MockGraphicsAllocation::objectNotResident, graphicsAllocation2.getResidencyTaskCount(i));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenUpdatedTaskCountThenAllocationWasUsed) {
|
||||
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0u);
|
||||
EXPECT_FALSE(graphicsAllocation.peekWasUsed());
|
||||
EXPECT_FALSE(graphicsAllocation.isUsed());
|
||||
graphicsAllocation.updateTaskCount(0u, 0u);
|
||||
EXPECT_TRUE(graphicsAllocation.peekWasUsed());
|
||||
EXPECT_TRUE(graphicsAllocation.isUsed());
|
||||
}
|
||||
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenUpdatedTaskCountThenOnlyOneTaskCountIsUpdated) {
|
||||
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0u);
|
||||
graphicsAllocation.updateTaskCount(1u, 0u);
|
||||
EXPECT_EQ(1u, graphicsAllocation.getTaskCount(0u));
|
||||
for (auto i = 1u; i < maxOsContextCount; i++) {
|
||||
EXPECT_EQ(ObjectNotUsed, graphicsAllocation.getTaskCount(i));
|
||||
EXPECT_EQ(MockGraphicsAllocation::objectNotUsed, graphicsAllocation.getTaskCount(i));
|
||||
}
|
||||
graphicsAllocation.updateTaskCount(2u, 1u);
|
||||
EXPECT_EQ(1u, graphicsAllocation.getTaskCount(0u));
|
||||
EXPECT_EQ(2u, graphicsAllocation.getTaskCount(1u));
|
||||
for (auto i = 2u; i < maxOsContextCount; i++) {
|
||||
EXPECT_EQ(ObjectNotUsed, graphicsAllocation.getTaskCount(i));
|
||||
EXPECT_EQ(MockGraphicsAllocation::objectNotUsed, graphicsAllocation.getTaskCount(i));
|
||||
}
|
||||
}
|
||||
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenUpdatedTaskCountToObjectNotUsedValueThenUnregisterContext) {
|
||||
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenUpdatedTaskCountToobjectNotUsedValueThenUnregisterContext) {
|
||||
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0u);
|
||||
EXPECT_FALSE(graphicsAllocation.peekWasUsed());
|
||||
EXPECT_FALSE(graphicsAllocation.isUsed());
|
||||
graphicsAllocation.updateTaskCount(0u, 0u);
|
||||
EXPECT_TRUE(graphicsAllocation.peekWasUsed());
|
||||
graphicsAllocation.updateTaskCount(ObjectNotUsed, 0u);
|
||||
EXPECT_FALSE(graphicsAllocation.peekWasUsed());
|
||||
EXPECT_TRUE(graphicsAllocation.isUsed());
|
||||
graphicsAllocation.updateTaskCount(MockGraphicsAllocation::objectNotUsed, 0u);
|
||||
EXPECT_FALSE(graphicsAllocation.isUsed());
|
||||
}
|
||||
TEST(GraphicsAllocationTest, whenTwoContextsUpdatedTaskCountAndOneOfThemUnregisteredThenOneContextUsageRemains) {
|
||||
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0u);
|
||||
EXPECT_FALSE(graphicsAllocation.peekWasUsed());
|
||||
EXPECT_FALSE(graphicsAllocation.isUsed());
|
||||
graphicsAllocation.updateTaskCount(0u, 0u);
|
||||
graphicsAllocation.updateTaskCount(0u, 1u);
|
||||
EXPECT_TRUE(graphicsAllocation.peekWasUsed());
|
||||
graphicsAllocation.updateTaskCount(ObjectNotUsed, 0u);
|
||||
EXPECT_TRUE(graphicsAllocation.peekWasUsed());
|
||||
graphicsAllocation.updateTaskCount(ObjectNotUsed, 0u);
|
||||
EXPECT_TRUE(graphicsAllocation.peekWasUsed());
|
||||
graphicsAllocation.updateTaskCount(ObjectNotUsed, 1u);
|
||||
EXPECT_FALSE(graphicsAllocation.peekWasUsed());
|
||||
EXPECT_TRUE(graphicsAllocation.isUsed());
|
||||
graphicsAllocation.updateTaskCount(MockGraphicsAllocation::objectNotUsed, 0u);
|
||||
EXPECT_TRUE(graphicsAllocation.isUsed());
|
||||
graphicsAllocation.updateTaskCount(MockGraphicsAllocation::objectNotUsed, 0u);
|
||||
EXPECT_TRUE(graphicsAllocation.isUsed());
|
||||
graphicsAllocation.updateTaskCount(MockGraphicsAllocation::objectNotUsed, 1u);
|
||||
EXPECT_FALSE(graphicsAllocation.isUsed());
|
||||
}
|
||||
|
||||
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenUpdatedResidencyTaskCountToNonDefaultValueThenAllocationIsResident) {
|
||||
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0u);
|
||||
EXPECT_FALSE(graphicsAllocation.isResident(0u));
|
||||
int residencyTaskCount = 1;
|
||||
uint32_t residencyTaskCount = 1u;
|
||||
graphicsAllocation.updateResidencyTaskCount(residencyTaskCount, 0u);
|
||||
EXPECT_EQ(residencyTaskCount, graphicsAllocation.getResidencyTaskCount(0u));
|
||||
EXPECT_TRUE(graphicsAllocation.isResident(0u));
|
||||
graphicsAllocation.updateResidencyTaskCount(ObjectNotResident, 0u);
|
||||
EXPECT_EQ(ObjectNotResident, graphicsAllocation.getResidencyTaskCount(0u));
|
||||
graphicsAllocation.updateResidencyTaskCount(MockGraphicsAllocation::objectNotResident, 0u);
|
||||
EXPECT_EQ(MockGraphicsAllocation::objectNotResident, graphicsAllocation.getResidencyTaskCount(0u));
|
||||
EXPECT_FALSE(graphicsAllocation.isResident(0u));
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ TEST_F(InternalAllocationStorageTest, whenNotUsedAllocationIsStoredAsReusableAnd
|
||||
void *host_ptr = (void *)0x1234;
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(1, host_ptr);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_FALSE(allocation->peekWasUsed());
|
||||
EXPECT_FALSE(allocation->isUsed());
|
||||
EXPECT_EQ(0u, csr->peekTaskCount());
|
||||
*csr->getTagAddress() = 0; // initial hw tag for dll
|
||||
|
||||
@@ -179,7 +179,8 @@ TEST_F(InternalAllocationStorageTest, whenObtainAllocationFromMidlleOfReusableLi
|
||||
EXPECT_TRUE(reusableAllocations.peekContains(*allocation3));
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation2);
|
||||
storage->cleanAllocationList(ObjectNotUsed, REUSABLE_ALLOCATION);
|
||||
allocation->updateTaskCount(0u, 0u);
|
||||
allocation3->updateTaskCount(0u, 0u);
|
||||
}
|
||||
|
||||
TEST_F(InternalAllocationStorageTest, givenNonInternalAllocationWhenItIsPutOnReusableListWhenInternalAllocationIsRequestedThenNullIsReturned) {
|
||||
|
||||
@@ -1235,7 +1235,7 @@ TEST_F(MemoryManagerWithCsrTest, givenAllocationThatWasUsedAndIsNotCompletedWhen
|
||||
EXPECT_EQ(csr->getTemporaryAllocations().peekHead(), usedAllocationAndNotGpuCompleted);
|
||||
|
||||
//change task count so cleanup will not clear alloc in use
|
||||
usedAllocationAndNotGpuCompleted->updateTaskCount(ObjectNotUsed, 0);
|
||||
usedAllocationAndNotGpuCompleted->updateTaskCount(csr->peekLatestFlushedTaskCount(), 0);
|
||||
}
|
||||
|
||||
class MockAlignMallocMemoryManager : public MockMemoryManager {
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
|
||||
namespace OCLRT {
|
||||
class MockGraphicsAllocation : public GraphicsAllocation {
|
||||
using GraphicsAllocation::GraphicsAllocation;
|
||||
|
||||
public:
|
||||
using GraphicsAllocation::GraphicsAllocation;
|
||||
using GraphicsAllocation::objectNotResident;
|
||||
using GraphicsAllocation::objectNotUsed;
|
||||
|
||||
MockGraphicsAllocation(void *buffer, size_t sizeIn) : GraphicsAllocation(buffer, castToUint64(buffer), 0llu, sizeIn) {
|
||||
}
|
||||
void resetInspectionId() {
|
||||
|
||||
@@ -1606,7 +1606,6 @@ TEST_F(DrmCommandStreamLeaksTest, BufferResidency) {
|
||||
std::unique_ptr<Buffer> buffer(DrmMockBuffer::create());
|
||||
|
||||
ASSERT_FALSE(buffer->getGraphicsAllocation()->isResident(0u));
|
||||
ASSERT_EQ(ObjectNotResident, buffer->getGraphicsAllocation()->getResidencyTaskCount(0u));
|
||||
ASSERT_GT(buffer->getSize(), 0u);
|
||||
|
||||
//make it resident 8 times
|
||||
@@ -1614,7 +1613,7 @@ TEST_F(DrmCommandStreamLeaksTest, BufferResidency) {
|
||||
csr->makeResident(*buffer->getGraphicsAllocation());
|
||||
csr->processResidency(csr->getResidencyAllocations(), *osContext);
|
||||
EXPECT_TRUE(buffer->getGraphicsAllocation()->isResident(0u));
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getResidencyTaskCount(0u), (int)csr->peekTaskCount() + 1);
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getResidencyTaskCount(0u), csr->peekTaskCount() + 1);
|
||||
}
|
||||
|
||||
csr->makeNonResident(*buffer->getGraphicsAllocation());
|
||||
@@ -1622,7 +1621,6 @@ TEST_F(DrmCommandStreamLeaksTest, BufferResidency) {
|
||||
|
||||
csr->makeNonResident(*buffer->getGraphicsAllocation());
|
||||
EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident(0u));
|
||||
EXPECT_EQ(ObjectNotResident, buffer->getGraphicsAllocation()->getResidencyTaskCount(0u));
|
||||
}
|
||||
|
||||
typedef Test<DrmCommandStreamEnhancedFixture> DrmCommandStreamMemoryManagerTest;
|
||||
|
||||
Reference in New Issue
Block a user