Move tests to shared

Signed-off-by: Daniel Chabrowski <daniel.chabrowski@intel.com>
This commit is contained in:
Daniel Chabrowski
2022-06-09 17:53:05 +00:00
committed by Compute-Runtime-Automation
parent 1b7555a49d
commit 6e3d373ef6
49 changed files with 66 additions and 84 deletions

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2020-2021 Intel Corporation
# Copyright (C) 2020-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -9,12 +9,12 @@ set(NEO_SHARED_TESTS_CMD_PARSE
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_3d_state_btd.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_base.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_base_mi_arb.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_compute_mi_arb.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_compute_mode.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_compute_walker.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_gpgpu_walker.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_l3_control.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_mi_arb.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_compute_mi_arb.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_sip.inl
${CMAKE_CURRENT_SOURCE_DIR}/gen_cmd_parse.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_parse.h
@@ -23,8 +23,8 @@ set(NEO_SHARED_TESTS_CMD_PARSE
if(TESTS_XEHP_AND_LATER)
list(APPEND NEO_SHARED_TESTS_CMD_PARSE
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_xehp_and_later.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_l3_control_xehp_and_later.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_xehp_and_later.inl
)
endif()

View File

@@ -6,11 +6,11 @@
set(NEO_CORE_HELPERS_TESTS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}hw_helper_extended_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bindless_heaps_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests.inl
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests_gen12lp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/debug_manager_state_restore.h
${CMAKE_CURRENT_SOURCE_DIR}/default_hw_info.h
${CMAKE_CURRENT_SOURCE_DIR}/default_hw_info.inl
@@ -19,8 +19,9 @@ set(NEO_CORE_HELPERS_TESTS
${CMAKE_CURRENT_SOURCE_DIR}/engine_node_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/file_io_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hash_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}hw_helper_extended_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/includes${BRANCH_DIR_SUFFIX}test_traits_common.h
${CMAKE_CURRENT_SOURCE_DIR}/includes${BRANCH_DIR_SUFFIX}test_traits_platforms_common.h
${CMAKE_CURRENT_SOURCE_DIR}/kernel_binary_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/kernel_filename_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers_tests.cpp
@@ -32,8 +33,6 @@ set(NEO_CORE_HELPERS_TESTS
${CMAKE_CURRENT_SOURCE_DIR}/string_to_hash_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_traits.h
${CMAKE_CURRENT_SOURCE_DIR}/test_traits_platforms.h
${CMAKE_CURRENT_SOURCE_DIR}/includes${BRANCH_DIR_SUFFIX}test_traits_common.h
${CMAKE_CURRENT_SOURCE_DIR}/includes${BRANCH_DIR_SUFFIX}test_traits_platforms_common.h
${CMAKE_CURRENT_SOURCE_DIR}/ult_hw_config.h
${CMAKE_CURRENT_SOURCE_DIR}/ult_hw_config.inl
${CMAKE_CURRENT_SOURCE_DIR}/ult_hw_helper.h
@@ -54,8 +53,8 @@ endif()
if(TESTS_PVC_AND_LATER)
list(APPEND NEO_CORE_HELPERS_TESTS
${CMAKE_CURRENT_SOURCE_DIR}/test_blit_commands_helper_pvc_and_later.cpp
${CMAKE_CURRENT_SOURCE_DIR}/simd_helper_tests_pvc_and_later.inl
${CMAKE_CURRENT_SOURCE_DIR}/test_blit_commands_helper_pvc_and_later.cpp
)
endif()

View File

@@ -14,10 +14,10 @@ if(UNIX)
if(NEO_ENABLE_i915_PRELIM_DETECTION)
target_sources(neo_libult_common PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_prelim_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_prelim_context.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_mock.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_mock.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_prelim_context.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_prelim_context.cpp
)
endif()

View File

@@ -52,6 +52,8 @@ set(NEO_CORE_tests_mocks
${CMAKE_CURRENT_SOURCE_DIR}/mock_gfx_partition.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_gfx_partition.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_client_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_client_context.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_client_context_base.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_client_context_base.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_page_table_mngr.h
@@ -84,8 +86,6 @@ set(NEO_CORE_tests_mocks
${CMAKE_CURRENT_SOURCE_DIR}/mock_timestamp_packet.h
${CMAKE_CURRENT_SOURCE_DIR}/ult_device_factory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ult_device_factory.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_client_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_client_context.h
)
if(WIN32)

View File

@@ -8,8 +8,8 @@ if(TESTS_XE_HPC_CORE)
set(NEO_CORE_TESTS_XE_HPC_CORE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_traits_xe_hpc_core.h
${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}unit_test_helper_xe_hpc_core_extra.inl
${CMAKE_CURRENT_SOURCE_DIR}/test_traits_xe_hpc_core.h
)
set_property(GLOBAL PROPERTY NEO_CORE_TESTS_XE_HPC_CORE ${NEO_CORE_TESTS_XE_HPC_CORE})

View File

@@ -13,10 +13,10 @@ if(TESTS_DG2)
set(NEO_CORE_TESTS_XE_HPG_CORE_DG2
${IGDRCL_SRCS_tests_xe_hpg_core_dg2_excludes}
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_dispatch_kernel_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_hw_info_config_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_hw_helper_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_dispatch_kernel_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_hw_helper_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_hw_info_config_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_traits_dg2.h
)

View File

@@ -6,6 +6,7 @@
set(NEO_SHARED_tests_command_stream
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}stream_properties_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/aub_command_stream_receiver_1_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/aub_command_stream_receiver_2_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/aub_command_stream_receiver_3_tests.cpp
@@ -15,7 +16,6 @@ set(NEO_SHARED_tests_command_stream
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/compute_mode_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/linear_stream_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}stream_properties_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/stream_properties_tests_common.cpp
${CMAKE_CURRENT_SOURCE_DIR}/stream_properties_tests_common.h
${CMAKE_CURRENT_SOURCE_DIR}/tbx_command_stream_tests.cpp

View File

@@ -22,8 +22,8 @@ target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/patchtokens_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/patchtokens_validator_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/yaml/yaml_parser_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/zebin_decoder_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/zebin_debug_binary_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/zebin_decoder_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/zebin_tests.h
)

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2020-2021 Intel Corporation
# Copyright (C) 2020-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -69,8 +69,8 @@ endif()
if(TESTS_PVC_AND_LATER)
target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_dispatch_kernel_pvc_and_later.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_3dstate_btd_pvc_and_later.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_dispatch_kernel_pvc_and_later.cpp
${CMAKE_CURRENT_SOURCE_DIR}/walker_partition_tests_pvc_and_later.cpp
)
endif()

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2021 Intel Corporation
# Copyright (C) 2021-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -7,6 +7,7 @@
if(TESTS_GEN11)
target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/coherency_tests_gen11.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_cmds_gen11_tests.cpp
)
add_subdirectories()

View File

