mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 05:56:36 +08:00
feature usm: allocate shared USM in heap extended
Related-To: NEO-7665 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
fa2bb2509b
commit
03ed1e1e12
@@ -19,6 +19,7 @@
|
||||
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
|
||||
#include "shared/test/common/mocks/linux/mock_ioctl_helper.h"
|
||||
#include "shared/test/common/mocks/mock_allocation_properties.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/mocks/mock_gfx_partition.h"
|
||||
@@ -6315,3 +6316,72 @@ TEST_F(DrmMemoryManagerTest, given48bAddressSpaceCpuAnd57bGpuWhenAllocatingHostU
|
||||
EXPECT_NE(hostUSM->getGpuAddress(), gpuAddress);
|
||||
memoryManager->freeGraphicsMemory(hostUSM);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, given57bAddressSpaceCpuAndGpuWhenAllocatingSharedUSMThenAddressFromExtendedHeapIsPassedAsHintAndSetAsGpuAddressAndReservedAddress) {
|
||||
if (defaultHwInfo->capabilityTable.gpuAddressSpace < maxNBitValue(57)) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
VariableBackup<bool> backupCaptureExtendedPointers(&SysCalls::mmapCaptureExtendedPointers, true);
|
||||
VariableBackup<bool> backupAllowExtendedPointers(&SysCalls::mmapAllowExtendedPointers, true);
|
||||
SysCalls::mmapCapturedExtendedPointers.clear();
|
||||
std::vector<MemoryRegion> regionInfo(1);
|
||||
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
|
||||
auto &drm = static_cast<DrmMockCustom &>(memoryManager->getDrm(mockRootDeviceIndex));
|
||||
drm.memoryInfo.reset(new MemoryInfo(regionInfo, drm));
|
||||
drm.ioctlHelper = std::make_unique<MockIoctlHelper>(drm);
|
||||
|
||||
AllocationData allocationData{};
|
||||
allocationData.size = MemoryConstants::cacheLineSize;
|
||||
allocationData.rootDeviceIndex = mockRootDeviceIndex;
|
||||
allocationData.alignment = MemoryConstants::pageSize;
|
||||
allocationData.useMmapObject = true;
|
||||
|
||||
auto sharedUSM = memoryManager->createSharedUnifiedMemoryAllocation(allocationData);
|
||||
EXPECT_NE(nullptr, sharedUSM);
|
||||
|
||||
EXPECT_EQ(2u, SysCalls::mmapCapturedExtendedPointers.size());
|
||||
auto gpuAddress = reinterpret_cast<uint64_t>(SysCalls::mmapCapturedExtendedPointers[0]);
|
||||
SysCalls::mmapCapturedExtendedPointers.clear();
|
||||
auto gmmHelper = memoryManager->getGmmHelper(mockRootDeviceIndex);
|
||||
EXPECT_LE(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapBase(HeapIndex::HEAP_EXTENDED), gmmHelper->decanonize(gpuAddress));
|
||||
EXPECT_GT(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED), gmmHelper->decanonize(gpuAddress));
|
||||
|
||||
EXPECT_EQ(sharedUSM->getGpuAddress(), gpuAddress);
|
||||
EXPECT_EQ(sharedUSM->getReservedAddressPtr(), reinterpret_cast<void *>(gpuAddress));
|
||||
memoryManager->freeGraphicsMemory(sharedUSM);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, given48bAddressSpaceCpuAnd57bGpuWhenAllocatingSharedUSMThenAddressFromExtendedHeapIsPassedAsHintAndThenIgnored) {
|
||||
if (defaultHwInfo->capabilityTable.gpuAddressSpace < maxNBitValue(57)) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
VariableBackup<bool> backupCaptureExtendedPointers(&SysCalls::mmapCaptureExtendedPointers, true);
|
||||
VariableBackup<bool> backupAllowExtendedPointers(&SysCalls::mmapAllowExtendedPointers, false);
|
||||
SysCalls::mmapCapturedExtendedPointers.clear();
|
||||
std::vector<MemoryRegion> regionInfo(1);
|
||||
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
|
||||
auto &drm = static_cast<DrmMockCustom &>(memoryManager->getDrm(mockRootDeviceIndex));
|
||||
drm.memoryInfo.reset(new MemoryInfo(regionInfo, drm));
|
||||
drm.ioctlHelper = std::make_unique<MockIoctlHelper>(drm);
|
||||
|
||||
AllocationData allocationData{};
|
||||
allocationData.size = MemoryConstants::cacheLineSize;
|
||||
allocationData.rootDeviceIndex = mockRootDeviceIndex;
|
||||
allocationData.alignment = MemoryConstants::pageSize;
|
||||
allocationData.useMmapObject = true;
|
||||
|
||||
auto sharedUSM = memoryManager->createSharedUnifiedMemoryAllocation(allocationData);
|
||||
EXPECT_NE(nullptr, sharedUSM);
|
||||
|
||||
EXPECT_EQ(1u, SysCalls::mmapCapturedExtendedPointers.size());
|
||||
auto gpuAddress = reinterpret_cast<uint64_t>(SysCalls::mmapCapturedExtendedPointers[0]);
|
||||
SysCalls::mmapCapturedExtendedPointers.clear();
|
||||
auto gmmHelper = memoryManager->getGmmHelper(mockRootDeviceIndex);
|
||||
EXPECT_LE(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapBase(HeapIndex::HEAP_EXTENDED), gmmHelper->decanonize(gpuAddress));
|
||||
EXPECT_GT(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED), gmmHelper->decanonize(gpuAddress));
|
||||
|
||||
EXPECT_NE(sharedUSM->getGpuAddress(), gpuAddress);
|
||||
memoryManager->freeGraphicsMemory(sharedUSM);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "shared/test/common/helpers/test_files.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/libult/linux/drm_mock.h"
|
||||
#include "shared/test/common/mocks/linux/mock_ioctl_helper.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h"
|
||||
@@ -1415,21 +1416,6 @@ TEST(DrmWrapperTest, WhenGettingRevisionParamValueThenIoctlHelperIsNotNeeded) {
|
||||
EXPECT_EQ(getDrmParamValue(DrmParam::ParamRevision, nullptr), static_cast<int>(I915_PARAM_REVISION));
|
||||
}
|
||||
|
||||
class MockIoctlHelper : public IoctlHelperPrelim20 {
|
||||
public:
|
||||
using IoctlHelperPrelim20::IoctlHelperPrelim20;
|
||||
unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) const override {
|
||||
return ioctlRequestValue;
|
||||
};
|
||||
|
||||
int getDrmParamValue(DrmParam drmParam) const override {
|
||||
return drmParamValue;
|
||||
}
|
||||
|
||||
unsigned int ioctlRequestValue = 1234u;
|
||||
int drmParamValue = 1234;
|
||||
};
|
||||
|
||||
TEST(DrmWrapperTest, whenGettingDrmParamOrIoctlRequestValueThenUseIoctlHelperWhenAvailable) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
Reference in New Issue
Block a user