[performance] do not perform migrations if not needed.

Skip migrations if nothing is migrated to the CPU side.

Related-To: NEO-5170
Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek
2023-02-17 17:02:39 +00:00
committed by Compute-Runtime-Automation
parent bd8b85c354
commit 15f08a92c0
3 changed files with 18 additions and 9 deletions

View File

@@ -208,6 +208,19 @@ inline ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::executeCommand
auto csr = static_cast<CommandQueueImp *>(cmdQ)->getCsr();
auto lockCSR = csr->obtainUniqueOwnership();
if (performMigration) {
auto deviceImp = static_cast<DeviceImp *>(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());
}
@@ -217,14 +230,6 @@ inline ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::executeCommand
cmdQ->handleIndirectAllocationResidency(this->getUnifiedMemoryControls(), lockForIndirect, performMigration);
}
if (performMigration) {
auto deviceImp = static_cast<DeviceImp *>(this->device);
auto pageFaultManager = deviceImp->getDriverHandle()->getMemoryManager()->getPageFaultManager();
if (pageFaultManager == nullptr) {
performMigration = false;
}
}
cmdQ->makeResidentAndMigrate(performMigration, this->commandContainer.getResidencyContainer());
static_cast<CommandQueueHw<gfxCoreFamily> *>(this->cmdQImmediate)->patchCommands(*this, 0u);

View File

@@ -776,6 +776,8 @@ 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<void *>(&one), sizeof(one), 4090u,
nullptr, 0, nullptr, false);
@@ -833,6 +835,8 @@ 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);