feature: support SVM heap in reserveVirtualMem

Related-To: NEO-11981

Signed-off-by: Wenbin Lu <wenbin.lu@intel.com>
This commit is contained in:
Wenbin Lu
2024-08-28 23:04:40 +00:00
committed by Compute-Runtime-Automation
parent d79889c3b2
commit 93cde3ee12
16 changed files with 388 additions and 17 deletions

View File

@@ -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();

View File

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