From 593b3cf4fd88b1427f641964f902642f56a8936e Mon Sep 17 00:00:00 2001 From: Michal Mrozek Date: Tue, 14 Mar 2023 18:37:38 +0000 Subject: [PATCH] Revert "[performance] do not perform migrations if not needed." Signed-off-by: Michal Mrozek --- .../source/cmdlist/cmdlist_hw_immediate.inl | 21 +++++++------------ .../sources/context/test_context.cpp | 4 ---- .../cpu_page_fault_manager.h | 2 +- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl index b0b9a12d57..2487efd281 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl @@ -222,19 +222,6 @@ inline ze_result_t CommandListCoreFamilyImmediate::executeCommand auto csr = static_cast(cmdQ)->getCsr(); auto lockCSR = csr->obtainUniqueOwnership(); - if (performMigration) { - auto deviceImp = static_cast(this->device); - auto pageFaultManager = deviceImp->getDriverHandle()->getMemoryManager()->getPageFaultManager(); - if (pageFaultManager == nullptr) { - performMigration = false; - } else { - auto ownershipForPageFaultManager = pageFaultManager->obtainUniqueOwnership(); - if (this->device->getDriverHandle()->getSvmAllocsManager()->nonGpuDomainAllocs.size() == 0u) { - performMigration = false; - } - } - } - if (cmdQ->getClientId() == CommandQueue::clientNotRegistered) { cmdQ->setClientId(csr->registerClient()); } @@ -244,6 +231,14 @@ inline ze_result_t CommandListCoreFamilyImmediate::executeCommand cmdQ->handleIndirectAllocationResidency(this->getUnifiedMemoryControls(), lockForIndirect, performMigration); } + if (performMigration) { + auto deviceImp = static_cast(this->device); + auto pageFaultManager = deviceImp->getDriverHandle()->getMemoryManager()->getPageFaultManager(); + if (pageFaultManager == nullptr) { + performMigration = false; + } + } + cmdQ->makeResidentAndMigrate(performMigration, this->commandContainer.getResidencyContainer()); static_cast *>(this->cmdQImmediate)->patchCommands(*this, 0u); diff --git a/level_zero/core/test/unit_tests/sources/context/test_context.cpp b/level_zero/core/test/unit_tests/sources/context/test_context.cpp index 6520793697..9315a5de49 100644 --- a/level_zero/core/test/unit_tests/sources/context/test_context.cpp +++ b/level_zero/core/test/unit_tests/sources/context/test_context.cpp @@ -776,8 +776,6 @@ HWTEST_F(ContextMakeMemoryResidentAndMigrationTests, result = context->allocSharedMem(device->toHandle(), &deviceDesc, &hostDesc, 16384u, 4090u, &dstBuffer); ASSERT_EQ(ZE_RESULT_SUCCESS, result); - device->getDriverHandle()->getSvmAllocsManager()->nonGpuDomainAllocs.push_back(dstBuffer); - int one = 1; result = commandList0->appendMemoryFill(dstBuffer, reinterpret_cast(&one), sizeof(one), 4090u, nullptr, 0, nullptr, false); @@ -835,8 +833,6 @@ HWTEST_F(ContextMakeMemoryResidentAndMigrationTests, auto sharedPtr = svmManager->createSharedUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, device); EXPECT_NE(nullptr, sharedPtr); - device->getDriverHandle()->getSvmAllocsManager()->nonGpuDomainAllocs.push_back(sharedPtr); - auto allocation = svmManager->getSVMAlloc(sharedPtr); auto gpuAllocation = allocation->gpuAllocations.getGraphicsAllocation(mockRootDeviceIndex); diff --git a/shared/source/page_fault_manager/cpu_page_fault_manager.h b/shared/source/page_fault_manager/cpu_page_fault_manager.h index f2a8d77404..831e8226c2 100644 --- a/shared/source/page_fault_manager/cpu_page_fault_manager.h +++ b/shared/source/page_fault_manager/cpu_page_fault_manager.h @@ -44,7 +44,7 @@ class PageFaultManager : public NonCopyableOrMovableClass { }; typedef void (*gpuDomainHandlerFunc)(PageFaultManager *pageFaultHandler, void *alloc, PageFaultData &pageFaultData); - [[nodiscard]] std::unique_lock obtainUniqueOwnership() { return std::unique_lock(this->mtx); } + void setGpuDomainHandler(gpuDomainHandlerFunc gpuHandlerFuncPtr); virtual void allowCPUMemoryAccess(void *ptr, size_t size) = 0;