public void GetPowerFanTemp(int gpuIndex, out uint power, out uint fanSpeed, out int temp) { power = 0; fanSpeed = 0; temp = 0; if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu)) { return; } try { if (gpu.OverdriveVersion < 8) { temp = GetTemperature(gpuIndex); power = GetPowerUsage(gpuIndex); fanSpeed = GetFanSpeed(gpuIndex); } else { ADLPMLogDataOutput logDataOutput = ADLPMLogDataOutput.Create(); var r = AdlNativeMethods.ADL2_New_QueryPMLogData_Get(_context, gpu.AdapterIndex, ref logDataOutput); if (r < AdlStatus.ADL_OK) { NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_New_QueryPMLogData_Get)} {r.ToString()}"); } int i = (int)ADLSensorType.PMLOG_ASIC_POWER; if (i < logDataOutput.Sensors.Length && logDataOutput.Sensors[i].Supported != 0) { power = (uint)logDataOutput.Sensors[i].Value; } i = (int)ADLSensorType.PMLOG_FAN_PERCENTAGE; if (i < logDataOutput.Sensors.Length && logDataOutput.Sensors[i].Supported != 0) { fanSpeed = (uint)logDataOutput.Sensors[i].Value; } i = (int)ADLSensorType.PMLOG_TEMPERATURE_EDGE; if (i < logDataOutput.Sensors.Length && logDataOutput.Sensors[i].Supported != 0) { temp = logDataOutput.Sensors[i].Value; } } } catch { } }
public static extern int ADL2_New_QueryPMLogData_Get(IntPtr context, int adapterIndex, ref ADLPMLogDataOutput aDLPMLogDataOutput);
static void Main(string[] args) { IntPtr context = IntPtr.Zero; const int adapterIndex = 1; ADL_Main_Control_Create(1); int supported = 0; int enabled = 0; int version = 0; if (ADL_OK == ADL_Overdrive_Caps(adapterIndex, ref supported, ref enabled, ref version)) { Console.WriteLine("supported: {0:D}", supported); Console.WriteLine("enabled: {0:D}", enabled); Console.WriteLine("version: {0:D}", version); Console.WriteLine("----------------------------------"); } if (ADL2_Main_Control_Create(Main_Memory_Alloc, adapterIndex, ref context) == ADL_OK) { Console.WriteLine("Context is: {0:D}", context); if (ADL_OK == ADL2_Overdrive_Caps(context, adapterIndex, ref supported, ref enabled, ref version)) { Console.WriteLine("v2 supported: {0:D}", supported); Console.WriteLine("v2 enabled: {0:D}", enabled); Console.WriteLine("v2 version: {0:D}", version); Console.WriteLine("----------------------------------"); } int isAccessible = 0; if (ADL2_Adapter_Accessibility_Get(context, adapterIndex, ref isAccessible) == ADL_OK) { Console.WriteLine("Adapter is accesible: {0:D}", isAccessible); } for (var powerIndex = 0; powerIndex < 4; powerIndex++) { int power = 0; if (ADL2_Overdrive6_CurrentPower_Get(context, adapterIndex, powerIndex, ref power) == ADL_OK) { Console.WriteLine("power query of {0:D} is => {1:F1}", powerIndex, power / 256f); } else { Console.WriteLine("power query error: {0:D}", powerIndex); } } ADLODNPerformanceStatus performanceStatus = new ADLODNPerformanceStatus(); if (ADL2_OverdriveN_PerformanceStatus_Get(context, adapterIndex, ref performanceStatus) == ADL_OK) { Console.WriteLine("-------------"); Console.WriteLine("perf status:"); Console.WriteLine("\tcurrent bus speed => {0:D}", performanceStatus.iCurrentBusSpeed); Console.WriteLine("\tcurrent bus lanes => {0:D}", performanceStatus.iCurrentBusLanes); Console.WriteLine("\tmaximum bus lanes => {0:D}", performanceStatus.iMaximumBusLanes); Console.WriteLine("\tgpu activity percent => {0:D}", performanceStatus.iGPUActivityPercent); Console.WriteLine("\tcurrent core perf. level => {0:D}", performanceStatus.iCurrentCorePerformanceLevel); Console.WriteLine("\tcurrent dcef perf. level => {0:D}", performanceStatus.iCurrentDCEFPerformanceLevel); Console.WriteLine("\tcurrent gfx perf. level => {0:D}", performanceStatus.iCurrentGFXPerformanceLevel); Console.WriteLine("\tcurrent mem. perf. level => {0:D}", performanceStatus.iCurrentMemoryPerformanceLevel); Console.WriteLine("\tcore clock => {0:D}", performanceStatus.iCoreClock); Console.WriteLine("\tdcef clock => {0:D}", performanceStatus.iDCEFClock); Console.WriteLine("\tgxf clock => {0:D}", performanceStatus.iGFXClock); Console.WriteLine("\tmem. clock => {0:D}", performanceStatus.iMemoryClock); Console.WriteLine("\tuvd clock => {0:D}", performanceStatus.iUVDClock); Console.WriteLine("\tuvd perf. level => {0:D}", performanceStatus.iUVDPerformanceLevel); Console.WriteLine("\tvce clock => {0:D}", performanceStatus.iVCEClock); Console.WriteLine("\tvce perf level => {0:D}", performanceStatus.iVCEPerformanceLevel); Console.WriteLine("\tvddc => {0:D}", performanceStatus.iVDDC); Console.WriteLine("\tvddci => {0:D}", performanceStatus.iVDDCI); Console.WriteLine("-------------"); } ADLPMActivity activity = new ADLPMActivity(); if (ADL_Overdrive5_CurrentActivity_Get(adapterIndex, ref activity) == ADL_OK) { Console.WriteLine("-------------"); Console.WriteLine("activity:"); Console.WriteLine("\tacivity percent => {0:D}", activity.iActivityPercent); Console.WriteLine("\tcurrent bus lanes => {0:D}", activity.iCurrentBusLanes); Console.WriteLine("\tcurrent bus speed => {0:D}", activity.iCurrentBusSpeed); Console.WriteLine("\tcurrent perf. level => {0:D}", activity.iCurrentPerformanceLevel); Console.WriteLine("\tengine clock => {0:D}", activity.iEngineClock); Console.WriteLine("\tmax. bus lanes => {0:D}", activity.iMaximumBusLanes); Console.WriteLine("\tmemory clock => {0:D}", activity.iMemoryClock); Console.WriteLine("\treserved => {0:D}", activity.iReserved); Console.WriteLine("\tsize => {0:D}", activity.iSize); Console.WriteLine("\tvddc => {0:D}", activity.iVddc); Console.WriteLine("-------------"); } Console.WriteLine("-------------"); Console.WriteLine("teperatures:"); foreach (var sensor in GPUTemperatureSensorIndexes) { int temp = 0; //ADLTemperature adlt = new ADLTemperature(); //if (ADL_Overdrive5_Temperature_Get(1, 0, ref adlt) == ADL_OK) int res = ADL2_OverdriveN_Temperature_Get(context, adapterIndex, sensor.Key, ref temp); if (res == ADL_OK) { if (sensor.Key == 1) { temp /= 1000; } Console.WriteLine("\t{0:S} Temperature: {1:D}", sensor.Value, temp); //Console.WriteLine(adlt.Temperature); } else { Console.WriteLine("error: {0:D}", res); } } Console.WriteLine("-------------"); Console.WriteLine("log data (without settings check):"); ADLPMLogDataOutput logDataOutput = new ADLPMLogDataOutput(); if (ADL2_New_QueryPMLogData_Get(context, adapterIndex, ref logDataOutput) == ADL_OK) { Console.WriteLine("\tLog Data Output size: {0:D}", logDataOutput.size); for (int i = 0; i < logDataOutput.size; i++) { Console.WriteLine("\tSensor type: {0:S} Value: {1:D}", Enum.GetName(typeof(ADLSensorType), i), logDataOutput.sensors[i].value); } } ADL2_Main_Control_Destroy(context); ADL_Main_Control_Destroy(); } else { Console.WriteLine("Alloc failed"); } Console.ReadKey(); }