Ejemplo n.º 1
0
            public Core(Hardware hw, int id)
            {
                Threads     = new List <CPUID>();
                CoreId      = id;
                _hw         = (AMD17CPU)hw;
                _clock      = new Sensor("Core #" + CoreId.ToString(), _hw._sensorClock++, SensorType.Clock, _hw, _hw.settings);
                _multiplier = new Sensor("Core #" + CoreId.ToString(), _hw._sensorMulti++, SensorType.Factor, _hw, _hw.settings);
                _power      = new Sensor("Core #" + CoreId.ToString() + " (SMU)", _hw._sensorPower++, SensorType.Power, _hw, _hw.settings);
                _vcore      = new Sensor("Core #" + CoreId.ToString() + " VID", _hw._sensorVoltage++, SensorType.Voltage, _hw, _hw.settings);

                _hw.ActivateSensor(_clock);
                _hw.ActivateSensor(_multiplier);
                _hw.ActivateSensor(_power);
                _hw.ActivateSensor(_vcore);
            }
Ejemplo n.º 2
0
            public Processor(Hardware hw)
            {
                this._hw = (AMD17CPU)hw;
                Nodes    = new List <NumaNode>();

                _packagePower        = new Sensor("Package Power", this._hw._sensorPower++, SensorType.Power, this._hw, this._hw.settings);
                _coreTemperatureTctl = new Sensor("Core (Tctl)", this._hw._sensorTemperatures++, SensorType.Temperature, this._hw, this._hw.settings);
                _coreTemperatureTdie = new Sensor("Core (Tdie)", this._hw._sensorTemperatures++, SensorType.Temperature, this._hw, this._hw.settings);
                _coreVoltage         = new Sensor("Core (SVI2)", this._hw._sensorVoltage++, SensorType.Voltage, this._hw, this._hw.settings);
                _socVoltage          = new Sensor("SoC (SVI2)", this._hw._sensorVoltage++, SensorType.Voltage, this._hw, this._hw.settings);

                _hw.ActivateSensor(_packagePower);
                _hw.ActivateSensor(_coreTemperatureTctl);
                _hw.ActivateSensor(_coreTemperatureTdie);
                _hw.ActivateSensor(_coreVoltage);
            }
Ejemplo n.º 3
0
      public Core(int index, CPUID[] threads, AMD17CPU cpu, ISettings settings) 
      {
        this.cpu = cpu;
        this.threadAffinityMask = 1UL << threads[0].Thread;

        string coreString = cpu.CoreString(index);
        this.powerSensor =
          new Sensor(coreString, index + 2, SensorType.Power, cpu, settings);
        this.clockSensor = 
          new Sensor(coreString, index + 1, SensorType.Clock, cpu, settings);

        if (cpu.energyUnitMultiplier != 0) {
          if (Ring0.RdmsrTx(MSR_CORE_ENERGY_STAT, out uint energyConsumed, 
            out _, threadAffinityMask)) 
          {
            lastEnergyTime = DateTime.UtcNow;
            lastEnergyConsumed = energyConsumed;
            cpu.ActivateSensor(powerSensor);
          }
        }
      }
