refactor: Add key to not register pagefault handler on migration

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2024-05-28 07:40:24 +00:00
committed by Compute-Runtime-Automation
parent 9d312995e2
commit 8217b76cef
4 changed files with 33 additions and 2 deletions

View File

@ -426,6 +426,7 @@ DECLARE_DEBUG_VARIABLE(bool, DirectSubmissionPrintBuffers, false, "Print address
/*FEATURE FLAGS*/
DECLARE_DEBUG_VARIABLE(bool, USMEvictAfterMigration, false, "Evict USM allocation after implicit migration to GPU")
DECLARE_DEBUG_VARIABLE(bool, RegisterPageFaultHandlerOnMigration, true, "Register handler on migration to GPU when current is not from pagefault manager")
DECLARE_DEBUG_VARIABLE(bool, EnableNV12, true, "Enables NV12 extension")
DECLARE_DEBUG_VARIABLE(bool, EnablePackedYuv, true, "Enables cl_packed_yuv extension")
DECLARE_DEBUG_VARIABLE(bool, EnableDeferredDeleter, true, "Enables async deleter")

View File

@ -77,9 +77,12 @@ inline void PageFaultManager::migrateStorageToGpuDomain(void *ptr, PageFaultData
std::chrono::steady_clock::time_point start;
std::chrono::steady_clock::time_point end;
if (this->checkFaultHandlerFromPageFaultManager() == false) {
this->registerFaultHandler();
if (debugManager.flags.RegisterPageFaultHandlerOnMigration.get()) {
if (this->checkFaultHandlerFromPageFaultManager() == false) {
this->registerFaultHandler();
}
}
start = std::chrono::steady_clock::now();
this->transferToGpu(ptr, pageFaultData.cmdQ);
end = std::chrono::steady_clock::now();

View File

@ -26,6 +26,7 @@ SetCommandStreamReceiver = -1
TbxPort = 4321
TbxFrontdoorMode = 0
FlattenBatchBufferForAUBDump = 0
RegisterPageFaultHandlerOnMigration = 1
AddPatchInfoCommentsForAUBDump = 0
UseAubStream = 1
AUBDumpAllocsOnEnqueueReadOnly = 0

View File

@ -289,6 +289,32 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocWhenMoveToGpuDomainTwiceThen
EXPECT_TRUE(pageFaultManager->checkFaultHandlerFromPageFaultManager());
}
TEST_F(PageFaultManagerTest, givenRegisterPageFaultHandlerOnMigrationDisabledWhenMoveToGpuDomainThenDoNotRegisterHandler) {
DebugManagerStateRestore restorer;
debugManager.flags.RegisterPageFaultHandlerOnMigration.set(false);
void *cmdQ = reinterpret_cast<void *>(0xFFFF);
void *alloc1 = reinterpret_cast<void *>(0x1);
pageFaultManager->insertAllocation(alloc1, 10u, unifiedMemoryManager.get(), cmdQ, {});
EXPECT_EQ(pageFaultManager->memoryData.size(), 1u);
EXPECT_EQ(pageFaultManager->transferToCpuCalled, 0);
EXPECT_FALSE(pageFaultManager->checkFaultHandlerFromPageFaultManager());
pageFaultManager->moveAllocationToGpuDomain(alloc1);
EXPECT_EQ(pageFaultManager->allowMemoryAccessCalled, 0);
EXPECT_EQ(pageFaultManager->protectMemoryCalled, 1);
EXPECT_EQ(pageFaultManager->transferToCpuCalled, 0);
EXPECT_EQ(pageFaultManager->transferToGpuCalled, 1);
EXPECT_EQ(pageFaultManager->registerFaultHandlerCalled, 0);
EXPECT_EQ(pageFaultManager->protectedMemoryAccessAddress, alloc1);
EXPECT_EQ(pageFaultManager->protectedSize, 10u);
EXPECT_EQ(pageFaultManager->transferToGpuAddress, alloc1);
EXPECT_FALSE(pageFaultManager->checkFaultHandlerFromPageFaultManager());
}
TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocWhenMovingToGpuDomainThenUpdateNonGpuAllocsContainer) {
void *alloc1 = reinterpret_cast<void *>(0x1);
void *alloc2 = reinterpret_cast<void *>(0x2);