Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temperature reporting fix for AMD Zen CPUs #1176

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
28 changes: 24 additions & 4 deletions linux/LibSensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,30 @@ void LibSensors_getCPUTemperatures(CPUData* cpus, unsigned int existingCPUs, uns
/* Check for further adjustments */
}

/* Only temperature for core 0, maybe Ryzen - copy to all other cores */
if (coreTempCount == 1 && !isnan(data[1])) {
for (unsigned int i = 2; i <= existingCPUs; i++)
data[i] = data[1];
/* Check AMD Zen CPUs packages, and mirror temps across packages */
if (coreTempCount != existingCPUs) {
double temp[coreTempCount];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is left partially uninitialized if data contains NAN values.

unsigned int count = 0;
unsigned int coresInDie = existingCPUs / coreTempCount;

// Find package temps
for (unsigned int i = 1; i <= existingCPUs; i++) {
if (!isnan(data[i])) {
temp[count] = data[i];
count++;
if (count == coreTempCount) {
break;
}
}
}

// Set Temperature
data[0] = temp[0];
for (unsigned int die = 0; die < coreTempCount; die++) {
for (unsigned int i = 1; i <= coresInDie; i++) {
data[(die*coresInDie)+i] = temp[die];
JohnsonGlenT marked this conversation as resolved.
Show resolved Hide resolved
}
}

/* No further adjustments */
goto out;
Expand Down