Example #1
0
        public uint GetPowerUsage(int gpuIndex)
        {
            if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
            {
                return(0);
            }
            int power = 0;

            try {
                var r = AdlNativeMethods.ADL2_Overdrive6_CurrentPower_Get(context, adapterIndex, 0, ref power);
                if (r < AdlStatus.ADL_OK)
                {
                    Write.DevError($"{nameof(AdlNativeMethods.ADL2_Overdrive6_CurrentPower_Get)} {r.ToString()}");
                    return(0);
                }
                return((uint)(power / 256.0));
            }
            catch {
            }
            return(0);
        }
Example #2
0
 private uint GetPowerUsage(int gpuIndex)
 {
     if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu))
     {
         return(0);
     }
     try {
         int power = 0;
         if (gpu.OverdriveVersion >= 6)
         {
             var r = AdlNativeMethods.ADL2_Overdrive6_CurrentPower_Get(_context, gpu.AdapterIndex, ADLODNCurrentPowerType.TOTAL_POWER, out power);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_Overdrive6_CurrentPower_Get)} {r.ToString()}");
                 return(0);
             }
             return((uint)(power / 256.0));
         }
     }
     catch {
     }
     return(0);
 }