mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Fix allocating small buffers from pool
Wait for engine completion before freeing from pool Related-To: NEO-7332 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
d9d706d747
commit
0cea7fe6d1
@ -94,6 +94,8 @@ MemObj::~MemObj() {
|
|||||||
}
|
}
|
||||||
destroyGraphicsAllocation(graphicsAllocation, doAsyncDestructions);
|
destroyGraphicsAllocation(graphicsAllocation, doAsyncDestructions);
|
||||||
graphicsAllocation = nullptr;
|
graphicsAllocation = nullptr;
|
||||||
|
} else if (graphicsAllocation && context->getBufferPoolAllocator().isPoolBuffer(associatedMemObject)) {
|
||||||
|
memoryManager->waitForEnginesCompletion(*graphicsAllocation);
|
||||||
}
|
}
|
||||||
if (!associatedMemObject) {
|
if (!associatedMemObject) {
|
||||||
releaseMapAllocation(rootDeviceIndex, doAsyncDestructions);
|
releaseMapAllocation(rootDeviceIndex, doAsyncDestructions);
|
||||||
|
@ -115,6 +115,25 @@ TEST_F(aggregatedSmallBuffersEnabledTest, givenAggregatedSmallBuffersEnabledAndS
|
|||||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(aggregatedSmallBuffersEnabledTest, givenAggregatedSmallBuffersEnabledWhenClReleaseMemObjectCalledThenWaitForEnginesCompletionCalled) {
|
||||||
|
ASSERT_TRUE(poolAllocator->isAggregatedSmallBuffersEnabled());
|
||||||
|
ASSERT_NE(poolAllocator->mainStorage, nullptr);
|
||||||
|
std::unique_ptr<Buffer> buffer(Buffer::create(context.get(), flags, size, hostPtr, retVal));
|
||||||
|
|
||||||
|
ASSERT_NE(buffer, nullptr);
|
||||||
|
ASSERT_EQ(retVal, CL_SUCCESS);
|
||||||
|
|
||||||
|
ASSERT_NE(poolAllocator->mainStorage, nullptr);
|
||||||
|
auto mockBuffer = static_cast<MockBuffer *>(buffer.get());
|
||||||
|
ASSERT_TRUE(mockBuffer->isSubBuffer());
|
||||||
|
ASSERT_EQ(poolAllocator->mainStorage, mockBuffer->associatedMemObject);
|
||||||
|
|
||||||
|
ASSERT_EQ(mockMemoryManager->waitForEnginesCompletionCalled, 0u);
|
||||||
|
retVal = clReleaseMemObject(buffer.release());
|
||||||
|
ASSERT_EQ(retVal, CL_SUCCESS);
|
||||||
|
EXPECT_EQ(mockMemoryManager->waitForEnginesCompletionCalled, 1u);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(aggregatedSmallBuffersEnabledTest, givenCopyHostPointerWhenCreatingBufferButCopyFailedThenDoNotUsePool) {
|
TEST_F(aggregatedSmallBuffersEnabledTest, givenCopyHostPointerWhenCreatingBufferButCopyFailedThenDoNotUsePool) {
|
||||||
class MockCommandQueueFailFirstEnqueueWrite : public MockCommandQueue {
|
class MockCommandQueueFailFirstEnqueueWrite : public MockCommandQueue {
|
||||||
public:
|
public:
|
||||||
|
Reference in New Issue
Block a user