mirror of
https://github.com/intel/compute-runtime.git
synced 2025-11-10 05:49:51 +08:00
Revert "Add mechanism to ensure resource lifetime residency on Linux"
This reverts commit 537ffbcb00.
Change-Id: I425a6167979e1f7bb9bc1ca8a8b91bd8174be480
This commit is contained in:
committed by
sys_ocldev
parent
85a5dcfe62
commit
a843293f89
@@ -17,7 +17,6 @@
|
||||
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
||||
#include "shared/source/os_interface/linux/drm_engine_mapper.h"
|
||||
#include "shared/source/os_interface/linux/drm_memory_manager.h"
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/source/os_interface/linux/os_interface.h"
|
||||
@@ -116,13 +115,6 @@ void DrmCommandStreamReceiver<GfxFamily>::processResidency(const ResidencyContai
|
||||
makeResidentBufferObjects(drmAlloc, handleId);
|
||||
}
|
||||
}
|
||||
|
||||
auto memoryOperationInterface = static_cast<DrmMemoryOperationsHandler *>(this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]->memoryOperationsInterface.get());
|
||||
auto allTimeResidentAllocs = memoryOperationInterface->getResidencySet();
|
||||
for (const auto &alloc : allTimeResidentAllocs) {
|
||||
const auto drmAlloc = static_cast<DrmAllocation *>(alloc);
|
||||
makeResidentBufferObjects(drmAlloc, handleId);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/source/os_interface/linux/os_interface.h"
|
||||
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
|
||||
@@ -35,7 +34,6 @@ class DrmCommandStreamTest : public ::testing::Test {
|
||||
|
||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock);
|
||||
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
||||
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
|
||||
osContext = std::make_unique<OsContextLinux>(*mock, 0u, 1, HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0],
|
||||
@@ -104,7 +102,6 @@ class DrmCommandStreamEnhancedTest : public ::testing::Test {
|
||||
mock = new DrmMockCustom();
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setDrm(mock);
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
||||
|
||||
csr = new TestedDrmCommandStreamReceiver<GfxFamily>(*executionEnvironment, rootDeviceIndex);
|
||||
ASSERT_NE(nullptr, csr);
|
||||
|
||||
@@ -576,17 +576,6 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenGemCloseWorkerInactiveMode
|
||||
mm->freeGraphicsMemory(dummyAllocation);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocInMemoryOperationsInterfaceWhenProcessResidencyThenAllocIsResident) {
|
||||
auto allocation = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||
executionEnvironment->rootDeviceEnvironments[csr->getRootDeviceIndex()]->memoryOperationsInterface->makeResident(ArrayRef<GraphicsAllocation *>(&allocation, 1));
|
||||
|
||||
csr->processResidency(csr->getResidencyAllocations(), 0u);
|
||||
|
||||
EXPECT_TRUE(isResident<FamilyType>(static_cast<DrmAllocation *>(allocation)->getBO()));
|
||||
|
||||
mm->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenTwoAllocationsWhenBackingStorageIsDifferentThenMakeResidentShouldAddTwoLocations) {
|
||||
auto allocation = static_cast<DrmAllocation *>(mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
||||
auto allocation2 = static_cast<DrmAllocation *>(mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
||||
|
||||
@@ -61,7 +61,6 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture {
|
||||
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[i].get();
|
||||
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
|
||||
rootDeviceEnvironment->osInterface->get()->setDrm(new DrmMockCustom());
|
||||
rootDeviceEnvironment->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
||||
}
|
||||
|
||||
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex].get();
|
||||
|
||||
@@ -27,19 +27,12 @@ struct DrmMemoryOperationsHandlerTest : public ::testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(DrmMemoryOperationsHandlerTest, whenMakingResidentAllocaionExpectMakeResidentFail) {
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->makeResident(ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->getResidencySet().size(), 1u);
|
||||
EXPECT_EQ(*drmMemoryOperationsHandler->getResidencySet().find(allocationPtr), allocationPtr);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->isResident(graphicsAllocation), MemoryOperationsStatus::SUCCESS);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->makeResident(ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::UNSUPPORTED);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->isResident(graphicsAllocation), MemoryOperationsStatus::UNSUPPORTED);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryOperationsHandlerTest, whenEvictingResidentAllocationExpectEvictFalse) {
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->getResidencySet().size(), 0u);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->makeResident(ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->isResident(graphicsAllocation), MemoryOperationsStatus::SUCCESS);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->getResidencySet().size(), 1u);
|
||||
EXPECT_EQ(*drmMemoryOperationsHandler->getResidencySet().find(allocationPtr), allocationPtr);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->evict(graphicsAllocation), MemoryOperationsStatus::SUCCESS);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->isResident(graphicsAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->getResidencySet().size(), 0u);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->makeResident(ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::UNSUPPORTED);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->evict(graphicsAllocation), MemoryOperationsStatus::UNSUPPORTED);
|
||||
EXPECT_EQ(drmMemoryOperationsHandler->isResident(graphicsAllocation), MemoryOperationsStatus::UNSUPPORTED);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/linux/os_interface.h"
|
||||
|
||||
#include "opencl/source/command_queue/command_queue_hw.h"
|
||||
@@ -26,7 +25,6 @@ struct clCreateCommandQueueWithPropertiesLinux : public UltCommandStreamReceiver
|
||||
auto osInterface = new OSInterface();
|
||||
osInterface->get()->setDrm(drm);
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface.reset(osInterface);
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
||||
executionEnvironment->memoryManager.reset(new TestedDrmMemoryManager(*executionEnvironment));
|
||||
mdevice = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, rootDeviceIndex));
|
||||
|
||||
|
||||
@@ -9,32 +9,19 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
DrmMemoryOperationsHandler::DrmMemoryOperationsHandler() = default;
|
||||
DrmMemoryOperationsHandler::~DrmMemoryOperationsHandler() = default;
|
||||
DrmMemoryOperationsHandler::DrmMemoryOperationsHandler() {
|
||||
}
|
||||
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandler::makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
this->residency.insert(gfxAllocations.begin(), gfxAllocations.end());
|
||||
return MemoryOperationsStatus::SUCCESS;
|
||||
return MemoryOperationsStatus::UNSUPPORTED;
|
||||
}
|
||||
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandler::evict(GraphicsAllocation &gfxAllocation) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
this->residency.erase(&gfxAllocation);
|
||||
return MemoryOperationsStatus::SUCCESS;
|
||||
return MemoryOperationsStatus::UNSUPPORTED;
|
||||
}
|
||||
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandler::isResident(GraphicsAllocation &gfxAllocation) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
auto ret = this->residency.find(&gfxAllocation);
|
||||
if (ret == this->residency.end()) {
|
||||
return MemoryOperationsStatus::MEMORY_NOT_FOUND;
|
||||
}
|
||||
return MemoryOperationsStatus::SUCCESS;
|
||||
return MemoryOperationsStatus::UNSUPPORTED;
|
||||
}
|
||||
|
||||
std::unordered_set<GraphicsAllocation *> DrmMemoryOperationsHandler::getResidencySet() {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
return this->residency;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -8,23 +8,15 @@
|
||||
#pragma once
|
||||
#include "shared/source/memory_manager/memory_operations_handler.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class DrmMemoryOperationsHandler : public MemoryOperationsHandler {
|
||||
public:
|
||||
DrmMemoryOperationsHandler();
|
||||
~DrmMemoryOperationsHandler() override;
|
||||
~DrmMemoryOperationsHandler() override = default;
|
||||
|
||||
MemoryOperationsStatus makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) override;
|
||||
MemoryOperationsStatus evict(GraphicsAllocation &gfxAllocation) override;
|
||||
MemoryOperationsStatus isResident(GraphicsAllocation &gfxAllocation) override;
|
||||
|
||||
std::unordered_set<GraphicsAllocation *> getResidencySet();
|
||||
|
||||
protected:
|
||||
std::unordered_set<GraphicsAllocation *> residency;
|
||||
std::mutex mutex;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user