mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-29 17:13:29 +08:00
feature: support SVM heap in reserveVirtualMem
Related-To: NEO-11981 Signed-off-by: Wenbin Lu <wenbin.lu@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
e30b8c0300
commit
bfaeeb01d6
@@ -135,6 +135,14 @@ GmmHelper *MemoryManager::getGmmHelper(uint32_t rootDeviceIndex) {
|
||||
return executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper();
|
||||
}
|
||||
|
||||
AddressRange MemoryManager::reserveCpuAddressWithZeroBaseRetry(const uint64_t requiredStartAddress, size_t size) {
|
||||
auto addressRange = reserveCpuAddress(requiredStartAddress, size);
|
||||
if ((addressRange.address == 0) && (requiredStartAddress != 0)) {
|
||||
addressRange = reserveCpuAddress(0, size);
|
||||
}
|
||||
return addressRange;
|
||||
}
|
||||
|
||||
HeapIndex MemoryManager::selectInternalHeap(bool useLocalMemory) {
|
||||
return useLocalMemory ? HeapIndex::heapInternalDeviceMemory : HeapIndex::heapInternal;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,10 @@ struct VirtualMemoryReservation {
|
||||
MemoryFlags flags;
|
||||
std::map<void *, MemoryMappedRange *> mappedAllocations;
|
||||
uint32_t rootDeviceIndex;
|
||||
bool isSvmReservation;
|
||||
size_t reservationSize;
|
||||
uint64_t reservationBase;
|
||||
size_t reservationTotalSize;
|
||||
};
|
||||
|
||||
struct PhysicalMemoryAllocation {
|
||||
@@ -248,6 +251,9 @@ class MemoryManager {
|
||||
virtual AddressRange reserveGpuAddressOnHeap(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex, HeapIndex heap, size_t alignment) = 0;
|
||||
virtual size_t selectAlignmentAndHeap(size_t size, HeapIndex *heap) = 0;
|
||||
virtual void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) = 0;
|
||||
virtual AddressRange reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) = 0;
|
||||
AddressRange reserveCpuAddressWithZeroBaseRetry(const uint64_t requiredStartAddress, size_t size);
|
||||
virtual void freeCpuAddress(AddressRange addressRange) = 0;
|
||||
static HeapIndex selectInternalHeap(bool useLocalMemory);
|
||||
static HeapIndex selectExternalHeap(bool useLocalMemory);
|
||||
|
||||
|
||||
@@ -555,6 +555,14 @@ void OsAgnosticMemoryManager::releaseReservedCpuAddressRange(void *reserved, siz
|
||||
alignedFreeWrapper(reserved);
|
||||
}
|
||||
|
||||
AddressRange OsAgnosticMemoryManager::reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) {
|
||||
return {castToUint64(alignedMallocWrapper(size, MemoryConstants::pageSize)), size};
|
||||
}
|
||||
|
||||
void OsAgnosticMemoryManager::freeCpuAddress(AddressRange addressRange) {
|
||||
alignedFreeWrapper(addrToPtr(addressRange.address));
|
||||
}
|
||||
|
||||
MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(AllocationType allocationType, void *driverAllocatedCpuPointer,
|
||||
void *pMem, uint64_t gpuAddress, size_t memSize, uint64_t count,
|
||||
MemoryPool pool, uint32_t rootDeviceIndex, bool uncacheable,
|
||||
|
||||
@@ -48,6 +48,8 @@ class OsAgnosticMemoryManager : public MemoryManager {
|
||||
AddressRange reserveGpuAddressOnHeap(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex, HeapIndex heap, size_t alignment) override;
|
||||
size_t selectAlignmentAndHeap(size_t size, HeapIndex *heap) override;
|
||||
void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) override;
|
||||
AddressRange reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) override;
|
||||
void freeCpuAddress(AddressRange addressRange) override;
|
||||
bool is64kbPagesEnabled(const HardwareInfo *hwInfo);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#include "shared/source/memory_manager/allocation_properties.h"
|
||||
#include "shared/source/memory_manager/gfx_partition.h"
|
||||
#include "shared/source/memory_manager/host_ptr_manager.h"
|
||||
#include "shared/source/memory_manager/local_memory_usage.h"
|
||||
#include "shared/source/memory_manager/memory_banks.h"
|
||||
#include "shared/source/memory_manager/memory_pool.h"
|
||||
#include "shared/source/memory_manager/multi_graphics_allocation.h"
|
||||
#include "shared/source/memory_manager/residency.h"
|
||||
@@ -47,7 +45,6 @@
|
||||
#include "shared/source/os_interface/product_helper.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@@ -95,6 +92,7 @@ DrmMemoryManager::DrmMemoryManager(GemCloseWorkerMode mode,
|
||||
const auto heapIndex = customAlignment >= MemoryConstants::pageSize2M ? HeapIndex::heapStandard2MB : HeapIndex::heapStandard64KB;
|
||||
alignmentSelector.addCandidateAlignment(customAlignment, true, AlignmentSelector::anyWastage, heapIndex);
|
||||
}
|
||||
osMemory = OSMemory::create();
|
||||
|
||||
initialize(mode);
|
||||
}
|
||||
@@ -1521,6 +1519,18 @@ void DrmMemoryManager::freeGpuAddress(AddressRange addressRange, uint32_t rootDe
|
||||
releaseGpuRange(reinterpret_cast<void *>(addressRange.address), addressRange.size, rootDeviceIndex);
|
||||
}
|
||||
|
||||
AddressRange DrmMemoryManager::reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) {
|
||||
void *ptr = osMemory->osReserveCpuAddressRange(addrToPtr(requiredStartAddress), size, false);
|
||||
if (ptr == MAP_FAILED) {
|
||||
ptr = nullptr;
|
||||
}
|
||||
return {castToUint64(ptr), size};
|
||||
}
|
||||
|
||||
void DrmMemoryManager::freeCpuAddress(AddressRange addressRange) {
|
||||
osMemory->osReleaseCpuAddressRange(addrToPtr(addressRange.address), addressRange.size);
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> DrmMemoryManager::acquireAllocLock() {
|
||||
return std::unique_lock<std::mutex>(this->allocMutex);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#pragma once
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
||||
#include "shared/source/os_interface/os_memory.h"
|
||||
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
@@ -70,6 +70,8 @@ class DrmMemoryManager : public MemoryManager {
|
||||
AddressRange reserveGpuAddressOnHeap(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex, HeapIndex heap, size_t alignment) override;
|
||||
size_t selectAlignmentAndHeap(size_t size, HeapIndex *heap) override;
|
||||
void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) override;
|
||||
AddressRange reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) override;
|
||||
void freeCpuAddress(AddressRange addressRange) override;
|
||||
MOCKABLE_VIRTUAL BufferObject *createBufferObjectInMemoryRegion(uint32_t rootDeviceIndex, Gmm *gmm, AllocationType allocationType, uint64_t gpuAddress, size_t size,
|
||||
DeviceBitfield memoryBanks, size_t maxOsContextCount, int32_t pairHandle, bool isSystemMemoryPool, bool isUsmHostAllocation);
|
||||
|
||||
@@ -178,6 +180,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
bool forcePinEnabled = false;
|
||||
const bool validateHostPtrMemory;
|
||||
std::unique_ptr<DrmGemCloseWorker> gemCloseWorker;
|
||||
std::unique_ptr<OSMemory> osMemory;
|
||||
decltype(&mmap) mmapFunction = mmap;
|
||||
decltype(&munmap) munmapFunction = munmap;
|
||||
decltype(&close) closeFunction = close;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
* Copyright (C) 2019-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -25,7 +25,7 @@ void *OSMemoryWindows::osReserveCpuAddressRange(void *baseAddress, size_t sizeTo
|
||||
}
|
||||
|
||||
void OSMemoryWindows::osReleaseCpuAddressRange(void *reservedCpuAddressRange, size_t size) {
|
||||
virtualFreeWrapper(reservedCpuAddressRange, size, MEM_RELEASE);
|
||||
virtualFreeWrapper(reservedCpuAddressRange, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
LPVOID OSMemoryWindows::virtualAllocWrapper(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) {
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "shared/source/os_interface/windows/wddm_allocation.h"
|
||||
#include "shared/source/os_interface/windows/wddm_residency_allocations_container.h"
|
||||
#include "shared/source/os_interface/windows/wddm_residency_controller.h"
|
||||
#include "shared/source/release_helper/release_helper.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <emmintrin.h>
|
||||
@@ -74,6 +73,7 @@ WddmMemoryManager::WddmMemoryManager(ExecutionEnvironment &executionEnvironment)
|
||||
if (customAlignment > 0) {
|
||||
alignmentSelector.addCandidateAlignment(customAlignment, false, AlignmentSelector::anyWastage);
|
||||
}
|
||||
osMemory = OSMemory::create();
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
@@ -1025,6 +1025,15 @@ void WddmMemoryManager::freeGpuAddress(AddressRange addressRange, uint32_t rootD
|
||||
getWddm(rootDeviceIndex).freeGpuVirtualAddress(addressRange.address, addressRange.size);
|
||||
}
|
||||
|
||||
AddressRange WddmMemoryManager::reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) {
|
||||
void *ptr = osMemory->osReserveCpuAddressRange(addrToPtr(requiredStartAddress), size, false);
|
||||
return {castToUint64(ptr), size};
|
||||
}
|
||||
|
||||
void WddmMemoryManager::freeCpuAddress(AddressRange addressRange) {
|
||||
osMemory->osReleaseCpuAddressRange(addrToPtr(addressRange.address), addressRange.size);
|
||||
}
|
||||
|
||||
bool WddmMemoryManager::mapGpuVaForOneHandleAllocation(WddmAllocation *allocation, const void *preferredGpuVirtualAddress) {
|
||||
D3DGPU_VIRTUAL_ADDRESS addressToMap = castToUint64(preferredGpuVirtualAddress);
|
||||
auto heapIndex = selectHeap(allocation, preferredGpuVirtualAddress != nullptr, is32bit || executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->isFullRangeSvm(), allocation->isAllocInFrontWindowPool());
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
#include "shared/source/os_interface/os_memory.h"
|
||||
#include "shared/source/os_interface/windows/wddm_allocation.h"
|
||||
|
||||
#include <d3dkmthk.h>
|
||||
@@ -69,6 +70,8 @@ class WddmMemoryManager : public MemoryManager {
|
||||
AddressRange reserveGpuAddressOnHeap(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex, HeapIndex heap, size_t alignment) override;
|
||||
size_t selectAlignmentAndHeap(size_t size, HeapIndex *heap) override;
|
||||
void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) override;
|
||||
AddressRange reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) override;
|
||||
void freeCpuAddress(AddressRange addressRange) override;
|
||||
bool verifyHandle(osHandle handle, uint32_t rootDeviceIndex, bool ntHandle) override;
|
||||
bool isNTHandle(osHandle handle, uint32_t rootDeviceIndex) override;
|
||||
void releaseDeviceSpecificMemResources(uint32_t rootDeviceIndex) override{};
|
||||
@@ -117,6 +120,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||
void adjustGpuPtrToHostAddressSpace(WddmAllocation &wddmAllocation, void *&requiredGpuVa);
|
||||
bool isStatelessAccessRequired(AllocationType type);
|
||||
AlignedMallocRestrictions mallocRestrictions;
|
||||
std::unique_ptr<OSMemory> osMemory;
|
||||
|
||||
Wddm &getWddm(uint32_t rootDeviceIndex) const;
|
||||
};
|
||||
|
||||
@@ -131,6 +131,17 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
|
||||
return OsAgnosticMemoryManager::reserveCpuAddressRange(size, rootDeviceIndex);
|
||||
}
|
||||
|
||||
AddressRange reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) override {
|
||||
if (failReserveAddress) {
|
||||
return {};
|
||||
}
|
||||
return OsAgnosticMemoryManager::reserveCpuAddress(requiredStartAddress, size);
|
||||
}
|
||||
|
||||
void freeCpuAddress(AddressRange addressRange) override {
|
||||
return OsAgnosticMemoryManager::freeCpuAddress(addressRange);
|
||||
}
|
||||
|
||||
void *createMultiGraphicsAllocationInSystemMemoryPool(RootDeviceIndicesContainer &rootDeviceIndices,
|
||||
AllocationProperties &properties,
|
||||
MultiGraphicsAllocation &multiGraphicsAllocation) override {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/source/helpers/array_count.h"
|
||||
#include "shared/source/helpers/driver_model_type.h"
|
||||
#include "shared/source/helpers/gfx_core_helper.h"
|
||||
#include "shared/source/memory_manager/allocations_list.h"
|
||||
#include "shared/source/memory_manager/gfx_partition.h"
|
||||
@@ -16,7 +15,6 @@
|
||||
#include "shared/source/os_interface/driver_info.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/os_interface/product_helper_hw.h"
|
||||
#include "shared/source/release_helper/release_helper.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
@@ -530,6 +528,8 @@ TEST_F(DeviceGetCapsTest, givenFlagEnabled64kbPagesWhenCallConstructorMemoryMana
|
||||
return MemoryConstants::pageSize64k;
|
||||
}
|
||||
void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) override{};
|
||||
AddressRange reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) override { return {}; }
|
||||
void freeCpuAddress(AddressRange addressRange) override{};
|
||||
GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) override { return nullptr; };
|
||||
GraphicsAllocation *allocateGraphicsMemoryForNonSvmHostPtr(const AllocationData &allocationData) override { return nullptr; };
|
||||
GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) override { return nullptr; };
|
||||
|
||||
@@ -1909,6 +1909,16 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWithFlagEnable64kbpage
|
||||
EXPECT_FALSE(memoryManager.is64kbPagesEnabled(&hwInfo));
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenStartAddressAndSizeWhenReservingCpuAddressThenPageAlignedAddressRangeIsReturned) {
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
auto addressRange = memoryManager.reserveCpuAddress(0, 1234);
|
||||
EXPECT_NE(0u, addressRange.address);
|
||||
EXPECT_EQ(1234u, addressRange.size);
|
||||
EXPECT_EQ(0u, addressRange.address & (MemoryConstants::pageSize - 1));
|
||||
memoryManager.freeCpuAddress(addressRange);
|
||||
}
|
||||
|
||||
TEST(MemoryManager, givenSharedResourceCopyWhenAllocatingGraphicsMemoryThenAllocateGraphicsMemoryForImageIsCalled) {
|
||||
MockExecutionEnvironment executionEnvironment{};
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
@@ -2750,6 +2760,83 @@ TEST(MemoryManagerTest, whenMemoryManagerReturnsNullptrThenAllocateGlobalsSurfac
|
||||
EXPECT_EQ(deviceBitfield, memoryManager->recentlyPassedDeviceBitfield);
|
||||
}
|
||||
|
||||
class FailFirstCpuReserveMemoryManager : public MockMemoryManager {
|
||||
public:
|
||||
using MockMemoryManager::MockMemoryManager;
|
||||
AddressRange reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) override {
|
||||
cpuReservationCallCount++;
|
||||
if (isFirstCpuReservationCall || alwaysFail) {
|
||||
isFirstCpuReservationCall = false;
|
||||
return {};
|
||||
}
|
||||
return AddressRange{0xDEADBEEF, size};
|
||||
}
|
||||
void freeCpuAddress(AddressRange addressRange) override{};
|
||||
|
||||
bool alwaysFail = false;
|
||||
bool isFirstCpuReservationCall = true;
|
||||
int8_t cpuReservationCallCount = 0;
|
||||
};
|
||||
|
||||
TEST(MemoryManagerTest, givenFirstCpuReservationFailsAndRequiredStartAddressIsZeroThenReservationIsNotTriedAgain) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
auto failFirstMemoryManager = std::make_unique<FailFirstCpuReserveMemoryManager>(executionEnvironment);
|
||||
|
||||
EXPECT_EQ(0, failFirstMemoryManager->cpuReservationCallCount);
|
||||
auto addressRange = failFirstMemoryManager->reserveCpuAddressWithZeroBaseRetry(0, 1234);
|
||||
EXPECT_EQ(0u, addressRange.address);
|
||||
EXPECT_EQ(0u, addressRange.size);
|
||||
EXPECT_EQ(1, failFirstMemoryManager->cpuReservationCallCount);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenFirstCpuReservationFailsAndRequiredStartAddressIsNotZeroThenReservationIsTriedAgain) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
auto failFirstMemoryManager = std::make_unique<FailFirstCpuReserveMemoryManager>(executionEnvironment);
|
||||
|
||||
EXPECT_EQ(0, failFirstMemoryManager->cpuReservationCallCount);
|
||||
auto addressRange = failFirstMemoryManager->reserveCpuAddressWithZeroBaseRetry(42, 1234);
|
||||
EXPECT_EQ(0xDEADBEEF, addressRange.address);
|
||||
EXPECT_EQ(1234u, addressRange.size);
|
||||
EXPECT_EQ(2, failFirstMemoryManager->cpuReservationCallCount);
|
||||
failFirstMemoryManager->freeCpuAddress(addressRange);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenCpuReservationFailsThenReservationIsTriedAgain) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
auto failFirstMemoryManager = std::make_unique<FailFirstCpuReserveMemoryManager>(executionEnvironment);
|
||||
|
||||
failFirstMemoryManager->alwaysFail = true;
|
||||
|
||||
EXPECT_EQ(0, failFirstMemoryManager->cpuReservationCallCount);
|
||||
auto addressRangeZeroStart = failFirstMemoryManager->reserveCpuAddressWithZeroBaseRetry(0, 1234);
|
||||
EXPECT_EQ(0u, addressRangeZeroStart.address);
|
||||
EXPECT_EQ(0u, addressRangeZeroStart.size);
|
||||
EXPECT_EQ(1, failFirstMemoryManager->cpuReservationCallCount);
|
||||
auto addressRangeNonZeroStart = failFirstMemoryManager->reserveCpuAddressWithZeroBaseRetry(42, 1234);
|
||||
EXPECT_EQ(0u, addressRangeNonZeroStart.address);
|
||||
EXPECT_EQ(0u, addressRangeNonZeroStart.size);
|
||||
EXPECT_EQ(3, failFirstMemoryManager->cpuReservationCallCount);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenCpuReservationPassesThenReservationIsNotTriedAgain) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
auto failFirstMemoryManager = std::make_unique<FailFirstCpuReserveMemoryManager>(executionEnvironment);
|
||||
|
||||
failFirstMemoryManager->isFirstCpuReservationCall = false;
|
||||
|
||||
EXPECT_EQ(0, failFirstMemoryManager->cpuReservationCallCount);
|
||||
auto addressRangeZeroStart = failFirstMemoryManager->reserveCpuAddressWithZeroBaseRetry(0, 1234);
|
||||
EXPECT_EQ(0xDEADBEEF, addressRangeZeroStart.address);
|
||||
EXPECT_EQ(1234u, addressRangeZeroStart.size);
|
||||
EXPECT_EQ(1, failFirstMemoryManager->cpuReservationCallCount);
|
||||
failFirstMemoryManager->freeCpuAddress(addressRangeZeroStart);
|
||||
auto addressRangeNonZeroStart = failFirstMemoryManager->reserveCpuAddressWithZeroBaseRetry(42, 1234);
|
||||
EXPECT_EQ(0xDEADBEEF, addressRangeNonZeroStart.address);
|
||||
EXPECT_EQ(1234u, addressRangeNonZeroStart.size);
|
||||
EXPECT_EQ(2, failFirstMemoryManager->cpuReservationCallCount);
|
||||
failFirstMemoryManager->freeCpuAddress(addressRangeNonZeroStart);
|
||||
}
|
||||
|
||||
HWTEST_F(MemoryAllocatorTest, givenMemoryManagerWhenEnableHostPtrTrackingFlagIsSetTo0ThenHostPointerTrackingIsDisabled) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
debugManager.flags.EnableHostPtrTracking.set(0);
|
||||
@@ -3227,4 +3314,4 @@ TEST(MemoryManagerTest, givenIsCompressionSupportedForShareableThenReturnTrue) {
|
||||
MockMemoryManager memoryManager;
|
||||
EXPECT_TRUE(memoryManager.isCompressionSupportedForShareable(true));
|
||||
EXPECT_TRUE(memoryManager.isCompressionSupportedForShareable(false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/linux/i915.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/test/common/fixtures/memory_allocator_multi_device_fixture.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/helpers/gtest_helpers.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
|
||||
@@ -46,6 +45,12 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
namespace SysCalls {
|
||||
extern bool failMmap;
|
||||
} // namespace SysCalls
|
||||
} // namespace NEO
|
||||
|
||||
namespace {
|
||||
using DrmMemoryManagerTest = Test<DrmMemoryManagerFixture>;
|
||||
using DrmMemoryManagerWithLocalMemoryTest = Test<DrmMemoryManagerWithLocalMemoryFixture>;
|
||||
@@ -7707,6 +7712,31 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenGp
|
||||
memoryManager->freeGpuAddress(addressRange, 1);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenCpuAddressReservationIsAttemptedThenCorrectAddressRangesAreReturned) {
|
||||
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, true, false, *executionEnvironment);
|
||||
RootDeviceIndicesContainer rootDeviceIndices;
|
||||
rootDeviceIndices.pushUnique(1);
|
||||
|
||||
auto addressRange = memoryManager->reserveCpuAddress(0, 0);
|
||||
EXPECT_EQ(0u, addressRange.address);
|
||||
EXPECT_EQ(0u, addressRange.size);
|
||||
|
||||
addressRange = memoryManager->reserveCpuAddress(0, MemoryConstants::pageSize);
|
||||
EXPECT_NE(0u, addressRange.address);
|
||||
EXPECT_EQ(MemoryConstants::pageSize, addressRange.size);
|
||||
memoryManager->freeCpuAddress(addressRange);
|
||||
|
||||
addressRange = memoryManager->reserveCpuAddress(MemoryConstants::pageSize * 1234, MemoryConstants::pageSize);
|
||||
EXPECT_NE(0u, addressRange.address);
|
||||
EXPECT_EQ(MemoryConstants::pageSize, addressRange.size);
|
||||
memoryManager->freeCpuAddress(addressRange);
|
||||
|
||||
VariableBackup<bool> backup(&SysCalls::failMmap, true);
|
||||
addressRange = memoryManager->reserveCpuAddress(0, 0);
|
||||
EXPECT_EQ(0u, addressRange.address);
|
||||
EXPECT_EQ(0u, addressRange.size);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, given57bAddressSpaceCpuAndGpuWhenAllocatingHostUSMThenAddressFromExtendedHeapIsPassedAsHintAndSetAsGpuAddressAndReservedAddress) {
|
||||
if (defaultHwInfo->capabilityTable.gpuAddressSpace < maxNBitValue(57)) {
|
||||
GTEST_SKIP();
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "shared/source/os_interface/windows/dxgi_wrapper.h"
|
||||
#include "shared/source/os_interface/windows/wddm/um_km_data_translator.h"
|
||||
#include "shared/source/os_interface/windows/windows_wrapper.h"
|
||||
#include "shared/source/release_helper/release_helper.h"
|
||||
#include "shared/source/utilities/tag_allocator.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/execution_environment_helper.h"
|
||||
@@ -29,7 +28,6 @@
|
||||
#include "shared/test/common/mocks/mock_gmm_page_table_mngr.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/mocks/mock_os_context.h"
|
||||
#include "shared/test/common/mocks/mock_product_helper.h"
|
||||
#include "shared/test/common/mocks/mock_release_helper.h"
|
||||
#include "shared/test/common/mocks/windows/mock_wddm_allocation.h"
|
||||
@@ -1318,6 +1316,13 @@ TEST_F(WddmMemoryManagerSimpleTest, givenWddmMemoryManagerWhenGpuAddressIsReserv
|
||||
memoryManager->freeGpuAddress(addressRange, 0);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerSimpleTest, givenWddmMemoryManagerWhenCpuAddressIsReservedAndFreedThenAddressRangeIsNonZero) {
|
||||
auto addressRange = memoryManager->reserveCpuAddress(0, 1234);
|
||||
EXPECT_NE(0u, addressRange.address);
|
||||
EXPECT_EQ(1234u, addressRange.size);
|
||||
memoryManager->freeCpuAddress(addressRange);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerSimpleTest, givenWddmMemoryManagerWhenAllocatingWithGpuVaThenNullptrIsReturned) {
|
||||
AllocationData allocationData;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user