Skip to content

Commit 4a59406

Browse files
feature(sysman): Implement/Update Frequency APIs at each Product Level
Related-To: NEO-8745 Signed-off-by: Bakwad, Anvesh <[email protected]>
1 parent a93b26a commit 4a59406

13 files changed

+71
-7
lines changed

level_zero/sysman/source/api/frequency/linux/sysman_os_frequency_imp.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "shared/source/device/device.h"
1212
#include "shared/source/helpers/hw_info.h"
1313

14+
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
1415
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
1516
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
1617
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
@@ -45,11 +46,7 @@ ze_result_t LinuxFrequencyImp::osFrequencyGetProperties(zes_freq_properties_t &p
4546

4647
double LinuxFrequencyImp::osFrequencyGetStepSize() {
4748
double stepSize;
48-
if (productFamily >= IGFX_XE_HP_SDV) {
49-
stepSize = 50.0;
50-
} else {
51-
stepSize = 50.0 / 3; // Step of 16.6666667 Mhz (GEN9 Hardcode)
52-
}
49+
pSysmanProductHelper->getFrequencyStepSize(&stepSize);
5350
return stepSize;
5451
}
5552

@@ -437,7 +434,7 @@ void LinuxFrequencyImp::init() {
437434
LinuxFrequencyImp::LinuxFrequencyImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId, zes_freq_domain_t frequencyDomainNumber) : isSubdevice(onSubdevice), subdeviceId(subdeviceId), frequencyDomainNumber(frequencyDomainNumber) {
438435
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
439436
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
440-
productFamily = pLinuxSysmanImp->getProductFamily();
437+
pSysmanProductHelper = pLinuxSysmanImp->getSysmanProductHelper();
441438
pSysmanKmdInterface = pLinuxSysmanImp->getSysmanKmdInterface();
442439
init();
443440
}

level_zero/sysman/source/api/frequency/linux/sysman_os_frequency_imp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace L0 {
1616
namespace Sysman {
1717

1818
class SysmanKmdInterface;
19+
class SysmanProductHelper;
1920
class SysFsAccessInterface;
2021

2122
class LinuxFrequencyImp : public OsFrequency, NEO::NonCopyableOrMovableClass {
@@ -77,7 +78,7 @@ class LinuxFrequencyImp : public OsFrequency, NEO::NonCopyableOrMovableClass {
7778
bool isSubdevice = false;
7879
uint32_t subdeviceId = 0;
7980
zes_freq_domain_t frequencyDomainNumber = ZES_FREQ_DOMAIN_GPU;
80-
PRODUCT_FAMILY productFamily;
81+
SysmanProductHelper *pSysmanProductHelper = nullptr;
8182
void init();
8283
};
8384

level_zero/sysman/source/shared/linux/product_helper/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ target_sources(${L0_STATIC_LIB_NAME}
1111
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_hw.h
1212
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_hw.inl
1313
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper.cpp
14+
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_xe_hp_and_later.inl
1415
)
1516

1617
add_subdirectories()

level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class SysmanProductHelper {
3636
return productHelper;
3737
}
3838

39+
// Frequency
40+
virtual void getFrequencyStepSize(double *pStepSize) = 0;
41+
3942
// Memory
4043
virtual ze_result_t getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) = 0;
4144
virtual ze_result_t getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, const LinuxSysmanImp *pLinuxSysmanImp) = 0;

level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class SysmanProductHelperHw : public SysmanProductHelper {
2222
return pSysmanProductHelper;
2323
}
2424

25+
// Frequency
26+
void getFrequencyStepSize(double *pStepSize) override;
27+
2528
// Memory
2629
ze_result_t getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) override;
2730
ze_result_t getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, const LinuxSysmanImp *pLinuxSysmanImp) override;

level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
namespace L0 {
1717
namespace Sysman {
1818

19+
template <PRODUCT_FAMILY gfxProduct>
20+
void SysmanProductHelperHw<gfxProduct>::getFrequencyStepSize(double *pStepSize) {
21+
*pStepSize = (50.0 / 3); // Step of 16.6666667 Mhz
22+
}
23+
1924
template <PRODUCT_FAMILY gfxProduct>
2025
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) {
2126
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright (C) 2023 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
template <>
9+
void SysmanProductHelperHw<gfxProduct>::getFrequencyStepSize(double *pStepSize) {
10+
*pStepSize = 50.0;
11+
}

level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace L0 {
1616
namespace Sysman {
1717
constexpr static auto gfxProduct = IGFX_PVC;
1818

19+
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_xe_hp_and_later.inl"
20+
1921
template <>
2022
void SysmanProductHelperHw<gfxProduct>::getMediaPerformanceFactorMultiplier(const double performanceFactor, double *pMultiplier) {
2123
if (performanceFactor > halfOfMaxPerformanceFactor) {

level_zero/sysman/source/shared/linux/product_helper/xe_hpg_core/arl/sysman_product_helper_arl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace Sysman {
1313

1414
constexpr static auto gfxProduct = IGFX_ARROWLAKE;
1515

16+
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_xe_hp_and_later.inl"
17+
1618
template class SysmanProductHelperHw<gfxProduct>;
1719

1820
} // namespace Sysman

level_zero/sysman/source/shared/linux/product_helper/xe_hpg_core/dg2/sysman_product_helper_dg2.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ RasInterfaceType SysmanProductHelperHw<gfxProduct>::getGtRasUtilInterface() {
1818
return RasInterfaceType::pmu;
1919
}
2020

21+
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_xe_hp_and_later.inl"
22+
2123
template class SysmanProductHelperHw<gfxProduct>;
2224

2325
} // namespace Sysman

level_zero/sysman/source/shared/linux/product_helper/xe_hpg_core/mtl/sysman_product_helper_mtl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace Sysman {
1313

1414
constexpr static auto gfxProduct = IGFX_METEORLAKE;
1515

16+
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_xe_hp_and_later.inl"
17+
1618
template class SysmanProductHelperHw<gfxProduct>;
1719

1820
} // namespace Sysman

level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ if(UNIX)
1111
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_memory_tests.cpp
1212
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_temperature_tests.cpp
1313
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_globalops_tests.cpp
14+
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_frequency_tests.cpp
1415
)
1516
endif()
1617

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2023 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
9+
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h"
10+
11+
namespace L0 {
12+
namespace Sysman {
13+
namespace ult {
14+
15+
using SysmanProductHelperFrequencyTest = ::testing::Test;
16+
using IsProductXeHpSdvPlus = IsAtLeastProduct<IGFX_XE_HP_SDV>;
17+
18+
HWTEST2_F(SysmanProductHelperFrequencyTest, GivenFrequencyModuleWhenGettingStepSizeThenValidStepSizeIsReturned, IsProductXeHpSdvPlus) {
19+
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
20+
double stepSize = 0;
21+
pSysmanProductHelper->getFrequencyStepSize(&stepSize);
22+
EXPECT_EQ(50.0, stepSize);
23+
}
24+
25+
HWTEST2_F(SysmanProductHelperFrequencyTest, GivenFrequencyModuleWhenGettingStepSizeThenValidStepSizeIsReturned, IsGen9) {
26+
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
27+
double stepSize = 0;
28+
pSysmanProductHelper->getFrequencyStepSize(&stepSize);
29+
EXPECT_EQ((50.0 / 3), stepSize);
30+
}
31+
32+
} // namespace ult
33+
} // namespace Sysman
34+
} // namespace L0

0 commit comments

Comments
 (0)