mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 18:25:05 +08:00
fix: Disable async release of buffers with external host ptr
Related-To: NEO-10036 Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d94be09020
commit
70a62d89e3
@@ -82,7 +82,8 @@ MemObj::~MemObj() {
|
|||||||
needWait |= multiGraphicsAllocation.getGraphicsAllocations().size() > 1u;
|
needWait |= multiGraphicsAllocation.getGraphicsAllocations().size() > 1u;
|
||||||
for (auto graphicsAllocation : multiGraphicsAllocation.getGraphicsAllocations()) {
|
for (auto graphicsAllocation : multiGraphicsAllocation.getGraphicsAllocations()) {
|
||||||
auto rootDeviceIndex = graphicsAllocation ? graphicsAllocation->getRootDeviceIndex() : 0;
|
auto rootDeviceIndex = graphicsAllocation ? graphicsAllocation->getRootDeviceIndex() : 0;
|
||||||
bool doAsyncDestructions = debugManager.flags.EnableAsyncDestroyAllocations.get();
|
|
||||||
|
bool doAsyncDestructions = debugManager.flags.EnableAsyncDestroyAllocations.get() && !this->memoryProperties.flags.useHostPtr;
|
||||||
if (graphicsAllocation && !associatedMemObject && !isHostPtrSVM && graphicsAllocation->peekReuseCount() == 0) {
|
if (graphicsAllocation && !associatedMemObject && !isHostPtrSVM && graphicsAllocation->peekReuseCount() == 0) {
|
||||||
memoryManager->removeAllocationFromHostPtrManager(graphicsAllocation);
|
memoryManager->removeAllocationFromHostPtrManager(graphicsAllocation);
|
||||||
if (!doAsyncDestructions) {
|
if (!doAsyncDestructions) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2018-2023 Intel Corporation
|
* Copyright (C) 2018-2024 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -55,7 +55,7 @@ class MyCsr : public UltCommandStreamReceiver<Family> {
|
|||||||
void CL_CALLBACK emptyDestructorCallback(cl_mem memObj, void *userData) {
|
void CL_CALLBACK emptyDestructorCallback(cl_mem memObj, void *userData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool useMultiGraphicsAllocation = false>
|
template <bool useMultiGraphicsAllocation = false, bool useHostPtr = false>
|
||||||
class MemObjDestructionTest : public ::testing::TestWithParam<bool> {
|
class MemObjDestructionTest : public ::testing::TestWithParam<bool> {
|
||||||
public:
|
public:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
@@ -65,7 +65,12 @@ class MemObjDestructionTest : public ::testing::TestWithParam<bool> {
|
|||||||
device = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0));
|
device = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0));
|
||||||
context.reset(new MockContext(device.get()));
|
context.reset(new MockContext(device.get()));
|
||||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), size});
|
allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), size});
|
||||||
if constexpr (useMultiGraphicsAllocation) {
|
if constexpr (useHostPtr) {
|
||||||
|
memObj = new MemObj(context.get(), CL_MEM_OBJECT_BUFFER,
|
||||||
|
ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, 0, 0, &device->getDevice()),
|
||||||
|
CL_MEM_READ_WRITE, 0, size,
|
||||||
|
nullptr, nullptr, GraphicsAllocationHelper::toMultiGraphicsAllocation(allocation), true, false, false);
|
||||||
|
} else if constexpr (useMultiGraphicsAllocation) {
|
||||||
MultiGraphicsAllocation multiAllocation(1u);
|
MultiGraphicsAllocation multiAllocation(1u);
|
||||||
multiAllocation.addAllocation(allocation);
|
multiAllocation.addAllocation(allocation);
|
||||||
memObj = new MemObj(context.get(), CL_MEM_OBJECT_BUFFER,
|
memObj = new MemObj(context.get(), CL_MEM_OBJECT_BUFFER,
|
||||||
@@ -137,6 +142,18 @@ class MemObjMulitAllocationAsyncDestructionTest : public MemObjDestructionTest<t
|
|||||||
DebugManagerStateRestore restorer;
|
DebugManagerStateRestore restorer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MemObjUseHostPtrAsyncDestructionTest : public MemObjDestructionTest<false, true> {
|
||||||
|
public:
|
||||||
|
void SetUp() override {
|
||||||
|
debugManager.flags.EnableAsyncDestroyAllocations.set(true);
|
||||||
|
MemObjDestructionTest::SetUp();
|
||||||
|
}
|
||||||
|
void TearDown() override {
|
||||||
|
MemObjDestructionTest::TearDown();
|
||||||
|
}
|
||||||
|
DebugManagerStateRestore restorer;
|
||||||
|
};
|
||||||
|
|
||||||
class MemObjSyncDestructionTest : public MemObjDestructionTest<> {
|
class MemObjSyncDestructionTest : public MemObjDestructionTest<> {
|
||||||
public:
|
public:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
@@ -199,6 +216,34 @@ HWTEST_F(MemObjMulitAllocationAsyncDestructionTest, givenUsedMemObjWithAsyncDest
|
|||||||
EXPECT_EQ(expectedTaskCount1, mockCsr1->waitForCompletionWithTimeoutParamsPassed[0].taskCountToWait);
|
EXPECT_EQ(expectedTaskCount1, mockCsr1->waitForCompletionWithTimeoutParamsPassed[0].taskCountToWait);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWTEST_F(MemObjUseHostPtrAsyncDestructionTest, givenUsedMemObjWithAsyncDestructionsEnabledThatUsesExternalHostPtrWhenItIsDestroyedThenDestructorWaitsOnTaskCount) {
|
||||||
|
auto rootDeviceIndex = device->getRootDeviceIndex();
|
||||||
|
auto mockCsr0 = new MyCsr<FamilyType>(*device->executionEnvironment, device->getDeviceBitfield());
|
||||||
|
auto mockCsr1 = new MyCsr<FamilyType>(*device->executionEnvironment, device->getDeviceBitfield());
|
||||||
|
device->resetCommandStreamReceiver(mockCsr0, 0);
|
||||||
|
device->resetCommandStreamReceiver(mockCsr1, 1);
|
||||||
|
*mockCsr0->getTagAddress() = 0;
|
||||||
|
*mockCsr1->getTagAddress() = 0;
|
||||||
|
mockCsr0->getTagAddressValue = taskCountReady;
|
||||||
|
mockCsr1->getTagAddressValue = taskCountReady;
|
||||||
|
auto osContextId0 = mockCsr0->getOsContext().getContextId();
|
||||||
|
auto osContextId1 = mockCsr1->getOsContext().getContextId();
|
||||||
|
memObj->getGraphicsAllocation(rootDeviceIndex)->updateTaskCount(taskCountReady, osContextId0);
|
||||||
|
memObj->getGraphicsAllocation(rootDeviceIndex)->updateTaskCount(taskCountReady, osContextId1);
|
||||||
|
auto expectedTaskCount0 = allocation->getTaskCount(osContextId0);
|
||||||
|
auto expectedTaskCount1 = allocation->getTaskCount(osContextId1);
|
||||||
|
|
||||||
|
delete memObj;
|
||||||
|
|
||||||
|
EXPECT_EQ(1u, mockCsr0->waitForCompletionWithTimeoutCalled);
|
||||||
|
EXPECT_EQ(TimeoutControls::maxTimeout, mockCsr0->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
||||||
|
EXPECT_EQ(expectedTaskCount0, mockCsr0->waitForCompletionWithTimeoutParamsPassed[0].taskCountToWait);
|
||||||
|
|
||||||
|
EXPECT_EQ(1u, mockCsr1->waitForCompletionWithTimeoutCalled);
|
||||||
|
EXPECT_EQ(TimeoutControls::maxTimeout, mockCsr1->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
||||||
|
EXPECT_EQ(expectedTaskCount1, mockCsr1->waitForCompletionWithTimeoutParamsPassed[0].taskCountToWait);
|
||||||
|
}
|
||||||
|
|
||||||
HWTEST_P(MemObjAsyncDestructionTest, givenUsedMemObjWithAsyncDestructionsEnabledThatHasDestructorCallbacksWhenItIsDestroyedThenDestructorWaitsOnTaskCount) {
|
HWTEST_P(MemObjAsyncDestructionTest, givenUsedMemObjWithAsyncDestructionsEnabledThatHasDestructorCallbacksWhenItIsDestroyedThenDestructorWaitsOnTaskCount) {
|
||||||
bool hasCallbacks = GetParam();
|
bool hasCallbacks = GetParam();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user