mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
test: move gmm client context initialize tests to single place
Related-To: NEO-11080 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
0696340d3d
commit
4e90d80bae
@@ -20,7 +20,6 @@ add_executable(igdrcl_${target_name}
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/main_linux_dll.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/main_linux_dll.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_os_layer.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/mock_os_layer.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_os_layer.h
|
${CMAKE_CURRENT_SOURCE_DIR}/mock_os_layer.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/os_interface_linux_tests.cpp
|
|
||||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/virtual_file_system_listener.cpp
|
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/virtual_file_system_listener.cpp
|
||||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_get_staging_buffer_size.cpp
|
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_get_staging_buffer_size.cpp
|
||||||
${NEO_SHARED_DIRECTORY}/os_interface/linux/sys_calls_linux.cpp
|
${NEO_SHARED_DIRECTORY}/os_interface/linux/sys_calls_linux.cpp
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2020-2025 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
|
|
||||||
#include "shared/source/gmm_helper/gmm_helper.h"
|
|
||||||
#include "shared/source/os_interface/os_interface.h"
|
|
||||||
#include "shared/test/common/helpers/default_hw_info.h"
|
|
||||||
#include "shared/test/common/helpers/variable_backup.h"
|
|
||||||
#include "shared/test/common/libult/linux/drm_mock.h"
|
|
||||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
|
||||||
#include "shared/test/common/test_macros/test.h"
|
|
||||||
|
|
||||||
#include "opencl/test/unit_test/linux/mock_os_layer.h"
|
|
||||||
|
|
||||||
namespace NEO {
|
|
||||||
extern GMM_INIT_IN_ARGS passedInputArgs;
|
|
||||||
extern bool copyInputArgs;
|
|
||||||
|
|
||||||
TEST(OsInterfaceTest, whenOsInterfaceSetupsGmmInputArgsThenFileDescriptorIsSetWithValueOfAdapterBdf) {
|
|
||||||
MockExecutionEnvironment executionEnvironment;
|
|
||||||
auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get();
|
|
||||||
auto osInterface = new OSInterface();
|
|
||||||
rootDeviceEnvironment->osInterface.reset(osInterface);
|
|
||||||
|
|
||||||
auto drm = new DrmMock(fakeFd, *rootDeviceEnvironment);
|
|
||||||
drm->setPciPath("0000:01:23.4");
|
|
||||||
EXPECT_EQ(0, drm->queryAdapterBDF());
|
|
||||||
|
|
||||||
osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
|
|
||||||
|
|
||||||
GMM_INIT_IN_ARGS gmmInputArgs = {};
|
|
||||||
EXPECT_EQ(0u, gmmInputArgs.FileDescriptor);
|
|
||||||
osInterface->getDriverModel()->setGmmInputArgs(&gmmInputArgs);
|
|
||||||
EXPECT_NE(0u, gmmInputArgs.FileDescriptor);
|
|
||||||
|
|
||||||
ADAPTER_BDF expectedAdapterBDF{};
|
|
||||||
expectedAdapterBDF.Bus = 0x1;
|
|
||||||
expectedAdapterBDF.Device = 0x23;
|
|
||||||
expectedAdapterBDF.Function = 0x4;
|
|
||||||
EXPECT_EQ(expectedAdapterBDF.Data, gmmInputArgs.FileDescriptor);
|
|
||||||
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, gmmInputArgs.ClientType);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(GmmHelperTest, whenInitializeGmmClientContextWithoutOsInterfaceThenPassedFileDescriptorIsZeroed) {
|
|
||||||
MockExecutionEnvironment executionEnvironment{};
|
|
||||||
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
|
|
||||||
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(©InputArgs, true);
|
|
||||||
|
|
||||||
uint32_t expectedFileDescriptor = 0u;
|
|
||||||
|
|
||||||
GmmClientContext clientContext{};
|
|
||||||
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
|
||||||
EXPECT_EQ(expectedFileDescriptor, passedInputArgs.FileDescriptor);
|
|
||||||
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType);
|
|
||||||
}
|
|
||||||
} // namespace NEO
|
|
||||||
@@ -23,8 +23,7 @@ class MockDriverModel : public NEO::DriverModel {
|
|||||||
MockDriverModel() : MockDriverModel(NEO::DriverModelType::unknown) {}
|
MockDriverModel() : MockDriverModel(NEO::DriverModelType::unknown) {}
|
||||||
MockDriverModel(DriverModelType driverModelType) : DriverModel(driverModelType) {}
|
MockDriverModel(DriverModelType driverModelType) : DriverModel(driverModelType) {}
|
||||||
ADDMETHOD_NOBASE_VOIDRETURN(cleanup, ());
|
ADDMETHOD_NOBASE_VOIDRETURN(cleanup, ());
|
||||||
|
ADDMETHOD_NOBASE_VOIDRETURN(setGmmInputArgs, (void *));
|
||||||
void setGmmInputArgs(void *args) override {}
|
|
||||||
|
|
||||||
uint32_t getDeviceHandle() const override { return {}; }
|
uint32_t getDeviceHandle() const override { return {}; }
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ uint64_t MockGmmClientContextBase::freeGpuVirtualAddress(FreeGpuVirtualAddressGm
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MockGmmClientContextBase::initialize(const RootDeviceEnvironment &rootDeviceEnvironment) {
|
void MockGmmClientContextBase::initialize(const RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||||
|
initializeCalled++;
|
||||||
clientContext = {reinterpret_cast<GMM_CLIENT_CONTEXT *>(0x08), [](auto) {}};
|
clientContext = {reinterpret_cast<GMM_CLIENT_CONTEXT *>(0x08), [](auto) {}};
|
||||||
};
|
};
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class MockGmmClientContextBase : public GmmClientContext {
|
|||||||
uint32_t getMediaSurfaceStateCompressionFormatCalled = 0u;
|
uint32_t getMediaSurfaceStateCompressionFormatCalled = 0u;
|
||||||
uint32_t mapGpuVirtualAddressCalled = 0u;
|
uint32_t mapGpuVirtualAddressCalled = 0u;
|
||||||
uint32_t freeGpuVirtualAddressCalled = 0u;
|
uint32_t freeGpuVirtualAddressCalled = 0u;
|
||||||
|
uint32_t initializeCalled = 0u;
|
||||||
bool returnErrorOnPatIndexQuery = false;
|
bool returnErrorOnPatIndexQuery = false;
|
||||||
|
|
||||||
bool passedCompressedSettingForGetPatIndexQuery = false;
|
bool passedCompressedSettingForGetPatIndexQuery = false;
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2025 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
#
|
||||||
|
|
||||||
|
target_sources(neo_shared_tests PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/gmm_client_context_initialize_tests.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectories()
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
|
||||||
|
#include "shared/source/helpers/hw_info.h"
|
||||||
|
#include "shared/source/sku_info/operations/sku_info_transfer.h"
|
||||||
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||||
|
#include "shared/test/common/helpers/default_hw_info.h"
|
||||||
|
#include "shared/test/common/helpers/variable_backup.h"
|
||||||
|
#include "shared/test/common/mocks/mock_driver_model.h"
|
||||||
|
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
using namespace NEO;
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
extern GMM_INIT_IN_ARGS passedInputArgs;
|
||||||
|
extern GT_SYSTEM_INFO passedGtSystemInfo;
|
||||||
|
extern SKU_FEATURE_TABLE passedFtrTable;
|
||||||
|
extern WA_TABLE passedWaTable;
|
||||||
|
extern bool copyInputArgs;
|
||||||
|
|
||||||
|
} // namespace NEO
|
||||||
|
|
||||||
|
TEST(GmmClientContextTest, whenInitializeIsCalledThenClientContextHandleIsSet) {
|
||||||
|
auto hwInfo = defaultHwInfo.get();
|
||||||
|
MockExecutionEnvironment executionEnvironment{hwInfo};
|
||||||
|
|
||||||
|
GmmClientContext clientContext{};
|
||||||
|
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
||||||
|
EXPECT_NE(nullptr, clientContext.getHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(GmmClientContextTest, givenNoOsInterfaceWhenIntializeIsCalledThenProperFlagsArePassedToGmmlib) {
|
||||||
|
MockExecutionEnvironment executionEnvironment{};
|
||||||
|
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
||||||
|
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
|
||||||
|
VariableBackup<decltype(passedFtrTable)> passedFtrTableBackup(&passedFtrTable);
|
||||||
|
VariableBackup<decltype(passedGtSystemInfo)> passedGtSystemInfoBackup(&passedGtSystemInfo);
|
||||||
|
VariableBackup<decltype(passedWaTable)> passedWaTableBackup(&passedWaTable);
|
||||||
|
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(©InputArgs, true);
|
||||||
|
|
||||||
|
SKU_FEATURE_TABLE expectedFtrTable = {};
|
||||||
|
WA_TABLE expectedWaTable = {};
|
||||||
|
auto hwInfo = rootDeviceEnvironment.getHardwareInfo();
|
||||||
|
SkuInfoTransfer::transferFtrTableForGmm(&expectedFtrTable, &hwInfo->featureTable);
|
||||||
|
SkuInfoTransfer::transferWaTableForGmm(&expectedWaTable, &hwInfo->workaroundTable);
|
||||||
|
|
||||||
|
GmmClientContext clientContext{};
|
||||||
|
clientContext.initialize(rootDeviceEnvironment);
|
||||||
|
|
||||||
|
EXPECT_EQ(nullptr, rootDeviceEnvironment.osInterface.get());
|
||||||
|
EXPECT_EQ(0, memcmp(&hwInfo->platform, &passedInputArgs.Platform, sizeof(PLATFORM)));
|
||||||
|
EXPECT_EQ(0, memcmp(&hwInfo->gtSystemInfo, &passedGtSystemInfo, sizeof(GT_SYSTEM_INFO)));
|
||||||
|
EXPECT_EQ(0, memcmp(&expectedFtrTable, &passedFtrTable, sizeof(SKU_FEATURE_TABLE)));
|
||||||
|
EXPECT_EQ(0, memcmp(&expectedWaTable, &passedWaTable, sizeof(WA_TABLE)));
|
||||||
|
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(GmmClientContextTest, givenOsInterfaceWhenIntializeIsCalledThenSetGmmInputArgsFuncIsCalled) {
|
||||||
|
MockExecutionEnvironment executionEnvironment{};
|
||||||
|
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
||||||
|
rootDeviceEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||||
|
auto &osInterface = *rootDeviceEnvironment.osInterface;
|
||||||
|
osInterface.setDriverModel(std::make_unique<MockDriverModel>());
|
||||||
|
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
|
||||||
|
VariableBackup<decltype(passedFtrTable)> passedFtrTableBackup(&passedFtrTable);
|
||||||
|
VariableBackup<decltype(passedGtSystemInfo)> passedGtSystemInfoBackup(&passedGtSystemInfo);
|
||||||
|
VariableBackup<decltype(passedWaTable)> passedWaTableBackup(&passedWaTable);
|
||||||
|
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(©InputArgs, true);
|
||||||
|
|
||||||
|
SKU_FEATURE_TABLE expectedFtrTable = {};
|
||||||
|
WA_TABLE expectedWaTable = {};
|
||||||
|
auto hwInfo = rootDeviceEnvironment.getHardwareInfo();
|
||||||
|
SkuInfoTransfer::transferFtrTableForGmm(&expectedFtrTable, &hwInfo->featureTable);
|
||||||
|
SkuInfoTransfer::transferWaTableForGmm(&expectedWaTable, &hwInfo->workaroundTable);
|
||||||
|
|
||||||
|
GmmClientContext clientContext{};
|
||||||
|
clientContext.initialize(rootDeviceEnvironment);
|
||||||
|
|
||||||
|
EXPECT_NE(nullptr, rootDeviceEnvironment.osInterface.get());
|
||||||
|
EXPECT_EQ(0, memcmp(&hwInfo->platform, &passedInputArgs.Platform, sizeof(PLATFORM)));
|
||||||
|
EXPECT_EQ(0, memcmp(&hwInfo->gtSystemInfo, &passedGtSystemInfo, sizeof(GT_SYSTEM_INFO)));
|
||||||
|
EXPECT_EQ(0, memcmp(&expectedFtrTable, &passedFtrTable, sizeof(SKU_FEATURE_TABLE)));
|
||||||
|
EXPECT_EQ(0, memcmp(&expectedWaTable, &passedWaTable, sizeof(WA_TABLE)));
|
||||||
|
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType);
|
||||||
|
|
||||||
|
EXPECT_EQ(1u, static_cast<MockDriverModel *>(osInterface.getDriverModel())->setGmmInputArgsCalled);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(GmmClientContextTest, givenEnableFtrTile64OptimizationDebugKeyWhenInitializeIsCalledThenProperValueIsPassedToGmmlib) {
|
||||||
|
auto hwInfo = defaultHwInfo.get();
|
||||||
|
MockExecutionEnvironment executionEnvironment{hwInfo};
|
||||||
|
DebugManagerStateRestore restorer;
|
||||||
|
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
|
||||||
|
VariableBackup<decltype(passedFtrTable)> passedFtrTableBackup(&passedFtrTable);
|
||||||
|
VariableBackup<decltype(passedGtSystemInfo)> passedGtSystemInfoBackup(&passedGtSystemInfo);
|
||||||
|
VariableBackup<decltype(passedWaTable)> passedWaTableBackup(&passedWaTable);
|
||||||
|
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(©InputArgs, true);
|
||||||
|
|
||||||
|
GmmClientContext clientContext{};
|
||||||
|
{
|
||||||
|
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
||||||
|
EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
debugManager.flags.EnableFtrTile64Optimization.set(-1);
|
||||||
|
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
||||||
|
EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
debugManager.flags.EnableFtrTile64Optimization.set(0);
|
||||||
|
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
||||||
|
EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
debugManager.flags.EnableFtrTile64Optimization.set(1);
|
||||||
|
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
||||||
|
EXPECT_EQ(1u, passedFtrTable.FtrTile64Optimization);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1140,73 +1140,8 @@ TEST(GmmHelperTest, whenGmmHelperIsInitializedThenClientContextIsSet) {
|
|||||||
MockExecutionEnvironment executionEnvironment{hwInfo};
|
MockExecutionEnvironment executionEnvironment{hwInfo};
|
||||||
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
||||||
ASSERT_NE(nullptr, rootDeviceEnvironment.getGmmHelper());
|
ASSERT_NE(nullptr, rootDeviceEnvironment.getGmmHelper());
|
||||||
EXPECT_NE(nullptr, rootDeviceEnvironment.getGmmClientContext());
|
ASSERT_NE(nullptr, rootDeviceEnvironment.getGmmClientContext());
|
||||||
}
|
EXPECT_EQ(1u, static_cast<MockGmmClientContextBase *>(rootDeviceEnvironment.getGmmClientContext())->initializeCalled);
|
||||||
|
|
||||||
TEST(GmmHelperTest, whenGmmClientContextIsInitializedThenClientContextHandleIsSet) {
|
|
||||||
auto hwInfo = defaultHwInfo.get();
|
|
||||||
MockExecutionEnvironment executionEnvironment{hwInfo};
|
|
||||||
|
|
||||||
GmmClientContext clientContext{};
|
|
||||||
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
|
||||||
EXPECT_NE(nullptr, clientContext.getHandle());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(GmmHelperTest, givenValidGmmFunctionsWhenCreateGmmHelperWithoutOsInterfaceThenInitializationDoesntCrashAndProperParametersArePassed) {
|
|
||||||
MockExecutionEnvironment executionEnvironment{};
|
|
||||||
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
|
||||||
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
|
|
||||||
VariableBackup<decltype(passedFtrTable)> passedFtrTableBackup(&passedFtrTable);
|
|
||||||
VariableBackup<decltype(passedGtSystemInfo)> passedGtSystemInfoBackup(&passedGtSystemInfo);
|
|
||||||
VariableBackup<decltype(passedWaTable)> passedWaTableBackup(&passedWaTable);
|
|
||||||
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(©InputArgs, true);
|
|
||||||
|
|
||||||
SKU_FEATURE_TABLE expectedFtrTable = {};
|
|
||||||
WA_TABLE expectedWaTable = {};
|
|
||||||
auto hwInfo = rootDeviceEnvironment.getHardwareInfo();
|
|
||||||
SkuInfoTransfer::transferFtrTableForGmm(&expectedFtrTable, &hwInfo->featureTable);
|
|
||||||
SkuInfoTransfer::transferWaTableForGmm(&expectedWaTable, &hwInfo->workaroundTable);
|
|
||||||
|
|
||||||
GmmClientContext clientContext{};
|
|
||||||
clientContext.initialize(rootDeviceEnvironment);
|
|
||||||
|
|
||||||
EXPECT_EQ(nullptr, rootDeviceEnvironment.osInterface.get());
|
|
||||||
EXPECT_EQ(0, memcmp(&hwInfo->platform, &passedInputArgs.Platform, sizeof(PLATFORM)));
|
|
||||||
EXPECT_EQ(0, memcmp(&hwInfo->gtSystemInfo, &passedGtSystemInfo, sizeof(GT_SYSTEM_INFO)));
|
|
||||||
EXPECT_EQ(0, memcmp(&expectedFtrTable, &passedFtrTable, sizeof(SKU_FEATURE_TABLE)));
|
|
||||||
EXPECT_EQ(0, memcmp(&expectedWaTable, &passedWaTable, sizeof(WA_TABLE)));
|
|
||||||
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType);
|
|
||||||
}
|
|
||||||
TEST(GmmHelperTest, givenEnableFtrTile64OptimizationDebugKeyWhenSetThenProperValueIsPassedToGmmlib) {
|
|
||||||
auto hwInfo = defaultHwInfo.get();
|
|
||||||
MockExecutionEnvironment executionEnvironment{hwInfo};
|
|
||||||
DebugManagerStateRestore restorer;
|
|
||||||
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
|
|
||||||
VariableBackup<decltype(passedFtrTable)> passedFtrTableBackup(&passedFtrTable);
|
|
||||||
VariableBackup<decltype(passedGtSystemInfo)> passedGtSystemInfoBackup(&passedGtSystemInfo);
|
|
||||||
VariableBackup<decltype(passedWaTable)> passedWaTableBackup(&passedWaTable);
|
|
||||||
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(©InputArgs, true);
|
|
||||||
|
|
||||||
GmmClientContext clientContext{};
|
|
||||||
{
|
|
||||||
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
|
||||||
EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
debugManager.flags.EnableFtrTile64Optimization.set(-1);
|
|
||||||
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
|
||||||
EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
debugManager.flags.EnableFtrTile64Optimization.set(0);
|
|
||||||
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
|
||||||
EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
debugManager.flags.EnableFtrTile64Optimization.set(1);
|
|
||||||
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
|
||||||
EXPECT_EQ(1u, passedFtrTable.FtrTile64Optimization);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GmmHelperTest, givenNewCoherencyModelWhenGetMocsThenDeferToPat) {
|
TEST(GmmHelperTest, givenNewCoherencyModelWhenGetMocsThenDeferToPat) {
|
||||||
|
|||||||
@@ -68,32 +68,24 @@ TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenCallingGetAggregatedProcessCountT
|
|||||||
EXPECT_EQ(5u, osInterface.getAggregatedProcessCount());
|
EXPECT_EQ(5u, osInterface.getAggregatedProcessCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(OsInterfaceTest, whenOsInterfaceSetupGmmInputArgsThenArgsAreSet) {
|
TEST(OsInterfaceTest, whenOsInterfaceSetupsGmmInputArgsThenFileDescriptorIsSetWithValueOfAdapterBdf) {
|
||||||
MockExecutionEnvironment executionEnvironment{};
|
MockExecutionEnvironment executionEnvironment{};
|
||||||
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
||||||
auto drm = std::make_unique<DrmMock>(rootDeviceEnvironment);
|
|
||||||
rootDeviceEnvironment.osInterface = std::make_unique<OSInterface>();
|
rootDeviceEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||||
rootDeviceEnvironment.osInterface->setDriverModel(std::move(drm));
|
auto drm = std::make_unique<DrmMock>(rootDeviceEnvironment);
|
||||||
|
drm->setPciPath("0000:01:23.4");
|
||||||
|
EXPECT_EQ(0, drm->queryAdapterBDF());
|
||||||
|
|
||||||
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
|
GMM_INIT_IN_ARGS gmmInputArgs = {};
|
||||||
VariableBackup<decltype(passedFtrTable)> passedFtrTableBackup(&passedFtrTable);
|
EXPECT_EQ(0u, gmmInputArgs.FileDescriptor);
|
||||||
VariableBackup<decltype(passedGtSystemInfo)> passedGtSystemInfoBackup(&passedGtSystemInfo);
|
drm->Drm::setGmmInputArgs(&gmmInputArgs);
|
||||||
VariableBackup<decltype(passedWaTable)> passedWaTableBackup(&passedWaTable);
|
EXPECT_NE(0u, gmmInputArgs.FileDescriptor);
|
||||||
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(©InputArgs, true);
|
|
||||||
|
|
||||||
auto hwInfo = rootDeviceEnvironment.getHardwareInfo();
|
ADAPTER_BDF expectedAdapterBDF{};
|
||||||
SKU_FEATURE_TABLE expectedFtrTable = {};
|
expectedAdapterBDF.Bus = 0x1;
|
||||||
WA_TABLE expectedWaTable = {};
|
expectedAdapterBDF.Device = 0x23;
|
||||||
SkuInfoTransfer::transferFtrTableForGmm(&expectedFtrTable, &hwInfo->featureTable);
|
expectedAdapterBDF.Function = 0x4;
|
||||||
SkuInfoTransfer::transferWaTableForGmm(&expectedWaTable, &hwInfo->workaroundTable);
|
EXPECT_EQ(expectedAdapterBDF.Data, gmmInputArgs.FileDescriptor);
|
||||||
|
|
||||||
GmmClientContext clientContext{};
|
|
||||||
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
|
||||||
EXPECT_EQ(0, memcmp(&hwInfo->platform, &passedInputArgs.Platform, sizeof(PLATFORM)));
|
|
||||||
EXPECT_EQ(&hwInfo->gtSystemInfo, passedInputArgs.pGtSysInfo);
|
|
||||||
EXPECT_EQ(0, memcmp(&expectedFtrTable, &passedFtrTable, sizeof(SKU_FEATURE_TABLE)));
|
|
||||||
EXPECT_EQ(0, memcmp(&expectedWaTable, &passedWaTable, sizeof(WA_TABLE)));
|
|
||||||
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenGetThresholdForStagingCalledThenReturnThresholdForIntegratedDevices) {
|
TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenGetThresholdForStagingCalledThenReturnThresholdForIntegratedDevices) {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ if(WIN32)
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/file_logger_win_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/file_logger_win_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_adapter_luid_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/wddm_adapter_luid_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/gmm_helper_tests_win.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/product_helper_win_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/product_helper_win_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/product_helper_win_tests.h
|
${CMAKE_CURRENT_SOURCE_DIR}/product_helper_win_tests.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/os_context_win_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/os_context_win_tests.cpp
|
||||||
@@ -62,4 +61,4 @@ if(NOT WIN32 AND NOT DISABLE_WDDM_LINUX)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectories()
|
add_subdirectories()
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2020-2025 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
|
|
||||||
#include "shared/source/gmm_helper/gmm_helper.h"
|
|
||||||
#include "shared/source/gmm_helper/gmm_lib.h"
|
|
||||||
#include "shared/test/common/helpers/default_hw_info.h"
|
|
||||||
#include "shared/test/common/helpers/variable_backup.h"
|
|
||||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
namespace NEO {
|
|
||||||
|
|
||||||
extern GMM_INIT_IN_ARGS passedInputArgs;
|
|
||||||
extern bool copyInputArgs;
|
|
||||||
|
|
||||||
TEST(GmmHelperTest, whenInitializeGmmClientContextWithoutOsInterfaceThenPassedAdapterBDFIsZeroed) {
|
|
||||||
ADAPTER_BDF expectedAdapterBDF{};
|
|
||||||
|
|
||||||
MockExecutionEnvironment executionEnvironment{};
|
|
||||||
|
|
||||||
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
|
|
||||||
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(©InputArgs, true);
|
|
||||||
GmmClientContext clientContext{};
|
|
||||||
clientContext.initialize(*executionEnvironment.rootDeviceEnvironments[0]);
|
|
||||||
EXPECT_EQ(0, memcmp(&expectedAdapterBDF, &passedInputArgs.stAdapterBDF, sizeof(ADAPTER_BDF)));
|
|
||||||
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace NEO
|
|
||||||
@@ -86,71 +86,13 @@ TEST_F(OsInterfaceTest, whenOsInterfaceSetupGmmInputArgsThenArgsAreSet) {
|
|||||||
uint32_t function = 0x56;
|
uint32_t function = 0x56;
|
||||||
adapterBDF.Function = function;
|
adapterBDF.Function = function;
|
||||||
|
|
||||||
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
|
GMM_INIT_IN_ARGS gmmInputArgs = {};
|
||||||
VariableBackup<decltype(passedFtrTable)> passedFtrTableBackup(&passedFtrTable);
|
wddm->Wddm::setGmmInputArgs(&gmmInputArgs);
|
||||||
VariableBackup<decltype(passedGtSystemInfo)> passedGtSystemInfoBackup(&passedGtSystemInfo);
|
|
||||||
VariableBackup<decltype(passedWaTable)> passedWaTableBackup(&passedWaTable);
|
|
||||||
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(©InputArgs, true);
|
|
||||||
|
|
||||||
GmmClientContext clientContext{};
|
EXPECT_EQ(0, memcmp(&wddm->adapterBDF, &gmmInputArgs.stAdapterBDF, sizeof(ADAPTER_BDF)));
|
||||||
clientContext.initialize(rootDeviceEnvironment);
|
EXPECT_STREQ(expectedRegistryPath, gmmInputArgs.DeviceRegistryPath);
|
||||||
|
EXPECT_EQ(expectedCoreFamily, gmmInputArgs.Platform.eRenderCoreFamily);
|
||||||
EXPECT_EQ(0, memcmp(&wddm->adapterBDF, &passedInputArgs.stAdapterBDF, sizeof(ADAPTER_BDF)));
|
EXPECT_EQ(expectedCoreFamily, gmmInputArgs.Platform.eDisplayCoreFamily);
|
||||||
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType);
|
|
||||||
EXPECT_STREQ(expectedRegistryPath, passedInputArgs.DeviceRegistryPath);
|
|
||||||
EXPECT_EQ(expectedCoreFamily, passedInputArgs.Platform.eRenderCoreFamily);
|
|
||||||
EXPECT_EQ(expectedCoreFamily, passedInputArgs.Platform.eDisplayCoreFamily);
|
|
||||||
EXPECT_EQ(wddm->gfxFeatureTable.get(), passedInputArgs.pSkuTable);
|
|
||||||
EXPECT_EQ(wddm->gfxWorkaroundTable.get(), passedInputArgs.pWaTable);
|
|
||||||
EXPECT_EQ(&rootDeviceEnvironment.getHardwareInfo()->gtSystemInfo, passedInputArgs.pGtSysInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(OsInterfaceTest, givenEnableFtrTile64OptimizationDebugKeyWhenSetThenProperValueIsPassedToGmmlib) {
|
|
||||||
MockExecutionEnvironment executionEnvironment;
|
|
||||||
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
|
||||||
auto wddm = new WddmMock(rootDeviceEnvironment);
|
|
||||||
EXPECT_EQ(nullptr, rootDeviceEnvironment.osInterface.get());
|
|
||||||
wddm->init();
|
|
||||||
EXPECT_NE(nullptr, rootDeviceEnvironment.osInterface.get());
|
|
||||||
|
|
||||||
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
|
|
||||||
VariableBackup<decltype(passedFtrTable)> passedFtrTableBackup(&passedFtrTable);
|
|
||||||
VariableBackup<decltype(passedGtSystemInfo)> passedGtSystemInfoBackup(&passedGtSystemInfo);
|
|
||||||
VariableBackup<decltype(passedWaTable)> passedWaTableBackup(&passedWaTable);
|
|
||||||
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(©InputArgs, true);
|
|
||||||
DebugManagerStateRestore restorer;
|
|
||||||
GmmClientContext clientContext{};
|
|
||||||
{
|
|
||||||
wddm->gfxFeatureTable->FtrTile64Optimization = 1;
|
|
||||||
clientContext.initialize(rootDeviceEnvironment);
|
|
||||||
EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
debugManager.flags.EnableFtrTile64Optimization.set(-1);
|
|
||||||
wddm->gfxFeatureTable->FtrTile64Optimization = 1;
|
|
||||||
clientContext.initialize(rootDeviceEnvironment);
|
|
||||||
EXPECT_EQ(1u, passedFtrTable.FtrTile64Optimization);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
debugManager.flags.EnableFtrTile64Optimization.set(-1);
|
|
||||||
wddm->gfxFeatureTable->FtrTile64Optimization = 0;
|
|
||||||
clientContext.initialize(rootDeviceEnvironment);
|
|
||||||
EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
debugManager.flags.EnableFtrTile64Optimization.set(0);
|
|
||||||
wddm->gfxFeatureTable->FtrTile64Optimization = 1;
|
|
||||||
clientContext.initialize(rootDeviceEnvironment);
|
|
||||||
EXPECT_EQ(0u, passedFtrTable.FtrTile64Optimization);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
debugManager.flags.EnableFtrTile64Optimization.set(1);
|
|
||||||
wddm->gfxFeatureTable->FtrTile64Optimization = 0;
|
|
||||||
clientContext.initialize(rootDeviceEnvironment);
|
|
||||||
EXPECT_EQ(1u, passedFtrTable.FtrTile64Optimization);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(OsInterfaceTest, whenGetThresholdForStagingCalledThenReturnNoThreshold) {
|
TEST_F(OsInterfaceTest, whenGetThresholdForStagingCalledThenReturnNoThreshold) {
|
||||||
@@ -162,4 +104,4 @@ TEST_F(OsInterfaceTest, whenGetThresholdForStagingCalledThenReturnNoThreshold) {
|
|||||||
EXPECT_NE(nullptr, rootDeviceEnvironment.osInterface.get());
|
EXPECT_NE(nullptr, rootDeviceEnvironment.osInterface.get());
|
||||||
auto alignedPtr = reinterpret_cast<const void *>(2 * MemoryConstants::megaByte);
|
auto alignedPtr = reinterpret_cast<const void *>(2 * MemoryConstants::megaByte);
|
||||||
EXPECT_TRUE(rootDeviceEnvironment.osInterface->isSizeWithinThresholdForStaging(alignedPtr, MemoryConstants::gigaByte));
|
EXPECT_TRUE(rootDeviceEnvironment.osInterface->isSizeWithinThresholdForStaging(alignedPtr, MemoryConstants::gigaByte));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user