Create structure UsageInfo for task count and residency task count

Change-Id: I0899c88d9e567a09ba46461ae69cf6c80f713e67
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2018-11-06 11:38:49 +01:00
committed by sys_ocldev
parent e599d1503b
commit 0e0a280803
23 changed files with 115 additions and 154 deletions

View File

@@ -201,26 +201,26 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC
// First makeResident marks the allocation resident
aubCsr->makeResident(*gfxAllocation);
EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]);
EXPECT_NE(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getTaskCount(0));
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount[0u]);
EXPECT_EQ((int)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->residencyTaskCount[0u]);
EXPECT_NE(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getTaskCount(0));
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount[0u]);
EXPECT_EQ((int)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->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_EQ(1u, aubCsr->getEvictionAllocations().size());
// Second makeNonResident should have no impact
aubCsr->makeNonResident(*gfxAllocation);
EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(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->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
aubCsr->overrideDispatchPolicy(DispatchMode::ImmediateDispatch);
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext());
EXPECT_NE(ObjectNotResident, commandBuffer->residencyTaskCount[0u]);
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->residencyTaskCount[0u]);
EXPECT_NE(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u));
aubCsr->makeSurfacePackNonResident(aubCsr->getResidencyAllocations(), *pDevice->getOsContext());
EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(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->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, aubExecutionEnvironment->commandBuffer->getResidencyTaskCount(0u));
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext());
EXPECT_EQ(ObjectNotResident, aubExecutionEnvironment->commandBuffer->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, aubExecutionEnvironment->commandBuffer->getResidencyTaskCount(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->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
aubCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext());
EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]);
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount[0u]);
EXPECT_NE(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_NE(ObjectNotResident, commandBuffer->residencyTaskCount[0u]);
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->residencyTaskCount[0u]);
EXPECT_NE(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u));
aubCsr->makeSurfacePackNonResident(allocationsForResidency, *pDevice->getOsContext());
EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
memoryManager->freeGraphicsMemory(gfxAllocation);
}
@@ -506,15 +506,15 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {gfxAllocation};
EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext());
EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]);
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount[0u]);
EXPECT_NE(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
}
@@ -544,22 +544,22 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {gfxAllocation};
EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
aubCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext());
EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]);
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount[0u]);
EXPECT_NE(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_NE(ObjectNotResident, commandBuffer->residencyTaskCount[0u]);
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->residencyTaskCount[0u]);
EXPECT_NE(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u));
aubCsr->makeSurfacePackNonResident(allocationsForResidency, *pDevice->getOsContext());
EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, gfxAllocation->getResidencyTaskCount(0u));
EXPECT_EQ(ObjectNotResident, commandBuffer->getResidencyTaskCount(0u));
memoryManager->freeGraphicsMemory(gfxAllocation);
}

View File

@@ -379,7 +379,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenRecorded
for (auto &graphicsAllocation : residentSurfaces) {
EXPECT_TRUE(graphicsAllocation->isResident(0u));
EXPECT_EQ(1, graphicsAllocation->residencyTaskCount[0u]);
EXPECT_EQ(1, graphicsAllocation->getResidencyTaskCount(0u));
}
mockCsr->flushBatchedSubmissions();

View File

