2018-12-17 11:49:17 +01:00
|
|
|
/*
|
2025-03-07 13:32:25 +00:00
|
|
|
* Copyright (C) 2018-2025 Intel Corporation
|
2018-12-17 11:49:17 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2022-12-29 12:27:52 +00:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/memory_manager/unified_memory_manager.h"
|
2022-11-17 10:33:19 +00:00
|
|
|
#include "shared/test/common/fixtures/cpu_page_fault_manager_tests_fixture.h"
|
2023-01-13 15:18:40 +00:00
|
|
|
#include "shared/test/common/helpers/default_hw_info.h"
|
2022-11-17 10:33:19 +00:00
|
|
|
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
2022-12-29 12:27:52 +00:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2022-04-14 15:23:52 +00:00
|
|
|
struct MockSVMAllocsManager : public SVMAllocsManager {
|
|
|
|
|
public:
|
2025-04-01 18:09:02 +00:00
|
|
|
using SVMAllocsManager::insertSVMAlloc;
|
2025-07-07 14:17:22 +00:00
|
|
|
using SVMAllocsManager::internalAllocationsMap;
|
2018-12-17 11:49:17 +01:00
|
|
|
using SVMAllocsManager::memoryManager;
|
2022-09-22 10:46:22 +00:00
|
|
|
using SVMAllocsManager::mtxForIndirectAccess;
|
2023-04-28 09:38:31 +00:00
|
|
|
using SVMAllocsManager::svmAllocs;
|
2018-12-17 11:49:17 +01:00
|
|
|
using SVMAllocsManager::SVMAllocsManager;
|
2023-11-08 14:04:01 +00:00
|
|
|
using SVMAllocsManager::svmDeferFreeAllocs;
|
2019-03-06 16:35:21 +01:00
|
|
|
using SVMAllocsManager::svmMapOperations;
|
2022-04-14 15:23:52 +00:00
|
|
|
using SVMAllocsManager::usmDeviceAllocationsCache;
|
2024-01-31 13:07:07 +00:00
|
|
|
using SVMAllocsManager::usmHostAllocationsCache;
|
2023-08-08 08:25:58 +00:00
|
|
|
|
2025-03-12 22:47:22 +00:00
|
|
|
void prefetchMemory(Device &device, CommandStreamReceiver &commandStreamReceiver, const void *ptr, const size_t size) override {
|
|
|
|
|
SVMAllocsManager::prefetchMemory(device, commandStreamReceiver, ptr, size);
|
2023-08-08 08:25:58 +00:00
|
|
|
prefetchMemoryCalled = true;
|
|
|
|
|
}
|
|
|
|
|
bool prefetchMemoryCalled = false;
|
2024-05-21 13:29:16 +00:00
|
|
|
|
|
|
|
|
void *createUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties &memoryProperties) override {
|
2024-05-29 10:52:58 +00:00
|
|
|
requestedZeroedOutAllocation = memoryProperties.isInternalAllocation;
|
2025-04-01 18:09:02 +00:00
|
|
|
if (createUnifiedMemoryAllocationCallBase) {
|
|
|
|
|
return SVMAllocsManager::createUnifiedMemoryAllocation(size, memoryProperties);
|
|
|
|
|
}
|
|
|
|
|
return createUnifiedMemoryAllocationReturnValue;
|
2024-05-21 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
bool requestedZeroedOutAllocation = false;
|
2025-04-01 18:09:02 +00:00
|
|
|
bool createUnifiedMemoryAllocationCallBase = true;
|
|
|
|
|
void *createUnifiedMemoryAllocationReturnValue = nullptr;
|
2018-12-17 11:49:17 +01:00
|
|
|
};
|
2022-11-17 10:33:19 +00:00
|
|
|
|
|
|
|
|
template <bool enableLocalMemory>
|
|
|
|
|
struct SVMMemoryAllocatorFixture {
|
|
|
|
|
SVMMemoryAllocatorFixture() : executionEnvironment(defaultHwInfo.get()) {}
|
|
|
|
|
|
|
|
|
|
void setUp() {
|
|
|
|
|
executionEnvironment.initGmm();
|
|
|
|
|
memoryManager = std::make_unique<MockMemoryManager>(false, enableLocalMemory, executionEnvironment);
|
2025-05-08 09:16:29 +00:00
|
|
|
svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager.get());
|
2022-11-17 10:33:19 +00:00
|
|
|
if (enableLocalMemory) {
|
|
|
|
|
memoryManager->pageFaultManager.reset(new MockPageFaultManager);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void tearDown() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment;
|
|
|
|
|
std::unique_ptr<MockMemoryManager> memoryManager;
|
|
|
|
|
std::unique_ptr<MockSVMAllocsManager> svmManager;
|
|
|
|
|
RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex};
|
|
|
|
|
std::map<uint32_t, DeviceBitfield> deviceBitfields{{mockRootDeviceIndex, mockDeviceBitfield}};
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-08 12:27:14 +00:00
|
|
|
} // namespace NEO
|