|
38 | 38 | #include "unit_tests/mocks/mock_context.h"
|
39 | 39 | #include "unit_tests/mocks/mock_csr.h"
|
40 | 40 | #include "unit_tests/mocks/mock_event.h"
|
| 41 | +#include "unit_tests/mocks/mock_internal_allocation_storage.h" |
41 | 42 | #include "unit_tests/mocks/mock_kernel.h"
|
42 | 43 | #include "unit_tests/mocks/mock_submissions_aggregator.h"
|
43 | 44 | #include "unit_tests/utilities/base_object_utils.h"
|
@@ -379,14 +380,7 @@ HWTEST_F(BcsTests, givenInputAllocationsWhenBlitDispatchedThenMakeAllAllocations
|
379 | 380 | EXPECT_TRUE(csr.isMadeResident(csr.getTagAllocation()));
|
380 | 381 | EXPECT_EQ(1u, csr.makeSurfacePackNonResidentCalled);
|
381 | 382 |
|
382 |
| - bool hostPtrAllocationFound = false; |
383 |
| - for (auto &allocation : csr.makeResidentAllocations) { |
384 |
| - if (allocation.first->getUnderlyingBuffer() == hostPtr) { |
385 |
| - hostPtrAllocationFound = true; |
386 |
| - break; |
387 |
| - } |
388 |
| - } |
389 |
| - EXPECT_TRUE(hostPtrAllocationFound); |
| 383 | + EXPECT_EQ(4u, csr.makeResidentAllocations.size()); |
390 | 384 | }
|
391 | 385 |
|
392 | 386 | HWTEST_F(BcsTests, givenBufferWhenBlitCalledThenFlushCommandBuffer) {
|
@@ -456,3 +450,22 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCallWaitWithKmdFallback) {
|
456 | 450 | EXPECT_FALSE(myMockCsr->useQuickKmdSleepPassed);
|
457 | 451 | EXPECT_FALSE(myMockCsr->forcePowerSavingModePassed);
|
458 | 452 | }
|
| 453 | + |
| 454 | +HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCleanTemporaryAllocations) { |
| 455 | + auto &bcsCsr = pDevice->getUltCommandStreamReceiver<FamilyType>(); |
| 456 | + auto mockInternalAllocationsStorage = new MockInternalAllocationStorage(bcsCsr); |
| 457 | + bcsCsr.internalAllocationStorage.reset(mockInternalAllocationsStorage); |
| 458 | + |
| 459 | + cl_int retVal = CL_SUCCESS; |
| 460 | + auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal)); |
| 461 | + void *hostPtr = reinterpret_cast<void *>(0x12340000); |
| 462 | + |
| 463 | + uint32_t newTaskCount = 17; |
| 464 | + bcsCsr.taskCount = newTaskCount - 1; |
| 465 | + |
| 466 | + EXPECT_EQ(0u, mockInternalAllocationsStorage->cleanAllocationsCalled); |
| 467 | + bcsCsr.blitFromHostPtr(*buffer, hostPtr, 1); |
| 468 | + EXPECT_EQ(1u, mockInternalAllocationsStorage->cleanAllocationsCalled); |
| 469 | + EXPECT_EQ(newTaskCount, mockInternalAllocationsStorage->lastCleanAllocationsTaskCount); |
| 470 | + EXPECT_TRUE(TEMPORARY_ALLOCATION == mockInternalAllocationsStorage->lastCleanAllocationUsage); |
| 471 | +} |
0 commit comments