Ejemplo n.º 4
0
            public void UpdateSensors()
            {
                var node = Nodes[0];

                if (node == null)
                {
                    return;
                }
                Core core = node.Cores[0];

                if (core == null)
                {
                    return;
                }
                CPUID cpu = core.Threads[0];

                if (cpu == null)
                {
                    return;
                }
                uint eax, edx;

                ulong mask = Ring0.ThreadAffinitySet(1UL << cpu.Thread);

                // MSRC001_0299
                // TU [19:16]
                // ESU [12:8] -> Unit 15.3 micro Joule per increment
                // PU [3:0]
                Ring0.Rdmsr(MSR_PWR_UNIT, out eax, out edx);
                int tu  = (int)((eax >> 16) & 0xf);
                int esu = (int)((eax >> 12) & 0xf);
                int pu  = (int)(eax & 0xf);

                // MSRC001_029B
                // total_energy [31:0]
                DateTime sample_time = DateTime.Now;

                Ring0.Rdmsr(MSR_PKG_ENERGY_STAT, out eax, out edx);
                uint total_energy = eax;

                // THM_TCON_CUR_TMP
                // CUR_TEMP [31:21]
                uint temperature = 0;

                Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M01H_THM_TCON_CUR_TMP);
                Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER + 4, out temperature);

                // SVI0_TFN_PLANE0 [0]
                // SVI0_TFN_PLANE1 [1]
                uint smusvi0_tfn = 0;

                Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M01H_SVI + 0x8);
                Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER + 4, out smusvi0_tfn);

                // SVI0_PLANE0_VDDCOR [24:16]
                // SVI0_PLANE0_IDDCOR [7:0]
                uint smusvi0_tel_plane0 = 0;

                Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M01H_SVI + 0xc);
                Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER + 4, out smusvi0_tel_plane0);

                // SVI0_PLANE1_VDDCOR [24:16]
                // SVI0_PLANE1_IDDCOR [7:0]
                uint smusvi0_tel_plane1 = 0;

                Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M01H_SVI + 0x10);
                Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER + 4, out smusvi0_tel_plane1);

                Ring0.ThreadAffinitySet(mask);

                // power consumption
                // power.Value = (float) ((double)pu * 0.125);
                // esu = 15.3 micro Joule per increment
                if (_lastPwrTime.Ticks == 0)
                {
                    _lastPwrTime  = sample_time;
                    _lastPwrValue = total_energy;
                }
                // ticks diff
                TimeSpan time = sample_time - _lastPwrTime;
                long     pwr;

                if (_lastPwrValue <= total_energy)
                {
                    pwr = total_energy - _lastPwrValue;
                }
                else
                {
                    pwr = (0xffffffff - _lastPwrValue) + total_energy;
                }

                // update for next sample
                _lastPwrTime  = sample_time;
                _lastPwrValue = total_energy;

                double energy = 15.3e-6 * pwr;

                energy /= time.TotalSeconds;

                _packagePower.Value = (float)energy;

                // current temp Bit [31:21]
                //If bit 19 of the Temperature Control register is set, there is an additional offset of 49 degrees C.
                bool temp_offset_flag = false;

                if ((temperature & F17H_TEMP_OFFSET_FLAG) != 0)
                {
                    temp_offset_flag = true;
                }
                temperature = (temperature >> 21) * 125;

                float offset = 0.0f;

                if (cpu.Name != null && (cpu.Name.Contains("2600X") || cpu.Name.Contains("2700X")))
                {
                    offset = -10.0f;
                }
                if (cpu.Name != null && (cpu.Name.Contains("1600X") || cpu.Name.Contains("1700X") || cpu.Name.Contains("1800X")))
                {
                    offset = -20.0f;
                }
                else if (cpu.Name != null && (cpu.Name.Contains("1920X") || cpu.Name.Contains("1950X") || cpu.Name.Contains("1900X")))
                {
                    offset = -27.0f;
                }
                else if (cpu.Name != null && (cpu.Name.Contains("1910") || cpu.Name.Contains("1920") || cpu.Name.Contains("1950")))
                {
                    offset = -10.0f;
                }

                float t = (temperature * 0.001f);

                if (temp_offset_flag)
                {
                    t += -49.0f;
                }

                _coreTemperatureTctl.Value = t;
                _coreTemperatureTdie.Value = t + offset;

                // voltage
                double VIDStep = 0.00625;
                double vcc;
                uint   svi0_plane_x_vddcor;
                uint   svi0_plane_x_iddcor;

                //Core
                if ((smusvi0_tfn & 0x01) == 0)
                {
                    svi0_plane_x_vddcor = (smusvi0_tel_plane0 >> 16) & 0xff;
                    svi0_plane_x_iddcor = smusvi0_tel_plane0 & 0xff;
                    vcc = 1.550 - (double)VIDStep * svi0_plane_x_vddcor;
                    _coreVoltage.Value = (float)vcc;
                }

                // SoC
                // not every zen cpu has this voltage
                if ((smusvi0_tfn & 0x02) == 0)
                {
                    svi0_plane_x_vddcor = (smusvi0_tel_plane1 >> 16) & 0xff;
                    svi0_plane_x_iddcor = smusvi0_tel_plane1 & 0xff;
                    vcc = 1.550 - (double)VIDStep * svi0_plane_x_vddcor;
                    _socVoltage.Value = (float)vcc;
                    _hw.ActivateSensor(_socVoltage);
                }
            }