@@ -0,0 +1,158 @@
/*
* Copyright (C) 2019-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/command_stream_receiver_hw.h"
#include "shared/source/gen11/reg_configs.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/helpers/dispatch_flags_helper.h"
#include "shared/test/common/mocks/mock_allocation_properties.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
struct Gen11CoherencyRequirements : public ::testing::Test {
typedef typename ICLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
struct myCsr : public CommandStreamReceiverHw<ICLFamily> {
using CommandStreamReceiver::commandStream;
using CommandStreamReceiver::streamProperties;
myCsr(ExecutionEnvironment &executionEnvironment) : CommandStreamReceiverHw<ICLFamily>(executionEnvironment, 0, 1){};
CsrSizeRequestFlags *getCsrRequestFlags() { return &csrSizeRequestFlags; }
};
void overrideCoherencyRequest(bool requestChanged, bool requireCoherency) {
csr->streamProperties.stateComputeMode.isCoherencyRequired.isDirty = requestChanged;
csr->streamProperties.stateComputeMode.isCoherencyRequired.value = requireCoherency;
flags.requiresCoherency = requireCoherency;
}
void SetUp() override {
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
csr = new myCsr(*device->executionEnvironment);
device->resetCommandStreamReceiver(csr);
}
myCsr *csr = nullptr;
std::unique_ptr<MockDevice> device;
DispatchFlags flags = DispatchFlagsHelper::createDefaultDispatchFlags();
};
GEN11TEST_F(Gen11CoherencyRequirements, GivenSettingsWhenCoherencyRequestedThenProgrammingIsCorrect) {
overrideCoherencyRequest(false, false);
EXPECT_FALSE(csr->streamProperties.stateComputeMode.isDirty());
overrideCoherencyRequest(false, true);
EXPECT_FALSE(csr->streamProperties.stateComputeMode.isDirty());
overrideCoherencyRequest(true, true);
EXPECT_TRUE(csr->streamProperties.stateComputeMode.isDirty());
overrideCoherencyRequest(true, false);
EXPECT_TRUE(csr->streamProperties.stateComputeMode.isDirty());
}
GEN11TEST_F(Gen11CoherencyRequirements, GivenSettingsWhenCoherencyRequestedThenHdcModeCmdValuesAreCorrect) {
auto lriSize = sizeof(MI_LOAD_REGISTER_IMM);
char buff[MemoryConstants::pageSize];
LinearStream stream(buff, MemoryConstants::pageSize);
auto expectedCmd = FamilyType::cmdInitLoadRegisterImm;
expectedCmd.setRegisterOffset(gen11HdcModeRegister::address);
expectedCmd.setDataDword(DwordBuilder::build(gen11HdcModeRegister::forceNonCoherentEnableBit, true));
overrideCoherencyRequest(true, false);
csr->programComputeMode(stream, flags, *defaultHwInfo);
EXPECT_EQ(lriSize, stream.getUsed());
auto cmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(stream.getCpuBase());
EXPECT_TRUE(memcmp(&expectedCmd, cmd, lriSize) == 0);
overrideCoherencyRequest(true, true);
csr->programComputeMode(stream, flags, *defaultHwInfo);
EXPECT_EQ(lriSize * 2, stream.getUsed());
cmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(ptrOffset(stream.getCpuBase(), lriSize));
expectedCmd.setDataDword(DwordBuilder::build(gen11HdcModeRegister::forceNonCoherentEnableBit, true, false));
EXPECT_TRUE(memcmp(&expectedCmd, cmd, lriSize) == 0);
}
struct Gen11CoherencyProgramingTest : public Gen11CoherencyRequirements {
void SetUp() override {
Gen11CoherencyRequirements::SetUp();
startOffset = csr->commandStream.getUsed();
}
void flushTask(bool coherencyRequired) {
flags.requiresCoherency = coherencyRequired;
auto graphicAlloc = csr->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
IndirectHeap stream(graphicAlloc);
startOffset = csr->commandStream.getUsed();
csr->flushTask(stream, 0, &stream, &stream, &stream, 0, flags, *device);
csr->getMemoryManager()->freeGraphicsMemory(graphicAlloc);
};
void findMmio(bool expectToBeProgrammed, uint32_t registerAddress) {
HardwareParse hwParser;
hwParser.parseCommands<ICLFamily>(csr->commandStream, startOffset);
bool foundOne = false;
for (auto it = hwParser.cmdList.begin(); it != hwParser.cmdList.end(); it++) {
auto cmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*it);
if (cmd && cmd->getRegisterOffset() == registerAddress) {
EXPECT_FALSE(foundOne);
foundOne = true;
}
}
EXPECT_EQ(expectToBeProgrammed, foundOne);
};
void findMmio(bool expectToBeProgrammed) {
findMmio(expectToBeProgrammed, gen11HdcModeRegister::address);
}
size_t startOffset;
};
GEN11TEST_F(Gen11CoherencyProgramingTest, givenCsrWhenFlushFirstTaskWithoutCoherencyRequiredThenProgramMmio) {
flushTask(false);
findMmio(true);
}
GEN11TEST_F(Gen11CoherencyProgramingTest, givenCsrWhenFlushFirstTaskWithCoherencyRequiredThenProgramMmio) {
flushTask(true);
findMmio(true);
}
GEN11TEST_F(Gen11CoherencyProgramingTest, givenCsrWithFlushedFirstTaskWithCoherencyRequiredWhenFlushNextTaskWithoutChangingCoherencyRequirementThenDoNotProgramMmio) {
flushTask(true);
flushTask(true);
findMmio(false);
}
GEN11TEST_F(Gen11CoherencyProgramingTest, givenCsrWithFlushedFirstTaskWithoutCoherencyRequiredWhenFlushNextTaskWithoutChangingCoherencyRequirementThenDoNotProgramMmio) {
flushTask(false);
flushTask(false);
findMmio(false);
}
GEN11TEST_F(Gen11CoherencyProgramingTest, givenCsrWithFlushedFirstTaskWithCoherencyRequiredWhenFlushNextTaskWithChangingCoherencyRequirementThenProgramMmio) {
flushTask(true);
flushTask(false);
findMmio(true);
}
GEN11TEST_F(Gen11CoherencyProgramingTest, givenCsrWithFlushedFirstTaskWithoutCoherencyRequiredWhenFlushNextTaskWithChangingCoherencyRequirementThenProgramMmio) {
flushTask(false);
flushTask(true);
findMmio(true);
}

View File

@@ -5,5 +5,8 @@
#
if(TESTS_EHL)
target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test_hw_info_config_ehl.cpp
)
add_subdirectories()
endif()

View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2019-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
using EhlHwInfo = ::testing::Test;
EHLTEST_F(EhlHwInfo, givenHwInfoConfigStringThenAfterSetupResultingVmeIsDisabled) {
HardwareInfo hwInfo = *defaultHwInfo;
hardwareInfoSetup[productFamily](&hwInfo, false, 0x100040008);
EXPECT_FALSE(hwInfo.capabilityTable.ftrSupportsVmeAvcTextureSampler);
EXPECT_FALSE(hwInfo.capabilityTable.ftrSupportsVmeAvcPreemption);
EXPECT_FALSE(hwInfo.capabilityTable.supportsVme);
}
EHLTEST_F(EhlHwInfo, givenBoolWhenCallEhlHardwareInfoSetupThenFeatureTableAndWorkaroundTableAreSetCorrect) {
bool boolValue[]{
true, false};
HardwareInfo hwInfo = *defaultHwInfo;
GT_SYSTEM_INFO &gtSystemInfo = hwInfo.gtSystemInfo;
FeatureTable &featureTable = hwInfo.featureTable;
WorkaroundTable &workaroundTable = hwInfo.workaroundTable;
for (auto setParamBool : boolValue) {
gtSystemInfo = {0};
featureTable = {};
workaroundTable = {};
hardwareInfoSetup[productFamily](&hwInfo, setParamBool, 0x100040008);
EXPECT_EQ(setParamBool, featureTable.flags.ftrL3IACoherency);
EXPECT_EQ(setParamBool, featureTable.flags.ftrPPGTT);
EXPECT_EQ(setParamBool, featureTable.flags.ftrSVM);
EXPECT_EQ(setParamBool, featureTable.flags.ftrIA32eGfxPTEs);
EXPECT_EQ(setParamBool, featureTable.flags.ftrStandardMipTailFormat);
EXPECT_EQ(setParamBool, featureTable.flags.ftrDisplayYTiling);
EXPECT_EQ(setParamBool, featureTable.flags.ftrTranslationTable);
EXPECT_EQ(setParamBool, featureTable.flags.ftrUserModeTranslationTable);
EXPECT_EQ(setParamBool, featureTable.flags.ftrTileMappedResource);
EXPECT_EQ(setParamBool, featureTable.flags.ftrEnableGuC);
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbc);
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbc2AddressTranslation);
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbcBlitterTracking);
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbcCpuTracking);
EXPECT_EQ(setParamBool, featureTable.flags.ftrTileY);
EXPECT_EQ(setParamBool, featureTable.flags.ftrAstcHdr2D);
EXPECT_EQ(setParamBool, featureTable.flags.ftrAstcLdr2D);
EXPECT_EQ(setParamBool, featureTable.flags.ftr3dMidBatchPreempt);
EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuMidBatchPreempt);
EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuMidThreadLevelPreempt);
EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuThreadGroupLevelPreempt);
EXPECT_EQ(setParamBool, featureTable.flags.ftrPerCtxtPreemptionGranularityControl);
EXPECT_EQ(setParamBool, workaroundTable.flags.wa4kAlignUVOffsetNV12LinearSurface);
EXPECT_EQ(setParamBool, workaroundTable.flags.waReportPerfCountUseGlobalContextID);
}
}

View File

@@ -7,6 +7,8 @@
if(TESTS_ICLLP)
set(NEO_SHARED_tests_gen11_icllp
${CMAKE_CURRENT_SOURCE_DIR}/excludes_gen11_icllp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_hw_info_config_icllp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_program_media_sampler_icllp.cpp
)
target_sources(${TARGET_NAME} PRIVATE ${NEO_SHARED_tests_gen11_icllp})

View File

@@ -0,0 +1,94 @@
/*
* Copyright (C) 2019-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
using IcllpHwInfoConfig = ::testing::Test;
ICLLPTEST_F(IcllpHwInfoConfig, givenInvalidSystemInfoWhenSettingHardwareInfoThenExpectThrow) {
HardwareInfo hwInfo = *defaultHwInfo;
GT_SYSTEM_INFO &gtSystemInfo = hwInfo.gtSystemInfo;
uint64_t config = 0xdeadbeef;
gtSystemInfo = {0};
EXPECT_ANY_THROW(hardwareInfoSetup[productFamily](&hwInfo, false, config));
EXPECT_EQ(0u, gtSystemInfo.SliceCount);
EXPECT_EQ(0u, gtSystemInfo.SubSliceCount);
EXPECT_EQ(0u, gtSystemInfo.DualSubSliceCount);
EXPECT_EQ(0u, gtSystemInfo.EUCount);
}
ICLLPTEST_F(IcllpHwInfoConfig, givenHwInfoConfigWhenAskedIfAdditionalMediaSamplerProgrammingIsRequiredThenTrueIsReturned) {
const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
EXPECT_TRUE(hwInfoConfig.isAdditionalMediaSamplerProgrammingRequired());
}
ICLLPTEST_F(IcllpHwInfoConfig, givenHwInfoConfigWhenAskedIfInitialFlagsProgrammingIsRequiredThenTrueIsReturned) {
const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
EXPECT_TRUE(hwInfoConfig.isInitialFlagsProgrammingRequired());
}
ICLLPTEST_F(IcllpHwInfoConfig, givenHwInfoConfigWhenAskedIfReturnedCmdSizeForMediaSamplerAdjustmentIsRequiredThenTrueIsReturned) {
const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
EXPECT_TRUE(hwInfoConfig.isReturnedCmdSizeForMediaSamplerAdjustmentRequired());
}
using IcllpHwInfo = ::testing::Test;
ICLLPTEST_F(IcllpHwInfo, givenBoolWhenCallIcllpHardwareInfoSetupThenFeatureTableAndWorkaroundTableAreSetCorrect) {
uint64_t configs[] = {
0x100080008,
0x100040008,
0x100060008};
bool boolValue[]{
true, false};
HardwareInfo hwInfo = *defaultHwInfo;
GT_SYSTEM_INFO &gtSystemInfo = hwInfo.gtSystemInfo;
FeatureTable &featureTable = hwInfo.featureTable;
WorkaroundTable &workaroundTable = hwInfo.workaroundTable;
for (auto config : configs) {
for (auto setParamBool : boolValue) {
gtSystemInfo = {0};
featureTable = {};
workaroundTable = {};
hardwareInfoSetup[productFamily](&hwInfo, setParamBool, config);
EXPECT_EQ(setParamBool, featureTable.flags.ftrL3IACoherency);
EXPECT_EQ(setParamBool, featureTable.flags.ftrPPGTT);
EXPECT_EQ(setParamBool, featureTable.flags.ftrSVM);
EXPECT_EQ(setParamBool, featureTable.flags.ftrIA32eGfxPTEs);
EXPECT_EQ(setParamBool, featureTable.flags.ftrStandardMipTailFormat);
EXPECT_EQ(setParamBool, featureTable.flags.ftrDisplayYTiling);
EXPECT_EQ(setParamBool, featureTable.flags.ftrTranslationTable);
EXPECT_EQ(setParamBool, featureTable.flags.ftrUserModeTranslationTable);
EXPECT_EQ(setParamBool, featureTable.flags.ftrTileMappedResource);
EXPECT_EQ(setParamBool, featureTable.flags.ftrEnableGuC);
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbc);
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbc2AddressTranslation);
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbcBlitterTracking);
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbcCpuTracking);
EXPECT_EQ(setParamBool, featureTable.flags.ftrTileY);
EXPECT_EQ(setParamBool, featureTable.flags.ftrAstcHdr2D);
EXPECT_EQ(setParamBool, featureTable.flags.ftrAstcLdr2D);
EXPECT_EQ(setParamBool, featureTable.flags.ftr3dMidBatchPreempt);
EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuMidBatchPreempt);
EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuMidThreadLevelPreempt);
EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuThreadGroupLevelPreempt);
EXPECT_EQ(setParamBool, featureTable.flags.ftrPerCtxtPreemptionGranularityControl);
EXPECT_EQ(setParamBool, workaroundTable.flags.wa4kAlignUVOffsetNV12LinearSurface);
EXPECT_EQ(setParamBool, workaroundTable.flags.waReportPerfCountUseGlobalContextID);
}
}
}

View File

@@ -0,0 +1,181 @@
/*
* Copyright (C) 2019-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/command_stream_receiver_hw.h"
#include "shared/source/gen11/reg_configs.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/dispatch_flags_helper.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
struct Gen11MediaSamplerProgramingTest : public ::testing::Test {
typedef typename ICLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
typedef typename ICLFamily::PIPE_CONTROL PIPE_CONTROL;
struct myCsr : public CommandStreamReceiverHw<ICLFamily> {
using CommandStreamReceiver::commandStream;
using CommandStreamReceiverHw<ICLFamily>::programMediaSampler;
myCsr(ExecutionEnvironment &executionEnvironment) : CommandStreamReceiverHw<ICLFamily>(executionEnvironment, 0, 1){};
void overrideLastVmeSubliceConfig(bool value) {
lastVmeSubslicesConfig = value;
}
};
void overrideMediaRequest(bool lastVmeConfig, bool mediaSamplerRequired) {
csr->overrideLastVmeSubliceConfig(lastVmeConfig);
flags.pipelineSelectArgs.mediaSamplerRequired = mediaSamplerRequired;
}
void SetUp() override {
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
csr = new myCsr(*device->executionEnvironment);
device->resetCommandStreamReceiver(csr);
stream.reset(new LinearStream(buff, MemoryConstants::pageSize));
}
void programMediaSampler() {
csr->programMediaSampler(*stream, flags);
}
size_t getCmdSize() {
return csr->getCmdSizeForMediaSampler(flags.pipelineSelectArgs.mediaSamplerRequired);
}
myCsr *csr = nullptr;
std::unique_ptr<MockDevice> device;
DispatchFlags flags = DispatchFlagsHelper::createDefaultDispatchFlags();
char buff[MemoryConstants::pageSize];
std::unique_ptr<LinearStream> stream;
};
template <typename PIPE_CONTROL>
void setFlushAllCaches(PIPE_CONTROL &pc) {
pc.setDcFlushEnable(true);
pc.setRenderTargetCacheFlushEnable(true);
pc.setInstructionCacheInvalidateEnable(true);
pc.setTextureCacheInvalidationEnable(true);
pc.setPipeControlFlushEnable(true);
pc.setVfCacheInvalidationEnable(true);
pc.setConstantCacheInvalidationEnable(true);
pc.setStateCacheInvalidationEnable(true);
}
ICLLPTEST_F(Gen11MediaSamplerProgramingTest, givenVmeEnableSubsliceDisabledWhenPowerClockStateRegisterEnableThenExpectCorrectCmdValues) {
uint32_t programVmeCmdSize = sizeof(MI_LOAD_REGISTER_IMM) + 2 * sizeof(PIPE_CONTROL);
overrideMediaRequest(false, true);
size_t estimatedCmdSize = getCmdSize();
EXPECT_EQ(programVmeCmdSize, estimatedCmdSize);
auto expectedMiLrCmd = FamilyType::cmdInitLoadRegisterImm;
expectedMiLrCmd.setRegisterOffset(gen11PowerClockStateRegister::address);
auto expectedRegValue = (device->getHardwareInfo().gtSystemInfo.SubSliceCount / 2) << gen11PowerClockStateRegister::subSliceCountShift;
expectedRegValue |= (gen11PowerClockStateRegister::vmeSliceCount << gen11PowerClockStateRegister::sliceCountShift);
expectedRegValue |= (device->getHardwareInfo().gtSystemInfo.MaxEuPerSubSlice << gen11PowerClockStateRegister::minEuCountShift);
expectedRegValue |= (device->getHardwareInfo().gtSystemInfo.MaxEuPerSubSlice << gen11PowerClockStateRegister::maxEuCountShift);
expectedRegValue |= gen11PowerClockStateRegister::enabledValue;
expectedMiLrCmd.setDataDword(expectedRegValue);
programMediaSampler();
ASSERT_EQ(programVmeCmdSize, stream->getUsed());
auto expectedPipeControlCmd = FamilyType::cmdInitPipeControl;
expectedPipeControlCmd.setCommandStreamerStallEnable(0x1);
setFlushAllCaches(expectedPipeControlCmd);
auto pipeControlCmd = genCmdCast<PIPE_CONTROL *>(stream->getCpuBase());
ASSERT_NE(nullptr, pipeControlCmd);
EXPECT_EQ(0, memcmp(&expectedPipeControlCmd, pipeControlCmd, sizeof(PIPE_CONTROL)));
size_t cmdOffset = sizeof(PIPE_CONTROL);
auto miLrCmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(ptrOffset(stream->getCpuBase(), cmdOffset));
ASSERT_NE(nullptr, miLrCmd);
EXPECT_EQ(0, memcmp(&expectedMiLrCmd, miLrCmd, sizeof(MI_LOAD_REGISTER_IMM)));
cmdOffset += sizeof(MI_LOAD_REGISTER_IMM);
expectedPipeControlCmd = FamilyType::cmdInitPipeControl;
expectedPipeControlCmd.setCommandStreamerStallEnable(0x1);
pipeControlCmd = genCmdCast<PIPE_CONTROL *>(ptrOffset(stream->getCpuBase(), cmdOffset));
ASSERT_NE(nullptr, pipeControlCmd);
EXPECT_EQ(0, memcmp(&expectedPipeControlCmd, pipeControlCmd, sizeof(PIPE_CONTROL)));
}
ICLLPTEST_F(Gen11MediaSamplerProgramingTest, givenVmeEnableSubsliceEnabledWhenPowerClockStateRegisterDisableThenExpectCorrectCmdValues) {
constexpr uint32_t programVmeCmdSize = sizeof(MI_LOAD_REGISTER_IMM) + 3 * sizeof(PIPE_CONTROL);
overrideMediaRequest(true, false);
size_t estimatedCmdSize = getCmdSize();
EXPECT_EQ(programVmeCmdSize, estimatedCmdSize);
programMediaSampler();
auto expectedMiLrCmd = FamilyType::cmdInitLoadRegisterImm;
expectedMiLrCmd.setRegisterOffset(gen11PowerClockStateRegister::address);
auto expectedRegValue = (device->getHardwareInfo().gtSystemInfo.SubSliceCount / 2) << gen11PowerClockStateRegister::subSliceCountShift;
expectedRegValue |= ((device->getHardwareInfo().gtSystemInfo.SliceCount * 2) << gen11PowerClockStateRegister::sliceCountShift);
expectedRegValue |= (device->getHardwareInfo().gtSystemInfo.MaxEuPerSubSlice << gen11PowerClockStateRegister::minEuCountShift);
expectedRegValue |= (device->getHardwareInfo().gtSystemInfo.MaxEuPerSubSlice << gen11PowerClockStateRegister::maxEuCountShift);
expectedRegValue |= gen11PowerClockStateRegister::disabledValue;
expectedMiLrCmd.setDataDword(expectedRegValue);
ASSERT_EQ(programVmeCmdSize, stream->getUsed());
auto expectedPipeControlCmd = FamilyType::cmdInitPipeControl;
expectedPipeControlCmd.setCommandStreamerStallEnable(0x1);
setFlushAllCaches(expectedPipeControlCmd);
expectedPipeControlCmd.setGenericMediaStateClear(true);
auto pipeControlCmd = genCmdCast<PIPE_CONTROL *>(stream->getCpuBase());
ASSERT_NE(nullptr, pipeControlCmd);
EXPECT_EQ(0, memcmp(&expectedPipeControlCmd, pipeControlCmd, sizeof(PIPE_CONTROL)));
size_t cmdOffset = sizeof(PIPE_CONTROL);
pipeControlCmd = genCmdCast<PIPE_CONTROL *>(ptrOffset(stream->getCpuBase(), cmdOffset));
ASSERT_NE(nullptr, pipeControlCmd);
expectedPipeControlCmd = FamilyType::cmdInitPipeControl;
expectedPipeControlCmd.setCommandStreamerStallEnable(0x1);
EXPECT_EQ(0, memcmp(&expectedPipeControlCmd, pipeControlCmd, sizeof(PIPE_CONTROL)));
cmdOffset += sizeof(PIPE_CONTROL);
auto miLrCmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(ptrOffset(stream->getCpuBase(), cmdOffset));
ASSERT_NE(nullptr, miLrCmd);
EXPECT_EQ(0, memcmp(&expectedMiLrCmd, miLrCmd, sizeof(MI_LOAD_REGISTER_IMM)));
cmdOffset += sizeof(MI_LOAD_REGISTER_IMM);
pipeControlCmd = genCmdCast<PIPE_CONTROL *>(ptrOffset(stream->getCpuBase(), cmdOffset));
ASSERT_NE(nullptr, pipeControlCmd);
EXPECT_EQ(0, memcmp(&expectedPipeControlCmd, pipeControlCmd, sizeof(PIPE_CONTROL)));
}
ICLLPTEST_F(Gen11MediaSamplerProgramingTest, givenVmeEnableSubsliceEnabledWhenPowerClockStateRegisterEnabledThenExpectNoCmds) {
constexpr uint32_t programVmeCmdSize = 0;
overrideMediaRequest(true, true);
size_t estimatedCmdSize = getCmdSize();
EXPECT_EQ(programVmeCmdSize, estimatedCmdSize);
programMediaSampler();
EXPECT_EQ(programVmeCmdSize, stream->getUsed());
}
ICLLPTEST_F(Gen11MediaSamplerProgramingTest, givenVmeEnableSubsliceDisabledWhenPowerClockStateRegisterDisableThenExpectNoCmds) {
constexpr uint32_t programVmeCmdSize = 0;
overrideMediaRequest(false, false);
size_t estimatedCmdSize = getCmdSize();
EXPECT_EQ(programVmeCmdSize, estimatedCmdSize);
programMediaSampler();
EXPECT_EQ(programVmeCmdSize, stream->getUsed());
}

View File

@@ -5,5 +5,8 @@
#
if(TESTS_LKF)
target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test_hw_info_config_lkf.cpp
)
add_subdirectories()
endif()

View File

@@ -0,0 +1,83 @@
/*
* Copyright (C) 2019-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
TEST(LkfHwInfoConfig, givenInvalidSystemInfoWhenSettingHardwareInfoThenExpectThrow) {
if (IGFX_LAKEFIELD != productFamily) {
return;
}
HardwareInfo hwInfo = *defaultHwInfo;
GT_SYSTEM_INFO &gtSystemInfo = hwInfo.gtSystemInfo;
uint64_t config = 0xdeadbeef;
gtSystemInfo = {0};
EXPECT_ANY_THROW(hardwareInfoSetup[productFamily](&hwInfo, false, config));
EXPECT_EQ(0u, gtSystemInfo.SliceCount);
EXPECT_EQ(0u, gtSystemInfo.SubSliceCount);
EXPECT_EQ(0u, gtSystemInfo.DualSubSliceCount);
EXPECT_EQ(0u, gtSystemInfo.EUCount);
}
using LkfHwInfo = ::testing::Test;
LKFTEST_F(LkfHwInfo, givenHwInfoConfigStringThenAfterSetupResultingVmeIsDisabled) {
HardwareInfo hwInfo = *defaultHwInfo;
uint64_t config = 0x100080008;
hardwareInfoSetup[productFamily](&hwInfo, false, config);
EXPECT_FALSE(hwInfo.capabilityTable.ftrSupportsVmeAvcTextureSampler);
EXPECT_FALSE(hwInfo.capabilityTable.ftrSupportsVmeAvcPreemption);
EXPECT_FALSE(hwInfo.capabilityTable.supportsVme);
}
LKFTEST_F(LkfHwInfo, givenBoolWhenCallLkfHardwareInfoSetupThenFeatureTableAndWorkaroundTableAreSetCorrect) {
bool boolValue[]{
true, false};
HardwareInfo hwInfo = *defaultHwInfo;
GT_SYSTEM_INFO &gtSystemInfo = hwInfo.gtSystemInfo;
FeatureTable &featureTable = hwInfo.featureTable;
WorkaroundTable &workaroundTable = hwInfo.workaroundTable;
uint64_t config = 0x100080008;
for (auto setParamBool : boolValue) {
gtSystemInfo = {0};
featureTable = {};
workaroundTable = {};
hardwareInfoSetup[productFamily](&hwInfo, setParamBool, config);
EXPECT_EQ(setParamBool, featureTable.flags.ftrL3IACoherency);
EXPECT_EQ(setParamBool, featureTable.flags.ftrPPGTT);
EXPECT_EQ(setParamBool, featureTable.flags.ftrSVM);
EXPECT_EQ(setParamBool, featureTable.flags.ftrIA32eGfxPTEs);
EXPECT_EQ(setParamBool, featureTable.flags.ftrStandardMipTailFormat);
EXPECT_EQ(setParamBool, featureTable.flags.ftrDisplayYTiling);
EXPECT_EQ(setParamBool, featureTable.flags.ftrTranslationTable);
EXPECT_EQ(setParamBool, featureTable.flags.ftrUserModeTranslationTable);
EXPECT_EQ(setParamBool, featureTable.flags.ftrTileMappedResource);
EXPECT_EQ(setParamBool, featureTable.flags.ftrEnableGuC);
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbc);
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbc2AddressTranslation);
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbcBlitterTracking);
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbcCpuTracking);
EXPECT_EQ(setParamBool, featureTable.flags.ftrTileY);
EXPECT_EQ(setParamBool, featureTable.flags.ftrAstcHdr2D);
EXPECT_EQ(setParamBool, featureTable.flags.ftrAstcLdr2D);
EXPECT_EQ(setParamBool, featureTable.flags.ftr3dMidBatchPreempt);
EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuMidBatchPreempt);
EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuMidThreadLevelPreempt);
EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuThreadGroupLevelPreempt);
EXPECT_EQ(setParamBool, featureTable.flags.ftrPerCtxtPreemptionGranularityControl);
EXPECT_EQ(setParamBool, workaroundTable.flags.wa4kAlignUVOffsetNV12LinearSurface);
EXPECT_EQ(setParamBool, workaroundTable.flags.waReportPerfCountUseGlobalContextID);
}
}

View File

@@ -12,8 +12,11 @@ target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/deferred_deleter_mt_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gfx_partition_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/graphics_allocation_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/host_ptr_manager_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/internal_allocation_storage_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_usage_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_allocate_in_device_pool_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_multi_device_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_pool_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/multi_graphics_allocation_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/page_table_tests.cpp

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,321 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/memory_manager/internal_allocation_storage.h"
#include "shared/source/os_interface/os_context.h"
#include "shared/test/common/fixtures/memory_allocator_fixture.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/libult/ult_command_stream_receiver.h"
#include "shared/test/common/mocks/mock_allocation_properties.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/test_macros/test.h"
#include "shared/test/unit_test/utilities/containers_tests_helpers.h"
struct InternalAllocationStorageTest : public MemoryAllocatorFixture,
public ::testing::Test {
using MemoryAllocatorFixture::TearDown;
void SetUp() override {
MemoryAllocatorFixture::SetUp();
storage = csr->getInternalAllocationStorage();
}
InternalAllocationStorage *storage;
};
TEST_F(InternalAllocationStorageTest, givenDebugFlagThatDisablesAllocationReuseWhenStoreReusableAllocationIsCalledThenAllocationIsReleased) {
DebugManagerStateRestore stateRestorer;
DebugManager.flags.DisableResourceRecycling.set(true);
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
EXPECT_NE(allocation, csr->getAllocationsForReuse().peekHead());
EXPECT_TRUE(csr->getAllocationsForReuse().peekIsEmpty());
}
TEST_F(InternalAllocationStorageTest, whenCleanAllocationListThenRemoveOnlyCompletedAllocations) {
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
auto allocation2 = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
auto allocation3 = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
allocation->updateTaskCount(10, csr->getOsContext().getContextId());
allocation2->updateTaskCount(5, csr->getOsContext().getContextId());
allocation3->updateTaskCount(15, csr->getOsContext().getContextId());
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), TEMPORARY_ALLOCATION);
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation2), TEMPORARY_ALLOCATION);
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation3), TEMPORARY_ALLOCATION);
//head point to alloc 2, tail points to alloc3
EXPECT_TRUE(csr->getTemporaryAllocations().peekContains(*allocation));
EXPECT_TRUE(csr->getTemporaryAllocations().peekContains(*allocation2));
EXPECT_TRUE(csr->getTemporaryAllocations().peekContains(*allocation3));
EXPECT_EQ(-1, verifyDListOrder(csr->getTemporaryAllocations().peekHead(), allocation, allocation2, allocation3));
//now remove element form the middle
storage->cleanAllocationList(6, TEMPORARY_ALLOCATION);
EXPECT_TRUE(csr->getTemporaryAllocations().peekContains(*allocation));
EXPECT_FALSE(csr->getTemporaryAllocations().peekContains(*allocation2));
EXPECT_TRUE(csr->getTemporaryAllocations().peekContains(*allocation3));
EXPECT_EQ(-1, verifyDListOrder(csr->getTemporaryAllocations().peekHead(), allocation, allocation3));
//now remove head
storage->cleanAllocationList(11, TEMPORARY_ALLOCATION);
EXPECT_FALSE(csr->getTemporaryAllocations().peekContains(*allocation));
EXPECT_FALSE(csr->getTemporaryAllocations().peekContains(*allocation2));
EXPECT_TRUE(csr->getTemporaryAllocations().peekContains(*allocation3));
//now remove tail
storage->cleanAllocationList(16, TEMPORARY_ALLOCATION);
EXPECT_TRUE(csr->getTemporaryAllocations().peekIsEmpty());
}
TEST_F(InternalAllocationStorageTest, whenAllocationIsStoredAsReusableButIsStillUsedThenCannotBeObtained) {
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{0, MemoryConstants::pageSize, AllocationType::BUFFER, mockDeviceBitfield});
storage->storeAllocationWithTaskCount(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION, 2u);
auto *hwTag = csr->getTagAddress();
*hwTag = 1u;
auto newAllocation = storage->obtainReusableAllocation(1, AllocationType::BUFFER);
EXPECT_EQ(nullptr, newAllocation);
storage->cleanAllocationList(2u, REUSABLE_ALLOCATION);
}
TEST_F(InternalAllocationStorageTest, whenAllocationIsStoredAsTemporaryAndIsStillUsedThenCanBeObtained) {
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{0, MemoryConstants::pageSize, AllocationType::BUFFER, mockDeviceBitfield});
storage->storeAllocationWithTaskCount(std::unique_ptr<GraphicsAllocation>(allocation), TEMPORARY_ALLOCATION, 2u);
auto *hwTag = csr->getTagAddress();
*hwTag = 1u;
auto newAllocation = storage->obtainTemporaryAllocationWithPtr(1, allocation->getUnderlyingBuffer(), AllocationType::BUFFER);
EXPECT_EQ(allocation, newAllocation.get());
EXPECT_TRUE(csr->getTemporaryAllocations().peekIsEmpty());
memoryManager->freeGraphicsMemory(newAllocation.release());
}
TEST_F(InternalAllocationStorageTest, givenTemporaryAllocationWhenAllocationIsObtainedThenItsTaskCountIsSetToNotReady) {
const uint32_t initialTaskCount = 37u;
const uint32_t contextId = csr->getOsContext().getContextId();
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{0, MemoryConstants::pageSize, AllocationType::BUFFER, mockDeviceBitfield});
storage->storeAllocationWithTaskCount(std::unique_ptr<GraphicsAllocation>(allocation), TEMPORARY_ALLOCATION, initialTaskCount);
ASSERT_EQ(initialTaskCount, allocation->getTaskCount(contextId));
auto newAllocation = storage->obtainTemporaryAllocationWithPtr(1, allocation->getUnderlyingBuffer(), AllocationType::BUFFER);
EXPECT_EQ(allocation, newAllocation.get());
EXPECT_EQ(CompletionStamp::notReady, allocation->getTaskCount(contextId));
memoryManager->freeGraphicsMemory(newAllocation.release());
}
TEST_F(InternalAllocationStorageTest, whenObtainAllocationFromEmptyReuseListThenReturnNullptr) {
auto allocation2 = storage->obtainReusableAllocation(1, AllocationType::BUFFER);
EXPECT_EQ(nullptr, allocation2);
}
TEST_F(InternalAllocationStorageTest, whenCompletedAllocationIsStoredAsReusableAndThenCanBeObtained) {
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{0, MemoryConstants::pageSize, AllocationType::BUFFER, mockDeviceBitfield});
EXPECT_NE(nullptr, allocation);
storage->storeAllocationWithTaskCount(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION, 2u);
EXPECT_FALSE(csr->getAllocationsForReuse().peekIsEmpty());
auto *hwTag = csr->getTagAddress();
*hwTag = 2u;
auto reusedAllocation = storage->obtainReusableAllocation(1, AllocationType::BUFFER).release();
EXPECT_EQ(allocation, reusedAllocation);
EXPECT_TRUE(csr->getAllocationsForReuse().peekIsEmpty());
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(InternalAllocationStorageTest, whenNotUsedAllocationIsStoredAsReusableAndThenCanBeObtained) {
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{0, MemoryConstants::pageSize, AllocationType::BUFFER, mockDeviceBitfield});
EXPECT_NE(nullptr, allocation);
EXPECT_FALSE(allocation->isUsed());
EXPECT_EQ(0u, csr->peekTaskCount());
*csr->getTagAddress() = 0; // initial hw tag for dll
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
EXPECT_EQ(0u, allocation->getTaskCount(csr->getOsContext().getContextId()));
EXPECT_FALSE(csr->getAllocationsForReuse().peekIsEmpty());
auto reusedAllocation = storage->obtainReusableAllocation(1, AllocationType::BUFFER).release();
EXPECT_EQ(allocation, reusedAllocation);
EXPECT_TRUE(csr->getAllocationsForReuse().peekIsEmpty());
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(InternalAllocationStorageTest, whenObtainAllocationFromMidlleOfReusableListThenItIsDetachedFromLinkedList) {
auto &reusableAllocations = csr->getAllocationsForReuse();
EXPECT_TRUE(reusableAllocations.peekIsEmpty());
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{0, 1, AllocationType::BUFFER, mockDeviceBitfield});
auto allocation2 = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{0, 10000, AllocationType::BUFFER, mockDeviceBitfield});
auto allocation3 = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{0, 1, AllocationType::BUFFER, mockDeviceBitfield});
EXPECT_TRUE(reusableAllocations.peekIsEmpty());
EXPECT_EQ(nullptr, allocation2->next);
EXPECT_EQ(nullptr, allocation2->prev);
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
EXPECT_TRUE(reusableAllocations.peekContains(*allocation));
EXPECT_FALSE(reusableAllocations.peekContains(*allocation2));
EXPECT_FALSE(reusableAllocations.peekContains(*allocation3));
EXPECT_EQ(nullptr, allocation2->next);
EXPECT_EQ(nullptr, allocation2->prev);
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation2), REUSABLE_ALLOCATION);
EXPECT_TRUE(reusableAllocations.peekContains(*allocation));
EXPECT_TRUE(reusableAllocations.peekContains(*allocation2));
EXPECT_FALSE(reusableAllocations.peekContains(*allocation3));
EXPECT_EQ(nullptr, allocation2->next);
EXPECT_EQ(allocation, allocation2->prev);
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation3), REUSABLE_ALLOCATION);
EXPECT_TRUE(reusableAllocations.peekContains(*allocation));
EXPECT_TRUE(reusableAllocations.peekContains(*allocation2));
EXPECT_TRUE(reusableAllocations.peekContains(*allocation3));
EXPECT_EQ(allocation3, allocation2->next);
EXPECT_EQ(allocation, allocation2->prev);
auto reusableAllocation = storage->obtainReusableAllocation(10000, AllocationType::BUFFER).release();
EXPECT_EQ(reusableAllocation, allocation2);
EXPECT_EQ(nullptr, allocation2->next);
EXPECT_EQ(nullptr, allocation2->prev);
EXPECT_EQ(nullptr, reusableAllocation->next);
EXPECT_EQ(nullptr, reusableAllocation->prev);
EXPECT_FALSE(reusableAllocations.peekContains(*reusableAllocation));
EXPECT_TRUE(reusableAllocations.peekContains(*allocation));
EXPECT_FALSE(reusableAllocations.peekContains(*allocation2));
EXPECT_TRUE(reusableAllocations.peekContains(*allocation3));
memoryManager->freeGraphicsMemory(allocation2);
allocation->updateTaskCount(0u, csr->getOsContext().getContextId());
allocation3->updateTaskCount(0u, csr->getOsContext().getContextId());
}
TEST_F(InternalAllocationStorageTest, givenAllocationWhenItIsPutOnReusableListWhenOtherAllocationTypeIsRequestedThenNullIsReturned) {
EXPECT_TRUE(csr->getAllocationsForReuse().peekIsEmpty());
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{0, MemoryConstants::pageSize, AllocationType::BUFFER, mockDeviceBitfield});
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
EXPECT_FALSE(csr->getAllocationsForReuse().peekIsEmpty());
auto internalAllocation = storage->obtainReusableAllocation(1, AllocationType::INTERNAL_HEAP);
EXPECT_EQ(nullptr, internalAllocation);
}
class WaitAtDeletionAllocation : public MockGraphicsAllocation {
public:
WaitAtDeletionAllocation(void *buffer, size_t sizeIn)
: MockGraphicsAllocation(buffer, sizeIn) {
inDestructor = false;
}
std::mutex mutex;
std::atomic<bool> inDestructor;
~WaitAtDeletionAllocation() override {
inDestructor = true;
std::lock_guard<std::mutex> lock(mutex);
}
};
TEST_F(InternalAllocationStorageTest, givenAllocationListWhenTwoThreadsCleanConcurrentlyThenBothThreadsCanAccessTheList) {
auto allocation1 = new WaitAtDeletionAllocation(nullptr, 0);
allocation1->updateTaskCount(1, csr->getOsContext().getContextId());
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation1), TEMPORARY_ALLOCATION);
std::unique_lock<std::mutex> allocationDeletionLock(allocation1->mutex);
auto allocation2 = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
allocation2->updateTaskCount(2, csr->getOsContext().getContextId());
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation2), TEMPORARY_ALLOCATION);
std::mutex mutex;
std::unique_lock<std::mutex> lock(mutex);
std::thread thread1([&] {
storage->cleanAllocationList(1, TEMPORARY_ALLOCATION);
});
std::thread thread2([&] {
std::lock_guard<std::mutex> lock(mutex);
storage->cleanAllocationList(2, TEMPORARY_ALLOCATION);
});
while (!allocation1->inDestructor)
;
lock.unlock();
allocationDeletionLock.unlock();
thread1.join();
thread2.join();
EXPECT_TRUE(csr->getTemporaryAllocations().peekIsEmpty());
}
HWTEST_F(InternalAllocationStorageTest, givenMultipleActivePartitionsWhenDetachingReusableAllocationThenCheckTaskCountFinishedOnAllTiles) {
auto ultCsr = reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(csr);
csr->setActivePartitions(2u);
ultCsr->postSyncWriteOffset = 32;
auto tagAddress = csr->getTagAddress();
*tagAddress = 0xFF;
tagAddress = ptrOffset(tagAddress, 32);
*tagAddress = 0x0;
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
EXPECT_EQ(allocation, csr->getAllocationsForReuse().peekHead());
EXPECT_FALSE(csr->getAllocationsForReuse().peekIsEmpty());
allocation->updateTaskCount(1u, csr->getOsContext().getContextId());
std::unique_ptr<GraphicsAllocation> allocationReusable = csr->getAllocationsForReuse().detachAllocation(0, nullptr, csr, AllocationType::INTERNAL_HOST_MEMORY);
EXPECT_EQ(nullptr, allocationReusable.get());
*tagAddress = 0x1;
allocationReusable = csr->getAllocationsForReuse().detachAllocation(0, nullptr, csr, AllocationType::INTERNAL_HOST_MEMORY);
EXPECT_EQ(allocation, allocationReusable.get());
memoryManager->freeGraphicsMemory(allocationReusable.release());
}
TEST_F(InternalAllocationStorageTest, givenInternalAllocationWhenTaskCountMetsExpectationAndItHasBeenAssignedThenAllocIsRemoved) {
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
uint32_t expectedTaskCount = 10u;
*csr->getTagAddress() = expectedTaskCount;
allocation->updateTaskCount(expectedTaskCount, csr->getOsContext().getContextId());
allocation->hostPtrTaskCountAssignment = 0;
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), TEMPORARY_ALLOCATION);
storage->cleanAllocationList(expectedTaskCount, TEMPORARY_ALLOCATION);
EXPECT_TRUE(csr->getTemporaryAllocations().peekIsEmpty());
}
TEST_F(InternalAllocationStorageTest, givenInternalAllocationWhenTaskCountMetsExpectationAndItHasNotBeenAssignedThenAllocIsNotRemoved) {
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
uint32_t expectedTaskCount = 10u;
*csr->getTagAddress() = expectedTaskCount;
allocation->updateTaskCount(expectedTaskCount, csr->getOsContext().getContextId());
allocation->hostPtrTaskCountAssignment = 1;
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), TEMPORARY_ALLOCATION);
storage->cleanAllocationList(expectedTaskCount, TEMPORARY_ALLOCATION);
EXPECT_FALSE(csr->getTemporaryAllocations().peekIsEmpty());
allocation->hostPtrTaskCountAssignment = 0;
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright (C) 2019-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/constants.h"
#include "shared/source/memory_manager/graphics_allocation.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/test/common/fixtures/memory_allocator_multi_device_fixture.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
using MemoryManagerMultiDeviceTest = MemoryAllocatorMultiDeviceFixture<10>;
TEST_P(MemoryManagerMultiDeviceTest, givenRootDeviceIndexSpecifiedWhenAllocateGraphicsMemoryIsCalledThenGraphicsAllocationHasTheSameRootDeviceIndex) {
std::vector<AllocationType> allocationTypes{AllocationType::BUFFER,
AllocationType::KERNEL_ISA};
for (auto allocationType : allocationTypes) {
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < getNumRootDevices(); ++rootDeviceIndex) {
AllocationProperties properties{rootDeviceIndex, true, MemoryConstants::pageSize, allocationType, false, false, mockDeviceBitfield};
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
ASSERT_NE(gfxAllocation, nullptr);
EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex());
memoryManager->freeGraphicsMemory(gfxAllocation);
gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, (void *)0x1234);
ASSERT_NE(gfxAllocation, nullptr);
EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex());
memoryManager->freeGraphicsMemory(gfxAllocation);
gfxAllocation = memoryManager->allocateGraphicsMemoryInPreferredPool(properties, nullptr);
ASSERT_NE(gfxAllocation, nullptr);
EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex());
memoryManager->freeGraphicsMemory(gfxAllocation);
gfxAllocation = memoryManager->allocateGraphicsMemoryInPreferredPool(properties, (void *)0x1234);
ASSERT_NE(gfxAllocation, nullptr);
EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex());
memoryManager->freeGraphicsMemory(gfxAllocation);
gfxAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(0u), properties, false, false);
ASSERT_NE(gfxAllocation, nullptr);
EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex());
memoryManager->freeGraphicsMemory(gfxAllocation);
gfxAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(0u), properties, true, false);
ASSERT_NE(gfxAllocation, nullptr);
EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex());
memoryManager->freeGraphicsMemory(gfxAllocation);
}
}
}
INSTANTIATE_TEST_CASE_P(MemoryManagerType, MemoryManagerMultiDeviceTest, ::testing::Bool());
TEST_P(MemoryManagerMultiDeviceTest, givenRootDeviceIndexSpecifiedWhenAllocateGraphicsMemoryIsCalledThenGraphicsAllocationHasProperGpuAddress) {
RootDeviceIndicesContainer rootDeviceIndices;
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < getNumRootDevices(); ++rootDeviceIndex) {
rootDeviceIndices.push_back(rootDeviceIndex);
}
rootDeviceIndices.remove_duplicates();
auto maxRootDeviceIndex = *std::max_element(rootDeviceIndices.begin(), rootDeviceIndices.end(), std::less<uint32_t const>());
auto tagsMultiAllocation = new MultiGraphicsAllocation(maxRootDeviceIndex);
AllocationProperties unifiedMemoryProperties{rootDeviceIndices.at(0), MemoryConstants::pageSize, AllocationType::TAG_BUFFER, systemMemoryBitfield};
memoryManager->createMultiGraphicsAllocationInSystemMemoryPool(rootDeviceIndices, unifiedMemoryProperties, *tagsMultiAllocation);
EXPECT_NE(nullptr, tagsMultiAllocation);
auto graphicsAllocation0 = tagsMultiAllocation->getGraphicsAllocation(0);
for (auto graphicsAllocation : tagsMultiAllocation->getGraphicsAllocations()) {
EXPECT_EQ(graphicsAllocation->getUnderlyingBuffer(), graphicsAllocation0->getUnderlyingBuffer());
}
for (auto graphicsAllocation : tagsMultiAllocation->getGraphicsAllocations()) {
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
delete tagsMultiAllocation;
}
TEST_P(MemoryManagerMultiDeviceTest, givenRootDeviceIndexSpecifiedWhenAllocateGraphicsMemoryIsCalledThenAllocationPropertiesUsmFlagIsSetAccordingToAddressRange) {
RootDeviceIndicesContainer rootDeviceIndices;
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < getNumRootDevices(); ++rootDeviceIndex) {
rootDeviceIndices.push_back(rootDeviceIndex);
}
rootDeviceIndices.remove_duplicates();
auto maxRootDeviceIndex = *std::max_element(rootDeviceIndices.begin(), rootDeviceIndices.end(), std::less<uint32_t const>());
auto tagsMultiAllocation = new MultiGraphicsAllocation(maxRootDeviceIndex);
AllocationProperties unifiedMemoryProperties{rootDeviceIndices.at(0), MemoryConstants::pageSize, AllocationType::TAG_BUFFER, systemMemoryBitfield};
memoryManager->createMultiGraphicsAllocationInSystemMemoryPool(rootDeviceIndices, unifiedMemoryProperties, *tagsMultiAllocation);
EXPECT_NE(nullptr, tagsMultiAllocation);
for (auto rootDeviceIndex : rootDeviceIndices) {
if (memoryManager->isLimitedRange(rootDeviceIndex)) {
EXPECT_EQ(unifiedMemoryProperties.flags.isUSMHostAllocation, false);
} else {
EXPECT_EQ(unifiedMemoryProperties.flags.isUSMHostAllocation, true);
}
}
for (auto graphicsAllocation : tagsMultiAllocation->getGraphicsAllocations()) {
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
delete tagsMultiAllocation;
}

View File

@@ -8,6 +8,9 @@ set(NEO_CORE_OS_INTERFACE_AUB_TESTS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/aub_memory_operations_handler_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/aub_memory_operations_handler_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/os_context_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_library_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_tests.cpp
)
set(NEO_CORE_OS_INTERFACE_TESTS

View File

@@ -28,12 +28,14 @@ set(NEO_CORE_OS_INTERFACE_TESTS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_uuid_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_version_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_uuid_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/file_logger_linux_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_linux_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_uuid_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_context_linux_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_interface_linux_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_library_linux_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_time_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/self_lib_lin.cpp
)
if(NEO_ENABLE_i915_PRELIM_DETECTION)
@@ -42,14 +44,14 @@ if(NEO_ENABLE_i915_PRELIM_DETECTION)
${CMAKE_CURRENT_SOURCE_DIR}/drm_cache_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_debug_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_engine_info_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_topology_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_info_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_debug_surface_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_localmem_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_topology_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_residency_handler_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_with_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_vm_bind_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_with_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_tests_prelim.cpp
${CMAKE_CURRENT_SOURCE_DIR}/prelim_helper_func.cpp
)
@@ -74,8 +76,8 @@ endif()
if("${BRANCH_TYPE}" STREQUAL "")
list(APPEND NEO_CORE_OS_INTERFACE_TESTS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_debug_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_tests_upstream.cpp
)
endif()

View File

@@ -0,0 +1,180 @@
/*
* Copyright (C) 2019-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/test/common/libult/linux/drm_mock.h"
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
#include "shared/test/common/test_macros/test.h"
#include "shared/test/unit_test/utilities/logger_tests.h"
using namespace NEO;
TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) {
std::string testFile = "testfile";
DebugVariables flags;
flags.LogAllocationMemoryPool.set(true);
FullyEnabledFileLogger fileLogger(testFile, flags);
// Log file not created
bool logFileCreated = fileExists(fileLogger.getLogFileName());
EXPECT_FALSE(logFileCreated);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::System64KBPages);
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
auto canonizedGpuAddress = gmmHelper->canonize(0x12345);
allocation.setCpuPtrAndGpuAddress(&allocation, canonizedGpuAddress);
MockBufferObject bo(&drm);
bo.handle = 4;
allocation.bufferObjects[0] = &bo;
fileLogger.logAllocation(&allocation);
std::thread::id thisThread = std::this_thread::get_id();
std::stringstream threadIDCheck;
threadIDCheck << " ThreadID: " << thisThread;
std::stringstream memoryPoolCheck;
memoryPoolCheck << " MemoryPool: " << getMemoryPoolString(&allocation);
std::stringstream gpuAddressCheck;
gpuAddressCheck << " GPU address: 0x" << std::hex << allocation.getGpuAddress();
std::stringstream rootDeviceIndexCheck;
rootDeviceIndexCheck << " Root device index: " << allocation.getRootDeviceIndex();
if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) {
auto str = fileLogger.getFileString(fileLogger.getLogFileName());
EXPECT_TRUE(str.find(threadIDCheck.str()) != std::string::npos);
EXPECT_TRUE(str.find(memoryPoolCheck.str()) != std::string::npos);
EXPECT_TRUE(str.find(gpuAddressCheck.str()) != std::string::npos);
EXPECT_TRUE(str.find(rootDeviceIndexCheck.str()) != std::string::npos);
EXPECT_TRUE(str.find("AllocationType: BUFFER") != std::string::npos);
EXPECT_TRUE(str.find("Handle: 4") != std::string::npos);
}
}
TEST(FileLogger, givenLogAllocationStdoutWhenLogAllocationThenLogToStdoutInsteadOfFileAndDoNotCreateFile) {
std::string testFile = "testfile";
DebugVariables flags;
flags.LogAllocationMemoryPool.set(true);
flags.LogAllocationStdout.set(true);
FullyEnabledFileLogger fileLogger(testFile, flags);
// Log file not created
bool logFileCreated = fileExists(fileLogger.getLogFileName());
EXPECT_FALSE(logFileCreated);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::System64KBPages);
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
auto canonizedGpuAddress = gmmHelper->canonize(0x12345);
allocation.setCpuPtrAndGpuAddress(&allocation, canonizedGpuAddress);
MockBufferObject bo(&drm);
bo.handle = 4;
allocation.bufferObjects[0] = &bo;
testing::internal::CaptureStdout();
fileLogger.logAllocation(&allocation);
std::string output = testing::internal::GetCapturedStdout();
std::thread::id thisThread = std::this_thread::get_id();
std::stringstream threadIDCheck;
threadIDCheck << " ThreadID: " << thisThread;
std::stringstream memoryPoolCheck;
memoryPoolCheck << " MemoryPool: " << getMemoryPoolString(&allocation);
std::stringstream gpuAddressCheck;
gpuAddressCheck << " GPU address: 0x" << std::hex << allocation.getGpuAddress();
std::stringstream rootDeviceIndexCheck;
rootDeviceIndexCheck << " Root device index: " << allocation.getRootDeviceIndex();
EXPECT_TRUE(output.find(threadIDCheck.str()) != std::string::npos);
EXPECT_TRUE(output.find(memoryPoolCheck.str()) != std::string::npos);
EXPECT_TRUE(output.find(gpuAddressCheck.str()) != std::string::npos);
EXPECT_TRUE(output.find(rootDeviceIndexCheck.str()) != std::string::npos);
EXPECT_TRUE(output.find("AllocationType: BUFFER") != std::string::npos);
EXPECT_TRUE(output.find("Handle: 4") != std::string::npos);
EXPECT_TRUE(output.find("\n") != std::string::npos);
logFileCreated = fileExists(fileLogger.getLogFileName());
EXPECT_FALSE(logFileCreated);
}
TEST(FileLogger, GivenDrmAllocationWithoutBOThenNoHandleLogged) {
std::string testFile = "testfile";
DebugVariables flags;
flags.LogAllocationMemoryPool.set(true);
FullyEnabledFileLogger fileLogger(testFile, flags);
// Log file not created
bool logFileCreated = fileExists(fileLogger.getLogFileName());
EXPECT_FALSE(logFileCreated);
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::System64KBPages);
fileLogger.logAllocation(&allocation);
std::thread::id thisThread = std::this_thread::get_id();
std::stringstream threadIDCheck;
threadIDCheck << " ThreadID: " << thisThread;
std::stringstream memoryPoolCheck;
memoryPoolCheck << " MemoryPool: " << getMemoryPoolString(&allocation);
if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) {
auto str = fileLogger.getFileString(fileLogger.getLogFileName());
EXPECT_TRUE(str.find(threadIDCheck.str()) != std::string::npos);
EXPECT_TRUE(str.find(memoryPoolCheck.str()) != std::string::npos);
EXPECT_TRUE(str.find("AllocationType: BUFFER") != std::string::npos);
EXPECT_FALSE(str.find("Handle: 4") != std::string::npos);
}
}
TEST(FileLogger, GivenLogAllocationMemoryPoolFlagSetFalseThenAllocationIsNotLogged) {
std::string testFile = "testfile";
DebugVariables flags;
flags.LogAllocationMemoryPool.set(false);
FullyEnabledFileLogger fileLogger(testFile, flags);
// Log file not created
bool logFileCreated = fileExists(fileLogger.getLogFileName());
EXPECT_FALSE(logFileCreated);
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::System64KBPages);
fileLogger.logAllocation(&allocation);
std::thread::id thisThread = std::this_thread::get_id();
std::stringstream threadIDCheck;
threadIDCheck << " ThreadID: " << thisThread;
std::stringstream memoryPoolCheck;
memoryPoolCheck << " MemoryPool: " << getMemoryPoolString(&allocation);
if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) {
auto str = fileLogger.getFileString(fileLogger.getLogFileName());
EXPECT_FALSE(str.find(threadIDCheck.str()) != std::string::npos);
EXPECT_FALSE(str.find(memoryPoolCheck.str()) != std::string::npos);
EXPECT_FALSE(str.find("AllocationType: BUFFER") != std::string::npos);
}
}

View File

@@ -0,0 +1,9 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
extern "C" __attribute__((visibility("default"))) void selfDynamicLibraryFunc() {
}

View File

@@ -0,0 +1,206 @@
/*
* Copyright (C) 2019-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/os_interface/os_context.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/engine_descriptor_helper.h"
#include "shared/test/common/mocks/mock_device.h"
#include "gtest/gtest.h"
using namespace NEO;
TEST(OSContext, whenCreatingDefaultOsContextThenExpectInitializedAlways) {
OsContext *osContext = OsContext::create(nullptr, 0, EngineDescriptorHelper::getDefaultDescriptor());
EXPECT_FALSE(osContext->isLowPriority());
EXPECT_FALSE(osContext->isInternalEngine());
EXPECT_FALSE(osContext->isRootDevice());
delete osContext;
}
TEST(OSContext, givenInternalAndRootDeviceAreTrueWhenCreatingDefaultOsContextThenExpectGettersTrue) {
auto descriptor = EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_RCS, EngineUsage::Internal});
descriptor.isRootDevice = true;
OsContext *osContext = OsContext::create(nullptr, 0, descriptor);
EXPECT_FALSE(osContext->isLowPriority());
EXPECT_TRUE(osContext->isInternalEngine());
EXPECT_TRUE(osContext->isRootDevice());
delete osContext;
}
TEST(OSContext, givenLowPriorityAndRootDeviceAreTrueWhenCreatingDefaultOsContextThenExpectGettersTrue) {
auto descriptor = EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_RCS, EngineUsage::LowPriority});
descriptor.isRootDevice = true;
OsContext *osContext = OsContext::create(nullptr, 0, descriptor);
EXPECT_TRUE(osContext->isLowPriority());
EXPECT_FALSE(osContext->isInternalEngine());
EXPECT_TRUE(osContext->isRootDevice());
delete osContext;
}
TEST(OSContext, givenOsContextCreatedDefaultIsFalseWhenSettingTrueThenFlagTrueReturned) {
OsContext *osContext = OsContext::create(nullptr, 0, EngineDescriptorHelper::getDefaultDescriptor());
EXPECT_FALSE(osContext->isDefaultContext());
osContext->setDefaultContext(true);
EXPECT_TRUE(osContext->isDefaultContext());
delete osContext;
}
TEST(OSContext, givenCooperativeEngineWhenIsCooperativeEngineIsCalledThenReturnTrue) {
auto engineDescriptor = EngineDescriptorHelper::getDefaultDescriptor();
engineDescriptor.engineTypeUsage.second = EngineUsage::Cooperative;
auto pOsContext = OsContext::create(nullptr, 0, engineDescriptor);
EXPECT_FALSE(pOsContext->isRegular());
EXPECT_FALSE(pOsContext->isLowPriority());
EXPECT_FALSE(pOsContext->isInternalEngine());
EXPECT_TRUE(pOsContext->isCooperativeEngine());
delete pOsContext;
}
TEST(OSContext, givenReinitializeContextWhenContextIsInitThenContextIsStillIinitializedAfter) {
auto engineDescriptor = EngineDescriptorHelper::getDefaultDescriptor();
auto pOsContext = OsContext::create(nullptr, 0, engineDescriptor);
EXPECT_NO_THROW(pOsContext->reInitializeContext());
EXPECT_NO_THROW(pOsContext->ensureContextInitialized());
delete pOsContext;
}
TEST(OSContext, givenSetPowerHintThenGetPowerHintShowsTheSameValue) {
auto engineDescriptor = EngineDescriptorHelper::getDefaultDescriptor();
auto pOsContext = OsContext::create(nullptr, 0, engineDescriptor);
pOsContext->setUmdPowerHintValue(1);
EXPECT_EQ(1, pOsContext->getUmdPowerHintValue());
delete pOsContext;
}
struct DeferredOsContextCreationTests : ::testing::Test {
void SetUp() override {
device = std::unique_ptr<MockDevice>{MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get())};
DeviceFactory::prepareDeviceEnvironments(*device->getExecutionEnvironment());
}
std::unique_ptr<OsContext> createOsContext(EngineTypeUsage engineTypeUsage, bool defaultEngine) {
OSInterface *osInterface = device->getRootDeviceEnvironment().osInterface.get();
std::unique_ptr<OsContext> osContext{OsContext::create(osInterface, 0, EngineDescriptorHelper::getDefaultDescriptor(engineTypeUsage))};
EXPECT_FALSE(osContext->isInitialized());
return osContext;
}
void expectContextCreation(EngineTypeUsage engineTypeUsage, bool defaultEngine, bool expectedImmediate) {
auto osContext = createOsContext(engineTypeUsage, defaultEngine);
const bool immediate = osContext->isImmediateContextInitializationEnabled(defaultEngine);
EXPECT_EQ(expectedImmediate, immediate);
if (immediate) {
osContext->ensureContextInitialized();
EXPECT_TRUE(osContext->isInitialized());
}
}
void expectDeferredContextCreation(EngineTypeUsage engineTypeUsage, bool defaultEngine) {
expectContextCreation(engineTypeUsage, defaultEngine, false);
}
void expectImmediateContextCreation(EngineTypeUsage engineTypeUsage, bool defaultEngine) {
expectContextCreation(engineTypeUsage, defaultEngine, true);
}
std::unique_ptr<MockDevice> device;
static inline const EngineTypeUsage engineTypeUsageRegular{aub_stream::ENGINE_RCS, EngineUsage::Regular};
static inline const EngineTypeUsage engineTypeUsageInternal{aub_stream::ENGINE_RCS, EngineUsage::Internal};
static inline const EngineTypeUsage engineTypeUsageBlitter{aub_stream::ENGINE_BCS, EngineUsage::Regular};
};
TEST_F(DeferredOsContextCreationTests, givenRegularEngineWhenCreatingOsContextThenOsContextIsInitializedDeferred) {
DebugManagerStateRestore restore{};
expectDeferredContextCreation(engineTypeUsageRegular, false);
DebugManager.flags.DeferOsContextInitialization.set(1);
expectDeferredContextCreation(engineTypeUsageRegular, false);
DebugManager.flags.DeferOsContextInitialization.set(0);
expectImmediateContextCreation(engineTypeUsageRegular, false);
}
TEST_F(DeferredOsContextCreationTests, givenDefaultEngineWhenCreatingOsContextThenOsContextIsInitializedImmediately) {
DebugManagerStateRestore restore{};
expectImmediateContextCreation(engineTypeUsageRegular, true);
DebugManager.flags.DeferOsContextInitialization.set(1);
expectImmediateContextCreation(engineTypeUsageRegular, true);
DebugManager.flags.DeferOsContextInitialization.set(0);
expectImmediateContextCreation(engineTypeUsageRegular, true);
}
TEST_F(DeferredOsContextCreationTests, givenInternalEngineWhenCreatingOsContextThenOsContextIsInitializedImmediately) {
DebugManagerStateRestore restore{};
expectImmediateContextCreation(engineTypeUsageInternal, false);
DebugManager.flags.DeferOsContextInitialization.set(1);
expectImmediateContextCreation(engineTypeUsageInternal, false);
DebugManager.flags.DeferOsContextInitialization.set(0);
expectImmediateContextCreation(engineTypeUsageInternal, false);
}
TEST_F(DeferredOsContextCreationTests, givenBlitterEngineWhenCreatingOsContextThenOsContextIsInitializedImmediately) {
DebugManagerStateRestore restore{};
expectImmediateContextCreation(engineTypeUsageBlitter, false);
DebugManager.flags.DeferOsContextInitialization.set(1);
expectImmediateContextCreation(engineTypeUsageBlitter, false);
DebugManager.flags.DeferOsContextInitialization.set(0);
expectImmediateContextCreation(engineTypeUsageBlitter, false);
}
TEST_F(DeferredOsContextCreationTests, givenEnsureContextInitializeCalledMultipleTimesWhenOsContextIsCreatedThenInitializeOnlyOnce) {
struct MyOsContext : OsContext {
MyOsContext(uint32_t contextId,
const EngineDescriptor &engineDescriptor) : OsContext(contextId, engineDescriptor) {}
void initializeContext() override {
initializeContextCalled++;
}
size_t initializeContextCalled = 0u;
};
MyOsContext osContext{0, EngineDescriptorHelper::getDefaultDescriptor(engineTypeUsageRegular)};
EXPECT_FALSE(osContext.isInitialized());
osContext.ensureContextInitialized();
EXPECT_TRUE(osContext.isInitialized());
EXPECT_EQ(1u, osContext.initializeContextCalled);
osContext.ensureContextInitialized();
EXPECT_TRUE(osContext.isInitialized());
EXPECT_EQ(1u, osContext.initializeContextCalled);
}
TEST_F(DeferredOsContextCreationTests, givenPrintOsContextInitializationsIsSetWhenOsContextItIsInitializedThenInfoIsLoggedToStdout) {
DebugManagerStateRestore restore{};
DebugManager.flags.DeferOsContextInitialization.set(1);
DebugManager.flags.PrintOsContextInitializations.set(1);
testing::internal::CaptureStdout();
auto osContext = createOsContext(engineTypeUsageRegular, false);
EXPECT_EQ(std::string{}, testing::internal::GetCapturedStdout());
testing::internal::CaptureStdout();
osContext->ensureContextInitialized();
std::string expectedMessage = "OsContext initialization: contextId=0 usage=Regular type=RCS isRootDevice=0\n";
EXPECT_EQ(expectedMessage, testing::internal::GetCapturedStdout());
}

View File

@@ -0,0 +1,130 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#if defined(_WIN32)
#include "shared/source/os_interface/windows/os_library_win.h"
#elif defined(__linux__)
#include "shared/source/os_interface/linux/os_library_linux.h"
#endif
#include "shared/source/os_interface/os_library.h"
#include "shared/test/common/fixtures/memory_management_fixture.h"
#include "shared/test/common/test_macros/test.h"
#include "gtest/gtest.h"
#include <memory>
namespace Os {
extern const char *testDllName;
} // namespace Os
const std::string fakeLibName = "_fake_library_name_";
const std::string fnName = "testDynamicLibraryFunc";
using namespace NEO;
TEST(OSLibraryTest, whenLibraryNameIsEmptyThenCurrentProcesIsUsedAsLibrary) {
std::unique_ptr<OsLibrary> library{OsLibrary::load("")};
EXPECT_NE(nullptr, library);
void *ptr = library->getProcAddress("selfDynamicLibraryFunc");
EXPECT_NE(nullptr, ptr);
}
TEST(OSLibraryTest, GivenFakeLibNameWhenLoadingLibraryThenNullIsReturned) {
OsLibrary *library = OsLibrary::load(fakeLibName);
EXPECT_EQ(nullptr, library);
}
TEST(OSLibraryTest, GivenFakeLibNameWhenLoadingLibraryThenNullIsReturnedAndErrorString) {
std::string errorValue;
OsLibrary *library = OsLibrary::load(fakeLibName, &errorValue);
EXPECT_FALSE(errorValue.empty());
EXPECT_EQ(nullptr, library);
}
TEST(OSLibraryTest, GivenValidLibNameWhenLoadingLibraryThenLibraryIsLoaded) {
std::unique_ptr<OsLibrary> library(OsLibrary::load(Os::testDllName));
EXPECT_NE(nullptr, library);
}
TEST(OSLibraryTest, GivenValidLibNameWhenLoadingLibraryThenLibraryIsLoadedWithNoErrorString) {
std::string errorValue;
std::unique_ptr<OsLibrary> library(OsLibrary::load(Os::testDllName, &errorValue));
EXPECT_TRUE(errorValue.empty());
EXPECT_NE(nullptr, library);
}
TEST(OSLibraryTest, whenSymbolNameIsValidThenGetProcAddressReturnsNonNullPointer) {
std::unique_ptr<OsLibrary> library(OsLibrary::load(Os::testDllName));
EXPECT_NE(nullptr, library);
void *ptr = library->getProcAddress(fnName);
EXPECT_NE(nullptr, ptr);
}
TEST(OSLibraryTest, whenSymbolNameIsInvalidThenGetProcAddressReturnsNullPointer) {
std::unique_ptr<OsLibrary> library(OsLibrary::load(Os::testDllName));
EXPECT_NE(nullptr, library);
void *ptr = library->getProcAddress(fnName + "invalid");
EXPECT_EQ(nullptr, ptr);
}
using OsLibraryTestWithFailureInjection = Test<MemoryManagementFixture>;
TEST_F(OsLibraryTestWithFailureInjection, GivenFailureInjectionWhenLibraryIsLoadedThenOnlyFailedAllocationIsNull) {
InjectedFunction method = [](size_t failureIndex) {
std::string libName(Os::testDllName);
// System under test
OsLibrary *library = OsLibrary::load(libName);
if (MemoryManagement::nonfailingAllocation == failureIndex) {
EXPECT_NE(nullptr, library);
} else {
EXPECT_EQ(nullptr, library);
}
// Make sure that we only have 1 buffer allocated at a time
delete library;
};
injectFailures(method);
}
TEST(OsLibrary, whenCallingIndexOperatorThenObjectConvertibleToFunctionOrVoidPointerIsReturned) {
struct MockOsLibrary : OsLibrary {
void *getProcAddress(const std::string &procName) override {
lastRequestedProcName = procName;
return ptrToReturn;
}
bool isLoaded() override { return true; }
void *ptrToReturn = nullptr;
std::string lastRequestedProcName;
};
MockOsLibrary lib;
int varA;
int varB;
int varC;
using FunctionTypeA = void (*)(int *, float);
using FunctionTypeB = int (*)();
lib.ptrToReturn = &varA;
FunctionTypeA functionA = lib["funcA"];
EXPECT_STREQ("funcA", lib.lastRequestedProcName.c_str());
EXPECT_EQ(&varA, reinterpret_cast<void *>(functionA));
lib.ptrToReturn = &varB;
FunctionTypeB functionB = lib["funcB"];
EXPECT_STREQ("funcB", lib.lastRequestedProcName.c_str());
EXPECT_EQ(&varB, reinterpret_cast<void *>(functionB));
lib.ptrToReturn = &varC;
void *rawPtr = lib["funcC"];
EXPECT_STREQ("funcC", lib.lastRequestedProcName.c_str());
EXPECT_EQ(&varC, rawPtr);
}

View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2019-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/aligned_memory.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/os_interface/os_memory.h"
#include "gtest/gtest.h"
using namespace NEO;
TEST(OSMemory, WhenReservingCpuAddressRangeThenMemoryIsAligned) {
auto osMemory = OSMemory::create();
size_t reservedCpuAddressRangeSize = 1024;
auto reservedCpuAddressRange = osMemory->reserveCpuAddressRange(reservedCpuAddressRangeSize, MemoryConstants::pageSize64k);
EXPECT_NE(reservedCpuAddressRange.originalPtr, nullptr);
EXPECT_TRUE(isAligned<MemoryConstants::pageSize64k>(reservedCpuAddressRange.alignedPtr));
osMemory->releaseCpuAddressRange(reservedCpuAddressRange);
}

View File

@@ -8,16 +8,22 @@ set(NEO_CORE_OS_INTERFACE_TESTS_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/adapter_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/adapter_info_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/deferrable_deletion_win_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gmm_helper_tests_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_win_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_win_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/os_context_win_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_library_win_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/self_lib_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/um_km_data_translator_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_address_space_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_command_stream_l0_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_preemption_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_shared_allocations_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_special_heap_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_shared_allocations_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_command_stream_l0_tests.cpp
)
set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_TESTS_WINDOWS ${NEO_CORE_OS_INTERFACE_TESTS_WINDOWS})

View File

@@ -0,0 +1,69 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/windows/deferrable_deletion_win.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_wddm.h"
#include "gtest/gtest.h"
#include <type_traits>
using namespace NEO;
TEST(DeferrableDeletionImpl, WhenCreatedThenItIsNonCopyable) {
EXPECT_FALSE(std::is_move_constructible<DeferrableDeletionImpl>::value);
EXPECT_FALSE(std::is_copy_constructible<DeferrableDeletionImpl>::value);
}
TEST(DeferrableDeletionImpl, WhenCreatedThenItIsNonAssignable) {
EXPECT_FALSE(std::is_move_assignable<DeferrableDeletionImpl>::value);
EXPECT_FALSE(std::is_copy_assignable<DeferrableDeletionImpl>::value);
}
class MockDeferrableDeletion : public DeferrableDeletionImpl {
public:
using DeferrableDeletionImpl::allocationCount;
using DeferrableDeletionImpl::DeferrableDeletionImpl;
using DeferrableDeletionImpl::handles;
using DeferrableDeletionImpl::resourceHandle;
using DeferrableDeletionImpl::wddm;
};
class DeferrableDeletionTest : public ::testing::Test {
public:
std::unique_ptr<MockExecutionEnvironment> executionEnvironment;
std::unique_ptr<WddmMock> wddm;
const D3DKMT_HANDLE handle = 0;
uint32_t allocationCount = 1;
D3DKMT_HANDLE resourceHandle = 0;
void SetUp() override {
executionEnvironment = std::make_unique<MockExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
wddm = std::make_unique<WddmMock>(*executionEnvironment->rootDeviceEnvironments[0]);
}
};
TEST_F(DeferrableDeletionTest, givenDeferrableDeletionWhenIsCreatedThenObjectMembersAreSetProperly) {
MockDeferrableDeletion deletion(wddm.get(), &handle, allocationCount, resourceHandle);
EXPECT_EQ(wddm.get(), deletion.wddm);
EXPECT_NE(nullptr, deletion.handles);
EXPECT_EQ(handle, *deletion.handles);
EXPECT_NE(&handle, deletion.handles);
EXPECT_EQ(allocationCount, deletion.allocationCount);
EXPECT_EQ(resourceHandle, deletion.resourceHandle);
}
TEST_F(DeferrableDeletionTest, givenDeferrableDeletionWhenApplyIsCalledThenDeletionIsApplied) {
wddm->callBaseDestroyAllocations = false;
std::unique_ptr<DeferrableDeletion> deletion(DeferrableDeletion::create((Wddm *)wddm.get(), &handle, allocationCount, resourceHandle));
EXPECT_EQ(0, wddm->destroyAllocationResult.called);
deletion->apply();
EXPECT_EQ(1, wddm->destroyAllocationResult.called);
}

View File

@@ -0,0 +1,90 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/mocks/mock_wddm.h"
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
using namespace NEO;
struct OsContextWinTest : public WddmTestWithMockGdiDll {
void SetUp() override {
WddmTestWithMockGdiDll::SetUp();
preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
engineTypeUsage = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*defaultHwInfo)[0];
init();
}
PreemptionMode preemptionMode;
EngineTypeUsage engineTypeUsage;
};
TEST_F(OsContextWinTest, givenWddm20WhenCreatingOsContextThenOsContextIsInitialized) {
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engineTypeUsage, preemptionMode));
EXPECT_NO_THROW(osContext->ensureContextInitialized());
}
TEST_F(OsContextWinTest, givenWddm20WhenCreatingWddmContextFailThenOsContextCreationFails) {
wddm->device = INVALID_HANDLE;
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engineTypeUsage, preemptionMode));
EXPECT_ANY_THROW(osContext->ensureContextInitialized());
}
TEST_F(OsContextWinTest, givenWddm20WhenCreatingWddmMonitorFenceFailThenOsContextCreationFails) {
*getCreateSynchronizationObject2FailCallFcn() = true;
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engineTypeUsage, preemptionMode));
EXPECT_ANY_THROW(osContext->ensureContextInitialized());
}
TEST_F(OsContextWinTest, givenWddm20WhenRegisterTrimCallbackFailThenOsContextCreationFails) {
*getRegisterTrimNotificationFailCallFcn() = true;
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engineTypeUsage, preemptionMode));
EXPECT_ANY_THROW(osContext->ensureContextInitialized());
}
TEST_F(OsContextWinTest, givenWddm20WhenRegisterTrimCallbackIsDisabledThenOsContextIsInitialized) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.DoNotRegisterTrimCallback.set(true);
*getRegisterTrimNotificationFailCallFcn() = true;
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engineTypeUsage, preemptionMode));
EXPECT_NO_THROW(osContext->ensureContextInitialized());
}
TEST_F(OsContextWinTest, givenReinitializeContextWhenContextIsInitThenContextIsDestroyedAndRecreated) {
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engineTypeUsage, preemptionMode));
EXPECT_NO_THROW(osContext->reInitializeContext());
EXPECT_NO_THROW(osContext->ensureContextInitialized());
}
TEST_F(OsContextWinTest, givenReinitializeContextWhenContextIsNotInitThenContextIsCreated) {
EXPECT_NO_THROW(osContext->reInitializeContext());
EXPECT_NO_THROW(osContext->ensureContextInitialized());
}
struct OsContextWinTestNoCleanup : public WddmTestWithMockGdiDllNoCleanup {
void SetUp() override {
WddmTestWithMockGdiDllNoCleanup::SetUp();
preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
engineTypeUsage = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*defaultHwInfo)[0];
init();
}
PreemptionMode preemptionMode;
EngineTypeUsage engineTypeUsage;
};
TEST_F(OsContextWinTestNoCleanup, givenReinitializeContextWhenContextIsInitThenContextIsNotDestroyed) {
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engineTypeUsage, preemptionMode));
EXPECT_FALSE(this->wddm->isDriverAvaliable());
EXPECT_TRUE(this->wddm->skipResourceCleanup());
EXPECT_NO_THROW(osContext->reInitializeContext());
EXPECT_NO_THROW(osContext->ensureContextInitialized());
}

View File

@@ -0,0 +1,120 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/windows/os_library_win.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/test_macros/test.h"
#include "gtest/gtest.h"
#include <memory>
namespace Os {
extern const char *testDllName;
}
using namespace NEO;
class OsLibraryBackup : public Windows::OsLibrary {
using Type = decltype(Windows::OsLibrary::loadLibraryExA);
using BackupType = typename VariableBackup<Type>;
using ModuleNameType = decltype(Windows::OsLibrary::getModuleFileNameA);
using ModuleNameBackupType = typename VariableBackup<ModuleNameType>;
using SystemDirectoryType = decltype(Windows::OsLibrary::getSystemDirectoryA);
using SystemDirectoryBackupType = typename VariableBackup<SystemDirectoryType>;
struct Backup {
std::unique_ptr<BackupType> bkp1 = nullptr;
std::unique_ptr<ModuleNameBackupType> bkp2 = nullptr;
std::unique_ptr<SystemDirectoryBackupType> bkp3 = nullptr;
};
public:
static std::unique_ptr<Backup> backup(Type newValue, ModuleNameType newModuleName, SystemDirectoryType newSystemDirectoryName) {
std::unique_ptr<Backup> bkp(new Backup());
bkp->bkp1.reset(new BackupType(&OsLibrary::loadLibraryExA, newValue));
bkp->bkp2.reset(new ModuleNameBackupType(&OsLibrary::getModuleFileNameA, newModuleName));
bkp->bkp3.reset(new SystemDirectoryBackupType(&OsLibrary::getSystemDirectoryA, newSystemDirectoryName));
return bkp;
};
};
bool mockWillFail = true;
void trimFileName(char *buff, size_t length) {
for (size_t l = length; l > 0; l--) {
if (buff[l - 1] == '\\') {
buff[l] = '\0';
break;
}
}
}
DWORD WINAPI GetModuleFileNameAMock(HMODULE hModule, LPSTR lpFilename, DWORD nSize) {
return snprintf(lpFilename, nSize, "z:\\SomeFakeName.dll");
}
HMODULE WINAPI LoadLibraryExAMock(LPCSTR lpFileName, HANDLE hFile, DWORD dwFlags) {
if (mockWillFail)
return NULL;
char fName[MAX_PATH];
auto lenFn = strlen(lpFileName);
strcpy_s(fName, sizeof(fName), lpFileName);
trimFileName(fName, lenFn);
EXPECT_STREQ("z:\\", fName);
return (HMODULE)1;
}
UINT WINAPI GetSystemDirectoryAMock(LPSTR lpBuffer, UINT uSize) {
const char path[] = "C:\\System";
strcpy_s(lpBuffer, sizeof(path), path);
return sizeof(path) - 1; // do not include terminating null
}
TEST(OSLibraryWinTest, WhenLoadDependencyFailsThenFallbackToNonDriverStore) {
auto bkp = OsLibraryBackup::backup(LoadLibraryExAMock, GetModuleFileNameAMock, GetSystemDirectoryAMock);
std::unique_ptr<OsLibrary> library(OsLibrary::load(Os::testDllName));
EXPECT_NE(nullptr, library);
}
TEST(OSLibraryWinTest, WhenDependencyLoadsThenProperPathIsConstructed) {
auto bkp = OsLibraryBackup::backup(LoadLibraryExAMock, GetModuleFileNameAMock, GetSystemDirectoryAMock);
VariableBackup<bool> bkpM(&mockWillFail, false);
std::unique_ptr<OsLibrary> library(OsLibrary::load(Os::testDllName));
EXPECT_NE(nullptr, library);
}
TEST(OSLibraryWinTest, WhenCreatingFullSystemPathThenProperPathIsConstructed) {
auto bkp = OsLibraryBackup::backup(LoadLibraryExAMock, GetModuleFileNameAMock, GetSystemDirectoryAMock);
VariableBackup<bool> bkpM(&mockWillFail, false);
auto fullPath = OsLibrary::createFullSystemPath("test");
EXPECT_STREQ("C:\\System\\test", fullPath.c_str());
}
TEST(OSLibraryWinTest, GivenInvalidLibraryWhenOpeningLibraryThenLoadLibraryErrorIsReturned) {
std::string errorValue;
auto lib = std::make_unique<Windows::OsLibrary>("abc", &errorValue);
EXPECT_FALSE(errorValue.empty());
}
TEST(OSLibraryWinTest, GivenNoLastErrorOnWindowsThenErrorStringisEmpty) {
std::string errorValue;
auto lib = std::make_unique<Windows::OsLibrary>(Os::testDllName, &errorValue);
EXPECT_NE(nullptr, lib);
EXPECT_TRUE(errorValue.empty());
lib->getLastErrorString(&errorValue);
EXPECT_TRUE(errorValue.empty());
lib->getLastErrorString(nullptr);
}

View File

@@ -0,0 +1,9 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
extern "C" __declspec(dllexport) void selfDynamicLibraryFunc() {
}

View File

@@ -0,0 +1,142 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/preemption.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_wddm.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
class WddmMockReserveAddress : public WddmMock {
public:
WddmMockReserveAddress(RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(rootDeviceEnvironment) {}
void *virtualAlloc(void *inPtr, size_t size, bool topDownHint) override {
if (returnGood != 0) {
return WddmMock::virtualAlloc(inPtr, size, topDownHint);
}
if (returnInvalidCount != 0) {
returnInvalidIter++;
if (returnInvalidIter > returnInvalidCount) {
return WddmMock::virtualAlloc(inPtr, size, topDownHint);
}
if (returnNullCount != 0) {
returnNullIter++;
if (returnNullIter > returnNullCount) {
return nullptr;
}
return reinterpret_cast<void *>(0x1000);
}
return reinterpret_cast<void *>(0x1000);
}
return nullptr;
}
void virtualFree(void *ptr, size_t size) override {
if ((ptr == reinterpret_cast<void *>(0x1000)) || (ptr == reinterpret_cast<void *>(0x0))) {
return;
}
return WddmMock::virtualFree(ptr, size);
}
uint32_t returnGood = 0;
uint32_t returnInvalidCount = 0;
uint32_t returnInvalidIter = 0;
uint32_t returnNullCount = 0;
uint32_t returnNullIter = 0;
};
TEST(WddmReserveAddressTest, givenWddmWhenFirstIsSuccessfulThenReturnReserveAddress) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
auto wddm = new WddmMockReserveAddress(rootDeviceEnvironment);
size_t size = 0x1000;
void *reserve = nullptr;
wddm->init();
wddm->returnGood = 1;
auto ret = wddm->reserveValidAddressRange(size, reserve);
uintptr_t expectedReserve = wddm->virtualAllocAddress;
EXPECT_TRUE(ret);
EXPECT_EQ(expectedReserve, reinterpret_cast<uintptr_t>(reserve));
wddm->releaseReservedAddress(reserve);
}
TEST(WddmReserveAddressTest, givenWddmWhenFirstIsNullThenReturnNull) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
auto wddm = new WddmMockReserveAddress(rootDeviceEnvironment);
size_t size = 0x1000;
void *reserve = nullptr;
wddm->init();
uintptr_t expectedReserve = 0;
auto ret = wddm->reserveValidAddressRange(size, reserve);
EXPECT_FALSE(ret);
EXPECT_EQ(expectedReserve, reinterpret_cast<uintptr_t>(reserve));
}
TEST(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondSuccessfulThenReturnSecond) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
auto wddm = new WddmMockReserveAddress(rootDeviceEnvironment);
size_t size = 0x1000;
void *reserve = nullptr;
wddm->init();
wddm->returnInvalidCount = 1;
auto ret = wddm->reserveValidAddressRange(size, reserve);
uintptr_t expectedReserve = wddm->virtualAllocAddress;
EXPECT_TRUE(ret);
EXPECT_EQ(expectedReserve, reinterpret_cast<uintptr_t>(reserve));
wddm->releaseReservedAddress(reserve);
}
TEST(WddmReserveAddressTest, givenWddmWhenSecondIsInvalidThirdSuccessfulThenReturnThird) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
auto wddm = new WddmMockReserveAddress(rootDeviceEnvironment);
size_t size = 0x1000;
void *reserve = nullptr;
wddm->init();
wddm->returnInvalidCount = 2;
auto ret = wddm->reserveValidAddressRange(size, reserve);
uintptr_t expectedReserve = wddm->virtualAllocAddress;
EXPECT_TRUE(ret);
EXPECT_EQ(expectedReserve, reinterpret_cast<uintptr_t>(reserve));
wddm->releaseReservedAddress(reserve);
}
TEST(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondNullThenReturnSecondNull) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
auto wddm = new WddmMockReserveAddress(rootDeviceEnvironment);
size_t size = 0x1000;
void *reserve = nullptr;
wddm->init();
wddm->returnInvalidCount = 2;
wddm->returnNullCount = 1;
uintptr_t expectedReserve = 0;
auto ret = wddm->reserveValidAddressRange(size, reserve);
EXPECT_FALSE(ret);
EXPECT_EQ(expectedReserve, reinterpret_cast<uintptr_t>(reserve));
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/windows/wddm_engine_mapper.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
TEST(WddmMapperTests, givenRcsEngineTypeWhenAskedForNodeOrdinalThenReturn3d) {
GPUNODE_ORDINAL gpuNodeBcs = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_BCS);
GPUNODE_ORDINAL gpuNodeRcs = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_RCS);
GPUNODE_ORDINAL gpuNodeCcs = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS);
GPUNODE_ORDINAL gpuNodeCcs1 = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS1);
GPUNODE_ORDINAL gpuNodeCcs2 = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS2);
GPUNODE_ORDINAL gpuNodeCcs3 = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS3);
GPUNODE_ORDINAL gpuNodeCccs = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCCS);
GPUNODE_ORDINAL expectedBcs = GPUNODE_BLT;
GPUNODE_ORDINAL expectedRcs = GPUNODE_3D;
GPUNODE_ORDINAL expectedCcs = GPUNODE_CCS0;
GPUNODE_ORDINAL expectedCccs = GPUNODE_3D;
EXPECT_EQ(expectedBcs, gpuNodeBcs);
EXPECT_EQ(expectedRcs, gpuNodeRcs);
EXPECT_EQ(expectedCcs, gpuNodeCcs);
EXPECT_EQ(expectedCcs, gpuNodeCcs1);
EXPECT_EQ(expectedCcs, gpuNodeCcs2);
EXPECT_EQ(expectedCcs, gpuNodeCcs3);
EXPECT_EQ(expectedCccs, gpuNodeCccs);
}
TEST(WddmMapperTests, givenLinkCopyEngineWhenMapperCalledThenReturnDefaultBltEngine) {
const std::array<aub_stream::EngineType, 8> bcsLinkEngines = {{aub_stream::ENGINE_BCS1, aub_stream::ENGINE_BCS2, aub_stream::ENGINE_BCS3,
aub_stream::ENGINE_BCS4, aub_stream::ENGINE_BCS5, aub_stream::ENGINE_BCS6,
aub_stream::ENGINE_BCS7, aub_stream::ENGINE_BCS8}};
for (auto engine : bcsLinkEngines) {
EXPECT_EQ(GPUNODE_BLT, WddmEngineMapper::engineNodeMap(engine));
}
}
TEST(WddmMapperTests, givenNotSupportedEngineWhenAskedForNodeThenAbort) {
EXPECT_THROW(WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_VCS), std::exception);
}

View File

@@ -6,12 +6,12 @@
target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}debug_file_reader_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/base_object_utils.h
${CMAKE_CURRENT_SOURCE_DIR}/const_stringref_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/containers_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/containers_tests_helpers.h
${CMAKE_CURRENT_SOURCE_DIR}/cpuintrinsics_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}debug_file_reader_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debug_file_reader_tests.inl
${CMAKE_CURRENT_SOURCE_DIR}/debug_settings_reader_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/destructor_counted.h

View File

@@ -7,6 +7,7 @@
if(TESTS_PVC)
set(NEO_SHARED_TESTS_PVC
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/device_binary_format_ar_tests_pvc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dispatch_walker_tests_pvc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_tests_pvc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/product_config_tests_pvc.cpp
@@ -14,7 +15,6 @@ if(TESTS_PVC)
${CMAKE_CURRENT_SOURCE_DIR}/test_hw_info_config_pvc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_pvc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_sample_pvc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device_binary_format_ar_tests_pvc.cpp
)
target_sources(${TARGET_NAME} PRIVATE ${NEO_SHARED_TESTS_PVC})

View File

@@ -7,12 +7,12 @@
if(TESTS_DG2)
target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}product_config_tests_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/compute_mode_tests_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device_binary_format_ar_tests_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/excludes_xe_hpg_core_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_tests_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}product_config_tests_dg2.cpp
)
add_subdirectories()
endif()