From a843293f89f5f3aed7883e0637462f8bbb0e8105 Mon Sep 17 00:00:00 2001 From: "Jobczyk, Lukasz" Date: Tue, 5 May 2020 00:40:18 -0700 Subject: [PATCH] Revert "Add mechanism to ensure resource lifetime residency on Linux" This reverts commit 537ffbcb0068ab7253f21086edcde049a2e81576. Change-Id: I425a6167979e1f7bb9bc1ca8a8b91bd8174be480 --- .../os_interface/linux/drm_command_stream.inl | 8 ------- .../linux/drm_command_stream_fixture.h | 3 --- .../linux/drm_command_stream_tests.cpp | 11 --------- .../linux/drm_memory_manager_tests.h | 1 - .../linux/drm_residency_handler_tests.cpp | 17 ++++---------- ...te_command_queue_with_properties_tests.cpp | 2 -- .../linux/drm_memory_operations_handler.cpp | 23 ++++--------------- .../linux/drm_memory_operations_handler.h | 12 ++-------- 8 files changed, 12 insertions(+), 65 deletions(-) diff --git a/opencl/source/os_interface/linux/drm_command_stream.inl b/opencl/source/os_interface/linux/drm_command_stream.inl index 0d9b977f54..a59d7f6acf 100644 --- a/opencl/source/os_interface/linux/drm_command_stream.inl +++ b/opencl/source/os_interface/linux/drm_command_stream.inl @@ -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::processResidency(const ResidencyContai makeResidentBufferObjects(drmAlloc, handleId); } } - - auto memoryOperationInterface = static_cast(this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]->memoryOperationsInterface.get()); - auto allTimeResidentAllocs = memoryOperationInterface->getResidencySet(); - for (const auto &alloc : allTimeResidentAllocs) { - const auto drmAlloc = static_cast(alloc); - makeResidentBufferObjects(drmAlloc, handleId); - } } template diff --git a/opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h b/opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h index 42d62f6f7c..8cfc1a2077 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h +++ b/opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h @@ -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(); executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock); - executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique(); auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo(); osContext = std::make_unique(*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(); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setDrm(mock); - executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique(); csr = new TestedDrmCommandStreamReceiver(*executionEnvironment, rootDeviceIndex); ASSERT_NE(nullptr, csr); diff --git a/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp index 889eb445fe..daedc9ba0a 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp @@ -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(&allocation, 1)); - - csr->processResidency(csr->getResidencyAllocations(), 0u); - - EXPECT_TRUE(isResident(static_cast(allocation)->getBO())); - - mm->freeGraphicsMemory(allocation); -} - HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenTwoAllocationsWhenBackingStorageIsDifferentThenMakeResidentShouldAddTwoLocations) { auto allocation = static_cast(mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize})); auto allocation2 = static_cast(mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize})); diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h index ec691c5602..3e44159617 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h @@ -61,7 +61,6 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture { auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[i].get(); rootDeviceEnvironment->osInterface = std::make_unique(); rootDeviceEnvironment->osInterface->get()->setDrm(new DrmMockCustom()); - rootDeviceEnvironment->memoryOperationsInterface = std::make_unique(); } rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex].get(); diff --git a/opencl/test/unit_test/os_interface/linux/drm_residency_handler_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_residency_handler_tests.cpp index 3a6e4e3e8a..6ba6e5af17 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_residency_handler_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_residency_handler_tests.cpp @@ -27,19 +27,12 @@ struct DrmMemoryOperationsHandlerTest : public ::testing::Test { }; TEST_F(DrmMemoryOperationsHandlerTest, whenMakingResidentAllocaionExpectMakeResidentFail) { - EXPECT_EQ(drmMemoryOperationsHandler->makeResident(ArrayRef(&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(&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(&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(&allocationPtr, 1)), MemoryOperationsStatus::UNSUPPORTED); + EXPECT_EQ(drmMemoryOperationsHandler->evict(graphicsAllocation), MemoryOperationsStatus::UNSUPPORTED); + EXPECT_EQ(drmMemoryOperationsHandler->isResident(graphicsAllocation), MemoryOperationsStatus::UNSUPPORTED); } diff --git a/opencl/test/unit_test/os_interface/linux/linux_create_command_queue_with_properties_tests.cpp b/opencl/test/unit_test/os_interface/linux/linux_create_command_queue_with_properties_tests.cpp index bb560826f8..5c8f593746 100644 --- a/opencl/test/unit_test/os_interface/linux/linux_create_command_queue_with_properties_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/linux_create_command_queue_with_properties_tests.cpp @@ -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(); executionEnvironment->memoryManager.reset(new TestedDrmMemoryManager(*executionEnvironment)); mdevice = std::make_unique(MockDevice::create(executionEnvironment, rootDeviceIndex)); diff --git a/shared/source/os_interface/linux/drm_memory_operations_handler.cpp b/shared/source/os_interface/linux/drm_memory_operations_handler.cpp index b28b5c8717..8084dd5a9d 100644 --- a/shared/source/os_interface/linux/drm_memory_operations_handler.cpp +++ b/shared/source/os_interface/linux/drm_memory_operations_handler.cpp @@ -9,32 +9,19 @@ namespace NEO { -DrmMemoryOperationsHandler::DrmMemoryOperationsHandler() = default; -DrmMemoryOperationsHandler::~DrmMemoryOperationsHandler() = default; +DrmMemoryOperationsHandler::DrmMemoryOperationsHandler() { +} MemoryOperationsStatus DrmMemoryOperationsHandler::makeResident(ArrayRef gfxAllocations) { - std::lock_guard lock(mutex); - this->residency.insert(gfxAllocations.begin(), gfxAllocations.end()); - return MemoryOperationsStatus::SUCCESS; + return MemoryOperationsStatus::UNSUPPORTED; } MemoryOperationsStatus DrmMemoryOperationsHandler::evict(GraphicsAllocation &gfxAllocation) { - std::lock_guard lock(mutex); - this->residency.erase(&gfxAllocation); - return MemoryOperationsStatus::SUCCESS; + return MemoryOperationsStatus::UNSUPPORTED; } MemoryOperationsStatus DrmMemoryOperationsHandler::isResident(GraphicsAllocation &gfxAllocation) { - std::lock_guard 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 DrmMemoryOperationsHandler::getResidencySet() { - std::lock_guard lock(mutex); - return this->residency; -} } // namespace NEO diff --git a/shared/source/os_interface/linux/drm_memory_operations_handler.h b/shared/source/os_interface/linux/drm_memory_operations_handler.h index e943011d61..bde6dfdcee 100644 --- a/shared/source/os_interface/linux/drm_memory_operations_handler.h +++ b/shared/source/os_interface/linux/drm_memory_operations_handler.h @@ -8,23 +8,15 @@ #pragma once #include "shared/source/memory_manager/memory_operations_handler.h" -#include -#include - namespace NEO { + class DrmMemoryOperationsHandler : public MemoryOperationsHandler { public: DrmMemoryOperationsHandler(); - ~DrmMemoryOperationsHandler() override; + ~DrmMemoryOperationsHandler() override = default; MemoryOperationsStatus makeResident(ArrayRef gfxAllocations) override; MemoryOperationsStatus evict(GraphicsAllocation &gfxAllocation) override; MemoryOperationsStatus isResident(GraphicsAllocation &gfxAllocation) override; - - std::unordered_set getResidencySet(); - - protected: - std::unordered_set residency; - std::mutex mutex; }; } // namespace NEO