From 676644bc50bcee88d60837bd3d1699dd69f8e4e8 Mon Sep 17 00:00:00 2001 From: Lukasz Jobczyk Date: Wed, 28 Feb 2024 16:49:03 +0000 Subject: [PATCH] performance: Enable internal heap preallocation on xe and later Signed-off-by: Lukasz Jobczyk --- shared/source/os_interface/product_helper.inl | 8 -------- .../os_interface/product_helper_bdw_and_later.inl | 8 ++++++++ .../os_interface/product_helper_xehp_and_later.inl | 8 ++++++++ .../xe_lpg/os_agnostic_product_helper_xe_lpg.inl | 8 -------- shared/test/common/mocks/mock_product_helper.cpp | 5 +++++ .../unit_test/os_interface/product_helper_tests.cpp | 8 ++++++++ .../gfx_core_helper_xe_hpc_core_tests.cpp | 12 +++++++++++- .../dg2/product_config_helper_tests_dg2.cpp | 8 ++++++++ .../os_agnostic_product_helper_xe_lpg_tests.cpp | 10 ++++++++++ 9 files changed, 58 insertions(+), 17 deletions(-) diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index f591553e12..a120e5885c 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -812,14 +812,6 @@ uint32_t ProductHelperHw::getCommandBuffersPreallocatedPerCommandQue return 0u; } -template -uint32_t ProductHelperHw::getInternalHeapsPreallocated() const { - if (debugManager.flags.SetAmountOfInternalHeapsToPreallocate.get() != -1) { - return debugManager.flags.SetAmountOfInternalHeapsToPreallocate.get(); - } - return 0u; -} - template bool ProductHelperHw::disableL3CacheForDebug(const HardwareInfo &) const { return false; diff --git a/shared/source/os_interface/product_helper_bdw_and_later.inl b/shared/source/os_interface/product_helper_bdw_and_later.inl index d3b83f6f0e..07ce9e4e29 100644 --- a/shared/source/os_interface/product_helper_bdw_and_later.inl +++ b/shared/source/os_interface/product_helper_bdw_and_later.inl @@ -65,6 +65,14 @@ bool ProductHelperHw::isTimestampWaitSupportedForEvents() const { return false; } +template +uint32_t ProductHelperHw::getInternalHeapsPreallocated() const { + if (debugManager.flags.SetAmountOfInternalHeapsToPreallocate.get() != -1) { + return debugManager.flags.SetAmountOfInternalHeapsToPreallocate.get(); + } + return 0u; +} + template bool ProductHelperHw::isTile64With3DSurfaceOnBCSSupported(const HardwareInfo &hwInfo) const { return true; diff --git a/shared/source/os_interface/product_helper_xehp_and_later.inl b/shared/source/os_interface/product_helper_xehp_and_later.inl index f9bd5ccee5..4850560ae2 100644 --- a/shared/source/os_interface/product_helper_xehp_and_later.inl +++ b/shared/source/os_interface/product_helper_xehp_and_later.inl @@ -69,6 +69,14 @@ bool ProductHelperHw::isTimestampWaitSupportedForEvents() const { return true; } +template +uint32_t ProductHelperHw::getInternalHeapsPreallocated() const { + if (debugManager.flags.SetAmountOfInternalHeapsToPreallocate.get() != -1) { + return debugManager.flags.SetAmountOfInternalHeapsToPreallocate.get(); + } + return 1u; +} + template bool ProductHelperHw::isTile64With3DSurfaceOnBCSSupported(const HardwareInfo &hwInfo) const { return false; diff --git a/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl b/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl index dc91aae89e..47f0af11fd 100644 --- a/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl +++ b/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl @@ -88,14 +88,6 @@ uint32_t ProductHelperHw::getCommandBuffersPreallocatedPerCommandQue return 2u; } -template <> -uint32_t ProductHelperHw::getInternalHeapsPreallocated() const { - if (debugManager.flags.SetAmountOfInternalHeapsToPreallocate.get() != -1) { - return debugManager.flags.SetAmountOfInternalHeapsToPreallocate.get(); - } - return 1u; -} - template <> std::optional ProductHelperHw::getPreferredAllocationMethod(AllocationType allocationType) const { switch (allocationType) { diff --git a/shared/test/common/mocks/mock_product_helper.cpp b/shared/test/common/mocks/mock_product_helper.cpp index 70ee0d9d35..f4ade002a6 100644 --- a/shared/test/common/mocks/mock_product_helper.cpp +++ b/shared/test/common/mocks/mock_product_helper.cpp @@ -345,6 +345,11 @@ bool ProductHelperHw::isTimestampWaitSupportedForEvents() const { return false; } +template <> +uint32_t ProductHelperHw::getInternalHeapsPreallocated() const { + return 0u; +} + template <> uint64_t ProductHelperHw::getHostMemCapabilitiesValue() const { return 0; diff --git a/shared/test/unit_test/os_interface/product_helper_tests.cpp b/shared/test/unit_test/os_interface/product_helper_tests.cpp index c913f24d7a..0f1b5bbe45 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -454,6 +454,14 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfIsTimestampWaitSupport EXPECT_FALSE(productHelper->isTimestampWaitSupportedForEvents()); } +HWTEST2_F(ProductHelperTest, givenProductHelperWhenCallGetInternalHeapsPreallocatedThenReturnCorrectValue, IsBeforeXeHpCore) { + EXPECT_EQ(productHelper->getInternalHeapsPreallocated(), 0u); + + DebugManagerStateRestore restorer; + debugManager.flags.SetAmountOfInternalHeapsToPreallocate.set(3); + EXPECT_EQ(productHelper->getInternalHeapsPreallocated(), 3u); +} + HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfIsTlbFlushRequiredThenTrueIsReturned, IsNotXeHpgOrXeHpcCore) { EXPECT_TRUE(productHelper->isTlbFlushRequired()); } diff --git a/shared/test/unit_test/xe_hpc_core/gfx_core_helper_xe_hpc_core_tests.cpp b/shared/test/unit_test/xe_hpc_core/gfx_core_helper_xe_hpc_core_tests.cpp index be12f8318c..bb50605ec6 100644 --- a/shared/test/unit_test/xe_hpc_core/gfx_core_helper_xe_hpc_core_tests.cpp +++ b/shared/test/unit_test/xe_hpc_core/gfx_core_helper_xe_hpc_core_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -9,6 +9,7 @@ #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/os_interface/product_helper.h" #include "shared/source/xe_hpc_core/hw_cmds_xe_hpc_core_base.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/gfx_core_helper_tests.h" #include "shared/test/common/mocks/mock_execution_environment.h" @@ -74,6 +75,15 @@ XE_HPC_CORETEST_F(ProductHelperTestXeHpcCore, givenProductHelperWhenCheckTimesta EXPECT_TRUE(helper.isTimestampWaitSupportedForEvents()); } +XE_HPC_CORETEST_F(ProductHelperTestXeHpcCore, givenProductHelperWhenCallGetInternalHeapsPreallocatedThenReturnCorrectValue) { + const auto &productHelper = getHelper(); + EXPECT_EQ(productHelper.getInternalHeapsPreallocated(), 1u); + + DebugManagerStateRestore restorer; + debugManager.flags.SetAmountOfInternalHeapsToPreallocate.set(3); + EXPECT_EQ(productHelper.getInternalHeapsPreallocated(), 3u); +} + XE_HPC_CORETEST_F(GfxCoreHelperTest, givenGfxCoreHelperWhenCallCopyThroughLockedPtrEnabledThenReturnTrue) { const auto &gfxCoreHelper = getHelper(); const auto &productHelper = getHelper(); diff --git a/shared/test/unit_test/xe_hpg_core/dg2/product_config_helper_tests_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/product_config_helper_tests_dg2.cpp index e6c5386910..69cb5e2ffd 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/product_config_helper_tests_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/product_config_helper_tests_dg2.cpp @@ -717,6 +717,14 @@ DG2TEST_F(ProductHelperTestDg2, givenDG2WhenCheckingIsTimestampWaitSupportedForE EXPECT_TRUE(productHelper->isTimestampWaitSupportedForEvents()); } +DG2TEST_F(ProductHelperTestDg2, givenProductHelperWhenCallGetInternalHeapsPreallocatedThenReturnCorrectValue) { + EXPECT_EQ(productHelper->getInternalHeapsPreallocated(), 1u); + + DebugManagerStateRestore restorer; + debugManager.flags.SetAmountOfInternalHeapsToPreallocate.set(3); + EXPECT_EQ(productHelper->getInternalHeapsPreallocated(), 3u); +} + DG2TEST_F(ProductConfigTests, givenDg2G10DeviceIdsWhenConfigIsCheckedThenCorrectValueIsReturned) { for (const auto &deviceId : dg2G10DeviceIds) { hwInfo.platform.usDeviceID = deviceId; diff --git a/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp b/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp index 23ce8dd459..34d96867c3 100644 --- a/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp +++ b/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp @@ -12,6 +12,7 @@ #include "shared/source/os_interface/product_helper.h" #include "shared/source/release_helper/release_helper.h" #include "shared/test/common/fixtures/device_fixture.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/gtest_helpers.h" #include "shared/test/common/mocks/mock_device.h" @@ -200,6 +201,15 @@ HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenCheckBlitEnqueueAllowed EXPECT_FALSE(productHelper->blitEnqueueAllowed()); } +HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenCallGetInternalHeapsPreallocatedThenReturnCorrectValue, IsXeLpg) { + const auto &productHelper = getHelper(); + EXPECT_EQ(productHelper.getInternalHeapsPreallocated(), 1u); + + DebugManagerStateRestore restorer; + debugManager.flags.SetAmountOfInternalHeapsToPreallocate.set(3); + EXPECT_EQ(productHelper.getInternalHeapsPreallocated(), 3u); +} + HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenGetCommandsStreamPropertiesSupportThenExpectCorrectValues, IsXeLpg) { EXPECT_FALSE(productHelper->getScmPropertyThreadArbitrationPolicySupport());