mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Enable xe_hp_sdv i915 config
Related-To: NEO-6149
Source location of Linux kernel DRM/i915 interface headers:
9641c49adb
Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
9276f689f8
commit
1a25cf0fe8
@ -49,7 +49,6 @@ if(I915_LOCAL_MEM_EXP)
|
||||
list(APPEND IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_info_tests_exp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_localmem_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_drm_tip.cpp
|
||||
)
|
||||
else()
|
||||
list(APPEND IGDRCL_SRCS_tests_os_interface_linux
|
||||
@ -61,6 +60,20 @@ if(NEO__LIBVA_FOUND)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_va_sharing_tests.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(SUPPORT_DG1 AND "${BRANCH_TYPE}" STREQUAL "")
|
||||
list(APPEND IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_helper_tests_dg1.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_prod_dg1.h
|
||||
)
|
||||
endif()
|
||||
|
||||
if(SUPPORT_XE_HP_SDV AND "${BRANCH_TYPE}" STREQUAL "")
|
||||
list(APPEND IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_helper_tests_xe_hp_sdv.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_os_interface_linux})
|
||||
endif()
|
||||
|
@ -68,18 +68,13 @@ class DrmMockCustomExp : public DrmMockCustom {
|
||||
}
|
||||
} break;
|
||||
default: {
|
||||
auto ret = ioctlGemCreateExt(request, arg);
|
||||
if (ret != 0) {
|
||||
std::cout << "unexpected IOCTL: " << std::hex << request << std::endl;
|
||||
UNRECOVERABLE_IF(true);
|
||||
}
|
||||
std::cout << "unexpected IOCTL: " << std::hex << request << std::endl;
|
||||
UNRECOVERABLE_IF(true);
|
||||
} break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ioctlGemCreateExt(unsigned long request, void *arg);
|
||||
|
||||
DrmMockCustomExp() : DrmMockCustom() {
|
||||
ioctlExp_cnt.reset();
|
||||
ioctlExp_expected.reset();
|
||||
|
@ -21,20 +21,15 @@ TEST(MemoryInfo, givenMemoryRegionQuerySupportedWhenQueryingMemoryInfoThenMemory
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
|
||||
for (auto onDrmTip : {false, true}) {
|
||||
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
|
||||
drm->queryMemoryRegionOnDrmTip = onDrmTip;
|
||||
drm->queryMemoryInfo();
|
||||
|
||||
drm->queryMemoryInfo();
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
|
||||
auto memoryInfo = static_cast<MemoryInfoImpl *>(drm->getMemoryInfo());
|
||||
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
EXPECT_EQ(2u, memoryInfo->getDrmRegionInfos().size());
|
||||
}
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
auto memoryInfo = static_cast<MemoryInfoImpl *>(drm->getMemoryInfo());
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
EXPECT_EQ(2u, memoryInfo->getDrmRegionInfos().size());
|
||||
}
|
||||
|
||||
TEST(MemoryInfo, givenMemoryRegionQueryNotSupportedWhenQueryingMemoryInfoThenMemoryInfoIsNotCreated) {
|
||||
@ -244,7 +239,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemWithExtensionsThenRetu
|
||||
auto ret = memoryInfo->createGemExt(drm.get(), ®ionInfo, 2, 1024, handle);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
EXPECT_EQ(1024u, drm->createExt.size);
|
||||
}
|
||||
|
||||
@ -267,7 +262,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemExtWithSingleRegionThe
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(drm.get(), 1, 1024, handle);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
EXPECT_EQ(I915_MEMORY_CLASS_DEVICE, drm->memRegions.memory_class);
|
||||
EXPECT_EQ(1024u, drm->createExt.size);
|
||||
}
|
||||
|
@ -148,19 +148,11 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWhenCreateBufferObj
|
||||
(1 << (MemoryBanks::getBankForLocalMemory(0) - 1)),
|
||||
1));
|
||||
ASSERT_NE(nullptr, bo);
|
||||
|
||||
EXPECT_EQ(2u, mock->ioctlCallsCount);
|
||||
|
||||
EXPECT_EQ(1u, mock->ioctlCallsCount);
|
||||
EXPECT_EQ(1u, mock->createExt.handle);
|
||||
EXPECT_EQ(size, mock->createExt.size);
|
||||
|
||||
EXPECT_EQ(I915_GEM_CREATE_EXT_SETPARAM, mock->setparamRegion.base.name);
|
||||
|
||||
auto regionParam = mock->setparamRegion.param;
|
||||
EXPECT_EQ(0u, regionParam.handle);
|
||||
EXPECT_EQ(1u, regionParam.size);
|
||||
EXPECT_EQ(I915_OBJECT_PARAM | I915_PARAM_MEMORY_REGIONS, regionParam.param);
|
||||
|
||||
EXPECT_EQ(1u, mock->numRegions);
|
||||
auto memRegions = mock->memRegions;
|
||||
EXPECT_EQ(I915_MEMORY_CLASS_DEVICE, memRegions.memory_class);
|
||||
EXPECT_EQ(0u, memRegions.memory_instance);
|
||||
@ -1087,28 +1079,6 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenAllocationWithUnifiedMemoryAllocati
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerLocalMemoryTest, whenPrintBOCreateDestroyResultFlagIsSetWhileCreatingBufferObjectInMemoryRegionThenDebugInformationIsPrinted) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.PrintBOCreateDestroyResult.set(true);
|
||||
DebugManager.flags.EnableLocalMemory.set(1);
|
||||
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
auto gpuAddress = 0x1234u;
|
||||
auto size = MemoryConstants::pageSize64k;
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto bo = std::unique_ptr<BufferObject>(memoryManager->createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, (1 << (MemoryBanks::getBankForLocalMemory(0) - 1)), 1));
|
||||
ASSERT_NE(nullptr, bo);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 65536, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_SETPARAM has returned: 0 BO-1 with size: 65536\n");
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
}
|
||||
|
||||
TEST(ResidencyTests, whenBuffersIsCreatedWithMakeResidentFlagThenItSuccessfulyCreates) {
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_exp.h"
|
||||
#include "opencl/test/unit_test/os_interface/linux/drm_mock_exp.h"
|
||||
|
||||
// clang-format off
|
||||
#include "shared/source/os_interface/linux/drm_tip.h"
|
||||
// clang-format on
|
||||
|
||||
void DrmMockExp::handleQueryItemOnDrmTip(drm_i915_query_item *queryItem) {
|
||||
switch (queryItem->query_id) {
|
||||
case DRM_I915_QUERY_MEMORY_REGIONS:
|
||||
if (queryMemoryRegionInfoSuccessCount == 0) {
|
||||
queryItem->length = -EINVAL;
|
||||
} else {
|
||||
queryMemoryRegionInfoSuccessCount--;
|
||||
auto numberOfLocalMemories = 1u;
|
||||
auto numberOfRegions = 1u + numberOfLocalMemories;
|
||||
int regionInfoSize = sizeof(DRM_TIP::drm_i915_query_memory_regions) + numberOfRegions * sizeof(DRM_TIP::drm_i915_memory_region_info);
|
||||
if (queryItem->length == 0) {
|
||||
queryItem->length = regionInfoSize;
|
||||
} else {
|
||||
EXPECT_EQ(regionInfoSize, queryItem->length);
|
||||
auto queryMemoryRegionInfo = reinterpret_cast<DRM_TIP::drm_i915_query_memory_regions *>(queryItem->data_ptr);
|
||||
EXPECT_EQ(0u, queryMemoryRegionInfo->num_regions);
|
||||
queryMemoryRegionInfo->num_regions = numberOfRegions;
|
||||
queryMemoryRegionInfo->regions[0].region.memory_class = I915_MEMORY_CLASS_SYSTEM;
|
||||
queryMemoryRegionInfo->regions[0].region.memory_instance = 1;
|
||||
queryMemoryRegionInfo->regions[0].probed_size = 2 * MemoryConstants::gigaByte;
|
||||
queryMemoryRegionInfo->regions[1].region.memory_class = I915_MEMORY_CLASS_DEVICE;
|
||||
queryMemoryRegionInfo->regions[1].region.memory_instance = 1;
|
||||
queryMemoryRegionInfo->regions[1].probed_size = 2 * MemoryConstants::gigaByte;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int DrmMockCustomExp::ioctlGemCreateExt(unsigned long request, void *arg) {
|
||||
if (request == DRM_IOCTL_I915_GEM_CREATE_EXT) {
|
||||
auto createExtParams = reinterpret_cast<DRM_TIP::drm_i915_gem_create_ext *>(arg);
|
||||
createExtSize = createExtParams->size;
|
||||
createExtHandle = createExtParams->handle;
|
||||
createExtExtensions = createExtParams->extensions;
|
||||
ioctlExp_cnt.gemCreateExt++;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
@ -23,12 +23,11 @@ class DrmMockExp : public DrmMock {
|
||||
|
||||
uint32_t i915QuerySuccessCount = std::numeric_limits<uint32_t>::max();
|
||||
uint32_t queryMemoryRegionInfoSuccessCount = std::numeric_limits<uint32_t>::max();
|
||||
bool queryMemoryRegionOnDrmTip = false;
|
||||
|
||||
//DRM_IOCTL_I915_GEM_CREATE_EXT
|
||||
drm_i915_gem_create_ext createExt{};
|
||||
drm_i915_gem_create_ext_setparam setparamRegion{};
|
||||
drm_i915_gem_memory_class_instance memRegions{};
|
||||
uint32_t numRegions = 0;
|
||||
int gemCreateExtRetVal = 0;
|
||||
|
||||
//DRM_IOCTL_I915_GEM_MMAP_OFFSET
|
||||
@ -47,52 +46,19 @@ class DrmMockExp : public DrmMock {
|
||||
return EINVAL;
|
||||
}
|
||||
for (auto i = 0u; i < query->num_items; i++) {
|
||||
if (queryMemoryRegionOnDrmTip) {
|
||||
handleQueryItemOnDrmTip(reinterpret_cast<drm_i915_query_item *>(query->items_ptr) + i);
|
||||
} else {
|
||||
handleQueryItem(reinterpret_cast<drm_i915_query_item *>(query->items_ptr) + i);
|
||||
}
|
||||
handleQueryItem(reinterpret_cast<drm_i915_query_item *>(query->items_ptr) + i);
|
||||
}
|
||||
return 0;
|
||||
} else if (request == DRM_IOCTL_I915_GEM_CREATE_EXT) {
|
||||
auto createExtParams = static_cast<drm_i915_gem_create_ext *>(arg);
|
||||
if (createExtParams->size == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
this->createExt.size = createExtParams->size;
|
||||
this->createExt.handle = createExtParams->handle = 1u;
|
||||
auto extensions = reinterpret_cast<drm_i915_gem_create_ext_setparam *>(createExtParams->extensions);
|
||||
if (extensions == nullptr) {
|
||||
return EINVAL;
|
||||
}
|
||||
this->setparamRegion = *extensions;
|
||||
if (this->setparamRegion.base.name != I915_GEM_CREATE_EXT_SETPARAM) {
|
||||
return EINVAL;
|
||||
}
|
||||
if ((this->setparamRegion.param.size == 0) ||
|
||||
(this->setparamRegion.param.param != (I915_OBJECT_PARAM | I915_PARAM_MEMORY_REGIONS))) {
|
||||
return EINVAL;
|
||||
}
|
||||
auto data = reinterpret_cast<drm_i915_gem_memory_class_instance *>(this->setparamRegion.param.data);
|
||||
if (data == nullptr) {
|
||||
return EINVAL;
|
||||
}
|
||||
this->memRegions = *data;
|
||||
if ((this->memRegions.memory_class != I915_MEMORY_CLASS_SYSTEM) && (this->memRegions.memory_class != I915_MEMORY_CLASS_DEVICE)) {
|
||||
return EINVAL;
|
||||
}
|
||||
return gemCreateExtRetVal;
|
||||
|
||||
} else if (request == DRM_IOCTL_I915_GEM_MMAP_OFFSET) {
|
||||
auto mmap_arg = static_cast<drm_i915_gem_mmap_offset *>(arg);
|
||||
mmapOffsetFlagsReceived = mmap_arg->flags;
|
||||
mmap_arg->offset = offset;
|
||||
return mmapOffsetRetVal;
|
||||
}
|
||||
return -1;
|
||||
return handleKernelSpecificRequests(request, arg);
|
||||
}
|
||||
|
||||
void handleQueryItem(drm_i915_query_item *queryItem) {
|
||||
virtual void handleQueryItem(drm_i915_query_item *queryItem) {
|
||||
switch (queryItem->query_id) {
|
||||
case DRM_I915_QUERY_MEMORY_REGIONS:
|
||||
if (queryMemoryRegionInfoSuccessCount == 0) {
|
||||
@ -121,5 +87,28 @@ class DrmMockExp : public DrmMock {
|
||||
}
|
||||
}
|
||||
|
||||
void handleQueryItemOnDrmTip(drm_i915_query_item *queryItem);
|
||||
virtual int handleKernelSpecificRequests(unsigned long request, void *arg) {
|
||||
if (request == DRM_IOCTL_I915_GEM_CREATE_EXT) {
|
||||
auto createExtParams = static_cast<drm_i915_gem_create_ext *>(arg);
|
||||
if (createExtParams->size == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
createExtParams->handle = 1u;
|
||||
this->createExt = *createExtParams;
|
||||
auto extMemRegions = reinterpret_cast<drm_i915_gem_create_ext_memory_regions *>(createExt.extensions);
|
||||
if (extMemRegions->base.name != I915_GEM_CREATE_EXT_MEMORY_REGIONS) {
|
||||
return EINVAL;
|
||||
}
|
||||
this->numRegions = extMemRegions->num_regions;
|
||||
this->memRegions = *reinterpret_cast<drm_i915_gem_memory_class_instance *>(extMemRegions->regions);
|
||||
if (this->numRegions == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
if ((this->memRegions.memory_class != I915_MEMORY_CLASS_SYSTEM) && (this->memRegions.memory_class != I915_MEMORY_CLASS_DEVICE)) {
|
||||
return EINVAL;
|
||||
}
|
||||
return gemCreateExtRetVal;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
78
opencl/test/unit_test/os_interface/linux/drm_mock_prod_dg1.h
Normal file
78
opencl/test/unit_test/os_interface/linux/drm_mock_prod_dg1.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "opencl/test/unit_test/os_interface/linux/drm_mock_exp.h"
|
||||
|
||||
namespace PROD_DG1 {
|
||||
#undef DRM_IOCTL_I915_GEM_CREATE_EXT
|
||||
#undef __I915_EXEC_UNKNOWN_FLAGS
|
||||
#include "third_party/uapi/dg1/drm/i915_drm.h"
|
||||
} // namespace PROD_DG1
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
class DrmMockProdDg1 : public DrmMockExp {
|
||||
public:
|
||||
DrmMockProdDg1(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockProdDg1(rootDeviceEnvironment, defaultHwInfo.get()) {}
|
||||
DrmMockProdDg1(RootDeviceEnvironment &rootDeviceEnvironment, const HardwareInfo *inputHwInfo) : DrmMockExp(rootDeviceEnvironment) {
|
||||
rootDeviceEnvironment.setHwInfo(inputHwInfo);
|
||||
}
|
||||
|
||||
void handleQueryItem(drm_i915_query_item *queryItem) override {
|
||||
switch (queryItem->query_id) {
|
||||
case DRM_I915_QUERY_MEMORY_REGIONS:
|
||||
if (queryMemoryRegionInfoSuccessCount == 0) {
|
||||
queryItem->length = -EINVAL;
|
||||
} else {
|
||||
queryMemoryRegionInfoSuccessCount--;
|
||||
auto numberOfLocalMemories = 1u;
|
||||
auto numberOfRegions = 1u + numberOfLocalMemories;
|
||||
int regionInfoSize = sizeof(PROD_DG1::drm_i915_query_memory_regions) + numberOfRegions * sizeof(PROD_DG1::drm_i915_memory_region_info);
|
||||
if (queryItem->length == 0) {
|
||||
queryItem->length = regionInfoSize;
|
||||
} else {
|
||||
EXPECT_EQ(regionInfoSize, queryItem->length);
|
||||
auto queryMemoryRegionInfo = reinterpret_cast<PROD_DG1::drm_i915_query_memory_regions *>(queryItem->data_ptr);
|
||||
EXPECT_EQ(0u, queryMemoryRegionInfo->num_regions);
|
||||
queryMemoryRegionInfo->num_regions = numberOfRegions;
|
||||
queryMemoryRegionInfo->regions[0].region.memory_class = I915_MEMORY_CLASS_SYSTEM;
|
||||
queryMemoryRegionInfo->regions[0].region.memory_instance = 1;
|
||||
queryMemoryRegionInfo->regions[0].probed_size = 2 * MemoryConstants::gigaByte;
|
||||
queryMemoryRegionInfo->regions[1].region.memory_class = I915_MEMORY_CLASS_DEVICE;
|
||||
queryMemoryRegionInfo->regions[1].region.memory_instance = 1;
|
||||
queryMemoryRegionInfo->regions[1].probed_size = 2 * MemoryConstants::gigaByte;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int handleKernelSpecificRequests(unsigned long request, void *arg) override {
|
||||
if (request == DRM_IOCTL_I915_GEM_CREATE_EXT) {
|
||||
auto createExtParams = static_cast<drm_i915_gem_create_ext *>(arg);
|
||||
if (createExtParams->size == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
createExtParams->handle = 1u;
|
||||
this->createExt = *createExtParams;
|
||||
auto setparamRegion = reinterpret_cast<PROD_DG1::drm_i915_gem_create_ext_setparam *>(createExtParams->extensions);
|
||||
if (setparamRegion->base.name != I915_GEM_CREATE_EXT_SETPARAM) {
|
||||
return EINVAL;
|
||||
}
|
||||
auto regionParam = reinterpret_cast<PROD_DG1::drm_i915_gem_object_param *>(&setparamRegion->param);
|
||||
if (regionParam->param != (I915_OBJECT_PARAM | I915_PARAM_MEMORY_REGIONS)) {
|
||||
return EINVAL;
|
||||
}
|
||||
numRegions = regionParam->size;
|
||||
memRegions = *reinterpret_cast<drm_i915_gem_memory_class_instance *>(regionParam->data);
|
||||
return gemCreateExtRetVal;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
};
|
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/os_interface/linux/local_memory_helper.h"
|
||||
#include "shared/source/os_interface/linux/memory_info_impl.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
|
||||
#include "opencl/test/unit_test/os_interface/linux/drm_mock_exp.h"
|
||||
#include "opencl/test/unit_test/os_interface/linux/drm_mock_prod_dg1.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using LocalMemoryHelperTestsDg1 = ::testing::Test;
|
||||
|
||||
DG1TEST_F(LocalMemoryHelperTestsDg1, givenDg1WhenCreateGemExtThenReturnCorrectValue) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probed_size = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probed_size = 16 * GB;
|
||||
|
||||
auto localMemHelper = LocalMemoryHelper::get(defaultHwInfo->platform.eProductFamily);
|
||||
uint32_t handle = 0;
|
||||
auto ret = localMemHelper->createGemExt(drm.get(), ®ionInfo[1], 1, 1024, handle);
|
||||
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(1u, drm->numRegions);
|
||||
EXPECT_EQ(1024u, drm->createExt.size);
|
||||
EXPECT_EQ(I915_MEMORY_CLASS_DEVICE, drm->memRegions.memory_class);
|
||||
}
|
||||
|
||||
DG1TEST_F(LocalMemoryHelperTestsDg1, givenDg1WithDrmTipWhenCreateGemExtWithDebugFlagThenPrintDebugInfo) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.PrintBOCreateDestroyResult.set(true);
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto localMemHelper = LocalMemoryHelper::get(defaultHwInfo->platform.eProductFamily);
|
||||
uint32_t handle = 0;
|
||||
|
||||
auto ret = localMemHelper->createGemExt(drm.get(), ®ionInfo[1], 1, 1024, handle);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: 0 BO-1 with size: 1024\n");
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
EXPECT_EQ(0u, ret);
|
||||
}
|
||||
|
||||
DG1TEST_F(LocalMemoryHelperTestsDg1, givenDg1WhenCreateGemExtWithDebugFlagThenPrintDebugInfo) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.PrintBOCreateDestroyResult.set(true);
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmMockProdDg1>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto localMemHelper = LocalMemoryHelper::get(defaultHwInfo->platform.eProductFamily);
|
||||
uint32_t handle = 0;
|
||||
|
||||
auto ret = localMemHelper->createGemExt(drm.get(), ®ionInfo[1], 1, 1024, handle);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_SETPARAM has returned: 0 BO-1 with size: 1024\n");
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
EXPECT_EQ(0u, ret);
|
||||
}
|
||||
|
||||
DG1TEST_F(LocalMemoryHelperTestsDg1, givenDg1AndMemoryRegionQuerySupportedWhenQueryingMemoryInfoThenMemoryInfoIsCreatedWithRegions) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
|
||||
auto drm = std::make_unique<DrmMockProdDg1>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
|
||||
drm->queryMemoryInfo();
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
|
||||
auto memoryInfo = static_cast<MemoryInfoImpl *>(drm->getMemoryInfo());
|
||||
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
EXPECT_EQ(2u, memoryInfo->getDrmRegionInfos().size());
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/os_interface/linux/local_memory_helper.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
|
||||
#include "opencl/test/unit_test/os_interface/linux/drm_mock_exp.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using LocalMemoryHelperTestsXeHpSdv = ::testing::Test;
|
||||
|
||||
XEHPTEST_F(LocalMemoryHelperTestsXeHpSdv, givenXeHpSdvWhenCreateGemExtThenReturnCorrectValue) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probed_size = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probed_size = 16 * GB;
|
||||
|
||||
auto localMemHelper = LocalMemoryHelper::get(defaultHwInfo->platform.eProductFamily);
|
||||
uint32_t handle = 0;
|
||||
auto ret = localMemHelper->createGemExt(drm.get(), ®ionInfo[1], 1, 1024, handle);
|
||||
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(1u, drm->numRegions);
|
||||
EXPECT_EQ(1024u, drm->createExt.size);
|
||||
EXPECT_EQ(I915_MEMORY_CLASS_DEVICE, drm->memRegions.memory_class);
|
||||
}
|
||||
|
||||
XEHPTEST_F(LocalMemoryHelperTestsXeHpSdv, givenXeHpSdvWhenCreateGemExtWithDebugFlagThenPrintDebugInfo) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.PrintBOCreateDestroyResult.set(true);
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto localMemHelper = LocalMemoryHelper::get(defaultHwInfo->platform.eProductFamily);
|
||||
uint32_t handle = 0;
|
||||
localMemHelper->createGemExt(drm.get(), ®ionInfo[1], 1, 1024, handle);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: 0 BO-1 with size: 1024\n");
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
}
|
Reference in New Issue
Block a user