diff --git a/shared/source/os_interface/aub_memory_operations_handler.cpp b/shared/source/os_interface/aub_memory_operations_handler.cpp index 2df20ee51c..abfec8f6d4 100644 --- a/shared/source/os_interface/aub_memory_operations_handler.cpp +++ b/shared/source/os_interface/aub_memory_operations_handler.cpp @@ -42,11 +42,12 @@ MemoryOperationsStatus AubMemoryOperationsHandler::makeResident(Device *device, continue; } + auto memoryBanks = static_cast(getMemoryBanksBitfield(allocation, device).to_ulong()); uint64_t gpuAddress = device ? device->getGmmHelper()->decanonize(allocation->getGpuAddress()) : allocation->getGpuAddress(); aub_stream::AllocationParams params(gpuAddress, allocation->getUnderlyingBuffer(), allocation->getUnderlyingBufferSize(), - allocation->storageInfo.getMemoryBanks(), + memoryBanks, hint, allocation->getUsedPageSize()); diff --git a/shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp b/shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp index bab0d36891..c7bacedb88 100644 --- a/shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp +++ b/shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp @@ -305,6 +305,27 @@ TEST_F(AubMemoryOperationsHandlerTests, givenLocalMemoryAndNonLocalMemoryAllocat device->getDefaultEngine().commandStreamReceiver = oldCsr; } +TEST_F(AubMemoryOperationsHandlerTests, givenNonLocalMemoryAllocationWithStorageInfoNonZeroWhenMakeResidentCalledThenSystemMemoryBankIsPassedToWriteMemory) { + auto executionEnvironment = device->getExecutionEnvironment(); + executionEnvironment->prepareRootDeviceEnvironments(1); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(&hardwareInfo); + executionEnvironment->initializeMemoryManager(); + + MemoryAllocation allocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, reinterpret_cast(0x1000), 0x1000u, + MemoryConstants::pageSize, 0, MemoryPool::system64KBPages, false, false, MemoryManager::maxOsContextCount); + allocation.storageInfo.memoryBanks = 0x3u; + MockAubManager aubManager; + aubManager.storeAllocationParams = true; + getMemoryOperationsHandler()->setAubManager(&aubManager); + auto memoryOperationsInterface = getMemoryOperationsHandler(); + + allocPtr = &allocation; + memoryOperationsInterface->makeResident(device.get(), ArrayRef(&allocPtr, 1), false); + + EXPECT_TRUE(aubManager.writeMemory2Called); + EXPECT_EQ(0u, aubManager.storedAllocationParams[0].memoryBanks); +} + TEST_F(AubMemoryOperationsHandlerTests, givenLocalMemoryNoncloneableAllocationWithManyBanksWhenGetMemoryBanksBitfieldThenSingleMemoryBankIsReturned) { auto executionEnvironment = device->getExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(1);