Clean temporary allocations after Blit operation

Change-Id: I5c9b6778c93c7422bb84ee367dbf298df5e06cab
Related-To: NEO-3020
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2019-05-10 12:59:39 +02:00
committed by sys_ocldev
parent cc6a94b5b6
commit a3ad3b9fa2
4 changed files with 25 additions and 8 deletions

View File

@@ -38,6 +38,7 @@
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_csr.h"
#include "unit_tests/mocks/mock_event.h"
#include "unit_tests/mocks/mock_internal_allocation_storage.h"
#include "unit_tests/mocks/mock_kernel.h"
#include "unit_tests/mocks/mock_submissions_aggregator.h"
#include "unit_tests/utilities/base_object_utils.h"
@@ -379,14 +380,7 @@ HWTEST_F(BcsTests, givenInputAllocationsWhenBlitDispatchedThenMakeAllAllocations
EXPECT_TRUE(csr.isMadeResident(csr.getTagAllocation()));
EXPECT_EQ(1u, csr.makeSurfacePackNonResidentCalled);
bool hostPtrAllocationFound = false;
for (auto &allocation : csr.makeResidentAllocations) {
if (allocation.first->getUnderlyingBuffer() == hostPtr) {
hostPtrAllocationFound = true;
break;
}
}
EXPECT_TRUE(hostPtrAllocationFound);
EXPECT_EQ(4u, csr.makeResidentAllocations.size());
}
HWTEST_F(BcsTests, givenBufferWhenBlitCalledThenFlushCommandBuffer) {
@@ -456,3 +450,22 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCallWaitWithKmdFallback) {
EXPECT_FALSE(myMockCsr->useQuickKmdSleepPassed);
EXPECT_FALSE(myMockCsr->forcePowerSavingModePassed);
}
HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCleanTemporaryAllocations) {
auto &bcsCsr = pDevice->getUltCommandStreamReceiver<FamilyType>();
auto mockInternalAllocationsStorage = new MockInternalAllocationStorage(bcsCsr);
bcsCsr.internalAllocationStorage.reset(mockInternalAllocationsStorage);
cl_int retVal = CL_SUCCESS;
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x12340000);
uint32_t newTaskCount = 17;
bcsCsr.taskCount = newTaskCount - 1;
EXPECT_EQ(0u, mockInternalAllocationsStorage->cleanAllocationsCalled);
bcsCsr.blitFromHostPtr(*buffer, hostPtr, 1);
EXPECT_EQ(1u, mockInternalAllocationsStorage->cleanAllocationsCalled);
EXPECT_EQ(newTaskCount, mockInternalAllocationsStorage->lastCleanAllocationsTaskCount);
EXPECT_TRUE(TEMPORARY_ALLOCATION == mockInternalAllocationsStorage->lastCleanAllocationUsage);
}

View File

@@ -40,6 +40,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
using BaseClass::CommandStreamReceiver::experimentalCmdBuffer;
using BaseClass::CommandStreamReceiver::flushStamp;
using BaseClass::CommandStreamReceiver::GSBAFor32BitProgrammed;
using BaseClass::CommandStreamReceiver::internalAllocationStorage;
using BaseClass::CommandStreamReceiver::isPreambleSent;
using BaseClass::CommandStreamReceiver::isStateSipSent;
using BaseClass::CommandStreamReceiver::lastMediaSamplerConfig;

View File

@@ -16,6 +16,7 @@ class MockInternalAllocationStorage : public InternalAllocationStorage {
void cleanAllocationList(uint32_t waitTaskCount, uint32_t allocationUsage) override {
cleanAllocationsCalled++;
lastCleanAllocationsTaskCount = waitTaskCount;
lastCleanAllocationUsage = allocationUsage;
InternalAllocationStorage::cleanAllocationList(waitTaskCount, allocationUsage);
if (doUpdateCompletion) {
*commandStreamReceiver.getTagAddress() = valueToUpdateCompletion;
@@ -28,6 +29,7 @@ class MockInternalAllocationStorage : public InternalAllocationStorage {
}
bool doUpdateCompletion = false;
uint32_t valueToUpdateCompletion;
uint32_t lastCleanAllocationUsage = 0;
uint32_t lastCleanAllocationsTaskCount = 0;
uint32_t cleanAllocationsCalled = 0;
};