@@ -363,14 +363,14 @@ TEST(CommandStreamReceiverMultiContextTests, givenMultipleCsrsWhenSameResourcesA
EXPECT_EQ(1u, commandStreamReceiver0.getResidencyAllocations().size());
EXPECT_EQ(1u, commandStreamReceiver1.getResidencyAllocations().size());
EXPECT_EQ(1, graphicsAllocation->residencyTaskCount[0u]);
EXPECT_EQ(1, graphicsAllocation->residencyTaskCount[1u]);
EXPECT_EQ(1, graphicsAllocation->getResidencyTaskCount(0u));
EXPECT_EQ(1, graphicsAllocation->getResidencyTaskCount(1u));
commandStreamReceiver0.makeNonResident(*graphicsAllocation);
commandStreamReceiver1.makeNonResident(*graphicsAllocation);
EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount[1u]);
EXPECT_EQ(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
EXPECT_EQ(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(1u));
EXPECT_EQ(1u, commandStreamReceiver0.getEvictionAllocations().size());
EXPECT_EQ(1u, commandStreamReceiver1.getEvictionAllocations().size());

View File

@@ -33,7 +33,7 @@ struct MyMockCsr : UltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
void makeResident(GraphicsAllocation &gfxAllocation) override {
makeResidentParameterization.wasCalled = true;
makeResidentParameterization.receivedGfxAllocation = &gfxAllocation;
gfxAllocation.residencyTaskCount[deviceIndex] = 1;
gfxAllocation.updateResidencyTaskCount(1, deviceIndex);
}
void processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) override {
@@ -42,10 +42,10 @@ struct MyMockCsr : UltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
}
void makeNonResident(GraphicsAllocation &gfxAllocation) override {
if (gfxAllocation.residencyTaskCount[this->deviceIndex] != ObjectNotResident) {
if (gfxAllocation.isResident(this->deviceIndex)) {
makeNonResidentParameterization.wasCalled = true;
makeNonResidentParameterization.receivedGfxAllocation = &gfxAllocation;
gfxAllocation.residencyTaskCount[this->deviceIndex] = ObjectNotResident;
gfxAllocation.resetResidencyTaskCount(this->deviceIndex);
}
}

View File

@@ -227,13 +227,13 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidenc
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096);
ASSERT_NE(nullptr, graphicsAllocation);
EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
ResidencyContainer allocationsForResidency = {graphicsAllocation};
tbxCsr->processResidency(allocationsForResidency, *pDevice->getOsContext());
EXPECT_NE(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]);
EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->residencyTaskCount[0u]);
EXPECT_NE(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
EXPECT_EQ((int)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->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
ResidencyContainer allocationsForResidency = {graphicsAllocation};
tbxCsr->processResidency(allocationsForResidency, *pDevice->getOsContext());
EXPECT_NE(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]);
EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->residencyTaskCount[0u]);
EXPECT_NE(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
EXPECT_EQ((int)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->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
tbxCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext());
EXPECT_NE(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]);
EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->residencyTaskCount[0u]);
EXPECT_NE(ObjectNotResident, graphicsAllocation->getResidencyTaskCount(0u));
EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u));
memoryManager->freeGraphicsMemory(commandBuffer);
memoryManager->freeGraphicsMemory(graphicsAllocation);

View File

@@ -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->residencyTaskCount[0u]);
EXPECT_NE(ObjectNotResident, privateSurface->getResidencyTaskCount(0u));
}
}

View File

@@ -1853,8 +1853,8 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenOneKernelIsSubmittedSeveral
// This simulates enqueuing blocked kernels
kernelExecQueue[0].isResourceResident = false;
kernelExecQueue[1].isResourceResident = false;
pGfxAlloc0->residencyTaskCount[0u] = ObjectNotResident;
pGfxAlloc1->residencyTaskCount[0u] = ObjectNotResident;
pGfxAlloc0->resetResidencyTaskCount(0u);
pGfxAlloc1->resetResidencyTaskCount(0u);
EXPECT_FALSE(pGfxAlloc0->isResident(0u));
EXPECT_FALSE(pGfxAlloc1->isResident(0u));
std::vector<Surface *> residencyVector;

View File

