feature(sysman): Expose the config pair to the Engine Handle

Related-To: NEO-14635

Signed-off-by: Pratik Bari <pratik.bari@intel.com>
This commit is contained in:
Pratik Bari 2025-04-23 07:41:22 +00:00 committed by Compute-Runtime-Automation
parent 2ea6c09f51
commit 2113882bf5
15 changed files with 116 additions and 31 deletions

View File

@ -95,7 +95,7 @@ ze_result_t LinuxEngineImp::getProperties(zes_engine_properties_t &properties) {
}
void LinuxEngineImp::init() {
initStatus = pSysmanKmdInterface->getEngineActivityFdList(engineGroup, engineInstance, gtId, pPmuInterface, fdList);
initStatus = pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(engineGroup, engineInstance, gtId, pPmuInterface, fdList, pmuConfigPair);
}
bool LinuxEngineImp::isEngineModuleSupported() {
@ -105,8 +105,13 @@ bool LinuxEngineImp::isEngineModuleSupported() {
return true;
}
void LinuxEngineImp::getConfigPair(std::pair<uint64_t, uint64_t> &configPair) {
configPair = pmuConfigPair;
return;
}
LinuxEngineImp::LinuxEngineImp(OsSysman *pOsSysman, zes_engine_group_t type, uint32_t engineInstance, uint32_t gtId, ze_bool_t onSubDevice) : engineGroup(type), engineInstance(engineInstance), gtId(gtId), onSubDevice(onSubDevice) {
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
pDrm = pLinuxSysmanImp->getDrm();
pDevice = pLinuxSysmanImp->getSysmanDeviceImp();
pPmuInterface = pLinuxSysmanImp->getPmuInterface();

View File

@ -19,6 +19,7 @@ namespace Sysman {
class SysmanKmdInterface;
class PmuInterface;
class LinuxSysmanImp;
struct Device;
class LinuxEngineImp : public OsEngine, NEO::NonCopyableAndNonMovableClass {
public:
@ -29,6 +30,7 @@ class LinuxEngineImp : public OsEngine, NEO::NonCopyableAndNonMovableClass {
ze_result_t getProperties(zes_engine_properties_t &properties) override;
bool isEngineModuleSupported() override;
static zes_engine_group_t getGroupFromEngineType(zes_engine_group_t type);
void getConfigPair(std::pair<uint64_t, uint64_t> &configPair) override;
LinuxEngineImp() = default;
LinuxEngineImp(OsSysman *pOsSysman, zes_engine_group_t type, uint32_t engineInstance, uint32_t gtId, ze_bool_t onSubDevice);
~LinuxEngineImp() override;
@ -36,6 +38,7 @@ class LinuxEngineImp : public OsEngine, NEO::NonCopyableAndNonMovableClass {
protected:
SysmanKmdInterface *pSysmanKmdInterface = nullptr;
LinuxSysmanImp *pLinuxSysmanImp = nullptr;
zes_engine_group_t engineGroup = ZES_ENGINE_GROUP_ALL;
uint32_t engineInstance = 0;
PmuInterface *pPmuInterface = nullptr;
@ -47,6 +50,7 @@ class LinuxEngineImp : public OsEngine, NEO::NonCopyableAndNonMovableClass {
private:
void init();
std::vector<std::pair<int64_t, int64_t>> fdList{};
std::pair<uint64_t, uint64_t> pmuConfigPair{};
ze_result_t initStatus = ZE_RESULT_SUCCESS;
};

View File

@ -31,6 +31,7 @@ class Engine : _zes_engine_handle_t {
}
inline zes_engine_handle_t toHandle() { return this; }
bool initSuccess = false;
std::pair<uint64_t, uint64_t> configPair{};
};
struct EngineHandleContext {

View File

@ -26,6 +26,7 @@ ze_result_t EngineImp::engineGetProperties(zes_engine_properties_t *pProperties)
void EngineImp::init() {
if (pOsEngine->isEngineModuleSupported()) {
pOsEngine->getProperties(engineProperties);
pOsEngine->getConfigPair(this->configPair);
this->initSuccess = true;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -22,6 +22,7 @@ class OsEngine {
virtual ze_result_t getActivity(zes_engine_stats_t *pStats) = 0;
virtual ze_result_t getActivityExt(uint32_t *pCount, zes_engine_stats_t *pStats) = 0;
virtual ze_result_t getProperties(zes_engine_properties_t &properties) = 0;
virtual void getConfigPair(std::pair<uint64_t, uint64_t> &configPair) = 0;
virtual bool isEngineModuleSupported() = 0;
static std::unique_ptr<OsEngine> create(OsSysman *pOsSysman, zes_engine_group_t engineType, uint32_t engineInstance, uint32_t subDeviceId, ze_bool_t onSubdevice);
static ze_result_t getNumEngineTypeAndInstances(std::set<std::pair<zes_engine_group_t, EngineInstanceSubDeviceId>> &engineGroupInstance, OsSysman *pOsSysman);

View File

@ -20,6 +20,7 @@ class WddmEngineImp : public OsEngine, NEO::NonCopyableAndNonMovableClass {
ze_result_t getActivityExt(uint32_t *pCount, zes_engine_stats_t *pStats) override;
ze_result_t getProperties(zes_engine_properties_t &properties) override;
bool isEngineModuleSupported() override;
void getConfigPair(std::pair<uint64_t, uint64_t> &configPair) override { return; }
WddmEngineImp() = default;
WddmEngineImp(OsSysman *pOsSysman, zes_engine_group_t type, uint32_t engineInstance, uint32_t gtId);

View File

@ -115,7 +115,12 @@ class SysmanKmdInterface {
virtual std::string getSysfsFilePath(SysfsName sysfsName, uint32_t subDeviceId, bool baseDirectoryExists) = 0;
virtual std::string getSysfsFilePathForPhysicalMemorySize(uint32_t subDeviceId) = 0;
virtual std::string getEnergyCounterNodeFile(zes_power_domain_t powerDomain) = 0;
virtual ze_result_t getEngineActivityFdList(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t gtId, PmuInterface *const &pPmuInterface, std::vector<std::pair<int64_t, int64_t>> &fdList) = 0;
virtual ze_result_t getEngineActivityFdListAndConfigPair(zes_engine_group_t engineGroup,
uint32_t engineInstance,
uint32_t gtId,
PmuInterface *const &pPmuInterface,
std::vector<std::pair<int64_t, int64_t>> &fdList,
std::pair<uint64_t, uint64_t> &configPair) = 0;
virtual ze_result_t readBusynessFromGroupFd(PmuInterface *const &pPmuInterface, std::pair<int64_t, int64_t> &fdPair, zes_engine_stats_t *pStats) = 0;
virtual std::string getHwmonName(uint32_t subDeviceId, bool isSubdevice) const = 0;
virtual bool isStandbyModeControlAvailable() const = 0;
@ -191,7 +196,12 @@ class SysmanKmdInterfaceI915Upstream : public SysmanKmdInterface, SysmanKmdInter
std::string getSysfsFilePath(SysfsName sysfsName, uint32_t subDeviceId, bool baseDirectoryExists) override;
std::string getSysfsFilePathForPhysicalMemorySize(uint32_t subDeviceId) override;
std::string getEnergyCounterNodeFile(zes_power_domain_t powerDomain) override;
ze_result_t getEngineActivityFdList(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t gtId, PmuInterface *const &pPmuInterface, std::vector<std::pair<int64_t, int64_t>> &fdList) override;
ze_result_t getEngineActivityFdListAndConfigPair(zes_engine_group_t engineGroup,
uint32_t engineInstance,
uint32_t gtId,
PmuInterface *const &pPmuInterface,
std::vector<std::pair<int64_t, int64_t>> &fdList,
std::pair<uint64_t, uint64_t> &configPair) override;
ze_result_t readBusynessFromGroupFd(PmuInterface *const &pPmuInterface, std::pair<int64_t, int64_t> &fdPair, zes_engine_stats_t *pStats) override;
std::string getHwmonName(uint32_t subDeviceId, bool isSubdevice) const override;
bool isStandbyModeControlAvailable() const override { return true; }
@ -241,7 +251,12 @@ class SysmanKmdInterfaceI915Prelim : public SysmanKmdInterface, SysmanKmdInterfa
std::string getSysfsFilePath(SysfsName sysfsName, uint32_t subDeviceId, bool baseDirectoryExists) override;
std::string getSysfsFilePathForPhysicalMemorySize(uint32_t subDeviceId) override;
std::string getEnergyCounterNodeFile(zes_power_domain_t powerDomain) override;
ze_result_t getEngineActivityFdList(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t gtId, PmuInterface *const &pPmuInterface, std::vector<std::pair<int64_t, int64_t>> &fdList) override;
ze_result_t getEngineActivityFdListAndConfigPair(zes_engine_group_t engineGroup,
uint32_t engineInstance,
uint32_t gtId,
PmuInterface *const &pPmuInterface,
std::vector<std::pair<int64_t, int64_t>> &fdList,
std::pair<uint64_t, uint64_t> &configPair) override;
ze_result_t readBusynessFromGroupFd(PmuInterface *const &pPmuInterface, std::pair<int64_t, int64_t> &fdPair, zes_engine_stats_t *pStats) override;
std::string getHwmonName(uint32_t subDeviceId, bool isSubdevice) const override;
bool isStandbyModeControlAvailable() const override { return true; }
@ -292,7 +307,12 @@ class SysmanKmdInterfaceXe : public SysmanKmdInterface {
std::string getSysfsFilePathForPhysicalMemorySize(uint32_t subDeviceId) override;
std::string getEngineBasePath(uint32_t subDeviceId) const override;
std::string getEnergyCounterNodeFile(zes_power_domain_t powerDomain) override;
ze_result_t getEngineActivityFdList(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t gtId, PmuInterface *const &pPmuInterface, std::vector<std::pair<int64_t, int64_t>> &fdList) override;
ze_result_t getEngineActivityFdListAndConfigPair(zes_engine_group_t engineGroup,
uint32_t engineInstance,
uint32_t gtId,
PmuInterface *const &pPmuInterface,
std::vector<std::pair<int64_t, int64_t>> &fdList,
std::pair<uint64_t, uint64_t> &configPair) override;
ze_result_t readBusynessFromGroupFd(PmuInterface *const &pPmuInterface, std::pair<int64_t, int64_t> &fdPair, zes_engine_stats_t *pStats) override;
std::string getHwmonName(uint32_t subDeviceId, bool isSubdevice) const override;
bool isStandbyModeControlAvailable() const override { return false; }

View File

@ -104,7 +104,12 @@ std::string SysmanKmdInterfaceI915Prelim::getEnergyCounterNodeFile(zes_power_dom
return filePath;
}
ze_result_t SysmanKmdInterfaceI915Prelim::getEngineActivityFdList(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t gtId, PmuInterface *const &pPmuInterface, std::vector<std::pair<int64_t, int64_t>> &fdList) {
ze_result_t SysmanKmdInterfaceI915Prelim::getEngineActivityFdListAndConfigPair(zes_engine_group_t engineGroup,
uint32_t engineInstance,
uint32_t gtId,
PmuInterface *const &pPmuInterface,
std::vector<std::pair<int64_t, int64_t>> &fdList,
std::pair<uint64_t, uint64_t> &configPair) {
uint64_t config = UINT64_MAX;
switch (engineGroup) {
case ZES_ENGINE_GROUP_ALL:
@ -127,14 +132,15 @@ ze_result_t SysmanKmdInterfaceI915Prelim::getEngineActivityFdList(zes_engine_gro
}
int64_t fd[2];
fd[0] = pPmuInterface->pmuInterfaceOpen(config, -1, PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
auto i915EngineClass = engineGroupToEngineClass.find(engineGroup);
configPair = std::make_pair(config, PRELIM_I915_PMU_ENGINE_TOTAL_TICKS(i915EngineClass->second, engineInstance));
fd[0] = pPmuInterface->pmuInterfaceOpen(configPair.first, -1, PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
if (fd[0] < 0) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Could not open Busy Ticks Handle \n", __FUNCTION__);
return checkErrorNumberAndReturnStatus();
}
auto i915EngineClass = engineGroupToEngineClass.find(engineGroup);
fd[1] = pPmuInterface->pmuInterfaceOpen(PRELIM_I915_PMU_ENGINE_TOTAL_TICKS(i915EngineClass->second, engineInstance), static_cast<int>(fd[0]), PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
fd[1] = pPmuInterface->pmuInterfaceOpen(configPair.second, static_cast<int>(fd[0]), PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
if (fd[1] < 0) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Could not open Total Active Ticks Handle \n", __FUNCTION__);
close(static_cast<int>(fd[0]));

View File

@ -97,11 +97,17 @@ std::string SysmanKmdInterfaceI915Upstream::getEnergyCounterNodeFile(zes_power_d
return filePath;
}
ze_result_t SysmanKmdInterfaceI915Upstream::getEngineActivityFdList(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t gtId, PmuInterface *const &pPmuInterface, std::vector<std::pair<int64_t, int64_t>> &fdList) {
ze_result_t SysmanKmdInterfaceI915Upstream::getEngineActivityFdListAndConfigPair(zes_engine_group_t engineGroup,
uint32_t engineInstance,
uint32_t gtId,
PmuInterface *const &pPmuInterface,
std::vector<std::pair<int64_t, int64_t>> &fdList,
std::pair<uint64_t, uint64_t> &configPair) {
uint64_t config = UINT64_MAX;
auto engineClass = engineGroupToEngineClass.find(engineGroup);
config = I915_PMU_ENGINE_BUSY(engineClass->second, engineInstance);
auto fd = pPmuInterface->pmuInterfaceOpen(config, -1, PERF_FORMAT_TOTAL_TIME_ENABLED);
configPair = std::make_pair(config, UINT64_MAX);
auto fd = pPmuInterface->pmuInterfaceOpen(configPair.first, -1, PERF_FORMAT_TOTAL_TIME_ENABLED);
if (fd < 0) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Could not open Busy Ticks Handle \n", __FUNCTION__);
return checkErrorNumberAndReturnStatus();

View File

@ -101,7 +101,12 @@ std::string SysmanKmdInterfaceXe::getEnergyCounterNodeFile(zes_power_domain_t po
return filePath;
}
ze_result_t SysmanKmdInterfaceXe::getEngineActivityFdList(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t gtId, PmuInterface *const &pPmuInterface, std::vector<std::pair<int64_t, int64_t>> &fdList) {
ze_result_t SysmanKmdInterfaceXe::getEngineActivityFdListAndConfigPair(zes_engine_group_t engineGroup,
uint32_t engineInstance,
uint32_t gtId,
PmuInterface *const &pPmuInterface,
std::vector<std::pair<int64_t, int64_t>> &fdList,
std::pair<uint64_t, uint64_t> &configPair) {
ze_result_t result = ZE_RESULT_SUCCESS;
@ -123,14 +128,16 @@ ze_result_t SysmanKmdInterfaceXe::getEngineActivityFdList(zes_engine_group_t eng
return result;
}
configPair = std::make_pair(activeTicksConfig, totalTicksConfig);
int64_t fd[2];
fd[0] = pPmuInterface->pmuInterfaceOpen(activeTicksConfig, -1, PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
fd[0] = pPmuInterface->pmuInterfaceOpen(configPair.first, -1, PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
if (fd[0] < 0) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Could not open Busy Ticks Handle \n", __FUNCTION__);
return checkErrorNumberAndReturnStatus();
}
fd[1] = pPmuInterface->pmuInterfaceOpen(totalTicksConfig, static_cast<int>(fd[0]), PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
fd[1] = pPmuInterface->pmuInterfaceOpen(configPair.second, static_cast<int>(fd[0]), PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
if (fd[1] < 0) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Could not open Total Active Ticks Handle \n", __FUNCTION__);
close(static_cast<int>(fd[0]));

View File

@ -96,6 +96,17 @@ TEST_F(ZesEngineFixtureXe, GivenComponentCountZeroWhenCallingZesDeviceEnumEngine
EXPECT_EQ(count, mockEngineHandleCount);
}
TEST_F(ZesEngineFixtureXe, GivenValidEngineHandleWhenFetchingConfigPairThenProperValuesAreReturned) {
auto handles = getEngineHandles(mockEngineHandleCount);
EXPECT_EQ(mockEngineHandleCount, handles.size());
for (auto handle : handles) {
L0::Sysman::Engine *pEngine = L0::Sysman::Engine::fromHandle(handle);
EXPECT_EQ(pEngine->configPair.first, pPmuInterface->mockActiveTicksConfig);
EXPECT_EQ(pEngine->configPair.second, pPmuInterface->mockTotalTicksConfig);
}
}
TEST_F(ZesEngineFixtureXe, GivenValidEngineHandleWhenCallingZesEngineGetActivityThenCallSuccedsAndValidValuesAreReturned) {
zes_engine_stats_t stats = {};

View File

@ -276,9 +276,10 @@ TEST_F(SysmanFixtureDeviceI915Prelim, GivenSysmanKmdInterfaceInstanceAndPmuFails
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
std::vector<std::pair<int64_t, int64_t>> fdList = {};
std::pair<uint64_t, uint64_t> configPair = {};
pPmuInterface->mockErrorNumber = EMFILE;
pPmuInterface->mockPerfEventOpenReadFail = true;
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_ALL, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_ALL, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE);
}
TEST_F(SysmanFixtureDeviceI915Prelim, GivenSysmanKmdInterfaceInstanceAndPmuOpenFailsDueToFileTableOverFlowWhenGetEngineActivityFdListIsCalledThenErrorIsReturned) {
@ -287,9 +288,10 @@ TEST_F(SysmanFixtureDeviceI915Prelim, GivenSysmanKmdInterfaceInstanceAndPmuOpenF
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
std::vector<std::pair<int64_t, int64_t>> fdList = {};
std::pair<uint64_t, uint64_t> configPair = {};
pPmuInterface->mockErrorNumber = ENFILE;
pPmuInterface->mockPerfEventOpenReadFail = true;
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_ALL, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_ALL, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE);
}
} // namespace ult

View File

@ -190,11 +190,12 @@ TEST_F(SysmanFixtureDeviceI915Upstream, GivenGroupEngineTypeAndSysmanKmdInterfac
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
std::vector<std::pair<int64_t, int64_t>> fdList = {};
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_ALL, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_COMPUTE_ALL, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_COPY_ALL, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_RENDER_ALL, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_MEDIA_ALL, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
std::pair<uint64_t, uint64_t> configPair = {};
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_ALL, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_COMPUTE_ALL, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_COPY_ALL, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_RENDER_ALL, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_MEDIA_ALL, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
TEST_F(SysmanFixtureDeviceI915Upstream, GivenSingleEngineTypeAndSysmanKmdInterfaceInstanceWhenGetEngineActivityFdListIsCalledThenValidFdAndSuccessIsReturned) {
@ -205,7 +206,8 @@ TEST_F(SysmanFixtureDeviceI915Upstream, GivenSingleEngineTypeAndSysmanKmdInterfa
pPmuInterface->mockPmuFd = 10;
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
std::vector<std::pair<int64_t, int64_t>> fdList = {};
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_COMPUTE_SINGLE, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_SUCCESS);
std::pair<uint64_t, uint64_t> configPair = {};
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_COMPUTE_SINGLE, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_SUCCESS);
EXPECT_EQ(fdList[0].first, pPmuInterface->mockPmuFd);
EXPECT_EQ(fdList[0].second, -1);
}
@ -216,9 +218,10 @@ TEST_F(SysmanFixtureDeviceI915Upstream, GivenSysmanKmdInterfaceInstanceAndPmuFai
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
std::vector<std::pair<int64_t, int64_t>> fdList = {};
std::pair<uint64_t, uint64_t> configPair = {};
pPmuInterface->mockErrorNumber = EMFILE;
pPmuInterface->mockPerfEventOpenReadFail = true;
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_ALL, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_ALL, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE);
}
TEST_F(SysmanFixtureDeviceI915Upstream, GivenSysmanKmdInterfaceInstanceAndPmuOpenFailsDueToFileTableOverFlowWhenGetEngineActivityFdListIsCalledThenErrorIsReturned) {
@ -227,9 +230,10 @@ TEST_F(SysmanFixtureDeviceI915Upstream, GivenSysmanKmdInterfaceInstanceAndPmuOpe
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
std::vector<std::pair<int64_t, int64_t>> fdList = {};
std::pair<uint64_t, uint64_t> configPair = {};
pPmuInterface->mockErrorNumber = ENFILE;
pPmuInterface->mockPerfEventOpenReadFail = true;
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_ALL, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_ALL, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE);
}
TEST_F(SysmanFixtureDeviceI915Upstream, GivenSysmanKmdInterfaceInstanceAndIsIntegratedDeviceWhenGetEventsIsCalledThenValidEventTypeIsReturned) {

View File

@ -200,41 +200,46 @@ TEST_F(SysmanFixtureDeviceXe, GivenSysmanKmdInterfaceWhenGetEnergyCounterNodeFil
TEST_F(SysmanFixtureDeviceXe, GivenGroupEngineTypeAndSysmanKmdInterfaceWhenCallingGetEngineActivityFdListThenErrorIsReturned) {
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
std::vector<std::pair<int64_t, int64_t>> fdList = {};
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_ALL, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
std::pair<uint64_t, uint64_t> configPair = {};
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_ALL, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
TEST_F(SysmanFixtureDeviceXe, GivenSysmanKmdInterfaceAndGettingConfigFromEventFileFailsForEngineActiveTicksWhenCallingGetEngineActivityFdListThenErrorIsReturned) {
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
std::vector<std::pair<int64_t, int64_t>> fdList = {};
std::pair<uint64_t, uint64_t> configPair = {};
pPmuInterface->mockEventConfigReturnValue.push_back(-1);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_COMPUTE_SINGLE, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_COMPUTE_SINGLE, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
TEST_F(SysmanFixtureDeviceXe, GivenSysmanKmdInterfaceAndGettingConfigFromEventFileFailsForEngineTotalTicksWhenCallingGetEngineActivityFdListThenErrorIsReturned) {
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
std::vector<std::pair<int64_t, int64_t>> fdList = {};
std::pair<uint64_t, uint64_t> configPair = {};
pPmuInterface->mockEventConfigReturnValue.push_back(0);
pPmuInterface->mockEventConfigReturnValue.push_back(-1);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_COMPUTE_SINGLE, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_COMPUTE_SINGLE, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
TEST_F(SysmanFixtureDeviceXe, GivenSysmanKmdInterfaceAndGettingConfigAfterFormatFailsForEngineActiveTicksWhenCallingGetEngineActivityFdListThenErrorIsReturned) {
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
std::vector<std::pair<int64_t, int64_t>> fdList = {};
std::pair<uint64_t, uint64_t> configPair = {};
pPmuInterface->mockFormatConfigReturnValue.push_back(-1);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_COMPUTE_SINGLE, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_COMPUTE_SINGLE, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
TEST_F(SysmanFixtureDeviceXe, GivenSysmanKmdInterfaceAndGettingConfigAfterFormatFailsForEngineTotalTicksWhenCallingGetEngineActivityFdListThenErrorIsReturned) {
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
std::vector<std::pair<int64_t, int64_t>> fdList = {};
std::pair<uint64_t, uint64_t> configPair = {};
pPmuInterface->mockFormatConfigReturnValue.push_back(0);
pPmuInterface->mockFormatConfigReturnValue.push_back(-1);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdList(ZES_ENGINE_GROUP_COMPUTE_SINGLE, 0, 0, pPmuInterface.get(), fdList), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(pSysmanKmdInterface->getEngineActivityFdListAndConfigPair(ZES_ENGINE_GROUP_COMPUTE_SINGLE, 0, 0, pPmuInterface.get(), fdList, configPair), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
} // namespace ult

View File

@ -22,10 +22,13 @@ class MockPmuInterfaceImp : public L0::Sysman::PmuInterfaceImp {
int64_t mockPmuFd = -1;
uint64_t mockTimestamp = 0;
uint64_t mockActiveTime = 0;
uint64_t mockActiveTicksConfig = 1;
uint64_t mockTotalTicksConfig = 2;
int32_t mockErrorNumber = -ENOSPC;
int32_t mockPerfEventOpenFailAtCount = 1;
int32_t mockPmuReadFailureReturnValue = 0;
bool mockPerfEventOpenReadFail = false;
uint32_t mockPmuConfigCallCount = 0;
std::vector<int32_t> mockEventConfigReturnValue = {};
std::vector<int32_t> mockFormatConfigReturnValue = {};
@ -67,6 +70,14 @@ class MockPmuInterfaceImp : public L0::Sysman::PmuInterfaceImp {
if (!mockFormatConfigReturnValue.empty()) {
returnValue = mockFormatConfigReturnValue.front();
mockFormatConfigReturnValue.erase(mockFormatConfigReturnValue.begin());
return returnValue;
}
if (mockPmuConfigCallCount++ < 1) {
config = mockActiveTicksConfig;
} else {
config = mockTotalTicksConfig;
mockPmuConfigCallCount = 0;
}
return returnValue;
}