diff --git a/level_zero/core/source/hw_helpers/l0_hw_helper.h b/level_zero/core/source/hw_helpers/l0_hw_helper.h index 3caac334d4..d7fc6559b2 100644 --- a/level_zero/core/source/hw_helpers/l0_hw_helper.h +++ b/level_zero/core/source/hw_helpers/l0_hw_helper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -35,6 +35,7 @@ class L0HwHelper { virtual bool imageCompressionSupported(const NEO::HardwareInfo &hwInfo) const = 0; virtual bool usmCompressionSupported(const NEO::HardwareInfo &hwInfo) const = 0; virtual bool forceDefaultUsmCompressionSupport() const = 0; + virtual bool isIpSamplingSupported(const NEO::HardwareInfo &hwInfo) const = 0; virtual void getAttentionBitmaskForSingleThreads(std::vector &threads, const NEO::HardwareInfo &hwInfo, std::unique_ptr &bitmask, size_t &bitmaskSize) const = 0; virtual std::vector getThreadsFromAttentionBitmask(const NEO::HardwareInfo &hwInfo, const uint8_t *bitmask, const size_t bitmaskSize) const = 0; @@ -58,6 +59,7 @@ class L0HwHelperHw : public L0HwHelper { bool imageCompressionSupported(const NEO::HardwareInfo &hwInfo) const override; bool usmCompressionSupported(const NEO::HardwareInfo &hwInfo) const override; bool forceDefaultUsmCompressionSupport() const override; + bool isIpSamplingSupported(const NEO::HardwareInfo &hwInfo) const override; void getAttentionBitmaskForSingleThreads(std::vector &threads, const NEO::HardwareInfo &hwInfo, std::unique_ptr &bitmask, size_t &bitmaskSize) const override; std::vector getThreadsFromAttentionBitmask(const NEO::HardwareInfo &hwInfo, const uint8_t *bitmask, const size_t bitmaskSize) const override; }; diff --git a/level_zero/core/source/hw_helpers/l0_hw_helper_base.inl b/level_zero/core/source/hw_helpers/l0_hw_helper_base.inl index 1c6eb47907..ff3126e602 100644 --- a/level_zero/core/source/hw_helpers/l0_hw_helper_base.inl +++ b/level_zero/core/source/hw_helpers/l0_hw_helper_base.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -111,4 +111,10 @@ template bool L0HwHelperHw::forceDefaultUsmCompressionSupport() const { return false; } + +template +bool L0HwHelperHw::isIpSamplingSupported(const NEO::HardwareInfo &hwInfo) const { + return false; +} + } // namespace L0 diff --git a/level_zero/core/source/xe_hpc_core/l0_hw_helper_xe_hpc_core.cpp b/level_zero/core/source/xe_hpc_core/l0_hw_helper_xe_hpc_core.cpp index 2a1e0c484e..334de646f4 100644 --- a/level_zero/core/source/xe_hpc_core/l0_hw_helper_xe_hpc_core.cpp +++ b/level_zero/core/source/xe_hpc_core/l0_hw_helper_xe_hpc_core.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -22,6 +22,19 @@ void populateFactoryTable>() { l0HwHelperFactory[gfxCore] = &L0HwHelperHw::get(); } +template <> +bool L0HwHelperHw::isIpSamplingSupported(const NEO::HardwareInfo &hwInfo) const { + + if (hwInfo.platform.usDeviceID == NEO::XE_HPC_CORE::pvcXtDeviceIds[0] || + hwInfo.platform.usDeviceID == NEO::XE_HPC_CORE::pvcXtDeviceIds[1] || + hwInfo.platform.usDeviceID == NEO::XE_HPC_CORE::pvcXtDeviceIds[2] || + hwInfo.platform.usDeviceID == NEO::XE_HPC_CORE::pvcXtDeviceIds[3] || + hwInfo.platform.usDeviceID == NEO::XE_HPC_CORE::pvcXtDeviceIds[4]) { + return true; + } + return false; +} + template class L0HwHelperHw; } // namespace L0 diff --git a/level_zero/tools/source/metrics/linux/os_metric_ip_sampling_imp_linux.cpp b/level_zero/tools/source/metrics/linux/os_metric_ip_sampling_imp_linux.cpp index 189282d83b..214dacb62b 100644 --- a/level_zero/tools/source/metrics/linux/os_metric_ip_sampling_imp_linux.cpp +++ b/level_zero/tools/source/metrics/linux/os_metric_ip_sampling_imp_linux.cpp @@ -11,10 +11,10 @@ #include "shared/source/os_interface/linux/ioctl_helper.h" #include "shared/source/os_interface/linux/sys_calls.h" #include "shared/source/os_interface/os_interface.h" -#include "shared/source/xe_hpc_core/hw_cmds_base.h" #include "level_zero/core/source/device/device.h" #include "level_zero/core/source/device/device_imp.h" +#include "level_zero/core/source/hw_helpers/l0_hw_helper.h" #include "level_zero/tools/source/metrics/os_metric_ip_sampling.h" #include @@ -163,20 +163,10 @@ bool MetricIpSamplingLinuxImp::isNReportsAvailable() { bool MetricIpSamplingLinuxImp::isDependencyAvailable() { - auto hwInfo = device.getNEODevice()->getHardwareInfo(); - auto isSupportedDevice = false; + const auto &hardwareInfo = device.getNEODevice()->getHardwareInfo(); + auto &l0HwHelper = L0HwHelper::get(hardwareInfo.platform.eRenderCoreFamily); - if (hwInfo.platform.eProductFamily == IGFX_PVC) { - if (hwInfo.platform.usDeviceID == NEO::XE_HPC_CORE::pvcXtDeviceIds[0] || - hwInfo.platform.usDeviceID == NEO::XE_HPC_CORE::pvcXtDeviceIds[1] || - hwInfo.platform.usDeviceID == NEO::XE_HPC_CORE::pvcXtDeviceIds[2] || - hwInfo.platform.usDeviceID == NEO::XE_HPC_CORE::pvcXtDeviceIds[3] || - hwInfo.platform.usDeviceID == NEO::XE_HPC_CORE::pvcXtDeviceIds[4]) { - isSupportedDevice = true; - } - } - - if (!isSupportedDevice) { + if (!l0HwHelper.isIpSamplingSupported(hardwareInfo)) { return false; } diff --git a/level_zero/tools/test/unit_tests/sources/metrics/linux/CMakeLists.txt b/level_zero/tools/test/unit_tests/sources/metrics/linux/CMakeLists.txt index 97149b50ce..300b530f8e 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/linux/CMakeLists.txt +++ b/level_zero/tools/test/unit_tests/sources/metrics/linux/CMakeLists.txt @@ -7,18 +7,21 @@ set(L0_TOOLS_METRICS_LINUX_TESTS_LINUX ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/test_metric_oa_query_pool_linux.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_metric_ip_sampling_linux.cpp ) -if(NEO_ENABLE_i915_PRELIM_DETECTION) - list(APPEND L0_TOOLS_METRICS_LINUX_TESTS_LINUX - ${CMAKE_CURRENT_SOURCE_DIR}/test_metric_ip_sampling_linux_prelim.cpp - ) -endif() +if(TESTS_PVC) + if(NEO_ENABLE_i915_PRELIM_DETECTION) + list(APPEND L0_TOOLS_METRICS_LINUX_TESTS_LINUX + ${CMAKE_CURRENT_SOURCE_DIR}/test_metric_ip_sampling_linux_pvc_prelim.cpp + ) + endif() -if("${BRANCH_TYPE}" STREQUAL "") - list(APPEND L0_TOOLS_METRICS_LINUX_TESTS_LINUX - ${CMAKE_CURRENT_SOURCE_DIR}/test_metric_ip_sampling_linux_upstream.cpp - ) + if("${BRANCH_TYPE}" STREQUAL "") + list(APPEND L0_TOOLS_METRICS_LINUX_TESTS_LINUX + ${CMAKE_CURRENT_SOURCE_DIR}/test_metric_ip_sampling_linux_pvc_upstream.cpp + ) + endif() endif() if(UNIX) diff --git a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux.cpp b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux.cpp new file mode 100644 index 0000000000..783cead244 --- /dev/null +++ b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/test_macros/test.h" + +#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" +#include "level_zero/tools/source/metrics/os_metric_ip_sampling.h" + +namespace L0 { +namespace ult { + +class MetricIpSamplingLinuxTest : public DeviceFixture, + public ::testing::Test { + public: + void SetUp() override { + DeviceFixture::SetUp(); + metricIpSamplingOsInterface = MetricIpSamplingOsInterface::create(static_cast(*device)); + } + + void TearDown() override { + DeviceFixture::TearDown(); + } + std::unique_ptr metricIpSamplingOsInterface = nullptr; +}; + +HWTEST2_F(MetricIpSamplingLinuxTest, GivenUnsupportedProductFamilyIsUsedWhenIsDependencyAvailableIsCalledThenReturnFailure, IsNotXeHpcCore) { + + auto hwInfo = neoDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); + hwInfo->platform.eProductFamily = productFamily; + EXPECT_FALSE(metricIpSamplingOsInterface->isDependencyAvailable()); +} + +} // namespace ult +} // namespace L0 diff --git a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_prelim.cpp b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_prelim.cpp similarity index 97% rename from level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_prelim.cpp rename to level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_prelim.cpp index a21db3750e..d9e89d99c3 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_prelim.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_prelim.cpp @@ -16,6 +16,8 @@ #include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" #include "level_zero/tools/source/metrics/os_metric_ip_sampling.h" +#include "hw_cmds.h" + namespace NEO { namespace SysCalls { extern int closeFuncRetVal; @@ -184,13 +186,6 @@ HWTEST2_F(MetricIpSamplingLinuxTestPrelim, GivenPollIsFailureWhenisNReportsAvail EXPECT_FALSE(metricIpSamplingOsInterface->isNReportsAvailable()); } -HWTEST2_F(MetricIpSamplingLinuxTestPrelim, GivenUnsupportedProductFamilyIsUsedWhenIsDependencyAvailableIsCalledThenReturnFailure, IsDG2) { - - auto hwInfo = neoDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); - hwInfo->platform.eProductFamily = productFamily; - EXPECT_FALSE(metricIpSamplingOsInterface->isDependencyAvailable()); -} - HWTEST2_F(MetricIpSamplingLinuxTestPrelim, GivenSupportedProductFamilyAndUnsupportedDeviceIdIsUsedWhenIsDependencyAvailableIsCalledThenReturnFailure, IsPVC) { auto hwInfo = neoDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); diff --git a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_upstream.cpp b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_upstream.cpp similarity index 99% rename from level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_upstream.cpp rename to level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_upstream.cpp index 36bff66ec2..825b8149e0 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_upstream.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_upstream.cpp @@ -11,6 +11,8 @@ #include "level_zero/tools/source/metrics/os_metric_ip_sampling.h" #include "level_zero/tools/test/unit_tests/sources/metrics/mock_metric_oa.h" +#include "hw_cmds.h" + namespace L0 { namespace ult {