mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-11 00:10:58 +08:00
Allow to reuse just completed allocation
Change-Id: I7c1ab153178b79348d49209ca09478543d35e197 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
337d374bc5
commit
630a7e1c26
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user