From a552d1fd65cf8dd7f5f0909140c397148046f55e Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Wed, 12 May 2021 11:24:10 +0000 Subject: [PATCH] Revert "Mark SVM_GPU allocation as not lockable" Signed-off-by: Mateusz Jablonski --- .../aub_command_stream_fixture.cpp | 9 +++-- .../aub_tests/fixtures/aub_fixture.h | 35 ++++--------------- .../unit_test/helpers/hw_helper_tests.cpp | 34 +----------------- .../graphics_allocation_tests.cpp | 4 +-- shared/source/device/device.cpp | 14 +++----- shared/source/device/device.h | 1 - shared/source/helpers/hw_helper_base.inl | 3 +- .../memory_manager/graphics_allocation.h | 1 + 8 files changed, 23 insertions(+), 78 deletions(-) diff --git a/opencl/test/unit_test/aub_tests/command_stream/aub_command_stream_fixture.cpp b/opencl/test/unit_test/aub_tests/command_stream/aub_command_stream_fixture.cpp index b96c3731bb..ce3a4c72d3 100644 --- a/opencl/test/unit_test/aub_tests/command_stream/aub_command_stream_fixture.cpp +++ b/opencl/test/unit_test/aub_tests/command_stream/aub_command_stream_fixture.cpp @@ -18,7 +18,6 @@ #include "opencl/source/command_queue/command_queue.h" #include "opencl/source/command_stream/tbx_command_stream_receiver.h" -#include "opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h" #include "gtest/gtest.h" @@ -35,10 +34,14 @@ void AUBCommandStreamFixture::SetUp(CommandQueue *pCmdQ) { auto engineType = pCmdQ->getGpgpuCommandStreamReceiver().getOsContext().getEngineType(); strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_" << hwHelper.getCsTraits(engineType).name; - pCommandStreamReceiver = AUBFixture::prepareComputeEngine(device, strfilename.str()); + if (testMode == TestMode::AubTestsWithTbx) { + pCommandStreamReceiver = TbxCommandStreamReceiver::create(strfilename.str(), true, *device.executionEnvironment, device.getRootDeviceIndex(), device.getDeviceBitfield()); + } else { + pCommandStreamReceiver = AUBCommandStreamReceiver::create(strfilename.str(), true, *device.executionEnvironment, device.getRootDeviceIndex(), device.getDeviceBitfield()); + } ASSERT_NE(nullptr, pCommandStreamReceiver); - AUBFixture::prepareCopyEngines(device, strfilename.str()); + device.resetCommandStreamReceiver(pCommandStreamReceiver); CommandStreamFixture::SetUp(pCmdQ); diff --git a/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h b/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h index 8a6f001bb6..9795f8616f 100644 --- a/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h +++ b/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h @@ -30,30 +30,6 @@ namespace NEO { class AUBFixture : public CommandQueueHwFixture { public: - static CommandStreamReceiver *prepareComputeEngine(MockDevice &device, const std::string &filename) { - CommandStreamReceiver *pCommandStreamReceiver = nullptr; - if (testMode == TestMode::AubTestsWithTbx) { - pCommandStreamReceiver = TbxCommandStreamReceiver::create(filename, true, *device.executionEnvironment, device.getRootDeviceIndex(), device.getDeviceBitfield()); - } else { - pCommandStreamReceiver = AUBCommandStreamReceiver::create(filename, true, *device.executionEnvironment, device.getRootDeviceIndex(), device.getDeviceBitfield()); - } - device.resetCommandStreamReceiver(pCommandStreamReceiver); - return pCommandStreamReceiver; - } - static void prepareCopyEngines(MockDevice &device, const std::string &filename) { - for (auto i = 0u; i < device.engines.size(); i++) { - if (EngineHelpers::isBcs(device.engines[i].getEngineType())) { - CommandStreamReceiver *pBcsCommandStreamReceiver = nullptr; - if (testMode == TestMode::AubTestsWithTbx) { - pBcsCommandStreamReceiver = TbxCommandStreamReceiver::create(filename, true, *device.executionEnvironment, device.getRootDeviceIndex(), device.getDeviceBitfield()); - } else { - pBcsCommandStreamReceiver = AUBCommandStreamReceiver::create(filename, true, *device.executionEnvironment, device.getRootDeviceIndex(), device.getDeviceBitfield()); - } - device.resetCommandStreamReceiver(pBcsCommandStreamReceiver, i); - } - } - } - void SetUp(const HardwareInfo *hardwareInfo) { const HardwareInfo &hwInfo = hardwareInfo ? *hardwareInfo : *defaultHwInfo; @@ -69,12 +45,15 @@ class AUBFixture : public CommandQueueHwFixture { executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hwInfo); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique(); - auto pDevice = MockDevice::create(executionEnvironment, rootDeviceIndex); - device = std::make_unique(pDevice); + device = std::make_unique(MockDevice::create(executionEnvironment, rootDeviceIndex)); - this->csr = prepareComputeEngine(*pDevice, strfilename.str()); + if (testMode == TestMode::AubTestsWithTbx) { + this->csr = TbxCommandStreamReceiver::create(strfilename.str(), true, *executionEnvironment, 0, device->getDeviceBitfield()); + } else { + this->csr = AUBCommandStreamReceiver::create(strfilename.str(), true, *executionEnvironment, 0, device->getDeviceBitfield()); + } - prepareCopyEngines(*pDevice, strfilename.str()); + device->resetCommandStreamReceiver(this->csr); CommandQueueHwFixture::SetUp(AUBFixture::device.get(), cl_command_queue_properties(0)); } diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index 6ddf599438..48789a0f90 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -937,15 +937,13 @@ HWTEST_F(HwHelperTest, givenDefaultHwHelperHwWhenMinimalSIMDSizeIsQueriedThen8Is EXPECT_EQ(8u, helper.getMinimalSIMDSize()); } -HWTEST_F(HwHelperTest, givenLockableAllocationWhenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectValuesAreReturned) { +HWTEST_F(HwHelperTest, whenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectValuesAreReturned) { DebugManagerStateRestore restore{}; auto &helper = HwHelper::get(renderCoreFamily); HardwareInfo hwInfo = *defaultHwInfo; hwInfo.capabilityTable.blitterOperationsSupported = true; MockGraphicsAllocation graphicsAllocation; - graphicsAllocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); - EXPECT_TRUE(GraphicsAllocation::isLockable(graphicsAllocation.getAllocationType())); graphicsAllocation.overrideMemoryPool(MemoryPool::LocalMemory); auto expectedDefaultValue = (helper.getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed); @@ -959,36 +957,7 @@ HWTEST_F(HwHelperTest, givenLockableAllocationWhenGettingIsBlitCopyRequiredForLo DebugManager.flags.ForceLocalMemoryAccessMode.set(3); EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); hwInfo.capabilityTable.blitterOperationsSupported = false; - EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); - - graphicsAllocation.overrideMemoryPool(MemoryPool::System64KBPages); EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); - hwInfo.capabilityTable.blitterOperationsSupported = true; - EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); -} - -HWTEST_F(HwHelperTest, givenNotLockableAllocationWhenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectValuesAreReturned) { - DebugManagerStateRestore restore{}; - auto &helper = HwHelper::get(renderCoreFamily); - HardwareInfo hwInfo = *defaultHwInfo; - hwInfo.capabilityTable.blitterOperationsSupported = true; - - MockGraphicsAllocation graphicsAllocation; - graphicsAllocation.setAllocationType(GraphicsAllocation::AllocationType::SVM_GPU); - EXPECT_FALSE(GraphicsAllocation::isLockable(graphicsAllocation.getAllocationType())); - graphicsAllocation.overrideMemoryPool(MemoryPool::LocalMemory); - - EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); - - DebugManager.flags.ForceLocalMemoryAccessMode.set(0); - EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); - DebugManager.flags.ForceLocalMemoryAccessMode.set(1); - EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); - - DebugManager.flags.ForceLocalMemoryAccessMode.set(3); - EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); - hwInfo.capabilityTable.blitterOperationsSupported = false; - EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); graphicsAllocation.overrideMemoryPool(MemoryPool::System64KBPages); EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); @@ -1030,7 +999,6 @@ HWTEST2_F(HwHelperTest, givenDefaultHwHelperHwWhenGettingIsBlitCopyRequiredForLo auto &helper = HwHelper::get(renderCoreFamily); MockGraphicsAllocation graphicsAllocation; graphicsAllocation.overrideMemoryPool(MemoryPool::LocalMemory); - graphicsAllocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(*defaultHwInfo, graphicsAllocation)); } diff --git a/opencl/test/unit_test/memory_manager/graphics_allocation_tests.cpp b/opencl/test/unit_test/memory_manager/graphics_allocation_tests.cpp index 9c1d4f1ea9..ecbe361f16 100644 --- a/opencl/test/unit_test/memory_manager/graphics_allocation_tests.cpp +++ b/opencl/test/unit_test/memory_manager/graphics_allocation_tests.cpp @@ -179,8 +179,8 @@ TEST(GraphicsAllocationTest, whenAllocationTypeIsGpuTimestampDeviceBufferThenAll EXPECT_TRUE(GraphicsAllocation::isLockable(GraphicsAllocation::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER)); } -TEST(GraphicsAllocationTest, whenAllocationTypeIsSvmGpuThenAllocationIsNotLockable) { - EXPECT_FALSE(GraphicsAllocation::isLockable(GraphicsAllocation::AllocationType::SVM_GPU)); +TEST(GraphicsAllocationTest, whenAllocationTypeIsSvmGpuThenAllocationIsLockable) { + EXPECT_TRUE(GraphicsAllocation::isLockable(GraphicsAllocation::AllocationType::SVM_GPU)); } TEST(GraphicsAllocationTest, whenAllocationTypeIsSharedResourceCopyThenAllocationIsLockable) { diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index aaf5fb25ad..ea1aae5698 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -439,24 +439,18 @@ size_t Device::getIndexOfNonEmptyEngineGroup(EngineGroupType engineGroupType) co return result; } -EngineControl *Device::tryGetEngine(aub_stream::EngineType engineType, EngineUsage engineUsage) { +EngineControl &Device::getEngine(aub_stream::EngineType engineType, EngineUsage engineUsage) { for (auto &engine : engines) { if (engine.osContext->getEngineType() == engineType && engine.osContext->isLowPriority() == (engineUsage == EngineUsage::LowPriority) && engine.osContext->isInternalEngine() == (engineUsage == EngineUsage::Internal)) { - return &engine; + return engine; } } if (DebugManager.flags.OverrideInvalidEngineWithDefault.get()) { - return &engines[0]; + return engines[0]; } - return nullptr; -} - -EngineControl &Device::getEngine(aub_stream::EngineType engineType, EngineUsage engineUsage) { - auto engine = tryGetEngine(engineType, engineUsage); - UNRECOVERABLE_IF(!engine); - return *engine; + UNRECOVERABLE_IF(true); } EngineControl &Device::getEngine(uint32_t index) { diff --git a/shared/source/device/device.h b/shared/source/device/device.h index c51447d553..a4691a1fa1 100644 --- a/shared/source/device/device.h +++ b/shared/source/device/device.h @@ -49,7 +49,6 @@ class Device : public ReferenceTrackedObject { bool getHostTimer(uint64_t *hostTimestamp) const; const HardwareInfo &getHardwareInfo() const; const DeviceInfo &getDeviceInfo() const; - EngineControl *tryGetEngine(aub_stream::EngineType engineType, EngineUsage engineUsage); EngineControl &getEngine(aub_stream::EngineType engineType, EngineUsage engineUsage); std::vector> &getEngineGroups() { return this->engineGroups; diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index 735cc6a1fa..d641ac75c2 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -452,7 +452,8 @@ inline bool HwHelperHw::allowRenderCompression(const HardwareInfo &hw template inline bool HwHelperHw::isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const { return allocation.isAllocatedInLocalMemoryPool() && - (getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed || !GraphicsAllocation::isLockable(allocation.getAllocationType())); + (getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed) && + hwInfo.capabilityTable.blitterOperationsSupported; } template diff --git a/shared/source/memory_manager/graphics_allocation.h b/shared/source/memory_manager/graphics_allocation.h index 34b0c99cfe..0c6aa6c272 100644 --- a/shared/source/memory_manager/graphics_allocation.h +++ b/shared/source/memory_manager/graphics_allocation.h @@ -236,6 +236,7 @@ class GraphicsAllocation : public IDNode { isIsaAllocationType(allocationType) || allocationType == AllocationType::BUFFER_HOST_MEMORY || allocationType == AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER || + allocationType == AllocationType::SVM_GPU || allocationType == AllocationType::SHARED_RESOURCE_COPY; }