Revert "feature: support SVM heap in reserveVirtualMem"

This reverts commit 93cde3ee12.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation
2024-09-03 17:16:54 +02:00
committed by Compute-Runtime-Automation
parent 37b7caa137
commit 99f62ac866
16 changed files with 17 additions and 388 deletions

View File

@@ -70,10 +70,7 @@ 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 {
@@ -251,8 +248,6 @@ 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;
virtual void freeCpuAddress(AddressRange addressRange) = 0;
static HeapIndex selectInternalHeap(bool useLocalMemory);
static HeapIndex selectExternalHeap(bool useLocalMemory);

View File

@@ -555,14 +555,6 @@ 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(reinterpret_cast<void *>(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,

View File

@@ -48,8 +48,6 @@ 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:

View File

@@ -95,7 +95,6 @@ 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);
}
@@ -1522,18 +1521,6 @@ 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(reinterpret_cast<void *>(requiredStartAddress), size, false);
if (ptr == MAP_FAILED) {
ptr = nullptr;
}
return {castToUint64(ptr), size};
}
void DrmMemoryManager::freeCpuAddress(AddressRange addressRange) {
osMemory->osReleaseCpuAddressRange(reinterpret_cast<void *>(addressRange.address), addressRange.size);
}
std::unique_lock<std::mutex> DrmMemoryManager::acquireAllocLock() {
return std::unique_lock<std::mutex>(this->allocMutex);
}

View File

@@ -8,7 +8,6 @@
#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>
@@ -71,8 +70,6 @@ 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);
@@ -181,7 +178,6 @@ 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;

View File

@@ -74,7 +74,6 @@ WddmMemoryManager::WddmMemoryManager(ExecutionEnvironment &executionEnvironment)
if (customAlignment > 0) {
alignmentSelector.addCandidateAlignment(customAlignment, false, AlignmentSelector::anyWastage);
}
osMemory = OSMemory::create();
initialized = true;
}
@@ -1026,15 +1025,6 @@ 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(reinterpret_cast<void *>(requiredStartAddress), size, false);
return {castToUint64(ptr), size};
}
void WddmMemoryManager::freeCpuAddress(AddressRange addressRange) {
osMemory->osReleaseCpuAddressRange(reinterpret_cast<void *>(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());

View File

@@ -8,7 +8,6 @@
#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>
@@ -70,8 +69,6 @@ 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{};
@@ -120,7 +117,6 @@ 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;
};

View File

@@ -131,17 +131,6 @@ 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 {

View File

@@ -530,8 +530,6 @@ 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; };

View File

@@ -1909,16 +1909,6 @@ 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);
@@ -3237,4 +3227,4 @@ TEST(MemoryManagerTest, givenIsCompressionSupportedForShareableThenReturnTrue) {
MockMemoryManager memoryManager;
EXPECT_TRUE(memoryManager.isCompressionSupportedForShareable(true));
EXPECT_TRUE(memoryManager.isCompressionSupportedForShareable(false));
}
}

View File

@@ -17,6 +17,7 @@
#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"
@@ -45,12 +46,6 @@
#include <memory>
#include <vector>
namespace NEO {
namespace SysCalls {
extern bool failMmap;
} // namespace SysCalls
} // namespace NEO
namespace {
using DrmMemoryManagerTest = Test<DrmMemoryManagerFixture>;
using DrmMemoryManagerWithLocalMemoryTest = Test<DrmMemoryManagerWithLocalMemoryFixture>;
@@ -7712,31 +7707,6 @@ 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();

View File

@@ -1317,13 +1317,6 @@ 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;