@@ -696,17 +696,6 @@ TEST_P(ValidHostPtr, isResident_defaultsToFalseAfterCreate) {
EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident(0u));
}
TEST_P(ValidHostPtr, isResident_returnsValueFromSetResident) {
buffer = createBuffer();
ASSERT_NE(nullptr, buffer);
buffer->getGraphicsAllocation()->residencyTaskCount[0u] = 1;
EXPECT_TRUE(buffer->getGraphicsAllocation()->isResident(0u));
buffer->getGraphicsAllocation()->residencyTaskCount[0u] = ObjectNotResident;
EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident(0u));
}
TEST_P(ValidHostPtr, getAddress) {
buffer = createBuffer();
ASSERT_NE(nullptr, buffer);

View File

@@ -503,17 +503,6 @@ TEST_P(CreateImageHostPtr, isResidentDefaultsToFalseAfterCreate) {
EXPECT_FALSE(image->getGraphicsAllocation()->isResident(0u));
}
TEST_P(CreateImageHostPtr, isResidentReturnsValueFromSetResident) {
image = createImage(retVal);
ASSERT_NE(nullptr, image);
image->getGraphicsAllocation()->residencyTaskCount[0u] = 1;
EXPECT_TRUE(image->getGraphicsAllocation()->isResident(0u));
image->getGraphicsAllocation()->residencyTaskCount[0u] = ObjectNotResident;
EXPECT_FALSE(image->getGraphicsAllocation()->isResident(0u));
}
TEST_P(CreateImageHostPtr, getAddress) {
image = createImage(retVal);
ASSERT_NE(nullptr, image);

View File

@@ -51,21 +51,6 @@ struct MySharingHandler : public SharingHandler {
GraphicsAllocation *allocation = nullptr;
};
TEST(MemObj, useCount) {
char buffer[64];
MockContext context;
MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer));
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR,
sizeof(buffer), buffer, buffer, mockAllocation, true, false, false);
EXPECT_EQ(ObjectNotResident, memObj.getGraphicsAllocation()->residencyTaskCount[0u]);
memObj.getGraphicsAllocation()->residencyTaskCount[0u] = 1;
EXPECT_EQ(1, memObj.getGraphicsAllocation()->residencyTaskCount[0u]);
memObj.getGraphicsAllocation()->residencyTaskCount[0u]--;
EXPECT_EQ(0, memObj.getGraphicsAllocation()->residencyTaskCount[0u]);
}
TEST(MemObj, GivenMemObjWhenInititalizedFromHostPtrThenInitializeFields) {
const size_t size = 64;
char buffer[size];

View File

@@ -16,16 +16,11 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenIsCreatedThenTaskCountsA
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));
}
}
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenAccessTaskCountForInvalidContextThenAbort) {
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0u);
EXPECT_THROW(graphicsAllocation.getTaskCount(maxOsContextCount), std::exception);
}
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenUpdateTaskCountForInvalidContextThenAbort) {
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0u);
EXPECT_THROW(graphicsAllocation.updateTaskCount(0u, maxOsContextCount), std::exception);
}
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenUpdatedTaskCountThenAllocationWasUsed) {
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0u);
EXPECT_FALSE(graphicsAllocation.peekWasUsed());
@@ -67,3 +62,24 @@ TEST(GraphicsAllocationTest, whenTwoContextsUpdatedTaskCountAndOneOfThemUnregist
graphicsAllocation.updateTaskCount(ObjectNotUsed, 1u);
EXPECT_FALSE(graphicsAllocation.peekWasUsed());
}
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenUpdatedResidencyTaskCountToNonDefaultValueThenAllocationIsResident) {
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0u);
EXPECT_FALSE(graphicsAllocation.isResident(0u));
int residencyTaskCount = 1;
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));
EXPECT_FALSE(graphicsAllocation.isResident(0u));
}
TEST(GraphicsAllocationTest, givenResidentGraphicsAllocationWhenResetResidencyTaskCountThenAllocationIsNotResident) {
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0u);
graphicsAllocation.updateResidencyTaskCount(1, 0u);
EXPECT_TRUE(graphicsAllocation.isResident(0u));
graphicsAllocation.resetResidencyTaskCount(0u);
EXPECT_FALSE(graphicsAllocation.isResident(0u));
}

View File

