mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 05:56:36 +08:00
refactor: do not add all mapped physical allocations to kernel residency
Related-To: NEO-11719 Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9632f91ee8
commit
42bf58a800
@@ -770,15 +770,6 @@ ze_result_t KernelImp::setArgBuffer(uint32_t argIndex, size_t argSize, const voi
|
||||
const uint32_t allocId = allocData->getAllocId();
|
||||
kernelArgInfos[argIndex] = KernelArgInfo{requestedAddress, allocId, allocationsCounter, false};
|
||||
|
||||
if (allocData->virtualReservationData) {
|
||||
for (const auto &mappedAllocationData : allocData->virtualReservationData->mappedAllocations) {
|
||||
// Add additional allocations to the residency container if the virtual reservation spans multiple allocations.
|
||||
if (requestedAddress != mappedAllocationData.second->ptr) {
|
||||
this->argumentsResidencyContainer.push_back(mappedAllocationData.second->mappedAllocation->allocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return setArgBufferWithAlloc(argIndex, gpuAddress, alloc, peerAllocData);
|
||||
}
|
||||
|
||||
|
||||
@@ -2640,14 +2640,20 @@ class MultiDeviceModuleSetArgBufferTest : public MultiDeviceModuleFixture, publi
|
||||
};
|
||||
|
||||
HWTEST_F(MultiDeviceModuleSetArgBufferTest,
|
||||
givenCallsToSetArgBufferWithReservedMemoryThenResidencyContainerHasAllMappedAllocations) {
|
||||
givenCallsToSetArgBufferWithReservedMemoryThenKernelResidencyContainerHasKernelArgMappedAllocationAndMemoryInterfaceHasAllMappedAllocations) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < numRootDevices; rootDeviceIndex++) {
|
||||
createModuleFromMockBinary(rootDeviceIndex);
|
||||
auto device = driverHandle->devices[rootDeviceIndex];
|
||||
driverHandle->devices[rootDeviceIndex]->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface =
|
||||
auto neoDevice = device->getNEODevice();
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface =
|
||||
std::make_unique<NEO::MockMemoryOperations>();
|
||||
|
||||
NEO::MockMemoryOperations *mockMemoryInterface = static_cast<NEO::MockMemoryOperations *>(
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface.get());
|
||||
|
||||
mockMemoryInterface->captureGfxAllocationsForMakeResident = true;
|
||||
|
||||
ze_kernel_handle_t kernelHandle;
|
||||
void *ptr = nullptr;
|
||||
size_t size = MemoryConstants::pageSize64k;
|
||||
@@ -2694,7 +2700,16 @@ HWTEST_F(MultiDeviceModuleSetArgBufferTest,
|
||||
EXPECT_EQ(surfaceStateAddress->getHeight(), static_cast<uint32_t>(length.surfaceState.height + 1));
|
||||
EXPECT_EQ(surfaceStateAddress->getDepth(), static_cast<uint32_t>(length.surfaceState.depth + 1));
|
||||
EXPECT_TRUE(phys1Resident);
|
||||
EXPECT_TRUE(phys2Resident);
|
||||
EXPECT_FALSE(phys2Resident);
|
||||
|
||||
auto physicalIt = driverHandle->getMemoryManager()->getPhysicalMemoryAllocationMap().find(static_cast<void *>(phPhysicalMemory));
|
||||
auto physical1Allocation = physicalIt->second->allocation;
|
||||
EXPECT_EQ(NEO::MemoryOperationsStatus::success, mockMemoryInterface->isResident(neoDevice, *physical1Allocation));
|
||||
|
||||
physicalIt = driverHandle->getMemoryManager()->getPhysicalMemoryAllocationMap().find(static_cast<void *>(phPhysicalMemory2));
|
||||
auto physical2Allocation = physicalIt->second->allocation;
|
||||
EXPECT_EQ(NEO::MemoryOperationsStatus::success, mockMemoryInterface->isResident(neoDevice, *physical2Allocation));
|
||||
|
||||
res = context->unMapVirtualMem(ptr, size);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
res = context->unMapVirtualMem(offsetAddress, size);
|
||||
@@ -2710,14 +2725,20 @@ HWTEST_F(MultiDeviceModuleSetArgBufferTest,
|
||||
}
|
||||
|
||||
HWTEST_F(MultiDeviceModuleSetArgBufferTest,
|
||||
givenCallsToSetArgBufferWithOffsetReservedMemoryThenResidencyContainerHasAllMappedAllocations) {
|
||||
givenCallsToSetArgBufferWithOffsetReservedMemoryThenKernelResidencyHasArgMappedAllocationAndMemoryInterfaceHasAllMappedAllocations) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < numRootDevices; rootDeviceIndex++) {
|
||||
createModuleFromMockBinary(rootDeviceIndex);
|
||||
auto device = driverHandle->devices[rootDeviceIndex];
|
||||
driverHandle->devices[rootDeviceIndex]->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface =
|
||||
auto neoDevice = device->getNEODevice();
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface =
|
||||
std::make_unique<NEO::MockMemoryOperations>();
|
||||
|
||||
NEO::MockMemoryOperations *mockMemoryInterface = static_cast<NEO::MockMemoryOperations *>(
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface.get());
|
||||
|
||||
mockMemoryInterface->captureGfxAllocationsForMakeResident = true;
|
||||
|
||||
ze_kernel_handle_t kernelHandle;
|
||||
void *ptr = nullptr;
|
||||
size_t size = MemoryConstants::pageSize64k;
|
||||
@@ -2763,8 +2784,17 @@ HWTEST_F(MultiDeviceModuleSetArgBufferTest,
|
||||
EXPECT_EQ(surfaceStateAddress->getWidth(), static_cast<uint32_t>(length.surfaceState.width));
|
||||
EXPECT_EQ(surfaceStateAddress->getHeight(), static_cast<uint32_t>(length.surfaceState.height + 1));
|
||||
EXPECT_EQ(surfaceStateAddress->getDepth(), static_cast<uint32_t>(length.surfaceState.depth + 1));
|
||||
EXPECT_TRUE(phys1Resident);
|
||||
EXPECT_FALSE(phys1Resident);
|
||||
EXPECT_TRUE(phys2Resident);
|
||||
|
||||
auto physicalIt = driverHandle->getMemoryManager()->getPhysicalMemoryAllocationMap().find(static_cast<void *>(phPhysicalMemory));
|
||||
auto physical1Allocation = physicalIt->second->allocation;
|
||||
EXPECT_EQ(NEO::MemoryOperationsStatus::success, mockMemoryInterface->isResident(neoDevice, *physical1Allocation));
|
||||
|
||||
physicalIt = driverHandle->getMemoryManager()->getPhysicalMemoryAllocationMap().find(static_cast<void *>(phPhysicalMemory2));
|
||||
auto physical2Allocation = physicalIt->second->allocation;
|
||||
EXPECT_EQ(NEO::MemoryOperationsStatus::success, mockMemoryInterface->isResident(neoDevice, *physical2Allocation));
|
||||
|
||||
res = context->unMapVirtualMem(ptr, size);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
res = context->unMapVirtualMem(offsetAddress, size);
|
||||
@@ -2901,7 +2931,7 @@ HWTEST_F(MultiDeviceModuleSetArgBufferTest,
|
||||
EXPECT_EQ(surfaceStateAddress->getHeight(), static_cast<uint32_t>(length.surfaceState.height + 1));
|
||||
EXPECT_EQ(surfaceStateAddress->getDepth(), static_cast<uint32_t>(length.surfaceState.depth + 1));
|
||||
EXPECT_TRUE(phys1Resident);
|
||||
EXPECT_TRUE(phys2Resident);
|
||||
EXPECT_FALSE(phys2Resident);
|
||||
res = context->unMapVirtualMem(ptr, size);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
res = context->unMapVirtualMem(offsetAddress, size);
|
||||
|
||||
Reference in New Issue
Block a user