Example #1
0
        public override void TickSpecificLoad(CpuidProcessorInfo info)
        {
            var tscSupport = info.IsTimeStampCounterSupported && info.TimeStampCounterFrequency > 0;

            double newBusClock = 0;

            foreach (var coreFrequencySensor in _coreFrequenciesSensors)
            {
                coreFrequencySensor.SetActive(tscSupport);
                if (!tscSupport)
                {
                    continue;
                }

                uint eax = 0, edx = 0;
                if (Msr.ReadTx(IntelCpu.Ia32PerfStatus, ref eax, ref edx,
                               (UIntPtr)(1UL << (int)Cpu.GetCpuidProcessorInfo()[0, 0].ThreadIndex)))
                {
                    newBusClock = Cpu.GetCpuidProcessorInfo().TimeStampCounterFrequency / Cpu.TimeStampCounterMultiper;
                    switch (Cpu.Microarchitecture)
                    {
                    case MicroArchitecture.Nehalem: {
                        var multiplier = eax & 0xff;
                        coreFrequencySensor.Update((float)(multiplier * newBusClock));
                    } break;

                    case MicroArchitecture.SandyBridge:
                    case MicroArchitecture.IvyBridge:
                    case MicroArchitecture.Haswell:
                    case MicroArchitecture.Broadwell:
                    case MicroArchitecture.Silvermont:
                    case MicroArchitecture.Skylake: {
                        var multiplier = (eax >> 8) & 0xff;
                        coreFrequencySensor.Update((float)(multiplier * newBusClock));
                    } break;

                    default: {
                        var multiplier = ((eax >> 8) & 0x1f) + 0.5 * ((eax >> 14) & 1);
                        coreFrequencySensor.Update((float)(multiplier * newBusClock));
                    } break;
                    }
                }
                else
                {
                    // If IA32_PERF_STATUS is not available, assume TSC frequency
                    coreFrequencySensor.Update((float)Cpu.GetCpuidProcessorInfo().TimeStampCounterFrequency);
                }
            }

            if (newBusClock > 0)
            {
                _baseClock.Update((float)newBusClock);
            }

            _baseClock.SetActive(newBusClock > 0);
            IsSensorActive = newBusClock > 0;
        }
Example #2
0
        private float[] GetTjMaxFromMsr()
        {
            uint eax = 0, edx = 0;
            var  result = new float[ThreadsCount];

            for (uint i = 0; i < ThreadsCount; i++)
            {
                if (Msr.ReadTx(Ia32TemperatureTarget, ref eax, ref edx, (UIntPtr)(1UL << (int)i)))
                {
                    result[i] = (eax >> 16) & 0xFF;
                }
                else
                {
                    result[i] = 100;
                }
            }
            return(result);
        }
        public override void Update(IntelCpu cpu)
        {
            uint eax = 0, edx = 0;

            if (Msr.ReadTx(Ia32PackageThermStatus, ref eax, ref edx, (UIntPtr)(1UL << 0)) && (eax & 0x80000000) != 0)
            {
                // From tjMax from at bits 22 -> 16
                float       deltaT = ((eax & 0x007F0000) >> 16);
                var         tjMax  = cpu.GetTjMaxOfThreadAt(0);
                const float tSlope = 1;
                Value = tjMax - tSlope * deltaT;
                SetActive(true);
            }
            else
            {
                Value = -1;
                SetActive(false);
            }
            AfterUpdate();
        }
        public override void Update(IntelCpu cpu)
        {
            uint eax = 0, edx = 0;

            if (Msr.ReadTx(Ia32ThermStatusMsr, ref eax, ref edx, _threadMask) && (eax & 0x80000000) != 0)
            {
                // From tjMax from at bits 22 -> 16
                float       deltaT = (eax & 0x007F0000) >> 16;
                var         tjMax  = cpu.GetTjMaxOfThreadAt(_threadIndex);
                const float tSlope = 1;
                Value = tjMax - tSlope * deltaT;
                SetActive(true);
            }
            else
            {
                Value = -1;
                SetActive(false);
            }

            AfterUpdate();
        }