mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Fix multi thread usage of external host alloc
This is fixed reupload of this commit after auto revert With this commit OpenCL will track if external host memory is used from few threads and will secure to update task count in all threads before destroing allocation. Resolves: NEO-6807 Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
2a0c395db5
commit
0a16dc6c47
@ -297,3 +297,25 @@ HWTEST_F(InternalAllocationStorageTest, givenMultipleActivePartitionsWhenDetachi
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocationReusable.release());
|
||||
}
|
||||
TEST_F(InternalAllocationStorageTest, givenInternalAllocationWhenTaskCountMetsExpectationAndItHasBeenAssignedThenAllocIsRemoved) {
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||
uint32_t expectedTaskCount = 10u;
|
||||
*csr->getTagAddress() = expectedTaskCount;
|
||||
allocation->updateTaskCount(expectedTaskCount, csr->getOsContext().getContextId());
|
||||
allocation->hostPtrTaskCountAssignment = 0;
|
||||
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), TEMPORARY_ALLOCATION);
|
||||
storage->cleanAllocationList(expectedTaskCount, TEMPORARY_ALLOCATION);
|
||||
EXPECT_TRUE(csr->getTemporaryAllocations().peekIsEmpty());
|
||||
}
|
||||
|
||||
TEST_F(InternalAllocationStorageTest, givenInternalAllocationWhenTaskCountMetsExpectationAndItHasNotBeenAssignedThenAllocIsNotRemoved) {
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||
uint32_t expectedTaskCount = 10u;
|
||||
*csr->getTagAddress() = expectedTaskCount;
|
||||
allocation->updateTaskCount(expectedTaskCount, csr->getOsContext().getContextId());
|
||||
allocation->hostPtrTaskCountAssignment = 1;
|
||||
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), TEMPORARY_ALLOCATION);
|
||||
storage->cleanAllocationList(expectedTaskCount, TEMPORARY_ALLOCATION);
|
||||
EXPECT_FALSE(csr->getTemporaryAllocations().peekIsEmpty());
|
||||
allocation->hostPtrTaskCountAssignment = 0;
|
||||
}
|
Reference in New Issue
Block a user