Skip to content

Commit d5125a4

Browse files
committed
Show Performance & Efficient Core instead of Core; Change Voltages, Temperatures to P/E Core; Use independent counter for P/E Core.
1 parent ae922e4 commit d5125a4

3 files changed

Lines changed: 74 additions & 19 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace OpenHardwareMonitor.Hardware;
2+
3+
public enum CoreType
4+
{
5+
Unknown = 0,
6+
Performance = 0x40,
7+
Efficient = 0x20
8+
}

OpenHardwareMonitorLib/Hardware/Cpu/CpuId.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ private CpuId(int group, int thread, GroupAffinity affinity)
7777
OpCode.CpuId(CPUID_0 + i, 0, out Data[i, 0], out Data[i, 1], out Data[i, 2], out Data[i, 3]);
7878
}
7979

80+
if (Vendor == Vendor.Intel && maxCpuid >= 0x1A)
81+
{
82+
// Leaf 0x1A, SubLeaf 0, EAX Bits 31:24 = Core Type ID
83+
uint coreType = (Data[0x1A, 0] >> 24) & 0xFF;
84+
85+
CoreType = coreType switch
86+
{
87+
// 0x40 = Core (P-Core), 0x20 = Atom (E-Core)
88+
0x40 => CoreType.Performance,
89+
0x20 => CoreType.Efficient,
90+
_ => CoreType.Unknown
91+
};
92+
}
93+
else
94+
{
95+
CoreType = CoreType.Unknown;
96+
}
97+
8098
ExtData = new uint[maxCpuidExt + 1, 4];
8199
for (uint i = 0; i < maxCpuidExt + 1; i++)
82100
{
@@ -185,6 +203,7 @@ private CpuId(int group, int thread, GroupAffinity affinity)
185203
public string BrandString { get; } = string.Empty;
186204

187205
public uint CoreId { get; }
206+
public CoreType CoreType { get; } = CoreType.Unknown;
188207

189208
public uint[,] Data { get; } = new uint[0, 0];
190209

OpenHardwareMonitorLib/Hardware/Cpu/IntelCpu.cs

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ internal sealed class IntelCpu : GenericCpu
1616
private readonly Sensor _coreVoltage;
1717
private readonly Sensor[] _distToTjMaxTemperatures;
1818

19+
private readonly string[] _coreNames;
20+
1921
private readonly uint[] _energyStatusMsrs = { MSR_PKG_ENERGY_STATUS, MSR_PP0_ENERGY_STATUS, MSR_PP1_ENERGY_STATUS, MSR_DRAM_ENERGY_STATUS, MSR_PLATFORM_ENERGY_STATUS };
2022
private readonly uint[] _lastEnergyConsumed;
2123
private readonly DateTime[] _lastEnergyTime;
@@ -318,6 +320,30 @@ public IntelCpu(int processorIndex, CpuId[][] cpuId, ISettings settings) : base(
318320
break;
319321
}
320322

323+
// Initialize core names
324+
_coreNames = new string[_coreCount];
325+
int pCoreIndex = 1;
326+
int eCoreIndex = 1;
327+
328+
for (int i = 0; i < _coreCount; i++)
329+
{
330+
if (_cpuId.Length > i && _cpuId[i].Length > 0)
331+
{
332+
CoreType coreType = _cpuId[i][0].CoreType;
333+
334+
_coreNames[i] = coreType switch
335+
{
336+
CoreType.Performance => $"P-Core #{pCoreIndex++}",
337+
CoreType.Efficient => $"E-Core #{eCoreIndex++}",
338+
_ => CoreString(i)
339+
};
340+
}
341+
else
342+
{
343+
_coreNames[i] = CoreString(i);
344+
}
345+
}
346+
321347
int coreSensorId = 0;
322348

323349
//core temp avg and max value
@@ -344,23 +370,24 @@ public IntelCpu(int processorIndex, CpuId[][] cpuId, ISettings settings) : base(
344370
_coreTemperatures = new Sensor[_coreCount];
345371
for (int i = 0; i < _coreTemperatures.Length; i++)
346372
{
347-
_coreTemperatures[i] = new Sensor(CoreString(i),
348-
coreSensorId,
349-
SensorType.Temperature,
350-
this,
351-
new[]
352-
{
353-
new ParameterDescription("TjMax [°C]", "TjMax temperature of the core sensor.\n" + "Temperature = TjMax - TSlope * Value.", tjMax[i]),
354-
new ParameterDescription("TSlope [°C]", "Temperature slope of the digital thermal sensor.\n" + "Temperature = TjMax - TSlope * Value.", 1)
355-
},
356-
settings);
373+
_coreTemperatures[i] = new Sensor(_coreNames[i],
374+
coreSensorId,
375+
SensorType.Temperature,
376+
this,
377+
[
378+
new ParameterDescription("TjMax [°C]", "TjMax temperature of the core sensor.\n" + "Temperature = TjMax - TSlope * Value.", tjMax[i]),
379+
new ParameterDescription("TSlope [°C]", "Temperature slope of the digital thermal sensor.\n" + "Temperature = TjMax - TSlope * Value.", 1)
380+
],
381+
settings);
357382

358383
ActivateSensor(_coreTemperatures[i]);
359384
coreSensorId++;
360385
}
361386
}
362387
else
363-
_coreTemperatures = Array.Empty<Sensor>();
388+
{
389+
_coreTemperatures = [];
390+
}
364391

365392
// check if processor supports a digital thermal sensor at package level
366393
if (cpuId[0][0].Data.GetLength(0) > 6 && (cpuId[0][0].Data[6, 0] & 0x40) != 0 && _microArchitecture != MicroArchitecture.Unknown)
@@ -369,11 +396,10 @@ public IntelCpu(int processorIndex, CpuId[][] cpuId, ISettings settings) : base(
369396
coreSensorId,
370397
SensorType.Temperature,
371398
this,
372-
new[]
373-
{
399+
[
374400
new ParameterDescription("TjMax [°C]", "TjMax temperature of the package sensor.\n" + "Temperature = TjMax - TSlope * Value.", tjMax[0]),
375401
new ParameterDescription("TSlope [°C]", "Temperature slope of the digital thermal sensor.\n" + "Temperature = TjMax - TSlope * Value.", 1)
376-
},
402+
],
377403
settings);
378404

379405
ActivateSensor(_packageTemperature);
@@ -386,19 +412,21 @@ public IntelCpu(int processorIndex, CpuId[][] cpuId, ISettings settings) : base(
386412
_distToTjMaxTemperatures = new Sensor[_coreCount];
387413
for (int i = 0; i < _distToTjMaxTemperatures.Length; i++)
388414
{
389-
_distToTjMaxTemperatures[i] = new Sensor(CoreString(i) + " Distance to TjMax", coreSensorId, SensorType.Temperature, this, settings);
415+
_distToTjMaxTemperatures[i] = new Sensor(_coreNames[i] + " Distance to TjMax", coreSensorId, SensorType.Temperature, this, settings);
390416
ActivateSensor(_distToTjMaxTemperatures[i]);
391417
coreSensorId++;
392418
}
393419
}
394420
else
395-
_distToTjMaxTemperatures = Array.Empty<Sensor>();
421+
{
422+
_distToTjMaxTemperatures = [];
423+
}
396424

397425
_busClock = new Sensor("Bus Speed", 0, SensorType.Clock, this, settings);
398426
_coreClocks = new Sensor[_coreCount];
399427
for (int i = 0; i < _coreClocks.Length; i++)
400428
{
401-
_coreClocks[i] = new Sensor(CoreString(i), i + 1, SensorType.Clock, this, settings);
429+
_coreClocks[i] = new Sensor(_coreNames[i], i + 1, SensorType.Clock, this, settings);
402430
if (HasTimeStampCounter && _microArchitecture != MicroArchitecture.Unknown)
403431
ActivateSensor(_coreClocks[i]);
404432
}
@@ -444,7 +472,7 @@ MicroArchitecture.ElkhartLake or
444472

445473
if (EnergyUnitsMultiplier != 0)
446474
{
447-
string[] powerSensorLabels = { "CPU Package", "CPU Cores", "CPU Graphics", "CPU Memory", "CPU Platform" };
475+
string[] powerSensorLabels = ["CPU Package", "CPU Cores", "CPU Graphics", "CPU Memory", "CPU Platform"];
448476

449477
for (int i = 0; i < _energyStatusMsrs.Length; i++)
450478
{
@@ -477,7 +505,7 @@ MicroArchitecture.ElkhartLake or
477505
_coreVIDs = new Sensor[_coreCount];
478506
for (int i = 0; i < _coreVIDs.Length; i++)
479507
{
480-
_coreVIDs[i] = new Sensor(CoreString(i), i + 1, SensorType.Voltage, this, settings);
508+
_coreVIDs[i] = new Sensor(_coreNames[i], i + 1, SensorType.Voltage, this, settings);
481509
ActivateSensor(_coreVIDs[i]);
482510
}
483511

0 commit comments

Comments
 (0)