fix(sysman): change KMD config macro for group all engine handles

Related-To: NEO-15172

Signed-off-by: Anvesh Bakwad <anvesh.bakwad@intel.com>
This commit is contained in:
Anvesh Bakwad
2025-06-10 11:00:02 +00:00
committed by Compute-Runtime-Automation
parent f75460e2a0
commit 2271ce2b7f
4 changed files with 33 additions and 10 deletions

View File

@@ -126,14 +126,20 @@ ze_result_t SysmanKmdInterfaceI915Prelim::getEngineActivityFdListAndConfigPair(z
config = __PRELIM_I915_PMU_MEDIA_GROUP_BUSY_TICKS(gtId);
break;
default:
auto engineClass = engineGroupToEngineClass.find(engineGroup);
config = PRELIM_I915_PMU_ENGINE_BUSY_TICKS(engineClass->second, engineInstance);
auto i915EngineClass = engineGroupToEngineClass.find(engineGroup);
config = PRELIM_I915_PMU_ENGINE_BUSY_TICKS(i915EngineClass->second, engineInstance);
break;
}
int64_t fd[2];
auto i915EngineClass = engineGroupToEngineClass.find(engineGroup);
configPair = std::make_pair(config, PRELIM_I915_PMU_ENGINE_TOTAL_TICKS(i915EngineClass->second, engineInstance));
if (isGroupEngineHandle(engineGroup)) {
configPair = std::make_pair(config, __PRELIM_I915_PMU_TOTAL_ACTIVE_TICKS(gtId));
} else {
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__);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2024 Intel Corporation
* Copyright (C) 2022-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -227,8 +227,17 @@ void LinuxEngineImpPrelim::init() {
checkErrorNumberAndUpdateStatus();
return;
}
auto i915EngineClass = engineToI915MapPrelim.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);
uint64_t totalTickConfig = 0u;
bool isGroupEngineHandle = (engineGroup == ZES_ENGINE_GROUP_ALL || engineGroup == ZES_ENGINE_GROUP_MEDIA_ALL || engineGroup == ZES_ENGINE_GROUP_COMPUTE_ALL || engineGroup == ZES_ENGINE_GROUP_RENDER_ALL || engineGroup == ZES_ENGINE_GROUP_COPY_ALL);
if (isGroupEngineHandle) {
totalTickConfig = __PRELIM_I915_PMU_TOTAL_ACTIVE_TICKS(subDeviceId);
} else {
auto i915EngineClass = engineToI915MapPrelim.find(engineGroup);
totalTickConfig = PRELIM_I915_PMU_ENGINE_TOTAL_TICKS(i915EngineClass->second, engineInstance);
}
fd[1] = pPmuInterface->pmuInterfaceOpen(totalTickConfig, 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__);
@@ -249,6 +258,7 @@ void LinuxEngineImpPrelim::init() {
// Delay fd opening till actually needed
for (uint64_t i = 0; i < numberOfVfs + 1; i++) {
const uint64_t busyConfig = ___PRELIM_I915_PMU_FN_EVENT(config, i);
auto i915EngineClass = engineToI915MapPrelim.find(engineGroup);
const uint64_t totalConfig = ___PRELIM_I915_PMU_FN_EVENT(PRELIM_I915_PMU_ENGINE_TOTAL_TICKS(i915EngineClass->second, engineInstance), i);
vfConfigs.push_back(std::make_pair(busyConfig, totalConfig));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2024 Intel Corporation
* Copyright (C) 2022-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -116,6 +116,11 @@ struct MockEnginePmuInterfaceImpPrelim : public PmuInterfaceImp {
int32_t mockErrorNumber = -ENOSPC;
int32_t mockPerfEventOpenFailAtCount = 1;
uint64_t mockTimestamp = 87654321;
static uint32_t engineConfigIndex;
std::vector<uint64_t> mockSingleEngineConfigs = {
__PRELIM_I915_PMU_TOTAL_ACTIVE_TICKS(0),
PRELIM_I915_PMU_ENGINE_TOTAL_TICKS(drm_i915_gem_engine_class::I915_ENGINE_CLASS_RENDER, 0),
__PRELIM_I915_PMU_TOTAL_ACTIVE_TICKS(0)};
int64_t perfEventOpen(perf_event_attr *attr, pid_t pid, int cpu, int groupFd, uint64_t flags) override {
@@ -157,7 +162,7 @@ struct MockEnginePmuInterfaceImpPrelim : public PmuInterfaceImp {
int64_t pmuInterfaceOpen(uint64_t config, int group, uint32_t format) override {
if (group > -1 && MockEngineNeoDrmPrelim::mockQuerySingleEngineInstance == true) {
uint64_t testConfig = PRELIM_I915_PMU_ENGINE_TOTAL_TICKS(drm_i915_gem_engine_class::I915_ENGINE_CLASS_RENDER, 0);
auto testConfig = mockSingleEngineConfigs[engineConfigIndex++];
EXPECT_EQ(config, testConfig);
}
return PmuInterfaceImp::pmuInterfaceOpen(config, group, format);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2024 Intel Corporation
* Copyright (C) 2022-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -20,6 +20,7 @@ constexpr uint32_t handleComponentCount = 13u;
constexpr uint32_t handleCountForMultiDeviceFixture = 7u;
bool MockEngineNeoDrmPrelim::mockQuerySingleEngineInstance = false;
uint32_t MockEnginePmuInterfaceImpPrelim::engineConfigIndex = 0u;
class ZesEngineFixturePrelim : public SysmanDeviceFixture {
protected:
@@ -104,6 +105,7 @@ TEST_F(ZesEngineFixturePrelim, GivenDeviceHandleAndSingleEngineInstanceIsQueried
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEnumEngineGroups(device->toHandle(), &count, NULL));
EXPECT_EQ(count, numHandles);
MockEngineNeoDrmPrelim::mockQuerySingleEngineInstance = false;
MockEnginePmuInterfaceImpPrelim::engineConfigIndex = 0u;
}
TEST_F(ZesEngineFixturePrelim, GivenComponentCountZeroWhenCallingzesDeviceEnumEngineGroupsThenNonZeroCountIsReturnedAndVerifyCallSucceeds) {