public AMD0FCPU(string name, uint family, uint model, uint stepping, uint[,] cpuidData, uint[,] cpuidExtData) { this.name = name; this.icon = Utilities.EmbeddedResources.GetImage("cpu.png"); uint coreCount = 1; if (cpuidExtData.GetLength(0) > 8) { coreCount = (cpuidExtData[8, 2] & 0xFF) + 1; } // max two cores coreCount = coreCount > 2 ? 2 : coreCount; totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); offset = -49.0f; // AM2+ 65nm +21 offset if (model >= 0x69 && model != 0xc1 && model != 0x6c && model != 0x7c) { offset += 21; } coreTemperatures = new Sensor[coreCount]; coreLoads = new Sensor[coreCount]; for (int i = 0; i < coreCount; i++) { coreTemperatures[i] = new Sensor("Core #" + (i + 1), i, SensorType.Temperature, this); coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, null, SensorType.Load, this, new ParameterDescription[] { new ParameterDescription("Offset", "Temperature offset of the thermal sensor.\n" + "Temperature = Value + Offset.", offset) }); } cpuLoad = new CPULoad(coreCount, 1); if (cpuLoad.IsAvailable) { foreach (Sensor sensor in coreLoads) { ActivateSensor(sensor); } ActivateSensor(totalLoad); } pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, PCI_AMD_0FH_MISCELLANEOUS_DEVICE_ID, 0); Update(); }
public AMD10CPU(string name, uint family, uint model, uint stepping, uint[,] cpuidData, uint[,] cpuidExtData) { this.name = name; this.icon = Utilities.EmbeddedResources.GetImage("cpu.png"); uint coreCount = 1; if (cpuidExtData.GetLength(0) > 8) { coreCount = (cpuidExtData[8, 2] & 0xFF) + 1; } totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); coreLoads = new Sensor[coreCount]; for (int i = 0; i < coreCount; i++) { coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, SensorType.Load, this); } cpuLoad = new CPULoad(coreCount, 1); if (cpuLoad.IsAvailable) { foreach (Sensor sensor in coreLoads) { ActivateSensor(sensor); } ActivateSensor(totalLoad); } // AMD family 10h processors support only one temperature sensor coreTemperature = new Sensor( "Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0, null, SensorType.Temperature, this, new ParameterDescription[] { new ParameterDescription("Offset", "Temperature offset.", 0) }); pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID, 0); if (pciAddress == 0xFFFFFFFF) { pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, PCI_AMD_11H_MISCELLANEOUS_DEVICE_ID, 0); } Update(); }
public AMD10CPU(int processorIndex, CPUID[][] cpuid) { this.processorIndex = processorIndex; this.name = cpuid[0][0].Name; this.icon = Utilities.EmbeddedResources.GetImage("cpu.png"); int coreCount = cpuid.Length; totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); coreLoads = new Sensor[coreCount]; for (int i = 0; i < coreCount; i++) { coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, SensorType.Load, this); } cpuLoad = new CPULoad(cpuid); if (cpuLoad.IsAvailable) { foreach (Sensor sensor in coreLoads) { ActivateSensor(sensor); } ActivateSensor(totalLoad); } // AMD family 10h processors support only one temperature sensor coreTemperature = new Sensor( "Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0, null, SensorType.Temperature, this, new ParameterDescription[] { new ParameterDescription("Offset", "Temperature offset.", 0) }); pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID, (byte)processorIndex); if (pciAddress == 0xFFFFFFFF) { pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, PCI_AMD_11H_MISCELLANEOUS_DEVICE_ID, (byte)processorIndex); } Update(); }
public IntelCPU(int processorIndex, CPUID[][] cpuid) { this.processorIndex = processorIndex; this.cpuid = cpuid; this.coreCount = cpuid.Length; this.name = cpuid[0][0].Name; this.icon = Utilities.EmbeddedResources.GetImage("cpu.png"); this.family = cpuid[0][0].Family; this.model = cpuid[0][0].Model; this.stepping = cpuid[0][0].Stepping; float[] tjMax; switch (family) { case 0x06: { switch (model) { case 0x0F: // Intel Core (65nm) switch (stepping) { case 0x06: // B2 switch (coreCount) { case 2: tjMax = Floats(80 + 10); break; case 4: tjMax = Floats(90 + 10); break; default: tjMax = Floats(85 + 10); break; } tjMax = Floats(80 + 10); break; case 0x0B: // G0 tjMax = Floats(90 + 10); break; case 0x0D: // M0 tjMax = Floats(85 + 10); break; default: tjMax = Floats(85 + 10); break; } break; case 0x17: // Intel Core (45nm) tjMax = Floats(100); break; case 0x1C: // Intel Atom (45nm) switch (stepping) { case 0x02: // C0 tjMax = Floats(90); break; case 0x0A: // A0, B0 tjMax = Floats(100); break; default: tjMax = Floats(90); break; } break; case 0x1A: // Intel Core i7 LGA1366 (45nm) case 0x1E: // Intel Core i5, i7 LGA1156 (45nm) case 0x25: // Intel Core i3, i5, i7 LGA1156 (32nm) case 0x2C: // Intel Core i7 LGA1366 (32nm) 6 Core uint eax, edx; tjMax = new float[coreCount]; for (int i = 0; i < coreCount; i++) { if (WinRing0.RdmsrTx(IA32_TEMPERATURE_TARGET, out eax, out edx, (UIntPtr)(1L << cpuid[i][0].Thread))) { tjMax[i] = (eax >> 16) & 0xFF; } else { tjMax[i] = 100; } } if (WinRing0.Rdmsr(MSR_PLATFORM_INFO, out eax, out edx)) { maxNehalemMultiplier = (eax >> 8) & 0xff; } break; default: tjMax = Floats(100); break; } } break; default: tjMax = Floats(100); break; } // check if processor supports a digital thermal sensor if (cpuid[0][0].Data.GetLength(0) > 6 && (cpuid[0][0].Data[6, 0] & 1) != 0) { coreTemperatures = new Sensor[coreCount]; for (int i = 0; i < coreTemperatures.Length; i++) { coreTemperatures[i] = new Sensor(CoreString(i), i, SensorType.Temperature, this, new ParameterDescription[] { new ParameterDescription( "TjMax [°C]", "TjMax temperature of the core.\n" + "Temperature = TjMax - TSlope * Value.", tjMax[i]), new ParameterDescription("TSlope [°C]", "Temperature slope of the digital thermal sensor.\n" + "Temperature = TjMax - TSlope * Value.", 1) }); } } else { coreTemperatures = new Sensor[0]; } if (coreCount > 1) { totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); } else { totalLoad = null; } coreLoads = new Sensor[coreCount]; for (int i = 0; i < coreLoads.Length; i++) { coreLoads[i] = new Sensor(CoreString(i), i + 1, SensorType.Load, this); } cpuLoad = new CPULoad(cpuid); if (cpuLoad.IsAvailable) { foreach (Sensor sensor in coreLoads) { ActivateSensor(sensor); } if (totalLoad != null) { ActivateSensor(totalLoad); } } // check if processor has TSC if (cpuid[0][0].Data.GetLength(0) > 1 && (cpuid[0][0].Data[1, 3] & 0x10) != 0) { hasTSC = true; } else { hasTSC = false; } // check if processor supports invariant TSC if (cpuid[0][0].ExtData.GetLength(0) > 7 && (cpuid[0][0].ExtData[7, 3] & 0x100) != 0) { invariantTSC = true; } else { invariantTSC = false; } // preload the function EstimateMaxClock(0); EstimateMaxClock(0); // estimate the max clock in MHz List <double> estimatedMaxClocks = new List <double>(3); for (int i = 0; i < 3; i++) { estimatedMaxClocks.Add(1e-6 * EstimateMaxClock(0.025)); } estimatedMaxClocks.Sort(); estimatedMaxClock = estimatedMaxClocks[1]; lastTimeStampCount = 0; lastTime = 0; busClock = new Sensor("Bus Speed", 0, SensorType.Clock, this); coreClocks = new Sensor[coreCount]; for (int i = 0; i < coreClocks.Length; i++) { coreClocks[i] = new Sensor(CoreString(i), i + 1, SensorType.Clock, this); if (hasTSC) { ActivateSensor(coreClocks[i]); } } Update(); }
public IntelCPU(string name, uint family, uint model, uint stepping, uint[,] cpuidData, uint[,] cpuidExtData) { this.name = name; this.icon = Utilities.EmbeddedResources.GetImage("cpu.png"); this.family = family; this.model = model; this.stepping = stepping; logicalProcessors = 0; if (cpuidData.GetLength(0) > 0x0B) { uint eax, ebx, ecx, edx; WinRing0.CpuidEx(0x0B, 0, out eax, out ebx, out ecx, out edx); logicalProcessorsPerCore = ebx & 0xFF; if (logicalProcessorsPerCore > 0) { WinRing0.CpuidEx(0x0B, 1, out eax, out ebx, out ecx, out edx); logicalProcessors = ebx & 0xFF; } } if (logicalProcessors <= 0 && cpuidData.GetLength(0) > 0x04) { logicalProcessors = ((cpuidData[4, 0] >> 26) & 0x3F) + 1; logicalProcessorsPerCore = 1; } if (logicalProcessors <= 0) { logicalProcessors = 1; logicalProcessorsPerCore = 1; } coreCount = logicalProcessors / logicalProcessorsPerCore; // check if processor supports a digital thermal sensor if (cpuidData.GetLength(0) > 6 && (cpuidData[6, 0] & 1) != 0) { switch (family) { case 0x06: { switch (model) { case 0x0F: // Intel Core 65nm switch (stepping) { case 0x06: // B2 switch (coreCount) { case 2: tjMax = 80; break; case 4: tjMax = 90; break; default: tjMax = 85; break; } tjMax = 80; break; case 0x0B: // G0 tjMax = 90; break; case 0x0D: // M0 tjMax = 85; break; default: tjMax = 85; break; } break; case 0x17: // Intel Core 45nm tjMax = 100; break; case 0x1C: // Intel Atom tjMax = 90; break; case 0x1A: // Intel Core i7 case 0x1E: // Intel Core i5 uint eax, edx; if (WinRing0.Rdmsr(IA32_TEMPERATURE_TARGET, out eax, out edx)) { tjMax = (eax >> 16) & 0xFF; } else { tjMax = 100; } break; default: tjMax = 100; break; } } break; default: tjMax = 100; break; } if (family == 0x06 && model >= 0x1A) // Core i5, i7 { uint eax, edx; if (WinRing0.Rdmsr(MSR_PLATFORM_INFO, out eax, out edx)) { maxNehalemMultiplier = (eax >> 8) & 0xff; } } coreTemperatures = new Sensor[coreCount]; for (int i = 0; i < coreTemperatures.Length; i++) { coreTemperatures[i] = new Sensor("Core #" + (i + 1), i, tjMax, SensorType.Temperature, this); } } else { coreTemperatures = new Sensor[0]; } totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); coreLoads = new Sensor[coreCount]; for (int i = 0; i < coreLoads.Length; i++) { coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, SensorType.Load, this); } cpuLoad = new CPULoad(coreCount, logicalProcessorsPerCore); if (cpuLoad.IsAvailable) { foreach (Sensor sensor in coreLoads) { ActivateSensor(sensor); } ActivateSensor(totalLoad); } lastCount = 0; lastTime = 0; busClock = new Sensor("Bus Speed", 0, SensorType.Clock, this); coreClocks = new Sensor[coreCount]; for (int i = 0; i < coreClocks.Length; i++) { coreClocks[i] = new Sensor("Core #" + (i + 1), i + 1, SensorType.Clock, this); ActivateSensor(coreClocks[i]); } Update(); }
public IntelCPU(string name, uint family, uint model, uint stepping, uint[,] cpuidData, uint[,] cpuidExtData) { this.name = name; this.icon = Utilities.EmbeddedResources.GetImage("cpu.png"); logicalProcessors = 0; if (cpuidData.GetLength(0) > 0x0B) { uint eax, ebx, ecx, edx; WinRing0.CpuidEx(0x0B, 0, out eax, out ebx, out ecx, out edx); logicalProcessorsPerCore = ebx & 0xFF; if (logicalProcessorsPerCore > 0) { WinRing0.CpuidEx(0x0B, 1, out eax, out ebx, out ecx, out edx); logicalProcessors = ebx & 0xFF; } } if (logicalProcessors <= 0 && cpuidData.GetLength(0) > 0x04) { logicalProcessors = ((cpuidData[4, 0] >> 26) & 0x3F) + 1; logicalProcessorsPerCore = 1; } if (logicalProcessors <= 0) { logicalProcessors = 1; logicalProcessorsPerCore = 1; } coreCount = logicalProcessors / logicalProcessorsPerCore; switch (family) { case 0x06: { switch (model) { case 0x0F: // Intel Core 65nm switch (stepping) { case 0x06: // B2 switch (coreCount) { case 2: tjMax = 80; break; case 4: tjMax = 90; break; default: tjMax = 85; break; } tjMax = 80; break; case 0x0B: // G0 tjMax = 90; break; case 0x0D: // M0 tjMax = 85; break; default: tjMax = 85; break; } break; case 0x17: // Intel Core 45nm tjMax = 100; break; case 0x1C: // Intel Atom tjMax = 90; break; case 0x1A: uint eax = 0, edx = 0; if (WinRing0.RdmsrPx( IA32_TEMPERATURE_TARGET, ref eax, ref edx, (UIntPtr)1)) { tjMax = (eax >> 16) & 0xFF; } else { tjMax = 100; } break; default: tjMax = 100; break; } } break; default: tjMax = 100; break; } totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); coreTemperatures = new Sensor[coreCount]; coreLoads = new Sensor[coreCount]; for (int i = 0; i < coreTemperatures.Length; i++) { coreTemperatures[i] = new Sensor("Core #" + (i + 1), i, tjMax, SensorType.Temperature, this); coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, SensorType.Load, this); } cpuLoad = new CPULoad(coreCount, logicalProcessorsPerCore); if (cpuLoad.IsAvailable) { foreach (Sensor sensor in coreLoads) { ActivateSensor(sensor); } ActivateSensor(totalLoad); } Update(); }
public GenericCPU(int processorIndex, CPUID[][] cpuid, ISettings settings) : base(cpuid[0][0].Name, CreateIdentifier(cpuid[0][0].Vendor, processorIndex), settings) { this.cpuid = cpuid; this.vendor = cpuid[0][0].Vendor; this.family = cpuid[0][0].Family; this.model = cpuid[0][0].Model; this.stepping = cpuid[0][0].Stepping; this.processorIndex = processorIndex; this.coreCount = cpuid.Length; // check if processor has MSRs if (cpuid[0][0].Data.GetLength(0) > 1 && (cpuid[0][0].Data[1, 3] & 0x20) != 0) hasModelSpecificRegisters = true; else hasModelSpecificRegisters = false; // check if processor has a TSC if (cpuid[0][0].Data.GetLength(0) > 1 && (cpuid[0][0].Data[1, 3] & 0x10) != 0) hasTimeStampCounter = true; else hasTimeStampCounter = false; // check if processor supports an invariant TSC if (cpuid[0][0].ExtData.GetLength(0) > 7 && (cpuid[0][0].ExtData[7, 3] & 0x100) != 0) isInvariantTimeStampCounter = true; else isInvariantTimeStampCounter = false; if (coreCount > 1) totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this, settings); else totalLoad = null; coreLoads = new Sensor[coreCount]; for (int i = 0; i < coreLoads.Length; i++) coreLoads[i] = new Sensor(CoreString(i), i + 1, SensorType.Load, this, settings); cpuLoad = new CPULoad(cpuid); if (cpuLoad.IsAvailable) { foreach (Sensor sensor in coreLoads) ActivateSensor(sensor); if (totalLoad != null) ActivateSensor(totalLoad); } if (hasTimeStampCounter) { ulong mask = ThreadAffinity.Set(1UL << cpuid[0][0].Thread); EstimateTimeStampCounterFrequency( out estimatedTimeStampCounterFrequency, out estimatedTimeStampCounterFrequencyError); ThreadAffinity.Set(mask); } else { estimatedTimeStampCounterFrequency = 0; } timeStampCounterFrequency = estimatedTimeStampCounterFrequency; }
public IntelCPU(string name, uint family, uint model, uint stepping, uint[,] cpuidData, uint[,] cpuidExtData) { this.name = name; this.icon = Utilities.EmbeddedResources.GetImage("cpu.png"); this.family = family; this.model = model; this.stepping = stepping; logicalProcessors = 0; if (cpuidData.GetLength(0) > 0x0B) { uint eax, ebx, ecx, edx; WinRing0.CpuidEx(0x0B, 0, out eax, out ebx, out ecx, out edx); logicalProcessorsPerCore = ebx & 0xFF; if (logicalProcessorsPerCore > 0) { WinRing0.CpuidEx(0x0B, 1, out eax, out ebx, out ecx, out edx); logicalProcessors = ebx & 0xFF; } } if (logicalProcessors <= 0 && cpuidData.GetLength(0) > 0x04) { uint coresPerPackage = ((cpuidData[4, 0] >> 26) & 0x3F) + 1; uint logicalPerPackage = (cpuidData[1, 1] >> 16) & 0xFF; logicalProcessorsPerCore = logicalPerPackage / coresPerPackage; logicalProcessors = logicalPerPackage; } if (logicalProcessors <= 0 && cpuidData.GetLength(0) > 0x01) { uint logicalPerPackage = (cpuidData[1, 1] >> 16) & 0xFF; logicalProcessorsPerCore = logicalPerPackage; logicalProcessors = logicalPerPackage; } if (logicalProcessors <= 0) { logicalProcessors = 1; logicalProcessorsPerCore = 1; } IntPtr processMask, systemMask; GetProcessAffinityMask(Process.GetCurrentProcess().Handle, out processMask, out systemMask); affinityMask = (ulong)systemMask; // correct values in case HypeThreading is disabled if (logicalProcessorsPerCore > 1) { ulong affinity = affinityMask; int availableLogicalProcessors = 0; while (affinity != 0) { if ((affinity & 0x1) > 0) { availableLogicalProcessors++; } affinity >>= 1; } while (logicalProcessorsPerCore > 1 && availableLogicalProcessors < logicalProcessors) { logicalProcessors >>= 1; logicalProcessorsPerCore >>= 1; } } coreCount = logicalProcessors / logicalProcessorsPerCore; float tjMax; switch (family) { case 0x06: { switch (model) { case 0x0F: // Intel Core (65nm) switch (stepping) { case 0x06: // B2 switch (coreCount) { case 2: tjMax = 80 + 10; break; case 4: tjMax = 90 + 10; break; default: tjMax = 85 + 10; break; } tjMax = 80 + 10; break; case 0x0B: // G0 tjMax = 90 + 10; break; case 0x0D: // M0 tjMax = 85 + 10; break; default: tjMax = 85 + 10; break; } break; case 0x17: // Intel Core (45nm) tjMax = 100; break; case 0x1C: // Intel Atom tjMax = 90; break; case 0x1A: // Intel Core i7 LGA1366 (45nm) case 0x1E: // Intel Core i5, i7 LGA1156 (45nm) case 0x25: // Intel Core i3, i5, i7 LGA1156 (32nm) uint eax, edx; if (WinRing0.Rdmsr(IA32_TEMPERATURE_TARGET, out eax, out edx)) { tjMax = (eax >> 16) & 0xFF; } else { tjMax = 100; } if (WinRing0.Rdmsr(MSR_PLATFORM_INFO, out eax, out edx)) { maxNehalemMultiplier = (eax >> 8) & 0xff; } break; default: tjMax = 100; break; } } break; default: tjMax = 100; break; } // check if processor supports a digital thermal sensor if (cpuidData.GetLength(0) > 6 && (cpuidData[6, 0] & 1) != 0) { coreTemperatures = new Sensor[coreCount]; for (int i = 0; i < coreTemperatures.Length; i++) { coreTemperatures[i] = new Sensor(CoreString(i), i, tjMax, SensorType.Temperature, this, new ParameterDescription[] { new ParameterDescription( "TjMax", "TjMax temperature of the core.\n" + "Temperature = TjMax - TSlope * Value.", tjMax), new ParameterDescription( "TSlope", "Temperature slope of the digital thermal sensor.\n" + "Temperature = TjMax - TSlope * Value.", 1) }); } } else { coreTemperatures = new Sensor[0]; } if (coreCount > 1) { totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); } else { totalLoad = null; } coreLoads = new Sensor[coreCount]; for (int i = 0; i < coreLoads.Length; i++) { coreLoads[i] = new Sensor(CoreString(i), i + 1, SensorType.Load, this); } cpuLoad = new CPULoad(coreCount, logicalProcessorsPerCore); if (cpuLoad.IsAvailable) { foreach (Sensor sensor in coreLoads) { ActivateSensor(sensor); } if (totalLoad != null) { ActivateSensor(totalLoad); } } lastCount = 0; lastTime = 0; busClock = new Sensor("Bus Speed", 0, SensorType.Clock, this); coreClocks = new Sensor[coreCount]; for (int i = 0; i < coreClocks.Length; i++) { coreClocks[i] = new Sensor(CoreString(i), i + 1, SensorType.Clock, this); ActivateSensor(coreClocks[i]); } Update(); }
public GenericCPU(int processorIndex, CPUID[][] cpuid, ISettings settings) : base(cpuid[0][0].Name, CreateIdentifier(cpuid[0][0].Vendor, processorIndex), settings) { this.cpuid = cpuid; this.vendor = cpuid[0][0].Vendor; this.family = cpuid[0][0].Family; this.model = cpuid[0][0].Model; this.stepping = cpuid[0][0].Stepping; this.processorIndex = processorIndex; this.coreCount = cpuid.Length; // check if processor has MSRs if (cpuid[0][0].Data.GetLength(0) > 1 && (cpuid[0][0].Data[1, 3] & 0x20) != 0) { hasModelSpecificRegisters = true; } else { hasModelSpecificRegisters = false; } // check if processor has a TSC if (cpuid[0][0].Data.GetLength(0) > 1 && (cpuid[0][0].Data[1, 3] & 0x10) != 0) { hasTimeStampCounter = true; } else { hasTimeStampCounter = false; } // check if processor supports an invariant TSC if (cpuid[0][0].ExtData.GetLength(0) > 7 && (cpuid[0][0].ExtData[7, 3] & 0x100) != 0) { isInvariantTimeStampCounter = true; } else { isInvariantTimeStampCounter = false; } if (coreCount > 1) { totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this, settings); } else { totalLoad = null; } coreLoads = new Sensor[coreCount]; for (int i = 0; i < coreLoads.Length; i++) { coreLoads[i] = new Sensor(CoreString(i), i + 1, SensorType.Load, this, settings); } cpuLoad = new CPULoad(cpuid); if (cpuLoad.IsAvailable) { foreach (Sensor sensor in coreLoads) { ActivateSensor(sensor); } if (totalLoad != null) { ActivateSensor(totalLoad); } } if (hasTimeStampCounter) { ulong mask = ThreadAffinity.Set(1UL << cpuid[0][0].Thread); EstimateTimeStampCounterFrequency(out estimatedTimeStampCounterFrequency, out estimatedTimeStampCounterFrequencyError); ThreadAffinity.Set(mask); } else { estimatedTimeStampCounterFrequency = 0; } timeStampCounterFrequency = estimatedTimeStampCounterFrequency; }
public GenericCPU(int processorIndex, CPUID[][] cpuid, ISettings settings) { this.cpuid = cpuid; this.vendor = cpuid[0][0].Vendor; this.family = cpuid[0][0].Family; this.model = cpuid[0][0].Model; this.stepping = cpuid[0][0].Stepping; this.processorIndex = processorIndex; this.coreCount = cpuid.Length; this.name = cpuid[0][0].Name; // check if processor has a TSC if (cpuid[0][0].Data.GetLength(0) > 1 && (cpuid[0][0].Data[1, 3] & 0x10) != 0) { hasTimeStampCounter = true; } else { hasTimeStampCounter = false; } // check if processor supports an invariant TSC if (cpuid[0][0].ExtData.GetLength(0) > 7 && (cpuid[0][0].ExtData[7, 3] & 0x100) != 0) { isInvariantTimeStampCounter = true; } else { isInvariantTimeStampCounter = false; } if (coreCount > 1) { totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this, settings); } else { totalLoad = null; } coreLoads = new Sensor[coreCount]; for (int i = 0; i < coreLoads.Length; i++) { coreLoads[i] = new Sensor(CoreString(i), i + 1, SensorType.Load, this, settings); } cpuLoad = new CPULoad(cpuid); if (cpuLoad.IsAvailable) { foreach (Sensor sensor in coreLoads) { ActivateSensor(sensor); } if (totalLoad != null) { ActivateSensor(totalLoad); } } if (hasTimeStampCounter) { estimatedTimeStampCounterFrequency = EstimateTimeStampCounterFrequency(); // set initial values uint lsb, msb; WinRing0.RdtscTx(out lsb, out msb, (UIntPtr)1); lastTime = Stopwatch.GetTimestamp(); lastTimeStampCount = ((ulong)msb << 32) | lsb; } else { estimatedTimeStampCounterFrequency = 0; lastTime = 0; lastTimeStampCount = 0; } timeStampCounterFrequency = estimatedTimeStampCounterFrequency; }
public AMD0FCPU(int processorIndex, CPUID[][] cpuid) { this.processorIndex = processorIndex; this.name = cpuid[0][0].Name; this.icon = Utilities.EmbeddedResources.GetImage("cpu.png"); int coreCount = cpuid.Length; totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); float offset = -49.0f; // AM2+ 65nm +21 offset uint model = cpuid[0][0].Model; if (model >= 0x69 && model != 0xc1 && model != 0x6c && model != 0x7c) { offset += 21; } // check if processor supports a digital thermal sensor if (cpuid[0][0].ExtData.GetLength(0) > 7 && (cpuid[0][0].ExtData[7, 3] & 1) != 0) { coreTemperatures = new Sensor[coreCount]; for (int i = 0; i < coreCount; i++) { coreTemperatures[i] = new Sensor("Core #" + (i + 1), i, null, SensorType.Temperature, this, new ParameterDescription[] { new ParameterDescription("Offset [°C]", "Temperature offset of the thermal sensor.\n" + "Temperature = Value + Offset.", offset) }); } } else { coreTemperatures = new Sensor[0]; } coreLoads = new Sensor[coreCount]; for (int i = 0; i < coreCount; i++) { coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, SensorType.Load, this); } cpuLoad = new CPULoad(cpuid); if (cpuLoad.IsAvailable) { foreach (Sensor sensor in coreLoads) { ActivateSensor(sensor); } ActivateSensor(totalLoad); } pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, PCI_AMD_0FH_MISCELLANEOUS_DEVICE_ID, (byte)processorIndex); Update(); }
public GenericCPU(int processorIndex, CPUID[][] cpuid, ISettings settings, ISensorConfig config) : base(cpuid[0][0].Name, CreateIdentifier(cpuid[0][0].Vendor, processorIndex), settings) { this.sensorConfig = config; this.cpuid = cpuid; this.vendor = cpuid[0][0].Vendor; this.family = cpuid[0][0].Family; this.model = cpuid[0][0].Model; this.stepping = cpuid[0][0].Stepping; Log.Logger.Information("CPUID core count: {coreCount}.", cpuid.Length); Log.Logger.Information("CPUID thread count per core: {coreThreadCount}.", cpuid[0].Length); this.processorIndex = processorIndex; this.coreCount = cpuid.Length; this.coreThreadCount = cpuid[0].Length; // check if processor has MSRs if (cpuid[0][0].Data.GetLength(0) > 1 && (cpuid[0][0].Data[1, 3] & 0x20) != 0) { HasModelSpecificRegisters = true; } else { HasModelSpecificRegisters = false; } // check if processor has a TSC if (cpuid[0][0].Data.GetLength(0) > 1 && (cpuid[0][0].Data[1, 3] & 0x10) != 0) { HasTimeStampCounter = true; } else { HasTimeStampCounter = false; } // check if processor supports an invariant TSC if (cpuid[0][0].ExtData.GetLength(0) > 7 && (cpuid[0][0].ExtData[7, 3] & 0x100) != 0) { isInvariantTimeStampCounter = true; } else { isInvariantTimeStampCounter = false; } if (coreCount > 1 || coreThreadCount > 1) { totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this, settings); } else { totalLoad = null; } coreLoads = new Sensor[coreCount * coreThreadCount]; for (int i = 0; i < coreLoads.Length; i++) { coreLoads[i] = new Sensor(CoreThreadString(i), i + 1, SensorType.Load, this, settings); } maxLoad = new Sensor("CPU Max", coreLoads.Length + 1, SensorType.Load, this, settings); cpuLoad = new CPULoad(cpuid); if (cpuLoad.IsAvailable) { foreach (Sensor sensor in coreLoads) { ActivateSensor(sensor); } if (totalLoad != null) { ActivateSensor(totalLoad); } if (maxLoad != null) { ActivateSensor(maxLoad); } } if (HasTimeStampCounter) { var previousAffinity = ThreadAffinity.Set(cpuid[0][0].Affinity); EstimateTimeStampCounterFrequency( out estimatedTimeStampCounterFrequency, out estimatedTimeStampCounterFrequencyError); ThreadAffinity.Set(previousAffinity); } else { estimatedTimeStampCounterFrequency = 0; } TimeStampCounterFrequency = estimatedTimeStampCounterFrequency; }