Skip to content

Commit 0f7e2d3

Browse files
committed
enumerate fans getting max fanspeed in igcl
1 parent 064c6c0 commit 0f7e2d3

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

IntelPresentMon/ControlLib/IntelPowerTelemetryAdapter.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
#include "../CommonUtilities/ref/GeneratedReflection.h"
77
#include "../CommonUtilities/ref/StaticReflection.h"
88
#include <regex>
9+
#include <ranges>
910

1011
using namespace pmon;
1112
using namespace util;
13+
namespace vi = std::views;
1214

1315
namespace pwr::intel
1416
{
@@ -60,6 +62,38 @@ namespace pwr::intel
6062
else {
6163
pmlog_error("ctlEnumPowerDomains failed to get count").code(result).pmwatch(GetName());
6264
}
65+
66+
// enumerate fans
67+
uint32_t fanCount = 0;
68+
if (auto res = ctlEnumFans(deviceHandle, &fanCount, nullptr); res == CTL_RESULT_SUCCESS) {
69+
if (fanCount > 0) {
70+
std::vector<ctl_fan_handle_t> fanHandles(fanCount);
71+
if (auto res = ctlEnumFans(deviceHandle, &fanCount, fanHandles.data()); res == CTL_RESULT_SUCCESS) {
72+
for (auto&&[iFan, hFan] : vi::enumerate(fanHandles)) {
73+
if (hFan) {
74+
ctl_fan_properties_t props{ .Size = sizeof(ctl_fan_properties_t) };
75+
if (auto res = ctlFanGetProperties(hFan, &props); res != CTL_RESULT_SUCCESS) {
76+
pmlog_error(std::format("failed to get properties for fan #{}", iFan)).code(res);
77+
maxFanSpeedsRpm_.push_back(0);
78+
}
79+
pmlog_verb(v::gpu)("Got fan properties").pmwatch(GetName()).pmwatch(iFan)
80+
.pmwatch(ref::DumpGenerated(props));
81+
maxFanSpeedsRpm_.push_back(props.maxRPM);
82+
}
83+
else {
84+
pmlog_warn("null handle received from ctlEnumFans");
85+
maxFanSpeedsRpm_.push_back(0);
86+
}
87+
}
88+
}
89+
else {
90+
pmlog_error("failed getting fan handles").code(res);
91+
}
92+
}
93+
}
94+
else {
95+
pmlog_error("failed getting fan count").code(res);
96+
}
6397
}
6498

6599
bool IntelPowerTelemetryAdapter::Sample() noexcept

IntelPresentMon/ControlLib/IntelPowerTelemetryAdapter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,7 @@ namespace pwr::intel
115115
// we have special handling for GPU current perf limitation on Alchemist
116116
// workaround for lack of discoverablity of perf limitation availability
117117
bool isAlchemist = false;
118+
// populated on init, used to calculate fan %
119+
std::vector<int32_t> maxFanSpeedsRpm_;
118120
};
119121
}

0 commit comments

Comments
 (0)