@@ -1392,13 +1392,6 @@ TEST(GraphicsAllocation, givenSharedHandleBasedConstructorWhenGraphicsAllocation
EXPECT_EQ(expectedGpuAddress, graphicsAllocation.getGpuAddress());
}
TEST(GraphicsAllocation, givenGraphicsAllocationCreatedWithDefaultConstructorThenItIsNotResidentInAllContexts) {
MockGraphicsAllocation graphicsAllocation(nullptr, 1u);
for (uint32_t index = 0u; index < maxOsContextCount; index++) {
EXPECT_EQ(ObjectNotResident, graphicsAllocation.residencyTaskCount[index]);
}
}
TEST(ResidencyDataTest, givenOsContextWhenItIsRegisteredToMemoryManagerThenRefCountIncreases) {
auto osContext = new OsContext(nullptr, 0u);
ExecutionEnvironment executionEnvironment;

View File

@@ -44,7 +44,7 @@ class MockCsrBase : public UltCommandStreamReceiver<GfxFamily> {
if (this->getMemoryManager()) {
this->getResidencyAllocations().push_back(&gfxAllocation);
}
gfxAllocation.residencyTaskCount[this->deviceIndex] = this->taskCount;
gfxAllocation.updateResidencyTaskCount(this->taskCount, this->deviceIndex);
}
void makeNonResident(GraphicsAllocation &gfxAllocation) override {
madeNonResidentGfxAllocations.push_back(&gfxAllocation);

View File

@@ -34,7 +34,7 @@ cl_int GlobalMockSipProgram::processGenBinaryOnce() {
}
void GlobalMockSipProgram::resetAllocationState() {
for (uint32_t index = 0u; index < maxOsContextCount; index++) {
this->kernelInfoArray[0]->kernelAllocation->residencyTaskCount[index] = 0xffffffff;
this->kernelInfoArray[0]->kernelAllocation->resetResidencyTaskCount(index);
}
static_cast<MockGraphicsAllocation *>(this->kernelInfoArray[0]->kernelAllocation)->resetInspectionId();
}

View File

@@ -1606,7 +1606,7 @@ TEST_F(DrmCommandStreamLeaksTest, BufferResidency) {
std::unique_ptr<Buffer> buffer(DrmMockBuffer::create());
ASSERT_FALSE(buffer->getGraphicsAllocation()->isResident(0u));
ASSERT_EQ(ObjectNotResident, buffer->getGraphicsAllocation()->residencyTaskCount[0u]);
ASSERT_EQ(ObjectNotResident, buffer->getGraphicsAllocation()->getResidencyTaskCount(0u));
ASSERT_GT(buffer->getSize(), 0u);
//make it resident 8 times
@@ -1614,7 +1614,7 @@ TEST_F(DrmCommandStreamLeaksTest, BufferResidency) {
csr->makeResident(*buffer->getGraphicsAllocation());
csr->processResidency(csr->getResidencyAllocations(), *osContext);
EXPECT_TRUE(buffer->getGraphicsAllocation()->isResident(0u));
EXPECT_EQ(buffer->getGraphicsAllocation()->residencyTaskCount[0u], (int)csr->peekTaskCount() + 1);
EXPECT_EQ(buffer->getGraphicsAllocation()->getResidencyTaskCount(0u), (int)csr->peekTaskCount() + 1);
}
csr->makeNonResident(*buffer->getGraphicsAllocation());
@@ -1622,7 +1622,7 @@ TEST_F(DrmCommandStreamLeaksTest, BufferResidency) {
csr->makeNonResident(*buffer->getGraphicsAllocation());
EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident(0u));
EXPECT_EQ(ObjectNotResident, buffer->getGraphicsAllocation()->residencyTaskCount[0u]);
EXPECT_EQ(ObjectNotResident, buffer->getGraphicsAllocation()->getResidencyTaskCount(0u));
}
typedef Test<DrmCommandStreamEnhancedFixture> DrmCommandStreamMemoryManagerTest;