From ebf09afc42e75bcb69dce83847e16d4648dcaf18 Mon Sep 17 00:00:00 2001 From: Compute-Runtime-Validation Date: Sat, 11 May 2024 04:39:38 +0200 Subject: [PATCH] Revert "performance: Stop direct submission before removing host ptrs" This reverts commit 4fd219cdbbd7ea239da4a497becb2132dfb8253f. Signed-off-by: Compute-Runtime-Validation --- level_zero/core/source/cmdlist/cmdlist.cpp | 17 --------- .../sources/cmdlist/test_cmdlist_3.cpp | 35 ------------------- .../command_stream/command_stream_receiver.h | 3 -- .../internal_allocation_storage.cpp | 9 ----- .../windows/wddm_device_command_stream.h | 3 -- .../windows/wddm_device_command_stream.inl | 14 -------- .../libult/ult_command_stream_receiver.h | 10 ------ .../internal_allocation_storage_tests.cpp | 17 --------- .../windows/device_command_stream_tests.cpp | 23 ------------ 9 files changed, 131 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist.cpp b/level_zero/core/source/cmdlist/cmdlist.cpp index 1897070be4..37b44368cc 100644 --- a/level_zero/core/source/cmdlist/cmdlist.cpp +++ b/level_zero/core/source/cmdlist/cmdlist.cpp @@ -49,27 +49,10 @@ void CommandList::storePrintfKernel(Kernel *kernel) { void CommandList::removeHostPtrAllocations() { auto memoryManager = device ? device->getNEODevice()->getMemoryManager() : nullptr; - - bool restartDirectSubmission = !this->hostPtrMap.empty() && memoryManager; - if (restartDirectSubmission) { - const auto &engines = memoryManager->getRegisteredEngines(device->getRootDeviceIndex()); - for (const auto &engine : engines) { - engine.commandStreamReceiver->stopDirectSubmissionForHostptrDestroy(); - } - } - for (auto &allocation : hostPtrMap) { UNRECOVERABLE_IF(memoryManager == nullptr); memoryManager->freeGraphicsMemory(allocation.second); } - - if (restartDirectSubmission) { - const auto &engines = memoryManager->getRegisteredEngines(device->getRootDeviceIndex()); - for (const auto &engine : engines) { - engine.commandStreamReceiver->startDirectSubmissionForHostptrDestroy(); - } - } - hostPtrMap.clear(); } diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_3.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_3.cpp index 11da9b8ea4..68bd939810 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_3.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_3.cpp @@ -314,41 +314,6 @@ HWTEST2_F(CommandListCreate, device->getNEODevice()->getMemoryManager()->freeSystemMemory(cmdListHostBuffer); } -HWTEST2_F(CommandListCreate, - givenCmdListHostPointerUsedWhenRemoveHostPtrAllocationThenStopDirectSubmissions, - IsAtLeastSkl) { - const auto &engines = device->getNEODevice()->getMemoryManager()->getRegisteredEngines(device->getRootDeviceIndex()); - for (const auto &engine : engines) { - auto ultCsr = static_cast *>(engine.commandStreamReceiver); - ultCsr->directSubmissionAvailable = true; - } - - auto commandList = std::make_unique<::L0::ult::CommandListCoreFamily>(); - commandList->initialize(device, NEO::EngineGroupType::renderCompute, 0u); - - size_t cmdListHostPtrSize = MemoryConstants::pageSize; - void *cmdListHostBuffer = device->getNEODevice()->getMemoryManager()->allocateSystemMemory(cmdListHostPtrSize, cmdListHostPtrSize); - - AlignedAllocationData outData = commandList->getAlignedAllocationData(device, cmdListHostBuffer, cmdListHostPtrSize, false); - ASSERT_NE(nullptr, outData.alloc); - - for (const auto &engine : engines) { - auto ultCsr = static_cast *>(engine.commandStreamReceiver); - EXPECT_FALSE(ultCsr->stopDirectSubmissionForHostptrDestroyCalled); - EXPECT_FALSE(ultCsr->startDirectSubmissionForHostptrDestroyCalled); - } - - commandList->removeHostPtrAllocations(); - - for (const auto &engine : engines) { - auto ultCsr = static_cast *>(engine.commandStreamReceiver); - EXPECT_TRUE(ultCsr->stopDirectSubmissionForHostptrDestroyCalled); - EXPECT_TRUE(ultCsr->startDirectSubmissionForHostptrDestroyCalled); - } - - device->getNEODevice()->getMemoryManager()->freeSystemMemory(cmdListHostBuffer); -} - using PlatformSupport = IsWithinProducts; HWTEST2_F(CommandListCreate, givenCommandListWhenMemoryCopyRegionHavingHostMemoryWithSignalAndWaitScopeEventsUsingRenderEngineThenPipeControlsWithDcFlushIsFound, diff --git a/shared/source/command_stream/command_stream_receiver.h b/shared/source/command_stream/command_stream_receiver.h index 86e1abc11f..34159f8a8c 100644 --- a/shared/source/command_stream/command_stream_receiver.h +++ b/shared/source/command_stream/command_stream_receiver.h @@ -359,9 +359,6 @@ class CommandStreamReceiver { virtual void stopDirectSubmission(bool blocking) {} - virtual void stopDirectSubmissionForHostptrDestroy() {} - virtual void startDirectSubmissionForHostptrDestroy() {} - virtual QueueThrottle getLastDirectSubmissionThrottle() = 0; bool isStaticWorkPartitioningEnabled() const { diff --git a/shared/source/memory_manager/internal_allocation_storage.cpp b/shared/source/memory_manager/internal_allocation_storage.cpp index f848c6335a..33dac03c0b 100644 --- a/shared/source/memory_manager/internal_allocation_storage.cpp +++ b/shared/source/memory_manager/internal_allocation_storage.cpp @@ -39,16 +39,7 @@ void InternalAllocationStorage::storeAllocationWithTaskCount(std::unique_ptrcommandStreamReceiver.stopDirectSubmissionForHostptrDestroy(); - } - freeAllocationsList(waitTaskCount, allocationLists[allocationUsage]); - - if (restartDirectSubmission) { - this->commandStreamReceiver.startDirectSubmissionForHostptrDestroy(); - } } void InternalAllocationStorage::freeAllocationsList(TaskCountType waitTaskCount, AllocationsList &allocationsList) { diff --git a/shared/source/os_interface/windows/wddm_device_command_stream.h b/shared/source/os_interface/windows/wddm_device_command_stream.h index 4fe5afbfaa..3b6138f02a 100644 --- a/shared/source/os_interface/windows/wddm_device_command_stream.h +++ b/shared/source/os_interface/windows/wddm_device_command_stream.h @@ -31,9 +31,6 @@ class WddmCommandStreamReceiver : public DeviceCommandStreamReceiver bool waitForFlushStamp(FlushStamp &flushStampToWait) override; bool isTlbFlushRequiredForStateCacheFlush() override; - void stopDirectSubmissionForHostptrDestroy() override; - void startDirectSubmissionForHostptrDestroy() override; - WddmMemoryManager *getMemoryManager() const; Wddm *peekWddm() const { return wddm; diff --git a/shared/source/os_interface/windows/wddm_device_command_stream.inl b/shared/source/os_interface/windows/wddm_device_command_stream.inl index 92179fb9e8..b2fdab693f 100644 --- a/shared/source/os_interface/windows/wddm_device_command_stream.inl +++ b/shared/source/os_interface/windows/wddm_device_command_stream.inl @@ -157,20 +157,6 @@ bool WddmCommandStreamReceiver::waitForFlushStamp(FlushStamp &flushSt return wddm->waitFromCpu(flushStampToWait, static_cast(this->osContext)->getResidencyController().getMonitoredFence(), false); } -template -void WddmCommandStreamReceiver::stopDirectSubmissionForHostptrDestroy() { - auto lock = this->obtainUniqueOwnership(); - this->stopDirectSubmission(false); -} - -template -void WddmCommandStreamReceiver::startDirectSubmissionForHostptrDestroy() { - if (this->isAnyDirectSubmissionEnabled()) { - auto lock = this->obtainUniqueOwnership(); - this->flushTagUpdate(); - } -} - template bool WddmCommandStreamReceiver::isTlbFlushRequiredForStateCacheFlush() { return true; diff --git a/shared/test/common/libult/ult_command_stream_receiver.h b/shared/test/common/libult/ult_command_stream_receiver.h index e1a2fa0729..38a9dc0d88 100644 --- a/shared/test/common/libult/ult_command_stream_receiver.h +++ b/shared/test/common/libult/ult_command_stream_receiver.h @@ -458,14 +458,6 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw, publ return *flushReturnValue; } - void stopDirectSubmissionForHostptrDestroy() override { - stopDirectSubmissionForHostptrDestroyCalled = true; - } - - void startDirectSubmissionForHostptrDestroy() override { - startDirectSubmissionForHostptrDestroyCalled = true; - } - void stopDirectSubmission(bool blocking) override { stopDirectSubmissionCalled = true; stopDirectSubmissionCalledBlocking = blocking; @@ -551,8 +543,6 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw, publ bool isKmdWaitOnTaskCountAllowedValue = false; bool stopDirectSubmissionCalled = false; bool stopDirectSubmissionCalledBlocking = false; - std::atomic_bool stopDirectSubmissionForHostptrDestroyCalled = false; - std::atomic_bool startDirectSubmissionForHostptrDestroyCalled = false; }; } // namespace NEO diff --git a/shared/test/unit_test/memory_manager/internal_allocation_storage_tests.cpp b/shared/test/unit_test/memory_manager/internal_allocation_storage_tests.cpp index ebe9c43e00..a0e70232fa 100644 --- a/shared/test/unit_test/memory_manager/internal_allocation_storage_tests.cpp +++ b/shared/test/unit_test/memory_manager/internal_allocation_storage_tests.cpp @@ -278,23 +278,6 @@ TEST_F(InternalAllocationStorageTest, givenAllocationListWhenTwoThreadsCleanConc EXPECT_TRUE(csr->getTemporaryAllocations().peekIsEmpty()); } -HWTEST_F(InternalAllocationStorageTest, givenDirectSubmissionAvailableWhenCleanInternalStorageThenRestartDirectSubmission) { - auto ultCsr = reinterpret_cast *>(csr); - ultCsr->directSubmissionAvailable = true; - - auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}); - allocation->updateTaskCount(10, csr->getOsContext().getContextId()); - storage->storeAllocation(std::unique_ptr(allocation), TEMPORARY_ALLOCATION); - - EXPECT_FALSE(ultCsr->stopDirectSubmissionForHostptrDestroyCalled); - EXPECT_FALSE(ultCsr->startDirectSubmissionForHostptrDestroyCalled); - - storage->cleanAllocationList(-1, TEMPORARY_ALLOCATION); - - EXPECT_TRUE(ultCsr->stopDirectSubmissionForHostptrDestroyCalled); - EXPECT_TRUE(ultCsr->startDirectSubmissionForHostptrDestroyCalled); -} - HWTEST_F(InternalAllocationStorageTest, givenMultipleActivePartitionsWhenDetachingReusableAllocationThenCheckTaskCountFinishedOnAllTiles) { auto ultCsr = reinterpret_cast *>(csr); csr->setActivePartitions(2u); diff --git a/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp b/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp index 4bda723410..ff8937f90d 100644 --- a/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp @@ -1151,29 +1151,6 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenCsrWhenFlushMonitorFenceTh EXPECT_EQ(directSubmission->flushMonitorFenceCalled, 1u); } -HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionWhenRestartForHostPtrThenRingIsRestarted) { - using MockSubmission = MockWddmDrmDirectSubmissionDispatchCommandBuffer; - auto mockCsr = static_cast *>(csr); - - debugManager.flags.EnableDirectSubmission.set(1); - - auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); - hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = true; - - mockCsr->callParentInitDirectSubmission = false; - csr->initDirectSubmission(); - - mockCsr->directSubmission = std::make_unique(*device->getDefaultEngine().commandStreamReceiver); - auto directSubmission = reinterpret_cast(mockCsr->directSubmission.get()); - EXPECT_FALSE(directSubmission->ringStart); - - csr->stopDirectSubmissionForHostptrDestroy(); - EXPECT_FALSE(directSubmission->ringStart); - - csr->startDirectSubmissionForHostptrDestroy(); - EXPECT_TRUE(directSubmission->dispatchCommandBufferCalled); -} - HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenLastSubmittedFenceLowerThanFenceValueToWaitWhenWaitFromCpuThenFlushMonitorFence) { using MockSubmission = MockWddmDrmDirectSubmissionDispatchCommandBuffer; auto mockCsr = static_cast *>(csr);