示例#1
0
        public PMC(Ols ols, ManufacturerName Manufacturer, int thread, byte uMask, byte eventSelect)
        {
            _ols = ols;
            if (_ols.IsMsr() > 0)
            {
                switch (Manufacturer)
                {
                case ManufacturerName.GenuineIntel:
                    Thread      = thread;
                    pthread     = (UIntPtr)(1UL << Thread);
                    UMask       = uMask;
                    EventSelect = eventSelect;
                    uint eax = 0, edx = 0;
                    for (uint i = 0; i < 8; i++)
                    {
                        if (_ols.RdmsrTx(i + 0x186, ref eax, ref edx, (UIntPtr)(1UL << Thread)) > 0)
                        {
                            if (CPUinfo.BitsSlicer(eax, 22, 22) == 0)
                            {
                                PMC_num = i;
                                edx     = 0;
                                eax     = eventSelect + uMask * 256U + 0x43 * 256 * 256;
                                if (_ols.WrmsrTx(PMC_num + 0x186, eax, edx, (UIntPtr)(1UL << Thread)) == 0)
                                {
                                    ErrorMessage = "Wrmsr failed";
                                    Dispose();
                                    return;
                                }
                                PMC_num_msr = 0x0c1 + PMC_num;
                                break;
                            }
                        }
                        else
                        {
                            ErrorMessage = "No available PMC for this logical processor";
                            Dispose();
                        }
                    }
                    break;

                case ManufacturerName.AuthenticAMD:
                    Thread       = thread;
                    pthread      = (UIntPtr)(1UL << Thread);
                    ErrorMessage = "Unsupported cpu vendor";
                    Dispose();
                    break;

                default:
                    ErrorMessage = "Unsupported cpu vendor";
                    Dispose();
                    break;
                }
            }
        }
示例#2
0
 public float GetCurrentTemprature()
 {
     if (Manufacturer == "GenuineIntel")
     {
         uint tjmax, t_tmp;
         uint eax = 0, edx = 0;
         tjmax = (_ols.Rdmsr(0x1a2, ref eax, ref edx) > 0) ? CPUinfo.BitsSlicer(eax, 22, 16) : 100;
         t_tmp = (_ols.Rdmsr(0x1b1, ref eax, ref edx) > 0) ? CPUinfo.BitsSlicer(eax, 22, 16) : 0;
         return(tjmax - t_tmp);
     }
     else if (Manufacturer == "AuthenticAMD")
     {
         return(0);
     }
     else
     {
         return(0);
     }
 }
示例#3
0
 public PackageMonitor(Ols ols, string manufacturer)
 {
     Manufacturer = manufacturer;
     if (Manufacturer == "GenuineIntel")
     {
         _ols = ols;
         uint edx = 0, eax = 0;
         if (_ols.Rdmsr(0x606, ref eax, ref edx) > 0)
         {
             PU             = 1F / (float)Math.Pow(2, CPUinfo.BitsSlicer(eax, 3, 0));
             ESU            = 1F / (float)Math.Pow(2, CPUinfo.BitsSlicer(eax, 12, 8));
             TU             = 1F / (float)Math.Pow(2, CPUinfo.BitsSlicer(eax, 19, 16));
             RAPL_supported = true;
         }
         RAPL_supported = true;
     }
     else
     {
         RAPL_supported = false;
     }
 }