From 7a99bcc2f70acf189e289218c3eb51c0c9265803 Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Mon, 19 Jul 2021 13:48:59 +0000 Subject: [PATCH] Add shared tests for xe_hp_core Signed-off-by: Bartosz Dunajski --- shared/test/common/xe_hp_core/CMakeLists.txt | 10 +- .../image_surface_state_tests_xe_hp_core.cpp | 52 ++++ .../simd_helper_tests_xe_hp_core.cpp | 16 ++ .../xe_hp_core/test_encode_xe_hp_core.cpp | 245 ++++++++++++++++++ .../test_hw_info_config_xe_hp_core.cpp | 6 +- .../common/xe_hp_core/xehp/CMakeLists.txt | 16 ++ .../xe_hp_core/xehp/test_hw_helper_xehp.cpp | 50 ++++ .../xe_hp_core/xehp/test_preamble_xehp.cpp | 94 +++++++ .../xe_hp_core/xehp/test_preemption_xehp.cpp | 98 +++++++ 9 files changed, 580 insertions(+), 7 deletions(-) create mode 100644 shared/test/common/xe_hp_core/image_surface_state_tests_xe_hp_core.cpp create mode 100644 shared/test/common/xe_hp_core/simd_helper_tests_xe_hp_core.cpp create mode 100644 shared/test/common/xe_hp_core/test_encode_xe_hp_core.cpp create mode 100644 shared/test/common/xe_hp_core/xehp/CMakeLists.txt create mode 100644 shared/test/common/xe_hp_core/xehp/test_hw_helper_xehp.cpp create mode 100644 shared/test/common/xe_hp_core/xehp/test_preamble_xehp.cpp create mode 100644 shared/test/common/xe_hp_core/xehp/test_preemption_xehp.cpp diff --git a/shared/test/common/xe_hp_core/CMakeLists.txt b/shared/test/common/xe_hp_core/CMakeLists.txt index b4376edaa3..3b5a42cc18 100644 --- a/shared/test/common/xe_hp_core/CMakeLists.txt +++ b/shared/test/common/xe_hp_core/CMakeLists.txt @@ -8,16 +8,18 @@ if(TESTS_XE_HP_CORE) set(NEO_CORE_TESTS_XE_HP_CORE ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/image_surface_state_tests_xe_hp_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/simd_helper_tests_xe_hp_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_encode_xe_hp_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_hw_info_config_xe_hp_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_xe_hp_core.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_traits_xe_hp_core.h + ${CMAKE_CURRENT_SOURCE_DIR}/unit_test_helper_xe_hp_core.cpp ) set_property(GLOBAL PROPERTY NEO_CORE_TESTS_XE_HP_CORE ${NEO_CORE_TESTS_XE_HP_CORE}) add_subdirectories() target_sources(${TARGET_NAME} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/unit_test_helper_xe_hp_core.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_hw_info_config_xe_hp_core.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_xe_hp_core.cpp ${COMPUTE_RUNTIME_ULT_XE_HP_CORE} ${NEO_CORE_TESTS_XE_HP_CORE} ) diff --git a/shared/test/common/xe_hp_core/image_surface_state_tests_xe_hp_core.cpp b/shared/test/common/xe_hp_core/image_surface_state_tests_xe_hp_core.cpp new file mode 100644 index 0000000000..1aa54ab78d --- /dev/null +++ b/shared/test/common/xe_hp_core/image_surface_state_tests_xe_hp_core.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/unit_test/image/image_surface_state_fixture.h" + +using namespace NEO; + +using ImageSurfaceStateTestsXeHpCore = ImageSurfaceStateTests; + +XE_HP_CORE_TEST_F(ImageSurfaceStateTestsXeHpCore, givenGmmWithMediaCompressedWhenSetFlagsForMediaCompressionThenAuxiliarySurfaceNoneIsSetAndMemoryCompressionEnable) { + auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE); + auto surfaceState = std::make_unique(size); + auto castSurfaceState = reinterpret_cast(surfaceState.get()); + castSurfaceState->setAuxiliarySurfaceMode(FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); + + mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false; + EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, &mockGmm); + EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); + EXPECT_EQ(castSurfaceState->getMemoryCompressionEnable(), false); + mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; + EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, &mockGmm); + EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE); + EXPECT_EQ(castSurfaceState->getMemoryCompressionEnable(), true); +} + +XE_HP_CORE_TEST_F(ImageSurfaceStateTestsXeHpCore, givenGmmWhenSetClearColorParamsThenClearValueAddressEnable) { + auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE); + auto surfaceState = std::make_unique(size); + auto castSurfaceState = reinterpret_cast(surfaceState.get()); + + mockGmm.gmmResourceInfo->getResourceFlags()->Gpu.IndirectClearColor = true; + EncodeSurfaceState::setClearColorParams(castSurfaceState, &mockGmm); + EXPECT_EQ(castSurfaceState->getClearValueAddressEnable(), true); +} + +XE_HP_CORE_TEST_F(ImageSurfaceStateTestsXeHpCore, givenGmmWithMediaCompressedWhenSetMipTailStartLodThenMipTailStartLodIsSet) { + auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE); + auto surfaceState = std::make_unique(size); + auto castSurfaceState = reinterpret_cast(surfaceState.get()); + + setMipTailStartLod(castSurfaceState, nullptr); + + EXPECT_EQ(castSurfaceState->getMipTailStartLod(), 0u); + + setMipTailStartLod(castSurfaceState, &mockGmm); + + EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm.gmmResourceInfo->getMipTailStartLodSurfaceState()); +} diff --git a/shared/test/common/xe_hp_core/simd_helper_tests_xe_hp_core.cpp b/shared/test/common/xe_hp_core/simd_helper_tests_xe_hp_core.cpp new file mode 100644 index 0000000000..82c76e29c9 --- /dev/null +++ b/shared/test/common/xe_hp_core/simd_helper_tests_xe_hp_core.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/helpers/simd_helper_tests.inl" + +using namespace NEO; + +using TestSimdConfigSet = ::testing::Test; + +XE_HP_CORE_TEST_F(TestSimdConfigSet, GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturnedXeHpCore) { + GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturned::TestBodyImpl(); +} \ No newline at end of file diff --git a/shared/test/common/xe_hp_core/test_encode_xe_hp_core.cpp b/shared/test/common/xe_hp_core/test_encode_xe_hp_core.cpp new file mode 100644 index 0000000000..5baba38893 --- /dev/null +++ b/shared/test/common/xe_hp_core/test_encode_xe_hp_core.cpp @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/command_encoder.h" +#include "shared/source/command_stream/stream_properties.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/fixtures/command_container_fixture.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_dispatch_kernel_encoder_interface.h" + +#include "test.h" + +#include "hw_cmds.h" + +using namespace NEO; + +using CommandEncodeXeHpCoreTest = ::testing::Test; + +XE_HP_CORE_TEST_F(CommandEncodeXeHpCoreTest, whenProgrammingStateComputeModeThenProperFieldsAreSet) { + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + uint8_t buffer[64]{}; + + StateComputeModeProperties properties; + auto pLinearStream = std::make_unique(buffer, sizeof(buffer)); + EncodeComputeMode::adjustComputeMode(*pLinearStream, nullptr, properties); + auto pScm = reinterpret_cast(pLinearStream->getCpuBase()); + EXPECT_EQ(0u, pScm->getMaskBits()); + EXPECT_EQ(STATE_COMPUTE_MODE::FORCE_NON_COHERENT_FORCE_DISABLED, pScm->getForceNonCoherent()); + EXPECT_FALSE(pScm->getLargeGrfMode()); + + properties.isCoherencyRequired.value = 0; + properties.largeGrfMode.value = 1; + pLinearStream = std::make_unique(buffer, sizeof(buffer)); + EncodeComputeMode::adjustComputeMode(*pLinearStream, nullptr, properties); + pScm = reinterpret_cast(pLinearStream->getCpuBase()); + EXPECT_EQ(0u, pScm->getMaskBits()); + EXPECT_EQ(STATE_COMPUTE_MODE::FORCE_NON_COHERENT_FORCE_DISABLED, pScm->getForceNonCoherent()); + EXPECT_FALSE(pScm->getLargeGrfMode()); + + properties.isCoherencyRequired.isDirty = true; + properties.largeGrfMode.isDirty = true; + pLinearStream = std::make_unique(buffer, sizeof(buffer)); + EncodeComputeMode::adjustComputeMode(*pLinearStream, nullptr, properties); + pScm = reinterpret_cast(pLinearStream->getCpuBase()); + auto expectedMask = FamilyType::stateComputeModeForceNonCoherentMask | + FamilyType::stateComputeModeLargeGrfModeMask; + EXPECT_EQ(expectedMask, pScm->getMaskBits()); + EXPECT_EQ(STATE_COMPUTE_MODE::FORCE_NON_COHERENT_FORCE_GPU_NON_COHERENT, pScm->getForceNonCoherent()); + EXPECT_TRUE(pScm->getLargeGrfMode()); +} + +struct EncodeKernelGlobalAtomicsFixture : public CommandEncodeStatesFixture, public ::testing::Test { + void SetUp() override { + DebugManager.flags.CreateMultipleSubDevices.set(2); + osLocalMemoryBackup = std::make_unique>(&OSInterface::osEnableLocalMemory, true); + mockDeviceBackup = std::make_unique>(&MockDevice::createSingleDevice, false); + + CommandEncodeStatesFixture::SetUp(); + } + + void TearDown() override { + CommandEncodeStatesFixture::TearDown(); + } + + DebugManagerStateRestore restorer; + std::unique_ptr> osLocalMemoryBackup; + std::unique_ptr> mockDeviceBackup; +}; + +struct EncodeKernelGlobalAtomicsTestWithImplicitScalingTests : public EncodeKernelGlobalAtomicsFixture { + void SetUp() override { + DebugManager.flags.EnableWalkerPartition.set(1); + EncodeKernelGlobalAtomicsFixture::SetUp(); + } + + void TearDown() override { + EncodeKernelGlobalAtomicsFixture::TearDown(); + } + + DebugManagerStateRestore restorer; +}; + +XE_HP_CORE_TEST_F(EncodeKernelGlobalAtomicsTestWithImplicitScalingTests, givenCleanHeapsAndSlmNotChangedAndNoUncachedMocsAndGlobalAtomicsUsedThenDisableSupportForMultiGpuAtomicsForStatelessAccessesIsFalse) { + uint32_t dims[] = {2, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + cmdContainer->slmSize = 1; + EXPECT_CALL(*dispatchInterface.get(), getSlmTotalSize()).WillRepeatedly(::testing::Return(cmdContainer->slmSize)); + cmdContainer->setDirtyStateForAllHeaps(false); + + bool requiresUncachedMocs = false; + bool useGlobalAtomics = true; + uint32_t partitionCount = 0; + EncodeDispatchKernel::encode(*cmdContainer.get(), dims, false, false, dispatchInterface.get(), 0, false, false, + pDevice, NEO::PreemptionMode::Disabled, requiresUncachedMocs, useGlobalAtomics, partitionCount, false); + + EXPECT_TRUE(cmdContainer->lastSentUseGlobalAtomics); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(commands.end(), itor); + + auto cmdSba = genCmdCast(*itor); + EXPECT_FALSE(cmdSba->getDisableSupportForMultiGpuAtomicsForStatelessAccesses()); +} + +XE_HP_CORE_TEST_F(EncodeKernelGlobalAtomicsTestWithImplicitScalingTests, givenCleanHeapsAndSlmNotChangedAndNoUncachedMocsAndGlobalAtomicsUsedAndLastSentGlobalAtomicsTrueThenSbaIsNotProgrammed) { + uint32_t dims[] = {2, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + cmdContainer->slmSize = 1; + EXPECT_CALL(*dispatchInterface.get(), getSlmTotalSize()).WillRepeatedly(::testing::Return(cmdContainer->slmSize)); + cmdContainer->setDirtyStateForAllHeaps(false); + + bool requiresUncachedMocs = false; + bool useGlobalAtomics = true; + cmdContainer->lastSentUseGlobalAtomics = true; + uint32_t partitionCount = 0; + EncodeDispatchKernel::encode(*cmdContainer.get(), dims, false, false, dispatchInterface.get(), 0, false, false, + pDevice, NEO::PreemptionMode::Disabled, requiresUncachedMocs, useGlobalAtomics, partitionCount, false); + + EXPECT_TRUE(cmdContainer->lastSentUseGlobalAtomics); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + auto itor = find(commands.begin(), commands.end()); + ASSERT_EQ(commands.end(), itor); +} + +XE_HP_CORE_TEST_F(EncodeKernelGlobalAtomicsTestWithImplicitScalingTests, givenCleanHeapsAndSlmNotChangedAndNoUncachedMocsAndNoGlobalAtomicsUsedAndLastSentGlobalAtomicsTrueThenDisableSupportForMultiGpuAtomicsForStatelessAccessesIsTrue) { + uint32_t dims[] = {2, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + cmdContainer->slmSize = 1; + EXPECT_CALL(*dispatchInterface.get(), getSlmTotalSize()).WillRepeatedly(::testing::Return(cmdContainer->slmSize)); + cmdContainer->setDirtyStateForAllHeaps(false); + + bool requiresUncachedMocs = false; + bool useGlobalAtomics = false; + cmdContainer->lastSentUseGlobalAtomics = true; + uint32_t partitionCount = 0; + EncodeDispatchKernel::encode(*cmdContainer.get(), dims, false, false, dispatchInterface.get(), 0, false, false, + pDevice, NEO::PreemptionMode::Disabled, requiresUncachedMocs, useGlobalAtomics, partitionCount, false); + + EXPECT_FALSE(cmdContainer->lastSentUseGlobalAtomics); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(commands.end(), itor); + + auto cmdSba = genCmdCast(*itor); + EXPECT_TRUE(cmdSba->getDisableSupportForMultiGpuAtomicsForStatelessAccesses()); +} + +XE_HP_CORE_TEST_F(EncodeKernelGlobalAtomicsTestWithImplicitScalingTests, givenCleanHeapsAndSlmNotChangedAndUncachedMocsAndNoGlobalAtomicsUsedAndLastSentGlobalAtomicsTrueThenDisableSupportForMultiGpuAtomicsForStatelessAccessesIsTrue) { + uint32_t dims[] = {2, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + cmdContainer->slmSize = 1; + EXPECT_CALL(*dispatchInterface.get(), getSlmTotalSize()).WillRepeatedly(::testing::Return(cmdContainer->slmSize)); + cmdContainer->setDirtyStateForAllHeaps(false); + + bool requiresUncachedMocs = true; + bool useGlobalAtomics = false; + cmdContainer->lastSentUseGlobalAtomics = true; + uint32_t partitionCount = 0; + EncodeDispatchKernel::encode(*cmdContainer.get(), dims, false, false, dispatchInterface.get(), 0, false, false, + pDevice, NEO::PreemptionMode::Disabled, requiresUncachedMocs, useGlobalAtomics, partitionCount, false); + + EXPECT_FALSE(cmdContainer->lastSentUseGlobalAtomics); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(commands.end(), itor); + + auto cmdSba = genCmdCast(*itor); + EXPECT_TRUE(cmdSba->getDisableSupportForMultiGpuAtomicsForStatelessAccesses()); +} + +XE_HP_CORE_TEST_F(EncodeKernelGlobalAtomicsTestWithImplicitScalingTests, givenCleanHeapsAndSlmNotChangedAndNoUncachedMocsAndNoGlobalAtomicsUsedThenSbaIsNotProgrammed) { + uint32_t dims[] = {2, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + cmdContainer->slmSize = 1; + EXPECT_CALL(*dispatchInterface.get(), getSlmTotalSize()).WillRepeatedly(::testing::Return(cmdContainer->slmSize)); + cmdContainer->setDirtyStateForAllHeaps(false); + + bool requiresUncachedMocs = false; + bool useGlobalAtomics = false; + uint32_t partitionCount = 0; + EncodeDispatchKernel::encode(*cmdContainer.get(), dims, false, false, dispatchInterface.get(), 0, false, false, + pDevice, NEO::PreemptionMode::Disabled, requiresUncachedMocs, useGlobalAtomics, partitionCount, false); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + auto itor = find(commands.begin(), commands.end()); + ASSERT_EQ(commands.end(), itor); +} + +struct EncodeKernelGlobalAtomicsTestWithNoImplicitScalingTests : public EncodeKernelGlobalAtomicsFixture { + void SetUp() override { + DebugManager.flags.EnableWalkerPartition.set(0); + EncodeKernelGlobalAtomicsFixture::SetUp(); + } + + void TearDown() override { + EncodeKernelGlobalAtomicsFixture::TearDown(); + } + + DebugManagerStateRestore restorer; +}; + +XE_HP_CORE_TEST_F(EncodeKernelGlobalAtomicsTestWithNoImplicitScalingTests, givenCleanHeapsAndSlmNotChangedAndNoUncachedMocsAndGlobalAtomicsUsedWithNoImplicitScalingThenSBAIsNotProgrammed) { + uint32_t dims[] = {2, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + cmdContainer->slmSize = 1; + EXPECT_CALL(*dispatchInterface.get(), getSlmTotalSize()).WillRepeatedly(::testing::Return(cmdContainer->slmSize)); + cmdContainer->setDirtyStateForAllHeaps(false); + + bool requiresUncachedMocs = false; + bool useGlobalAtomics = true; + uint32_t partitionCount = 0; + EncodeDispatchKernel::encode(*cmdContainer.get(), dims, false, false, dispatchInterface.get(), 0, false, false, + pDevice, NEO::PreemptionMode::Disabled, requiresUncachedMocs, useGlobalAtomics, partitionCount, false); + + EXPECT_FALSE(cmdContainer->lastSentUseGlobalAtomics); + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + auto itor = find(commands.begin(), commands.end()); + EXPECT_EQ(commands.end(), itor); +} diff --git a/shared/test/common/xe_hp_core/test_hw_info_config_xe_hp_core.cpp b/shared/test/common/xe_hp_core/test_hw_info_config_xe_hp_core.cpp index d96adfe274..53f728739b 100644 --- a/shared/test/common/xe_hp_core/test_hw_info_config_xe_hp_core.cpp +++ b/shared/test/common/xe_hp_core/test_hw_info_config_xe_hp_core.cpp @@ -13,9 +13,9 @@ using namespace NEO; -using XeHPHwInfoConfig = Test; +using XeHPMaxThreadsTest = Test; -XEHPTEST_F(XeHPHwInfoConfig, givenXEHPWithA0SteppingThenMaxThreadsForWorkgroupWAIsRequired) { +XEHPTEST_F(XeHPMaxThreadsTest, givenXEHPWithA0SteppingThenMaxThreadsForWorkgroupWAIsRequired) { auto hwInfoConfig = HwInfoConfig::get(productFamily); auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); auto &hwHelper = HwHelper::get(hwInfo->platform.eRenderCoreFamily); @@ -24,7 +24,7 @@ XEHPTEST_F(XeHPHwInfoConfig, givenXEHPWithA0SteppingThenMaxThreadsForWorkgroupWA EXPECT_TRUE(isWARequired); } -XEHPTEST_F(XeHPHwInfoConfig, givenXEHPWithBSteppingThenMaxThreadsForWorkgroupWAIsNotRequired) { +XEHPTEST_F(XeHPMaxThreadsTest, givenXEHPWithBSteppingThenMaxThreadsForWorkgroupWAIsNotRequired) { auto hwInfoConfig = HwInfoConfig::get(productFamily); auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); auto &hwHelper = HwHelper::get(hwInfo->platform.eRenderCoreFamily); diff --git a/shared/test/common/xe_hp_core/xehp/CMakeLists.txt b/shared/test/common/xe_hp_core/xehp/CMakeLists.txt new file mode 100644 index 0000000000..f01ad23b02 --- /dev/null +++ b/shared/test/common/xe_hp_core/xehp/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright (C) 2021 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_XEHP) + set(NEO_CORE_TESTS_XE_HP_CORE_XEHP + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/test_hw_helper_xehp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_xehp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_xehp.cpp + ) + + target_sources(${TARGET_NAME} PRIVATE ${NEO_CORE_TESTS_XE_HP_CORE_XEHP}) +endif() diff --git a/shared/test/common/xe_hp_core/xehp/test_hw_helper_xehp.cpp b/shared/test/common/xe_hp_core/xehp/test_hw_helper_xehp.cpp new file mode 100644 index 0000000000..c25d3034ab --- /dev/null +++ b/shared/test/common/xe_hp_core/xehp/test_hw_helper_xehp.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/hw_helper.h" +#include "shared/test/common/helpers/default_hw_info.h" + +#include "test.h" + +using namespace NEO; +using HwHelperTestXeHP = ::testing::Test; + +XEHPTEST_F(HwHelperTestXeHP, givenSteppingWhenAskingForLocalMemoryAccessModeThenDisallowOnA0) { + HardwareInfo hwInfo = *defaultHwInfo; + auto renderCoreFamily = defaultHwInfo->platform.eRenderCoreFamily; + + auto &helper = HwHelper::get(renderCoreFamily); + + hwInfo.platform.usRevId = helper.getHwRevIdFromStepping(REVISION_A0, hwInfo); + EXPECT_EQ(LocalMemoryAccessMode::CpuAccessDisallowed, helper.getLocalMemoryAccessMode(hwInfo)); + + hwInfo.platform.usRevId = helper.getHwRevIdFromStepping(REVISION_B, hwInfo); + EXPECT_EQ(LocalMemoryAccessMode::Default, helper.getLocalMemoryAccessMode(hwInfo)); +} + +XEHPTEST_F(HwHelperTestXeHP, givenSteppingAorBWhenCheckingSipWAThenTrueIsReturned) { + HardwareInfo hwInfo = *defaultHwInfo; + auto renderCoreFamily = defaultHwInfo->platform.eRenderCoreFamily; + + auto &helper = HwHelper::get(renderCoreFamily); + + hwInfo.platform.usRevId = helper.getHwRevIdFromStepping(REVISION_A0, hwInfo); + EXPECT_TRUE(helper.isSipWANeeded(hwInfo)); + + hwInfo.platform.usRevId = helper.getHwRevIdFromStepping(REVISION_B, hwInfo); + EXPECT_TRUE(helper.isSipWANeeded(hwInfo)); +} + +XEHPTEST_F(HwHelperTestXeHP, givenSteppingCWhenCheckingSipWAThenFalseIsReturned) { + HardwareInfo hwInfo = *defaultHwInfo; + auto renderCoreFamily = defaultHwInfo->platform.eRenderCoreFamily; + + auto &helper = HwHelper::get(renderCoreFamily); + + hwInfo.platform.usRevId = helper.getHwRevIdFromStepping(REVISION_C, hwInfo); + EXPECT_FALSE(helper.isSipWANeeded(hwInfo)); +} diff --git a/shared/test/common/xe_hp_core/xehp/test_preamble_xehp.cpp b/shared/test/common/xe_hp_core/xehp/test_preamble_xehp.cpp new file mode 100644 index 0000000000..f5d9727f6a --- /dev/null +++ b/shared/test/common/xe_hp_core/xehp/test_preamble_xehp.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/preemption.h" +#include "shared/test/common/cmd_parse/hw_parse.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_graphics_allocation.h" + +#include "opencl/source/helpers/hardware_commands_helper.h" +#include "test.h" + +using namespace NEO; + +struct XeHPSlm : HardwareParse, ::testing::Test { + void SetUp() override { + HardwareParse::SetUp(); + } + + void TearDown() override { + HardwareParse::TearDown(); + } + + uint32_t cmdBuffer[1024]; + MockGraphicsAllocation gfxAllocation{cmdBuffer, sizeof(cmdBuffer)}; + LinearStream linearStream{&gfxAllocation}; +}; + +XEHPTEST_F(XeHPSlm, givenTglWhenPreambleIsBeingProgrammedThenThreadArbitrationPolicyIsIgnored) { + typedef XeHpFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; + LinearStream &cs = linearStream; + uint32_t l3Config = PreambleHelper::getL3Config(*defaultHwInfo, true); + MockDevice mockDevice; + PreambleHelper::programPreamble(&linearStream, mockDevice, l3Config, + ThreadArbitrationPolicy::RoundRobin, + nullptr); + + parseCommands(cs); + + // parse through commands and ensure that 0xE404 is not being programmed + EXPECT_EQ(0U, countMmio(cmdList.begin(), cmdList.end(), 0xE404)); +} + +XEHPTEST_F(XeHPSlm, WhenProgrammingL3ThenLoadRegisterImmNotUsed) { + typedef XeHpFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; + LinearStream &cs = linearStream; + uint32_t l3Config = PreambleHelper::getL3Config(*defaultHwInfo, true); + PreambleHelper::programL3(&cs, l3Config); + + parseCommands(cs); + + auto itorLRI = find(cmdList.begin(), cmdList.end()); + ASSERT_EQ(cmdList.end(), itorLRI); +} + +using XeHPUrbEntryAllocationSize = ::testing::Test; +XEHPTEST_F(XeHPUrbEntryAllocationSize, WhenGettingUrbEntryAllocationSizeTheZeroIsReturned) { + uint32_t actualVal = PreambleHelper::getUrbEntryAllocationSize(); + EXPECT_EQ(0u, actualVal); +} + +using XeHPPreambleVfeState = XeHPSlm; +XEHPTEST_F(XeHPPreambleVfeState, givenDefaultPipeControlWhenItIsProgrammedThenCsStallBitIsSet) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + + PIPE_CONTROL *pipeControl = static_cast(linearStream.getSpace(sizeof(PIPE_CONTROL))); + *pipeControl = FamilyType::cmdInitPipeControl; + + EXPECT_EQ(1u, pipeControl->getCommandStreamerStallEnable()); +} + +XEHPTEST_F(XeHPPreambleVfeState, whenProgrammingComputeWalkerThenUavFieldsSetToZero) { + using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; + + COMPUTE_WALKER *computeWalker = static_cast(linearStream.getSpace(sizeof(COMPUTE_WALKER))); + *computeWalker = FamilyType::cmdInitGpgpuWalker; + + EXPECT_FALSE(computeWalker->getUavWaitToProduce()); + EXPECT_FALSE(computeWalker->getUavProducer()); + EXPECT_FALSE(computeWalker->getUavConsumer()); +} + +XEHPTEST_F(XeHPPreambleVfeState, whenProgrammingVfeStateThenDoNotAddPipeControlWaCmd) { + LinearStream &cs = linearStream; + + size_t sizeBefore = cs.getUsed(); + PreambleHelper::addPipeControlBeforeVfeCmd(&cs, defaultHwInfo.get(), EngineGroupType::RenderCompute); + size_t sizeAfter = cs.getUsed(); + + EXPECT_EQ(sizeBefore, sizeAfter); +} diff --git a/shared/test/common/xe_hp_core/xehp/test_preemption_xehp.cpp b/shared/test/common/xe_hp_core/xehp/test_preemption_xehp.cpp new file mode 100644 index 0000000000..4a8d833fd2 --- /dev/null +++ b/shared/test/common/xe_hp_core/xehp/test_preemption_xehp.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/preemption.h" +#include "shared/source/helpers/hw_info.h" +#include "shared/test/common/cmd_parse/hw_parse.h" +#include "shared/test/common/mocks/mock_debugger.h" +#include "shared/test/common/mocks/mock_device.h" + +#include "test.h" + +#include +using namespace NEO; + +using PreemptionXeHPTest = ::testing::Test; + +XEHPTEST_F(PreemptionXeHPTest, givenRevisionA0toBWhenProgrammingSipThenGlobalSipIsSet) { + using PIPE_CONTROL = XeHpFamily::PIPE_CONTROL; + using MI_LOAD_REGISTER_IMM = XeHpFamily::MI_LOAD_REGISTER_IMM; + using STATE_SIP = XeHpFamily::STATE_SIP; + HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + + HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); + + std::array revisions = {hwHelper.getHwRevIdFromStepping(REVID::REVISION_A0, hwInfo), + hwHelper.getHwRevIdFromStepping(REVID::REVISION_B, hwInfo)}; + + for (auto revision : revisions) { + hwInfo.platform.usRevId = revision; + + std::unique_ptr mockDevice(NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + mockDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(new MockDebugger); + auto sipAllocation = SipKernel::getSipKernel(*mockDevice).getSipAllocation(); + + size_t requiredSize = PreemptionHelper::getRequiredStateSipCmdSize(*mockDevice); + StackVec streamStorage(1024); + LinearStream cmdStream{streamStorage.begin(), streamStorage.size()}; + + auto expectedGlobalSipWaSize = sizeof(PIPE_CONTROL) + 2 * sizeof(MI_LOAD_REGISTER_IMM); + EXPECT_EQ(expectedGlobalSipWaSize, requiredSize); + PreemptionHelper::programStateSip(cmdStream, *mockDevice); + EXPECT_NE(0U, cmdStream.getUsed()); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(cmdStream.getCpuBase(), 0), cmdStream.getUsed())); + + auto itorLRI = findMmio(cmdList.begin(), cmdList.end(), 0xE42C); + EXPECT_NE(cmdList.end(), itorLRI); + + auto cmdLRI = genCmdCast(*itorLRI); + auto sipAddress = cmdLRI->getDataDword() & 0xfffffff8; + EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), sipAddress); + } +} + +XEHPTEST_F(PreemptionXeHPTest, givenRevisionA0toBWhenProgrammingSipEndWaThenGlobalSipIsRestored) { + using PIPE_CONTROL = XeHpFamily::PIPE_CONTROL; + using MI_LOAD_REGISTER_IMM = XeHpFamily::MI_LOAD_REGISTER_IMM; + using STATE_SIP = XeHpFamily::STATE_SIP; + HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + + HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); + + std::array revisions = {hwHelper.getHwRevIdFromStepping(REVID::REVISION_A0, hwInfo), + hwHelper.getHwRevIdFromStepping(REVID::REVISION_B, hwInfo)}; + + for (auto revision : revisions) { + hwInfo.platform.usRevId = revision; + + std::unique_ptr mockDevice(NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + mockDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(new MockDebugger); + + StackVec streamStorage(1024); + LinearStream cmdStream{streamStorage.begin(), streamStorage.size()}; + + PreemptionHelper::programStateSipEndWa(cmdStream, *mockDevice); + EXPECT_NE(0U, cmdStream.getUsed()); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(cmdStream.getCpuBase(), 0), cmdStream.getUsed())); + + auto itorPC = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itorPC); + + auto itorLRI = findMmio(itorPC, cmdList.end(), 0xE42C); + EXPECT_NE(cmdList.end(), itorLRI); + + auto cmdLRI = genCmdCast(*itorLRI); + auto sipAddress = cmdLRI->getDataDword() & 0xfffffff8; + EXPECT_EQ(0u, sipAddress); + } +}