Allow to reuse just completed allocation

Change-Id: I7c1ab153178b79348d49209ca09478543d35e197
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2018-11-06 09:07:10 +01:00
committed by sys_ocldev
parent 337d374bc5
commit 630a7e1c26
2 changed files with 23 additions and 4 deletions

View File

@@ -92,7 +92,7 @@ TEST_F(InternalAllocationStorageTest, whenObtainAllocationFromEmptyReuseListThen
EXPECT_EQ(nullptr, allocation2);
}
TEST_F(InternalAllocationStorageTest, whenAllocationIsStoredAsReusableAndNotUsedThenCanBeObtained) {
TEST_F(InternalAllocationStorageTest, whenCompletedAllocationIsStoredAsReusableAndThenCanBeObtained) {
void *host_ptr = (void *)0x1234;
auto allocation = memoryManager->allocateGraphicsMemory(1, host_ptr);
EXPECT_NE(nullptr, allocation);
@@ -102,7 +102,26 @@ TEST_F(InternalAllocationStorageTest, whenAllocationIsStoredAsReusableAndNotUsed
auto *hwTag = csr->getTagAddress();
*hwTag = 3u;
*hwTag = 2u;
auto reusedAllocation = storage->obtainReusableAllocation(1, false).release();
EXPECT_EQ(allocation, reusedAllocation);
EXPECT_TRUE(csr->getAllocationsForReuse().peekIsEmpty());
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(InternalAllocationStorageTest, whenNotUsedAllocationIsStoredAsReusableAndThenCanBeObtained) {
void *host_ptr = (void *)0x1234;
auto allocation = memoryManager->allocateGraphicsMemory(1, host_ptr);
EXPECT_NE(nullptr, allocation);
EXPECT_FALSE(allocation->peekWasUsed());
EXPECT_EQ(0u, csr->peekTaskCount());
*csr->getTagAddress() = 0; // initial hw tag for dll
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
EXPECT_EQ(0u, allocation->getTaskCount(0u));
EXPECT_FALSE(csr->getAllocationsForReuse().peekIsEmpty());
auto reusedAllocation = storage->obtainReusableAllocation(1, false).release();
EXPECT_EQ(allocation, reusedAllocation);
@@ -203,4 +222,4 @@ TEST_F(InternalAllocationStorageTest, givenInternalAllocationWhenItIsPutOnReusab
EXPECT_EQ(allocation, internalAllocation.get());
internalAllocation.release();
memoryManager->freeGraphicsMemory(allocation);
}
}