feature: Support Product Helper for Performance Module
Related-To: NEO-9593 Signed-off-by: Bakwad, Anvesh <anvesh.bakwad@intel.com>
This commit is contained in:
parent
39ccf0297f
commit
c367c2b332
|
@ -11,6 +11,7 @@
|
|||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
|
@ -109,47 +110,33 @@ ze_result_t LinuxPerformanceImp::osPerformanceGetConfig(double *pFactor) {
|
|||
return result;
|
||||
}
|
||||
|
||||
ze_result_t LinuxPerformanceImp::osPerformanceSetConfig(double pFactor) {
|
||||
ze_result_t LinuxPerformanceImp::osPerformanceSetConfig(double performanceFactor) {
|
||||
double multiplier = 0;
|
||||
ze_result_t result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
if (pFactor < minPerformanceFactor || pFactor > maxPerformanceFactor) {
|
||||
if (performanceFactor < minPerformanceFactor || performanceFactor > maxPerformanceFactor) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
switch (domain) {
|
||||
case ZES_ENGINE_TYPE_FLAG_OTHER:
|
||||
if (pFactor <= halfOfMaxPerformanceFactor) {
|
||||
multiplier = 63.0 - std::round(pFactor * (47.0) / 50.0); // multiplier = 63 - ROUND(pFactor * (63.0 - 16.0) / 50.0)
|
||||
if (performanceFactor <= halfOfMaxPerformanceFactor) {
|
||||
multiplier = 63.0 - std::round(performanceFactor * (47.0) / 50.0); // multiplier = 63 - ROUND(performanceFactor * (63.0 - 16.0) / 50.0)
|
||||
} else {
|
||||
multiplier = 16.0 - std::round((pFactor - 50.0) * 16.0 / 50.0);
|
||||
multiplier = 16.0 - std::round((performanceFactor - 50.0) * 16.0 / 50.0);
|
||||
}
|
||||
result = pSysfsAccess->write(sysPwrBalance, multiplier);
|
||||
break;
|
||||
case ZES_ENGINE_TYPE_FLAG_MEDIA:
|
||||
if (productFamily == IGFX_PVC) {
|
||||
if (pFactor > halfOfMaxPerformanceFactor) {
|
||||
multiplier = 1;
|
||||
} else {
|
||||
multiplier = 0.5;
|
||||
}
|
||||
} else {
|
||||
if (pFactor > halfOfMaxPerformanceFactor) {
|
||||
multiplier = 1;
|
||||
} else if (pFactor > minPerformanceFactor) {
|
||||
multiplier = 0.5;
|
||||
} else {
|
||||
multiplier = 0; // dynamic control mode is not supported on PVC
|
||||
}
|
||||
}
|
||||
pSysmanProductHelper->getMediaPerformanceFactorMultiplier(performanceFactor, &multiplier);
|
||||
multiplier = multiplier / mediaScaleReading; // Divide by scale factor and then round off to convert from decimal to U format
|
||||
multiplier = std::round(multiplier);
|
||||
result = pSysfsAccess->write(mediaFreqFactor, multiplier);
|
||||
break;
|
||||
case ZES_ENGINE_TYPE_FLAG_COMPUTE:
|
||||
if (pFactor < halfOfMaxPerformanceFactor) {
|
||||
multiplier = 2 - (pFactor / 50.0);
|
||||
if (performanceFactor < halfOfMaxPerformanceFactor) {
|
||||
multiplier = 2 - (performanceFactor / 50.0);
|
||||
} else {
|
||||
multiplier = 1 - ((pFactor - 50) / 100.0);
|
||||
multiplier = 1 - ((performanceFactor - 50) / 100.0);
|
||||
}
|
||||
multiplier = multiplier / baseScaleReading; // Divide by scale factor and then round off to convert from decimal to U format
|
||||
multiplier = std::round(multiplier);
|
||||
|
@ -209,7 +196,7 @@ LinuxPerformanceImp::LinuxPerformanceImp(OsSysman *pOsSysman, ze_bool_t onSubdev
|
|||
zes_engine_type_flag_t domain) : domain(domain), subdeviceId(subdeviceId), isSubdevice(onSubdevice) {
|
||||
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||
productFamily = pLinuxSysmanImp->getProductFamily();
|
||||
pSysmanProductHelper = pLinuxSysmanImp->getSysmanProductHelper();
|
||||
init();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,12 @@ namespace L0 {
|
|||
namespace Sysman {
|
||||
|
||||
class SysFsAccessInterface;
|
||||
class SysmanProductHelper;
|
||||
class LinuxPerformanceImp : public OsPerformance, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
ze_result_t osPerformanceGetProperties(zes_perf_properties_t &pProperties) override;
|
||||
ze_result_t osPerformanceGetConfig(double *pFactor) override;
|
||||
ze_result_t osPerformanceSetConfig(double pFactor) override;
|
||||
ze_result_t osPerformanceSetConfig(double performanceFactor) override;
|
||||
|
||||
bool isPerformanceSupported(void) override;
|
||||
|
||||
|
@ -43,7 +44,7 @@ class LinuxPerformanceImp : public OsPerformance, NEO::NonCopyableOrMovableClass
|
|||
ze_bool_t isSubdevice = 0;
|
||||
double baseScaleReading = 0;
|
||||
double mediaScaleReading = 0;
|
||||
PRODUCT_FAMILY productFamily{};
|
||||
SysmanProductHelper *pSysmanProductHelper = nullptr;
|
||||
ze_result_t getMediaFreqFactor();
|
||||
ze_result_t getMediaScaleFactor();
|
||||
ze_result_t getBaseFreqFactor();
|
||||
|
|
|
@ -34,8 +34,13 @@ class SysmanProductHelper {
|
|||
return productHelper;
|
||||
}
|
||||
|
||||
// Memory
|
||||
virtual ze_result_t getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) = 0;
|
||||
virtual ze_result_t getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, const LinuxSysmanImp *pLinuxSysmanImp) = 0;
|
||||
|
||||
// Performance
|
||||
virtual void getMediaPerformanceFactorMultiplier(const double performanceFactor, double *pMultiplier) = 0;
|
||||
|
||||
virtual ~SysmanProductHelper() = default;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -19,9 +19,13 @@ class SysmanProductHelperHw : public SysmanProductHelper {
|
|||
return pSysmanProductHelper;
|
||||
}
|
||||
|
||||
// Memory
|
||||
ze_result_t getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) override;
|
||||
ze_result_t getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, const LinuxSysmanImp *pLinuxSysmanImp) override;
|
||||
|
||||
// Performance
|
||||
void getMediaPerformanceFactorMultiplier(const double performanceFactor, double *pMultiplier) override;
|
||||
|
||||
~SysmanProductHelperHw() override = default;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
|
||||
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
@ -21,5 +22,16 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandwidth(zes_mem_bandwi
|
|||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
void SysmanProductHelperHw<gfxProduct>::getMediaPerformanceFactorMultiplier(const double performanceFactor, double *pMultiplier) {
|
||||
if (performanceFactor > halfOfMaxPerformanceFactor) {
|
||||
*pMultiplier = 1;
|
||||
} else if (performanceFactor > minPerformanceFactor) {
|
||||
*pMultiplier = 0.5;
|
||||
} else {
|
||||
*pMultiplier = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
@ -21,5 +22,14 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandwidth(zes_mem_bandwi
|
|||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
template <>
|
||||
void SysmanProductHelperHw<gfxProduct>::getMediaPerformanceFactorMultiplier(const double performanceFactor, double *pMultiplier) {
|
||||
if (performanceFactor > halfOfMaxPerformanceFactor) {
|
||||
*pMultiplier = 1;
|
||||
} else {
|
||||
*pMultiplier = 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
||||
|
|
|
@ -8,6 +8,7 @@ if(UNIX)
|
|||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_performance_tests.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/performance/linux/mock_sysfs_performance_prelim.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
namespace ult {
|
||||
|
||||
class SysmanProductHelperPerformanceTest : public SysmanMultiDeviceFixture {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
SysmanMultiDeviceFixture::SetUp();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
SysmanMultiDeviceFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
HWTEST2_F(SysmanProductHelperPerformanceTest, GivenMediaPerformanceFactorWhenGettingMediaPerformanceMultiplierForProductsAtMostDg2ThenValidMultiplierIsReturned, IsAtMostDg2) {
|
||||
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
|
||||
|
||||
double performanceFactor = 0;
|
||||
double multiplier = 0;
|
||||
pSysmanProductHelper->getMediaPerformanceFactorMultiplier(performanceFactor, &multiplier);
|
||||
EXPECT_EQ(0, multiplier);
|
||||
|
||||
performanceFactor = 30;
|
||||
pSysmanProductHelper->getMediaPerformanceFactorMultiplier(performanceFactor, &multiplier);
|
||||
EXPECT_EQ(0.5, multiplier);
|
||||
|
||||
performanceFactor = 50;
|
||||
pSysmanProductHelper->getMediaPerformanceFactorMultiplier(performanceFactor, &multiplier);
|
||||
EXPECT_EQ(0.5, multiplier);
|
||||
|
||||
performanceFactor = 100;
|
||||
pSysmanProductHelper->getMediaPerformanceFactorMultiplier(performanceFactor, &multiplier);
|
||||
EXPECT_EQ(1, multiplier);
|
||||
}
|
||||
|
||||
HWTEST2_F(SysmanProductHelperPerformanceTest, GivenMediaPerformanceFactorWhenGettingMediaPerformanceMultiplierForProductFamilyIsPVCThenValidMultiplierIsReturned, IsPVC) {
|
||||
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
|
||||
|
||||
double performanceFactor = 0;
|
||||
double multiplier = 0;
|
||||
pSysmanProductHelper->getMediaPerformanceFactorMultiplier(performanceFactor, &multiplier);
|
||||
EXPECT_EQ(0.5, multiplier);
|
||||
|
||||
performanceFactor = 50;
|
||||
pSysmanProductHelper->getMediaPerformanceFactorMultiplier(performanceFactor, &multiplier);
|
||||
EXPECT_EQ(0.5, multiplier);
|
||||
|
||||
performanceFactor = 100;
|
||||
pSysmanProductHelper->getMediaPerformanceFactorMultiplier(performanceFactor, &multiplier);
|
||||
EXPECT_EQ(1, multiplier);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
Loading…
Reference in New Issue