From 5cfb59c27e4ae394c031f910ad693e18eb5565fb Mon Sep 17 00:00:00 2001 From: Katarzyna Cencelewska Date: Fri, 4 Nov 2022 17:00:28 +0000 Subject: [PATCH] Disable timestamp shift for gen9 also move hwhelper tests from opencl to shared folder Related-To: HSD-18025130857 Signed-off-by: Katarzyna Cencelewska --- opencl/test/unit_test/helpers/CMakeLists.txt | 10 +- .../cl_hw_helper_tests_xehp_and_later.cpp | 31 ++ .../helpers/hw_helper_tests_dg2_and_later.cpp | 168 ------ .../hw_helper_tests_xehp_and_later.cpp | 501 ------------------ shared/source/gen9/hw_helper_gen9.cpp | 5 + .../helpers/hw_helper_bdw_and_later.inl | 1 - .../helpers/hw_helper_dg2_and_later.inl | 1 - .../unit_test/gen9/hw_helper_tests_gen9.cpp | 5 + shared/test/unit_test/helpers/CMakeLists.txt | 2 + .../helpers/hw_helper_tests_dg2_and_later.cpp | 158 +++++- .../helpers/hw_helper_tests_dg2_or_below.cpp | 11 +- .../helpers/hw_helper_tests_pvc_and_later.cpp | 0 12 files changed, 205 insertions(+), 688 deletions(-) create mode 100644 opencl/test/unit_test/helpers/cl_hw_helper_tests_xehp_and_later.cpp delete mode 100644 opencl/test/unit_test/helpers/hw_helper_tests_dg2_and_later.cpp delete mode 100644 opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp rename {opencl => shared}/test/unit_test/helpers/hw_helper_tests_dg2_or_below.cpp (58%) rename {opencl => shared}/test/unit_test/helpers/hw_helper_tests_pvc_and_later.cpp (100%) diff --git a/opencl/test/unit_test/helpers/CMakeLists.txt b/opencl/test/unit_test/helpers/CMakeLists.txt index e5e8ace4190fc..95e5f99c60f6d 100644 --- a/opencl/test/unit_test/helpers/CMakeLists.txt +++ b/opencl/test/unit_test/helpers/CMakeLists.txt @@ -18,7 +18,6 @@ set(IGDRCL_SRCS_tests_helpers ${CMAKE_CURRENT_SOURCE_DIR}/heap_assigner_ocl_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_default_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_dg2_or_below.cpp ${CMAKE_CURRENT_SOURCE_DIR}/kmd_notify_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_helpers_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mipmap_tests.cpp @@ -37,24 +36,17 @@ if(TESTS_XEHP_AND_LATER) list(APPEND IGDRCL_SRCS_tests_helpers ${CMAKE_CURRENT_SOURCE_DIR}/aub_helper_hw_tests_xehp_and_later.cpp ${CMAKE_CURRENT_SOURCE_DIR}/engine_node_helper_tests_xehp_and_later.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_xehp_and_later.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/cl_hw_helper_tests_xehp_and_later.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_xehp_and_later.cpp ) endif() if(TESTS_DG2_AND_LATER) list(APPEND IGDRCL_SRCS_tests_helpers - ${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_dg2_and_later.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_dg2_and_later.cpp ) endif() -if(TESTS_PVC_AND_LATER) - list(APPEND IGDRCL_SRCS_tests_helpers - ${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_pvc_and_later.cpp - ) -endif() - get_property(NEO_CORE_PREAMBLE_TESTS GLOBAL PROPERTY NEO_CORE_PREAMBLE_TESTS) target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_helpers}) diff --git a/opencl/test/unit_test/helpers/cl_hw_helper_tests_xehp_and_later.cpp b/opencl/test/unit_test/helpers/cl_hw_helper_tests_xehp_and_later.cpp new file mode 100644 index 0000000000000..761be69611d57 --- /dev/null +++ b/opencl/test/unit_test/helpers/cl_hw_helper_tests_xehp_and_later.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2021-2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/helpers/hw_helper_tests.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "opencl/source/helpers/cl_hw_helper.h" +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" +#include "opencl/test/unit_test/mocks/mock_context.h" + +using ClHwHelperTestXeHpAndLater = ::testing::Test; + +HWCMDTEST_F(IGFX_XE_HP_CORE, ClHwHelperTestXeHpAndLater, givenCLImageFormatsWhenCallingIsFormatRedescribableThenFalseIsReturned) { + static const cl_image_format redescribeFormats[] = { + {CL_R, CL_UNSIGNED_INT8}, + {CL_R, CL_UNSIGNED_INT16}, + {CL_R, CL_UNSIGNED_INT32}, + {CL_RG, CL_UNSIGNED_INT32}, + {CL_RGBA, CL_UNSIGNED_INT32}, + }; + MockContext context; + auto &clHwHelper = ClHwHelper::get(context.getDevice(0)->getHardwareInfo().platform.eRenderCoreFamily); + + for (const auto &format : redescribeFormats) { + EXPECT_EQ(false, clHwHelper.isFormatRedescribable(format)); + } +} diff --git a/opencl/test/unit_test/helpers/hw_helper_tests_dg2_and_later.cpp b/opencl/test/unit_test/helpers/hw_helper_tests_dg2_and_later.cpp deleted file mode 100644 index d616a657f4779..0000000000000 --- a/opencl/test/unit_test/helpers/hw_helper_tests_dg2_and_later.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2021-2022 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "shared/source/helpers/hw_helper.h" -#include "shared/source/helpers/pipe_control_args.h" -#include "shared/source/os_interface/hw_info_config.h" -#include "shared/test/common/cmd_parse/gen_cmd_parse.h" -#include "shared/test/common/helpers/debug_manager_state_restore.h" -#include "shared/test/common/helpers/hw_helper_tests.h" -#include "shared/test/common/helpers/unit_test_helper.h" -#include "shared/test/common/test_macros/hw_test.h" - -#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" - -using PipeControlHelperTestsDg2AndLater = ::testing::Test; -using HwHelperTestsDg2AndLater = Test; - -HWTEST2_F(PipeControlHelperTestsDg2AndLater, WhenAddingPipeControlWAThenCorrectCommandsAreProgrammed, IsAtLeastXeHpgCore) { - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; - uint8_t buffer[128]; - uint64_t address = 0x1234567887654321; - HardwareInfo hardwareInfo = *defaultHwInfo; - bool requiresMemorySynchronization = (MemorySynchronizationCommands::getSizeForAdditonalSynchronization(hardwareInfo) > 0) ? true : false; - - for (auto ftrLocalMemory : ::testing::Bool()) { - LinearStream stream(buffer, 128); - hardwareInfo.featureTable.flags.ftrLocalMemory = ftrLocalMemory; - - MemorySynchronizationCommands::addBarrierWa(stream, address, hardwareInfo); - - if (MemorySynchronizationCommands::isBarrierWaRequired(hardwareInfo) == false) { - EXPECT_EQ(0u, stream.getUsed()); - continue; - } - - GenCmdList cmdList; - FamilyType::PARSE::parseCommandBuffer(cmdList, stream.getCpuBase(), stream.getUsed()); - EXPECT_EQ(requiresMemorySynchronization ? 2u : 1u, cmdList.size()); - - PIPE_CONTROL expectedPipeControl = FamilyType::cmdInitPipeControl; - expectedPipeControl.setCommandStreamerStallEnable(true); - UnitTestHelper::setPipeControlHdcPipelineFlush(expectedPipeControl, true); - expectedPipeControl.setUnTypedDataPortCacheFlush(true); - auto it = cmdList.begin(); - auto pPipeControl = genCmdCast(*it); - ASSERT_NE(nullptr, pPipeControl); - EXPECT_TRUE(memcmp(&expectedPipeControl, pPipeControl, sizeof(PIPE_CONTROL)) == 0); - - if (requiresMemorySynchronization) { - if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(hardwareInfo)) { - MI_SEMAPHORE_WAIT expectedMiSemaphoreWait; - EncodeSempahore::programMiSemaphoreWait(&expectedMiSemaphoreWait, address, - EncodeSempahore::invalidHardwareTag, - MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD, - false); - auto pMiSemaphoreWait = genCmdCast(*(++it)); - ASSERT_NE(nullptr, pMiSemaphoreWait); - EXPECT_TRUE(memcmp(&expectedMiSemaphoreWait, pMiSemaphoreWait, sizeof(MI_SEMAPHORE_WAIT)) == 0); - } - } - } -} - -HWTEST2_F(PipeControlHelperTestsDg2AndLater, WhenSettingExtraPipeControlPropertiesThenCorrectValuesAreSet, IsAtLeastXeHpgCore) { - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - - for (auto ftrLocalMemory : ::testing::Bool()) { - HardwareInfo hardwareInfo = *defaultHwInfo; - hardwareInfo.featureTable.flags.ftrLocalMemory = ftrLocalMemory; - - PipeControlArgs args; - MemorySynchronizationCommands::setPostSyncExtraProperties(args, hardwareInfo); - - if (ftrLocalMemory) { - EXPECT_TRUE(args.hdcPipelineFlush); - EXPECT_TRUE(args.unTypedDataPortCacheFlush); - } else { - EXPECT_FALSE(args.hdcPipelineFlush); - EXPECT_FALSE(args.unTypedDataPortCacheFlush); - } - } -} - -HWTEST2_F(PipeControlHelperTestsDg2AndLater, whenSettingCacheFlushExtraFieldsThenExpectHdcAndUnTypedDataPortFlushSet, IsAtLeastXeHpgCore) { - PipeControlArgs args; - - MemorySynchronizationCommands::setCacheFlushExtraProperties(args); - EXPECT_TRUE(args.hdcPipelineFlush); - EXPECT_TRUE(args.unTypedDataPortCacheFlush); -} - -HWTEST2_F(PipeControlHelperTestsDg2AndLater, givenRequestedCacheFlushesWhenProgrammingPipeControlThenFlushHdcAndUnTypedDataPortCache, IsAtLeastXeHpgCore) { - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - - uint32_t buffer[sizeof(PIPE_CONTROL) * 2] = {}; - LinearStream stream(buffer, sizeof(buffer)); - - PipeControlArgs args; - args.hdcPipelineFlush = true; - args.unTypedDataPortCacheFlush = true; - args.compressionControlSurfaceCcsFlush = true; - MemorySynchronizationCommands::addSingleBarrier(stream, args); - - auto pipeControl = reinterpret_cast(buffer); - EXPECT_TRUE(UnitTestHelper::getPipeControlHdcPipelineFlush(*pipeControl)); - EXPECT_TRUE(pipeControl->getUnTypedDataPortCacheFlush()); - EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush()); -} - -HWTEST2_F(PipeControlHelperTestsDg2AndLater, givenDebugVariableSetWhenProgrammingPipeControlThenFlushHdcAndUnTypedDataPortCache, IsAtLeastXeHpgCore) { - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - DebugManagerStateRestore restore; - DebugManager.flags.FlushAllCaches.set(true); - - uint32_t buffer[sizeof(PIPE_CONTROL) * 2] = {}; - LinearStream stream(buffer, sizeof(buffer)); - - PipeControlArgs args; - MemorySynchronizationCommands::addSingleBarrier(stream, args); - - auto pipeControl = reinterpret_cast(buffer); - EXPECT_TRUE(UnitTestHelper::getPipeControlHdcPipelineFlush(*pipeControl)); - EXPECT_TRUE(pipeControl->getUnTypedDataPortCacheFlush()); - EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush()); -} - -HWTEST2_F(PipeControlHelperTestsDg2AndLater, givenDebugDisableCacheFlushWhenProgrammingPipeControlWithCacheFlushThenExpectDebugOverrideFlushHdcAndUnTypedDataPortCache, IsAtLeastXeHpgCore) { - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - DebugManagerStateRestore restore; - DebugManager.flags.DoNotFlushCaches.set(true); - - uint32_t buffer[sizeof(PIPE_CONTROL) * 2] = {}; - LinearStream stream(buffer, sizeof(buffer)); - - PipeControlArgs args; - args.hdcPipelineFlush = true; - args.unTypedDataPortCacheFlush = true; - args.compressionControlSurfaceCcsFlush = true; - MemorySynchronizationCommands::addSingleBarrier(stream, args); - - auto pipeControl = reinterpret_cast(buffer); - EXPECT_FALSE(UnitTestHelper::getPipeControlHdcPipelineFlush(*pipeControl)); - EXPECT_FALSE(pipeControl->getUnTypedDataPortCacheFlush()); - EXPECT_FALSE(pipeControl->getCompressionControlSurfaceCcsFlush()); -} - -HWTEST2_F(HwHelperTestsDg2AndLater, givenXeHPGAndLaterPlatformWhenCheckingIfUnTypedDataPortCacheFlushRequiredThenReturnTrue, IsAtLeastXeHpgCore) { - auto &hwHelper = HwHelper::get(renderCoreFamily); - EXPECT_TRUE(hwHelper.unTypedDataPortCacheFlushRequired()); -} - -HWTEST2_F(HwHelperTestsDg2AndLater, givenHwHelperWhenCheckIsUpdateTaskCountFromWaitSupportedThenReturnsTrue, IsAtLeastXeHpgCore) { - auto &hwHelper = HwHelper::get(hardwareInfo.platform.eRenderCoreFamily); - - EXPECT_TRUE(hwHelper.isUpdateTaskCountFromWaitSupported()); -} - -using HwInfoConfigTestDg2AndLater = ::testing::Test; - -HWTEST2_F(HwInfoConfigTestDg2AndLater, givenDg2AndLaterPlatformWhenAskedIfHeapInLocalMemThenTrueIsReturned, IsAtLeastXeHpgCore) { - const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily); - EXPECT_TRUE(hwInfoConfig.heapInLocalMem(*defaultHwInfo)); -} diff --git a/opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp b/opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp deleted file mode 100644 index b3635aa8439bb..0000000000000 --- a/opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp +++ /dev/null @@ -1,501 +0,0 @@ -/* - * Copyright (C) 2021-2022 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "shared/source/command_container/command_encoder.h" -#include "shared/source/gmm_helper/gmm_helper.h" -#include "shared/source/helpers/engine_node_helper.h" -#include "shared/source/helpers/pipe_control_args.h" -#include "shared/source/os_interface/hw_info_config.h" -#include "shared/test/common/cmd_parse/gen_cmd_parse.h" -#include "shared/test/common/helpers/debug_manager_state_restore.h" -#include "shared/test/common/helpers/hw_helper_tests.h" -#include "shared/test/common/helpers/ult_hw_helper.h" -#include "shared/test/common/helpers/unit_test_helper.h" -#include "shared/test/common/test_macros/hw_test.h" - -#include "opencl/source/command_queue/gpgpu_walker.h" -#include "opencl/source/helpers/cl_hw_helper.h" -#include "opencl/source/helpers/hardware_commands_helper.h" -#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" -#include "opencl/test/unit_test/mocks/mock_context.h" - -#include "engine_node.h" - -using HwHelperTestXeHPAndLater = Test; - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, WhenGettingMaxBarriersPerSliceThen32IsReturned) { - auto &helper = HwHelper::get(renderCoreFamily); - EXPECT_EQ(32u, helper.getMaxBarrierRegisterPerSlice()); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenHwHelperWhenGetGpuTimeStampInNSIsCalledThenOnlyLow32BitsFromTimeStampAreUsedAndCorrectValueIsReturned) { - constexpr uint64_t mask = static_cast(std::numeric_limits::max()); - - auto &helper = HwHelper::get(renderCoreFamily); - auto timeStamp = 0x00ff'ffff'ffff; - auto frequency = 123456.0; - auto result = static_cast((timeStamp & mask) * frequency); - - EXPECT_EQ(result, helper.getGpuTimeStampInNS(timeStamp, frequency)); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, GivenNoCcsNodeThenDefaultEngineTypeIsRcs) { - hardwareInfo.featureTable.flags.ftrCCSNode = false; - - auto &helper = HwHelper::get(renderCoreFamily); - helper.adjustDefaultEngineType(&hardwareInfo); - - auto expectedEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, hardwareInfo); - - EXPECT_EQ(expectedEngine, hardwareInfo.capabilityTable.defaultEngineType); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, GiveCcsNodeThenDefaultEngineTypeIsCcs) { - hardwareInfo.featureTable.flags.ftrCCSNode = true; - - auto &helper = HwHelper::get(renderCoreFamily); - helper.adjustDefaultEngineType(&hardwareInfo); - EXPECT_EQ(aub_stream::ENGINE_CCS, hardwareInfo.capabilityTable.defaultEngineType); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenXeHPAndLaterPlatformWithLocalMemoryFeatureWhenIsLocalMemoryEnabledIsCalledThenTrueIsReturned) { - hardwareInfo.featureTable.flags.ftrLocalMemory = true; - - auto &helper = reinterpret_cast &>(HwHelperHw::get()); - EXPECT_TRUE(helper.isLocalMemoryEnabled(hardwareInfo)); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenXeHPAndLaterPlatformWithoutLocalMemoryFeatureWhenIsLocalMemoryEnabledIsCalledThenFalseIsReturned) { - hardwareInfo.featureTable.flags.ftrLocalMemory = false; - - auto &helper = reinterpret_cast &>(HwHelperHw::get()); - EXPECT_FALSE(helper.isLocalMemoryEnabled(hardwareInfo)); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenXeHPAndLaterPlatformWhenCheckingIfHvAlign4IsRequiredThenReturnFalse) { - auto &helper = HwHelperHw::get(); - EXPECT_FALSE(helper.hvAlign4Required()); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenXeHPAndLaterPlatformWhenCheckTimestampPacketWriteThenReturnTrue) { - auto &hwHelper = HwHelperHw::get(); - EXPECT_TRUE(hwHelper.timestampPacketWriteSupported()); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenXeHPAndLaterPlatformWhenPreferInternalBcsEngineThenReturnTrue) { - auto &hwHelper = HwHelperHw::get(); - EXPECT_TRUE(hwHelper.preferInternalBcsEngine()); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenXeHPAndLaterPlatformAndDebugFlagsWhenPreferInternalBcsEngineThenReturnsCorrectResult) { - DebugManagerStateRestore restore; - auto &hwHelper = HwHelperHw::get(); - - DebugManager.flags.PreferInternalBcsEngine.set(1); - EXPECT_TRUE(hwHelper.preferInternalBcsEngine()); - - DebugManager.flags.PreferInternalBcsEngine.set(0); - EXPECT_FALSE(hwHelper.preferInternalBcsEngine()); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenAllFlagsSetWhenGetGpgpuEnginesThenReturnThreeRcsEnginesFourCcsEnginesAndOneBcsEngine) { - HardwareInfo hwInfo = *defaultHwInfo; - hwInfo.featureTable.flags.ftrCCSNode = true; - hwInfo.featureTable.ftrBcsInfo = 1; - hwInfo.featureTable.flags.ftrRcsNode = true; - hwInfo.capabilityTable.blitterOperationsSupported = true; - hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; - hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; - - auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); - - EXPECT_EQ(9u, device->allEngines.size()); - auto &engines = HwHelperHw::get().getGpgpuEngineInstances(hwInfo); - EXPECT_EQ(9u, engines.size()); - - EXPECT_EQ(aub_stream::ENGINE_CCS, engines[0].first); - EXPECT_EQ(aub_stream::ENGINE_CCS1, engines[1].first); - EXPECT_EQ(aub_stream::ENGINE_CCS2, engines[2].first); - EXPECT_EQ(aub_stream::ENGINE_CCS3, engines[3].first); - EXPECT_EQ(aub_stream::ENGINE_RCS, engines[4].first); - EXPECT_EQ(hwInfo.capabilityTable.defaultEngineType, engines[5].first); // low priority - EXPECT_EQ(EngineUsage::LowPriority, engines[5].second); - EXPECT_EQ(hwInfo.capabilityTable.defaultEngineType, engines[6].first); // internal - EXPECT_EQ(EngineUsage::Internal, engines[6].second); - EXPECT_EQ(aub_stream::ENGINE_BCS, engines[7].first); - EXPECT_EQ(aub_stream::ENGINE_BCS, engines[8].first); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenBcsDisabledWhenGetGpgpuEnginesThenReturnThreeRcsEnginesFourCcsEngines) { - HardwareInfo hwInfo = *defaultHwInfo; - hwInfo.featureTable.flags.ftrCCSNode = true; - hwInfo.featureTable.ftrBcsInfo = 0; - hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; - hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; - - auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); - - EXPECT_EQ(7u, device->allEngines.size()); - auto &engines = HwHelperHw::get().getGpgpuEngineInstances(hwInfo); - EXPECT_EQ(7u, engines.size()); - - EXPECT_EQ(aub_stream::ENGINE_CCS, engines[0].first); - EXPECT_EQ(aub_stream::ENGINE_CCS1, engines[1].first); - EXPECT_EQ(aub_stream::ENGINE_CCS2, engines[2].first); - EXPECT_EQ(aub_stream::ENGINE_CCS3, engines[3].first); - EXPECT_EQ(aub_stream::ENGINE_RCS, engines[4].first); - EXPECT_EQ(hwInfo.capabilityTable.defaultEngineType, engines[5].first); // low priority - EXPECT_EQ(aub_stream::ENGINE_CCS, engines[6].first); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenCcsDisabledWhenGetGpgpuEnginesThenReturnRcsAndOneBcsEngine) { - HardwareInfo hwInfo = *defaultHwInfo; - hwInfo.featureTable.flags.ftrCCSNode = false; - hwInfo.featureTable.ftrBcsInfo = 1; - hwInfo.capabilityTable.blitterOperationsSupported = true; - hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_RCS; - hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 0; - - auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); - - EXPECT_EQ(5u, device->allEngines.size()); - auto &engines = HwHelperHw::get().getGpgpuEngineInstances(hwInfo); - EXPECT_EQ(5u, engines.size()); - - EXPECT_EQ(aub_stream::ENGINE_RCS, engines[0].first); - EXPECT_EQ(aub_stream::ENGINE_RCS, engines[1].first); - EXPECT_EQ(aub_stream::ENGINE_RCS, engines[2].first); - EXPECT_EQ(aub_stream::ENGINE_BCS, engines[3].first); - EXPECT_EQ(aub_stream::ENGINE_BCS, engines[4].first); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenCcsDisabledAndNumberOfCcsEnabledWhenGetGpgpuEnginesThenReturnRcsAndOneBcsEngine) { - HardwareInfo hwInfo = *defaultHwInfo; - hwInfo.featureTable.flags.ftrCCSNode = false; - hwInfo.featureTable.ftrBcsInfo = 1; - hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_RCS; - hwInfo.capabilityTable.blitterOperationsSupported = true; - hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; - - auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); - - EXPECT_EQ(5u, device->allEngines.size()); - auto &engines = HwHelperHw::get().getGpgpuEngineInstances(hwInfo); - EXPECT_EQ(5u, engines.size()); - - EXPECT_EQ(aub_stream::ENGINE_RCS, engines[0].first); - EXPECT_EQ(aub_stream::ENGINE_RCS, engines[1].first); - EXPECT_EQ(aub_stream::ENGINE_RCS, engines[2].first); - EXPECT_EQ(aub_stream::ENGINE_BCS, engines[3].first); - EXPECT_EQ(aub_stream::ENGINE_BCS, engines[4].first); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenVariousCachesRequestProperMOCSIndexesAreBeingReturned) { - DebugManagerStateRestore restore; - - auto &helper = HwHelper::get(renderCoreFamily); - auto gmmHelper = this->pDevice->getRootDeviceEnvironment().getGmmHelper(); - auto expectedMocsForL3off = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED) >> 1; - auto expectedMocsForL3on = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER) >> 1; - auto expectedMocsForL3andL1on = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST) >> 1; - - auto mocsIndex = helper.getMocsIndex(*gmmHelper, false, true); - EXPECT_EQ(expectedMocsForL3off, mocsIndex); - - mocsIndex = helper.getMocsIndex(*gmmHelper, true, false); - EXPECT_EQ(expectedMocsForL3andL1on, mocsIndex); - - mocsIndex = helper.getMocsIndex(*gmmHelper, true, true); - - EXPECT_EQ(expectedMocsForL3andL1on, mocsIndex); - - DebugManager.flags.ForceL1Caching.set(0u); - - mocsIndex = helper.getMocsIndex(*gmmHelper, true, false); - EXPECT_EQ(expectedMocsForL3on, mocsIndex); - - mocsIndex = helper.getMocsIndex(*gmmHelper, true, true); - expectedMocsForL3andL1on = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST) >> 1; - - EXPECT_EQ(expectedMocsForL3andL1on, mocsIndex); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenStoreRegMemCommandWhenAdjustingThenSetRemapEnabled) { - typename FamilyType::MI_STORE_REGISTER_MEM_CMD storeRegMem = {}; - - storeRegMem.setMmioRemapEnable(false); - - GpgpuWalkerHelper::adjustMiStoreRegMemMode(&storeRegMem); - - EXPECT_TRUE(storeRegMem.getMmioRemapEnable()); -} - -using PipeControlHelperTestsXeHPAndLater = ::testing::Test; - -HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPAndLater, WhenAddingPipeControlWAThenCorrectCommandsAreProgrammed) { - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; - uint8_t buffer[128]; - uint64_t address = 0x1234567887654321; - HardwareInfo hardwareInfo = *defaultHwInfo; - bool requiresMemorySynchronization = (MemorySynchronizationCommands::getSizeForAdditonalSynchronization(hardwareInfo) > 0) ? true : false; - - for (auto ftrLocalMemory : ::testing::Bool()) { - LinearStream stream(buffer, 128); - hardwareInfo.featureTable.flags.ftrLocalMemory = ftrLocalMemory; - - MemorySynchronizationCommands::addBarrierWa(stream, address, hardwareInfo); - - if (MemorySynchronizationCommands::isBarrierWaRequired(hardwareInfo) == false) { - EXPECT_EQ(0u, stream.getUsed()); - continue; - } - - GenCmdList cmdList; - FamilyType::PARSE::parseCommandBuffer(cmdList, stream.getCpuBase(), stream.getUsed()); - EXPECT_EQ(requiresMemorySynchronization ? 2u : 1u, cmdList.size()); - - PIPE_CONTROL expectedPipeControl = FamilyType::cmdInitPipeControl; - expectedPipeControl.setCommandStreamerStallEnable(true); - UnitTestHelper::setPipeControlHdcPipelineFlush(expectedPipeControl, true); - auto it = cmdList.begin(); - auto pPipeControl = genCmdCast(*it); - ASSERT_NE(nullptr, pPipeControl); - EXPECT_TRUE(memcmp(&expectedPipeControl, pPipeControl, sizeof(PIPE_CONTROL)) == 0); - - if (requiresMemorySynchronization) { - if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(hardwareInfo)) { - MI_SEMAPHORE_WAIT expectedMiSemaphoreWait; - EncodeSempahore::programMiSemaphoreWait(&expectedMiSemaphoreWait, address, - EncodeSempahore::invalidHardwareTag, - MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD, - false); - auto pMiSemaphoreWait = genCmdCast(*(++it)); - ASSERT_NE(nullptr, pMiSemaphoreWait); - EXPECT_TRUE(memcmp(&expectedMiSemaphoreWait, pMiSemaphoreWait, sizeof(MI_SEMAPHORE_WAIT)) == 0); - } - } - } -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPAndLater, WhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) { - HardwareInfo hardwareInfo = *defaultHwInfo; - - EXPECT_EQ(0u, UltMemorySynchronizationCommands::getSizeForAdditonalSynchronization(hardwareInfo)); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPAndLater, WhenSettingExtraPipeControlPropertiesThenCorrectValuesAreSet) { - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - - for (auto ftrLocalMemory : ::testing::Bool()) { - HardwareInfo hardwareInfo = *defaultHwInfo; - hardwareInfo.featureTable.flags.ftrLocalMemory = ftrLocalMemory; - - PipeControlArgs args; - MemorySynchronizationCommands::setPostSyncExtraProperties(args, hardwareInfo); - - if (ftrLocalMemory) { - EXPECT_TRUE(args.hdcPipelineFlush); - } else { - EXPECT_FALSE(args.hdcPipelineFlush); - } - } -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPAndLater, whenSettingCacheFlushExtraFieldsThenExpectHdcFlushSet) { - PipeControlArgs args; - - MemorySynchronizationCommands::setCacheFlushExtraProperties(args); - EXPECT_TRUE(args.hdcPipelineFlush); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPAndLater, givenRequestedCacheFlushesWhenProgrammingPipeControlThenFlushHdc) { - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - - uint32_t buffer[sizeof(PIPE_CONTROL) * 2] = {}; - LinearStream stream(buffer, sizeof(buffer)); - - PipeControlArgs args; - args.hdcPipelineFlush = true; - args.compressionControlSurfaceCcsFlush = true; - MemorySynchronizationCommands::addSingleBarrier(stream, args); - - auto pipeControl = reinterpret_cast(buffer); - EXPECT_TRUE(UnitTestHelper::getPipeControlHdcPipelineFlush(*pipeControl)); - EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush()); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPAndLater, givenDebugVariableSetWhenProgrammingPipeControlThenFlushHdc) { - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - DebugManagerStateRestore restore; - DebugManager.flags.FlushAllCaches.set(true); - - uint32_t buffer[sizeof(PIPE_CONTROL) * 2] = {}; - LinearStream stream(buffer, sizeof(buffer)); - - PipeControlArgs args; - MemorySynchronizationCommands::addSingleBarrier(stream, args); - - auto pipeControl = reinterpret_cast(buffer); - EXPECT_TRUE(UnitTestHelper::getPipeControlHdcPipelineFlush(*pipeControl)); - EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush()); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPAndLater, givenDebugDisableCacheFlushWhenProgrammingPipeControlWithCacheFlushThenExpectDebugOverrideFlushHdc) { - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - DebugManagerStateRestore restore; - DebugManager.flags.DoNotFlushCaches.set(true); - - uint32_t buffer[sizeof(PIPE_CONTROL) * 2] = {}; - LinearStream stream(buffer, sizeof(buffer)); - - PipeControlArgs args; - args.hdcPipelineFlush = true; - args.compressionControlSurfaceCcsFlush = true; - MemorySynchronizationCommands::addSingleBarrier(stream, args); - - auto pipeControl = reinterpret_cast(buffer); - EXPECT_FALSE(UnitTestHelper::getPipeControlHdcPipelineFlush(*pipeControl)); - EXPECT_FALSE(pipeControl->getCompressionControlSurfaceCcsFlush()); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenHwHelperXeCoreWhenGettingGlobalTimeStampBitsThen32IsReturned) { - auto &helper = HwHelper::get(renderCoreFamily); - EXPECT_EQ(helper.getGlobalTimeStampBits(), 32U); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenHwHelperWhenGettingPlanarYuvHeightThenHelperReturnsCorrectValue) { - auto &helper = HwHelper::get(renderCoreFamily); - EXPECT_EQ(helper.getPlanarYuvMaxHeight(), 16128u); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, WhenIsPipeControlWArequiredIsCalledThenCorrectValueIsReturned) { - auto hwInfo = pDevice->getHardwareInfo(); - for (auto ftrLocalMemory : ::testing::Bool()) { - hwInfo.featureTable.flags.ftrLocalMemory = ftrLocalMemory; - - EXPECT_EQ(UnitTestHelper::isPipeControlWArequired(hwInfo), - MemorySynchronizationCommands::isBarrierWaRequired(hwInfo)); - } -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, whenGettingPreferenceForSmallKernelsThenCertainThresholdIsTested) { - DebugManagerStateRestore restorer; - auto &hwInfo = pDevice->getHardwareInfo(); - auto &helper = HwHelper::get(renderCoreFamily); - if (HwInfoConfig::get(hwInfo.platform.eProductFamily)->getSteppingFromHwRevId(hwInfo) >= REVISION_B) { - EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(512u, hwInfo)); - EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(10000u, hwInfo)); - EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(2047u, hwInfo)); - EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(2048u, hwInfo)); - } else { - EXPECT_TRUE(helper.preferSmallWorkgroupSizeForKernel(512u, hwInfo)); - EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(10000u, hwInfo)); - EXPECT_TRUE(helper.preferSmallWorkgroupSizeForKernel(2047u, hwInfo)); - EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(2048u, hwInfo)); - - DebugManager.flags.OverrideKernelSizeLimitForSmallDispatch.set(1u); - EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(1u, hwInfo)); - EXPECT_TRUE(helper.preferSmallWorkgroupSizeForKernel(0u, hwInfo)); - - DebugManager.flags.OverrideKernelSizeLimitForSmallDispatch.set(0u); - EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(1u, hwInfo)); - EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(0u, hwInfo)); - } -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenHwHelperWhenGettingBindlessSurfaceExtendedMessageDescriptorValueThenCorrectValueIsReturned) { - auto &hwHelper = HwHelper::get(pDevice->getHardwareInfo().platform.eRenderCoreFamily); - auto value = hwHelper.getBindlessSurfaceExtendedMessageDescriptorValue(0x200); - - typename FamilyType::DataPortBindlessSurfaceExtendedMessageDescriptor messageExtDescriptor = {}; - messageExtDescriptor.setBindlessSurfaceOffset(0x200); - - EXPECT_EQ(messageExtDescriptor.getBindlessSurfaceOffsetToPatch(), value); - EXPECT_EQ(0x200u, value); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPAndLater, givenPostSyncPipeControlWhenSettingWorkloadPartitionFlagThenExpectPipeControlFlagSet) { - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - using POST_SYNC_OPERATION = typename FamilyType::PIPE_CONTROL::POST_SYNC_OPERATION; - - uint8_t buffer[128] = {}; - LinearStream stream(buffer, sizeof(buffer)); - HardwareInfo hardwareInfo = *defaultHwInfo; - uint64_t gpuAddress = 0xBADA550; - uint64_t data = 0xABCDEF; - - PipeControlArgs args; - args.workloadPartitionOffset = true; - - MemorySynchronizationCommands::addBarrierWithPostSyncOperation( - stream, - PostSyncMode::ImmediateData, - gpuAddress, - data, - hardwareInfo, - args); - - GenCmdList cmdList; - FamilyType::PARSE::parseCommandBuffer(cmdList, stream.getCpuBase(), stream.getUsed()); - auto pipeControls = findAll(cmdList.begin(), cmdList.end()); - - bool foundPostSyncPipeControl = false; - for (size_t i = 0; i < pipeControls.size(); i++) { - auto pipeControl = reinterpret_cast(*pipeControls[i]); - if (pipeControl->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) { - EXPECT_EQ(gpuAddress, NEO::UnitTestHelper::getPipeControlPostSyncAddress(*pipeControl)); - EXPECT_EQ(data, pipeControl->getImmediateData()); - EXPECT_TRUE(pipeControl->getWorkloadPartitionIdOffsetEnable()); - foundPostSyncPipeControl = true; - break; - } - } - EXPECT_TRUE(foundPostSyncPipeControl); -} - -using HwInfoConfigTestXeHpAndLater = ::testing::Test; - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwInfoConfigTestXeHpAndLater, givenXeHPAndLaterPlatformWhenCheckNewResidencyModelSupportedThenReturnTrue) { - auto hwInfoConfig = HwInfoConfig::get(productFamily); - EXPECT_TRUE(hwInfoConfig->isNewResidencyModelSupported()); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwInfoConfigTestXeHpAndLater, whenCapabilityCoherencyFlagSetTrueThenOverrideToFalse) { - auto &hwInfoConfig = *HwInfoConfig::get(productFamily); - - bool coherency = true; - hwInfoConfig.setCapabilityCoherencyFlag(*defaultHwInfo, coherency); - EXPECT_FALSE(coherency); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwInfoConfigTestXeHpAndLater, givenXeHPAndLaterPlatformWhenAskedIfTile64With3DSurfaceOnBCSIsSupportedThenFalseIsReturned) { - const auto &hwInfoConfig = *HwInfoConfig::get(productFamily); - const auto &hwInfo = *defaultHwInfo; - - EXPECT_FALSE(hwInfoConfig.isTile64With3DSurfaceOnBCSSupported(hwInfo)); -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwInfoConfigTestXeHpAndLater, givenCLImageFormatsWhenCallingIsFormatRedescribableThenFalseIsReturned) { - static const cl_image_format redescribeFormats[] = { - {CL_R, CL_UNSIGNED_INT8}, - {CL_R, CL_UNSIGNED_INT16}, - {CL_R, CL_UNSIGNED_INT32}, - {CL_RG, CL_UNSIGNED_INT32}, - {CL_RGBA, CL_UNSIGNED_INT32}, - }; - MockContext context; - auto &clHwHelper = ClHwHelper::get(context.getDevice(0)->getHardwareInfo().platform.eRenderCoreFamily); - - for (const auto &format : redescribeFormats) { - EXPECT_EQ(false, clHwHelper.isFormatRedescribable(format)); - } -} - -HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenHwInfosWhenIsMatrixMultiplyAccumulateSupportedThenReturnTrue) { - EXPECT_TRUE(HwInfoConfig::get(productFamily)->isMatrixMultiplyAccumulateSupported(*defaultHwInfo)); -} diff --git a/shared/source/gen9/hw_helper_gen9.cpp b/shared/source/gen9/hw_helper_gen9.cpp index bf22c13e70567..1f32a83d91ca5 100644 --- a/shared/source/gen9/hw_helper_gen9.cpp +++ b/shared/source/gen9/hw_helper_gen9.cpp @@ -47,6 +47,11 @@ uint32_t HwHelperHw::getDefaultRevisionId(const HardwareInfo &hwInfo) co template <> bool MemorySynchronizationCommands::isBarrierWaRequired(const HardwareInfo &hwInfo) { return true; } +template <> +bool HwHelperHw::isTimestampShiftRequired() const { + return false; +} + template class HwHelperHw; template class FlatBatchBufferHelperHw; template struct MemorySynchronizationCommands; diff --git a/shared/source/helpers/hw_helper_bdw_and_later.inl b/shared/source/helpers/hw_helper_bdw_and_later.inl index 808db2c5cc87e..fb830e0eaccc9 100644 --- a/shared/source/helpers/hw_helper_bdw_and_later.inl +++ b/shared/source/helpers/hw_helper_bdw_and_later.inl @@ -163,5 +163,4 @@ template uint32_t HwHelperHw::getMinimalScratchSpaceSize() const { return 1024U; } - } // namespace NEO diff --git a/shared/source/helpers/hw_helper_dg2_and_later.inl b/shared/source/helpers/hw_helper_dg2_and_later.inl index 613b546270e20..af8a0fbb72325 100644 --- a/shared/source/helpers/hw_helper_dg2_and_later.inl +++ b/shared/source/helpers/hw_helper_dg2_and_later.inl @@ -65,5 +65,4 @@ template <> bool HwHelperHw::unTypedDataPortCacheFlushRequired() const { return true; } - } // namespace NEO diff --git a/shared/test/unit_test/gen9/hw_helper_tests_gen9.cpp b/shared/test/unit_test/gen9/hw_helper_tests_gen9.cpp index 15edf46365d65..c71c61e5f103f 100644 --- a/shared/test/unit_test/gen9/hw_helper_tests_gen9.cpp +++ b/shared/test/unit_test/gen9/hw_helper_tests_gen9.cpp @@ -47,6 +47,11 @@ GEN9TEST_F(HwHelperTestGen9, whenGetGpgpuEnginesThenReturnThreeRcsEngines) { EXPECT_EQ(3u, pDevice->allEngines.size()); } +GEN9TEST_F(HwHelperTestGen9, givenGen9WhenCallIsTimestampShiftRequiredThenFalseIsReturned) { + auto &hwHelper = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily); + EXPECT_FALSE(hwHelper.isTimestampShiftRequired()); +} + using MemorySynchronizatiopCommandsTestsGen9 = ::testing::Test; GEN9TEST_F(MemorySynchronizatiopCommandsTestsGen9, WhenProgrammingCacheFlushThenExpectConstantCacheFieldSet) { using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; diff --git a/shared/test/unit_test/helpers/CMakeLists.txt b/shared/test/unit_test/helpers/CMakeLists.txt index fb992e79e62ff..84fbda4a34840 100644 --- a/shared/test/unit_test/helpers/CMakeLists.txt +++ b/shared/test/unit_test/helpers/CMakeLists.txt @@ -40,6 +40,7 @@ target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test_hw_info_config.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/timestamp_packet_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_dg2_or_below.cpp ) if(MSVC OR COMPILER_SUPPORTS_SSE42) @@ -62,6 +63,7 @@ if(TESTS_PVC_AND_LATER) target_sources(neo_shared_tests PRIVATE ${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}/hw_helper_tests_pvc_and_later.cpp ) endif() diff --git a/shared/test/unit_test/helpers/hw_helper_tests_dg2_and_later.cpp b/shared/test/unit_test/helpers/hw_helper_tests_dg2_and_later.cpp index 3d3bff9b0ecb0..1518d82ee511e 100644 --- a/shared/test/unit_test/helpers/hw_helper_tests_dg2_and_later.cpp +++ b/shared/test/unit_test/helpers/hw_helper_tests_dg2_and_later.cpp @@ -5,14 +5,18 @@ * */ +#include "shared/source/command_container/command_encoder.h" +#include "shared/source/command_stream/linear_stream.h" #include "shared/source/helpers/hw_helper.h" -#include "shared/test/common/fixtures/device_fixture.h" +#include "shared/source/os_interface/hw_info_config.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/unit_test_helper.h" #include "shared/test/common/test_macros/hw_test.h" using namespace NEO; -using HwHelperDg2AndLaterTest = Test; +using HwHelperDg2AndLaterTest = ::testing::Test; HWTEST2_F(HwHelperDg2AndLaterTest, GivenUseL1CacheAsTrueWhenCallSetL1CachePolicyThenL1CachePolicyL1CacheControlIsSetProperly, IsAtLeastXeHpgCore) { using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; @@ -51,3 +55,153 @@ HWTEST2_F(HwHelperDg2AndLaterTest, GivenUseL1CacheAsFalseWhenCallSetL1CachePolic helper.setL1CachePolicy(useL1Cache, &surfaceState, defaultHwInfo.get()); EXPECT_NE(RENDER_SURFACE_STATE::L1_CACHE_POLICY_WB, surfaceState.getL1CachePolicyL1CacheControl()); } + +using PipeControlHelperTestsDg2AndLater = ::testing::Test; + +HWTEST2_F(PipeControlHelperTestsDg2AndLater, WhenAddingPipeControlWAThenCorrectCommandsAreProgrammed, IsAtLeastXeHpgCore) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; + uint8_t buffer[128]; + uint64_t address = 0x1234567887654321; + HardwareInfo hardwareInfo = *defaultHwInfo; + bool requiresMemorySynchronization = (MemorySynchronizationCommands::getSizeForAdditonalSynchronization(hardwareInfo) > 0) ? true : false; + + for (auto ftrLocalMemory : ::testing::Bool()) { + LinearStream stream(buffer, 128); + hardwareInfo.featureTable.flags.ftrLocalMemory = ftrLocalMemory; + + MemorySynchronizationCommands::addBarrierWa(stream, address, hardwareInfo); + + if (MemorySynchronizationCommands::isBarrierWaRequired(hardwareInfo) == false) { + EXPECT_EQ(0u, stream.getUsed()); + continue; + } + + GenCmdList cmdList; + FamilyType::PARSE::parseCommandBuffer(cmdList, stream.getCpuBase(), stream.getUsed()); + EXPECT_EQ(requiresMemorySynchronization ? 2u : 1u, cmdList.size()); + + PIPE_CONTROL expectedPipeControl = FamilyType::cmdInitPipeControl; + expectedPipeControl.setCommandStreamerStallEnable(true); + UnitTestHelper::setPipeControlHdcPipelineFlush(expectedPipeControl, true); + expectedPipeControl.setUnTypedDataPortCacheFlush(true); + auto it = cmdList.begin(); + auto pPipeControl = genCmdCast(*it); + ASSERT_NE(nullptr, pPipeControl); + EXPECT_TRUE(memcmp(&expectedPipeControl, pPipeControl, sizeof(PIPE_CONTROL)) == 0); + + if (requiresMemorySynchronization) { + if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(hardwareInfo)) { + MI_SEMAPHORE_WAIT expectedMiSemaphoreWait; + EncodeSempahore::programMiSemaphoreWait(&expectedMiSemaphoreWait, address, + EncodeSempahore::invalidHardwareTag, + MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD, + false); + auto pMiSemaphoreWait = genCmdCast(*(++it)); + ASSERT_NE(nullptr, pMiSemaphoreWait); + EXPECT_TRUE(memcmp(&expectedMiSemaphoreWait, pMiSemaphoreWait, sizeof(MI_SEMAPHORE_WAIT)) == 0); + } + } + } +} + +HWTEST2_F(PipeControlHelperTestsDg2AndLater, WhenSettingExtraPipeControlPropertiesThenCorrectValuesAreSet, IsAtLeastXeHpgCore) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + + for (auto ftrLocalMemory : ::testing::Bool()) { + HardwareInfo hardwareInfo = *defaultHwInfo; + hardwareInfo.featureTable.flags.ftrLocalMemory = ftrLocalMemory; + + PipeControlArgs args; + MemorySynchronizationCommands::setPostSyncExtraProperties(args, hardwareInfo); + + if (ftrLocalMemory) { + EXPECT_TRUE(args.hdcPipelineFlush); + EXPECT_TRUE(args.unTypedDataPortCacheFlush); + } else { + EXPECT_FALSE(args.hdcPipelineFlush); + EXPECT_FALSE(args.unTypedDataPortCacheFlush); + } + } +} + +HWTEST2_F(PipeControlHelperTestsDg2AndLater, whenSettingCacheFlushExtraFieldsThenExpectHdcAndUnTypedDataPortFlushSet, IsAtLeastXeHpgCore) { + PipeControlArgs args; + + MemorySynchronizationCommands::setCacheFlushExtraProperties(args); + EXPECT_TRUE(args.hdcPipelineFlush); + EXPECT_TRUE(args.unTypedDataPortCacheFlush); +} + +HWTEST2_F(PipeControlHelperTestsDg2AndLater, givenRequestedCacheFlushesWhenProgrammingPipeControlThenFlushHdcAndUnTypedDataPortCache, IsAtLeastXeHpgCore) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + + uint32_t buffer[sizeof(PIPE_CONTROL) * 2] = {}; + LinearStream stream(buffer, sizeof(buffer)); + + PipeControlArgs args; + args.hdcPipelineFlush = true; + args.unTypedDataPortCacheFlush = true; + args.compressionControlSurfaceCcsFlush = true; + MemorySynchronizationCommands::addSingleBarrier(stream, args); + + auto pipeControl = reinterpret_cast(buffer); + EXPECT_TRUE(UnitTestHelper::getPipeControlHdcPipelineFlush(*pipeControl)); + EXPECT_TRUE(pipeControl->getUnTypedDataPortCacheFlush()); + EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush()); +} + +HWTEST2_F(PipeControlHelperTestsDg2AndLater, givenDebugVariableSetWhenProgrammingPipeControlThenFlushHdcAndUnTypedDataPortCache, IsAtLeastXeHpgCore) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + DebugManagerStateRestore restore; + DebugManager.flags.FlushAllCaches.set(true); + + uint32_t buffer[sizeof(PIPE_CONTROL) * 2] = {}; + LinearStream stream(buffer, sizeof(buffer)); + + PipeControlArgs args; + MemorySynchronizationCommands::addSingleBarrier(stream, args); + + auto pipeControl = reinterpret_cast(buffer); + EXPECT_TRUE(UnitTestHelper::getPipeControlHdcPipelineFlush(*pipeControl)); + EXPECT_TRUE(pipeControl->getUnTypedDataPortCacheFlush()); + EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush()); +} + +HWTEST2_F(PipeControlHelperTestsDg2AndLater, givenDebugDisableCacheFlushWhenProgrammingPipeControlWithCacheFlushThenExpectDebugOverrideFlushHdcAndUnTypedDataPortCache, IsAtLeastXeHpgCore) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + DebugManagerStateRestore restore; + DebugManager.flags.DoNotFlushCaches.set(true); + + uint32_t buffer[sizeof(PIPE_CONTROL) * 2] = {}; + LinearStream stream(buffer, sizeof(buffer)); + + PipeControlArgs args; + args.hdcPipelineFlush = true; + args.unTypedDataPortCacheFlush = true; + args.compressionControlSurfaceCcsFlush = true; + MemorySynchronizationCommands::addSingleBarrier(stream, args); + + auto pipeControl = reinterpret_cast(buffer); + EXPECT_FALSE(UnitTestHelper::getPipeControlHdcPipelineFlush(*pipeControl)); + EXPECT_FALSE(pipeControl->getUnTypedDataPortCacheFlush()); + EXPECT_FALSE(pipeControl->getCompressionControlSurfaceCcsFlush()); +} + +HWTEST2_F(HwHelperDg2AndLaterTest, givenXeHPGAndLaterPlatformWhenCheckingIfUnTypedDataPortCacheFlushRequiredThenReturnTrue, IsAtLeastXeHpgCore) { + auto &hwHelper = HwHelper::get(renderCoreFamily); + EXPECT_TRUE(hwHelper.unTypedDataPortCacheFlushRequired()); +} + +HWTEST2_F(HwHelperDg2AndLaterTest, givenHwHelperWhenCheckIsUpdateTaskCountFromWaitSupportedThenReturnsTrue, IsAtLeastXeHpgCore) { + auto &hwHelper = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily); + + EXPECT_TRUE(hwHelper.isUpdateTaskCountFromWaitSupported()); +} + +using HwInfoConfigTestDg2AndLater = ::testing::Test; + +HWTEST2_F(HwInfoConfigTestDg2AndLater, givenDg2AndLaterPlatformWhenAskedIfHeapInLocalMemThenTrueIsReturned, IsAtLeastXeHpgCore) { + const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily); + EXPECT_TRUE(hwInfoConfig.heapInLocalMem(*defaultHwInfo)); +} diff --git a/opencl/test/unit_test/helpers/hw_helper_tests_dg2_or_below.cpp b/shared/test/unit_test/helpers/hw_helper_tests_dg2_or_below.cpp similarity index 58% rename from opencl/test/unit_test/helpers/hw_helper_tests_dg2_or_below.cpp rename to shared/test/unit_test/helpers/hw_helper_tests_dg2_or_below.cpp index 996807d3654c6..6c2c7ba6bef04 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests_dg2_or_below.cpp +++ b/shared/test/unit_test/helpers/hw_helper_tests_dg2_or_below.cpp @@ -6,16 +6,15 @@ */ #include "shared/source/helpers/hw_helper.h" +#include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/test_macros/hw_test.h" -#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" - using namespace NEO; -using HwHelperDg2OrBelowTests = Test; +using HwHelperDg2OrBelowTests = ::testing::Test; using isDG2OrBelow = IsAtMostProduct; HWTEST2_F(HwHelperDg2OrBelowTests, WhenGettingIsKmdMigrationSupportedThenFalseIsReturned, isDG2OrBelow) { - auto &hwHelper = HwHelper::get(hardwareInfo.platform.eRenderCoreFamily); - EXPECT_FALSE(hwHelper.isKmdMigrationSupported(hardwareInfo)); -} + auto &hwHelper = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily); + EXPECT_FALSE(hwHelper.isKmdMigrationSupported(*defaultHwInfo)); +} \ No newline at end of file diff --git a/opencl/test/unit_test/helpers/hw_helper_tests_pvc_and_later.cpp b/shared/test/unit_test/helpers/hw_helper_tests_pvc_and_later.cpp similarity index 100% rename from opencl/test/unit_test/helpers/hw_helper_tests_pvc_and_later.cpp rename to shared/test/unit_test/helpers/hw_helper_tests_pvc_and_later.cpp