Add support for multiple processor groups.

Merge from upstream.
This commit is contained in:
Phyxion
2020-05-11 13:29:52 +02:00
parent a18136b55e
commit 3cc3d9139c
22 changed files with 390 additions and 135 deletions
@@ -79,9 +79,9 @@ namespace LibreHardwareMonitor.Hardware.CPU
if (HasTimeStampCounter)
{
ulong mask = ThreadAffinity.Set(1UL << cpuId[0][0].Thread);
GroupAffinity previousAffinity = ThreadAffinity.Set(cpuId[0][0].Affinity);
EstimateTimeStampCounterFrequency(out _estimatedTimeStampCounterFrequency, out _estimatedTimeStampCounterFrequencyError);
ThreadAffinity.Set(mask);
ThreadAffinity.Set(previousAffinity);
}
else
{
@@ -182,9 +182,9 @@ namespace LibreHardwareMonitor.Hardware.CPU
error = beginError + endError;
}
private static void AppendMsrData(StringBuilder r, uint msr, int thread)
private static void AppendMsrData(StringBuilder r, uint msr, GroupAffinity affinity)
{
if (Ring0.ReadMsr(msr, out uint eax, out uint edx, 1UL << thread))
if (Ring0.ReadMsr(msr, out uint eax, out uint edx, affinity))
{
r.Append(" ");
r.Append(msr.ToString("X8", CultureInfo.InvariantCulture));
@@ -241,7 +241,7 @@ namespace LibreHardwareMonitor.Hardware.CPU
r.AppendLine();
r.AppendLine(" MSR EDX EAX");
foreach (uint msr in msrArray)
AppendMsrData(r, msr, _cpuId[i][0].Thread);
AppendMsrData(r, msr, _cpuId[i][0].Affinity);
r.AppendLine();
}
@@ -255,7 +255,7 @@ namespace LibreHardwareMonitor.Hardware.CPU
if (HasTimeStampCounter && _isInvariantTimeStampCounter)
{
// make sure always the same thread is used
ulong mask = ThreadAffinity.Set(1UL << _cpuId[0][0].Thread);
GroupAffinity previousAffinity = ThreadAffinity.Set(_cpuId[0][0].Affinity);
// read time before and after getting the TSC to estimate the error
long firstTime = Stopwatch.GetTimestamp();
@@ -263,7 +263,7 @@ namespace LibreHardwareMonitor.Hardware.CPU
long time = Stopwatch.GetTimestamp();
// restore the thread affinity mask
ThreadAffinity.Set(mask);
ThreadAffinity.Set(previousAffinity);
double delta = (double)(time - _lastTime) / Stopwatch.Frequency;
double error = (double)(time - firstTime) / Stopwatch.Frequency;