Fixed conditions to remove memory prefetch allocations in L0 backend

Ensure memory prefetch be applied in every execution of command list.

Related-To: NEO-6740

Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
Milczarek, Slawomir
2022-11-22 12:33:16 +00:00
committed by Compute-Runtime-Automation
parent f267c34327
commit 4476e7ad76
13 changed files with 113 additions and 39 deletions

View File

@@ -14,12 +14,16 @@ using namespace NEO;
class MockPrefetchManager : public PrefetchManager {
public:
using PrefetchManager::allocations;
void migrateAllocationsToGpu(SVMAllocsManager &unifiedMemoryManager, Device &device) override {
PrefetchManager::migrateAllocationsToGpu(unifiedMemoryManager, device);
void migrateAllocationsToGpu(PrefetchContext &prefetchContext, SVMAllocsManager &unifiedMemoryManager, Device &device) override {
PrefetchManager::migrateAllocationsToGpu(prefetchContext, unifiedMemoryManager, device);
migrateAllocationsToGpuCalled = true;
}
void removeAllocations(PrefetchContext &prefetchContext) override {
PrefetchManager::removeAllocations(prefetchContext);
removeAllocationsCalled = true;
}
bool migrateAllocationsToGpuCalled = false;
bool removeAllocationsCalled = false;
};

View File

@@ -24,6 +24,7 @@ target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/page_table_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/physical_address_allocator_hw_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/physical_address_allocator_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/prefetch_manager_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/special_heap_pool_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/storage_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/surface_tests.cpp

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/memory_manager/prefetch_manager.h"
#include "shared/test/common/memory_manager/mock_prefetch_manager.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_svm_manager.h"
#include "shared/test/common/mocks/ult_device_factory.h"
#include "gtest/gtest.h"
using namespace NEO;
TEST(PrefetchManagerTests, givenPrefetchManagerWhenCallingInterfaceFunctionsThenUpdateAllocationsInPrefetchContext) {
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex};
std::map<uint32_t, DeviceBitfield> deviceBitfields{{mockRootDeviceIndex, mockDeviceBitfield}};
auto device = deviceFactory->rootDevices[0];
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
auto prefetchManager = std::make_unique<MockPrefetchManager>();
PrefetchContext prefetchContext;
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY, rootDeviceIndices, deviceBitfields);
auto ptr = svmManager->createSharedUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, nullptr);
ASSERT_NE(nullptr, ptr);
auto svmData = svmManager->getSVMAlloc(ptr);
ASSERT_NE(nullptr, svmData);
EXPECT_EQ(0u, prefetchContext.allocations.size());
prefetchManager->insertAllocation(prefetchContext, *svmData);
EXPECT_EQ(1u, prefetchContext.allocations.size());
prefetchManager->migrateAllocationsToGpu(prefetchContext, *svmManager.get(), *device);
EXPECT_EQ(1u, prefetchContext.allocations.size());
prefetchManager->removeAllocations(prefetchContext);
EXPECT_EQ(0u, prefetchContext.allocations.size());
svmManager->freeSVMAlloc(ptr);
}