diff --git a/level_zero/core/source/kernel/kernel_imp.cpp b/level_zero/core/source/kernel/kernel_imp.cpp index e52fa30561..54dc59b10d 100644 --- a/level_zero/core/source/kernel/kernel_imp.cpp +++ b/level_zero/core/source/kernel/kernel_imp.cpp @@ -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); } diff --git a/level_zero/core/test/unit_tests/sources/module/test_module.cpp b/level_zero/core/test/unit_tests/sources/module/test_module.cpp index 5ccf2a4652..fda32be173 100644 --- a/level_zero/core/test/unit_tests/sources/module/test_module.cpp +++ b/level_zero/core/test/unit_tests/sources/module/test_module.cpp @@ -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 *mockMemoryInterface = static_cast( + 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(length.surfaceState.height + 1)); EXPECT_EQ(surfaceStateAddress->getDepth(), static_cast(length.surfaceState.depth + 1)); EXPECT_TRUE(phys1Resident); - EXPECT_TRUE(phys2Resident); + EXPECT_FALSE(phys2Resident); + + auto physicalIt = driverHandle->getMemoryManager()->getPhysicalMemoryAllocationMap().find(static_cast(phPhysicalMemory)); + auto physical1Allocation = physicalIt->second->allocation; + EXPECT_EQ(NEO::MemoryOperationsStatus::success, mockMemoryInterface->isResident(neoDevice, *physical1Allocation)); + + physicalIt = driverHandle->getMemoryManager()->getPhysicalMemoryAllocationMap().find(static_cast(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 *mockMemoryInterface = static_cast( + 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(length.surfaceState.width)); EXPECT_EQ(surfaceStateAddress->getHeight(), static_cast(length.surfaceState.height + 1)); EXPECT_EQ(surfaceStateAddress->getDepth(), static_cast(length.surfaceState.depth + 1)); - EXPECT_TRUE(phys1Resident); + EXPECT_FALSE(phys1Resident); EXPECT_TRUE(phys2Resident); + + auto physicalIt = driverHandle->getMemoryManager()->getPhysicalMemoryAllocationMap().find(static_cast(phPhysicalMemory)); + auto physical1Allocation = physicalIt->second->allocation; + EXPECT_EQ(NEO::MemoryOperationsStatus::success, mockMemoryInterface->isResident(neoDevice, *physical1Allocation)); + + physicalIt = driverHandle->getMemoryManager()->getPhysicalMemoryAllocationMap().find(static_cast(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(length.surfaceState.height + 1)); EXPECT_EQ(surfaceStateAddress->getDepth(), static_cast(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);