mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Test local memory DRM allocations
Signed-off-by: Daniel Chabrowski daniel.chabrowski@intel.com Related-To: NEO-6591
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
50efd09ad8
commit
090a79f3f9
@@ -18,7 +18,6 @@ set(IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_mapper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_manager_localmem_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_os_memory_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_residency_handler_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_system_info_tests.cpp
|
||||
@@ -38,6 +37,12 @@ set(IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/self_lib_lin.cpp
|
||||
)
|
||||
|
||||
if("${BRANCH_TYPE}" STREQUAL "")
|
||||
list(APPEND IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_localmem_upstream_tests.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NEO_ENABLE_i915_PRELIM_DETECTION)
|
||||
list(APPEND IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_fixture_context.cpp
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/os_interface/linux/ioctl_strings.h"
|
||||
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
|
||||
|
||||
class DrmMockCustomImpl : public DrmMockCustom {
|
||||
@@ -49,7 +50,7 @@ class DrmMockCustomImpl : public DrmMockCustom {
|
||||
ioctlImpl_cnt.gemCreateExt++;
|
||||
} break;
|
||||
default: {
|
||||
std::cout << "unexpected IOCTL: " << std::hex << request << std::endl;
|
||||
std::cout << "unexpected IOCTL: " << NEO::IoctlToStringHelper::getIoctlString(request) << std::endl;
|
||||
UNRECOVERABLE_IF(true);
|
||||
} break;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -49,14 +49,6 @@ class DrmMemoryManagerLocalMemoryTest : public ::testing::Test {
|
||||
memoryManager = std::make_unique<TestedDrmMemoryManager>(localMemoryEnabled, false, false, *executionEnvironment);
|
||||
}
|
||||
|
||||
bool isAllocationWithinHeap(const GraphicsAllocation &allocation, HeapIndex heap) {
|
||||
const auto allocationStart = allocation.getGpuAddress();
|
||||
const auto allocationEnd = allocationStart + allocation.getUnderlyingBufferSize();
|
||||
const auto heapStart = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(heap));
|
||||
const auto heapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(heap));
|
||||
return heapStart <= allocationStart && allocationEnd <= heapEnd;
|
||||
}
|
||||
|
||||
protected:
|
||||
DebugManagerStateRestore restorer{};
|
||||
ExecutionEnvironment *executionEnvironment = nullptr;
|
||||
@@ -10,9 +10,11 @@
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/libult/linux/drm_mock_helper.h"
|
||||
#include "shared/test/common/libult/linux/drm_query_mock.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/os_interface/linux/drm_memory_manager_tests.h"
|
||||
|
||||
#include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_prelim.h"
|
||||
#include "opencl/test/unit_test/os_interface/linux/drm_mock_memory_info.h"
|
||||
@@ -21,31 +23,42 @@
|
||||
|
||||
class DrmMemoryManagerLocalMemoryPrelimTest : public ::testing::Test {
|
||||
public:
|
||||
DrmQueryMock *mock;
|
||||
|
||||
void SetUp() override {
|
||||
executionEnvironment = new ExecutionEnvironment;
|
||||
DebugManager.flags.EnableLocalMemory.set(localMemoryEnabled);
|
||||
|
||||
executionEnvironment = new ExecutionEnvironment();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get());
|
||||
|
||||
mock = new DrmQueryMock(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]);
|
||||
mock->memoryInfo.reset(new MockExtendedMemoryInfo());
|
||||
auto memoryInfo = new MockExtendedMemoryInfo();
|
||||
mock->memoryInfo.reset(memoryInfo);
|
||||
|
||||
auto &multiTileArchInfo = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getMutableHardwareInfo()->gtSystemInfo.MultiTileArchInfo;
|
||||
multiTileArchInfo.TileCount = (memoryInfo->getDrmRegionInfos().size() - 1);
|
||||
multiTileArchInfo.IsValid = (multiTileArchInfo.TileCount > 0);
|
||||
|
||||
mock->queryEngineInfo();
|
||||
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u);
|
||||
|
||||
memoryManager = new TestedDrmMemoryManager(localMemoryEnabled, false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
|
||||
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, rootDeviceIndex));
|
||||
constexpr bool localMemoryEnabled = true;
|
||||
memoryManager = std::make_unique<TestedDrmMemoryManager>(localMemoryEnabled, false, false, *executionEnvironment);
|
||||
}
|
||||
|
||||
protected:
|
||||
DebugManagerStateRestore restorer{};
|
||||
ExecutionEnvironment *executionEnvironment;
|
||||
ExecutionEnvironment *executionEnvironment{nullptr};
|
||||
DrmQueryMock *mock{nullptr};
|
||||
std::unique_ptr<MockDevice> device;
|
||||
std::unique_ptr<TestedDrmMemoryManager> memoryManager;
|
||||
const uint32_t rootDeviceIndex = 0u;
|
||||
TestedDrmMemoryManager *memoryManager{nullptr};
|
||||
|
||||
constexpr static uint32_t rootDeviceIndex{0u};
|
||||
constexpr static bool localMemoryEnabled{true};
|
||||
};
|
||||
|
||||
class DrmMemoryManagerLocalMemoryWithCustomPrelimMockTest : public ::testing::Test {
|
||||
@@ -55,6 +68,7 @@ class DrmMemoryManagerLocalMemoryWithCustomPrelimMockTest : public ::testing::Te
|
||||
executionEnvironment = new ExecutionEnvironment;
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
||||
|
||||
mock = new DrmMockCustomPrelim(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
|
||||
@@ -69,3 +83,27 @@ class DrmMemoryManagerLocalMemoryWithCustomPrelimMockTest : public ::testing::Te
|
||||
DrmMockCustomPrelim *mock;
|
||||
ExecutionEnvironment *executionEnvironment;
|
||||
};
|
||||
|
||||
class DrmMemoryManagerFixturePrelim : public DrmMemoryManagerFixture {
|
||||
public:
|
||||
void SetUp() override {
|
||||
regionInfo.resize(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 1};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, DrmMockHelper::getEngineOrMemoryInstanceValue(0, 0)};
|
||||
|
||||
MemoryManagementFixture::SetUp();
|
||||
executionEnvironment = MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), numRootDevices - 1);
|
||||
mock = new DrmMockCustomPrelim(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
|
||||
DrmMemoryManagerFixture::SetUp(mock, true);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
mock->testIoctls();
|
||||
DrmMemoryManagerFixture::TearDown();
|
||||
}
|
||||
|
||||
std::vector<MemoryRegion> regionInfo;
|
||||
DrmMockCustomPrelim *mock;
|
||||
};
|
||||
|
||||
@@ -7,25 +7,30 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
|
||||
const std::vector<MemoryRegion> memoryRegions = {
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
const std::vector<NEO::MemoryRegion> memoryRegions = {
|
||||
{{I915_MEMORY_CLASS_SYSTEM, 0}, 64 * GB, 0},
|
||||
{{I915_MEMORY_CLASS_DEVICE, 0}, 8 * GB, 0}};
|
||||
|
||||
struct MockMemoryInfo : public MemoryInfo {
|
||||
struct MockMemoryInfo : public NEO::MemoryInfo {
|
||||
MockMemoryInfo() : MemoryInfo(memoryRegions) {}
|
||||
~MockMemoryInfo() override = default;
|
||||
};
|
||||
|
||||
const std::vector<MemoryRegion> extendedMemoryRegions = {
|
||||
const std::vector<NEO::MemoryRegion> extendedMemoryRegions = {
|
||||
{{I915_MEMORY_CLASS_SYSTEM, 1}, 64 * GB, 0},
|
||||
{{I915_MEMORY_CLASS_DEVICE, 0x100}, 8 * GB, 0},
|
||||
{{I915_MEMORY_CLASS_DEVICE, 0x200}, 8 * GB, 0},
|
||||
{{I915_MEMORY_CLASS_DEVICE, 0x400}, 8 * GB, 0},
|
||||
{{I915_MEMORY_CLASS_DEVICE, 0x800}, 8 * GB, 0}};
|
||||
|
||||
struct MockExtendedMemoryInfo : public MemoryInfo {
|
||||
struct MockExtendedMemoryInfo : public NEO::MemoryInfo {
|
||||
MockExtendedMemoryInfo() : MemoryInfo(extendedMemoryRegions) {}
|
||||
~MockExtendedMemoryInfo() override = default;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user