Skip to content

Commit

Permalink
Add more GPU stat details
Browse files Browse the repository at this point in the history
  • Loading branch information
tylercamp committed Dec 27, 2022
1 parent 5a7913a commit 7618ee2
Show file tree
Hide file tree
Showing 14 changed files with 288 additions and 24 deletions.
20 changes: 20 additions & 0 deletions GPUControl.Lib/GPU/IDeviceInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GPUControl.Lib.GPU
{
public interface IDeviceInfo
{
string ArchitectureName { get; }
string PciBusInfo { get; }
string BiosVersion { get; }
int NumCores { get; }
int NumRops { get; }
int NumConnectedDisplays { get; }
int NumAvailableConnections { get; }
int VramSizeMB { get; }
}
}
2 changes: 2 additions & 0 deletions GPUControl.Lib/GPU/IGpuWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public abstract class IGpuWrapper
public abstract IClockInfo Clocks { get; }
public abstract IPowerInfo Power { get; }
public abstract ITempInfo Temps { get; }
public abstract IUtilizationInfo Utilization { get; }
public abstract IDeviceInfo Device { get; }

public abstract uint GpuId { get; }

Expand Down
18 changes: 18 additions & 0 deletions GPUControl.Lib/GPU/IUtilizationInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GPUControl.Lib.GPU
{
public interface IUtilizationInfo
{
string CurrentPerformanceState { get; }

string PerformanceLimit { get; }
uint BusUsagePercent { get; }
uint MemoryUsagePercent { get; }
uint GpuUsagePercent { get; }
}
}
26 changes: 26 additions & 0 deletions GPUControl.Lib/GPU/mockimpl/MockDeviceInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GPUControl.Lib.GPU.mockimpl
{
public class MockDeviceInfo : IDeviceInfo
{
public string ArchitectureName => "Mock";
public string PciBusInfo => "PCI Express Bus #0 Slot #10";

public string BiosVersion => "100.90.80.70.60";

public int NumCores => 4096;

public int NumRops => 32;

public int NumConnectedDisplays => 2;

public int NumAvailableConnections => 12;

public int VramSizeMB => 12000;
}
}
5 changes: 5 additions & 0 deletions GPUControl.Lib/GPU/mockimpl/MockGpuWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public MockGpuWrapper(uint id, string name)
Clocks = new MockClockInfo();
Power = new MockPowerInfo();
Temps = new MockTempInfo();
Utilization = new MockUtilizationInfo();
Device = new MockDeviceInfo();
}

public override IClockInfo Clocks { get; }
Expand All @@ -25,6 +27,9 @@ public MockGpuWrapper(uint id, string name)

public override ITempInfo Temps { get; }

public override IUtilizationInfo Utilization { get; }
public override IDeviceInfo Device { get; }

public override uint GpuId { get; }

public override string Label { get; }
Expand Down
22 changes: 22 additions & 0 deletions GPUControl.Lib/GPU/mockimpl/MockUtilizationInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GPUControl.Lib.GPU.mockimpl
{
public class MockUtilizationInfo : IUtilizationInfo
{
public string CurrentPerformanceState => "P0";

public string PerformanceLimit => "No Limit";


public uint BusUsagePercent => (uint)MockValueProvider.Percent.Value;

public uint MemoryUsagePercent => (uint)MockValueProvider.Percent.Value;

public uint GpuUsagePercent => (uint)MockValueProvider.Percent.Value;
}
}
2 changes: 2 additions & 0 deletions GPUControl.Lib/GPU/mockimpl/MockValueProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ public MockValueProvider(decimal minValue, decimal maxValue)
private static Random Random = new Random();

public decimal Value => Random.Next((int)minValue, (int)maxValue);

public static MockValueProvider Percent = new MockValueProvider(0, 100);
}
}
2 changes: 0 additions & 2 deletions GPUControl.Lib/GPU/nvidiaimpl/NvidiaClockInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public NvidiaClockInfo(PhysicalGPU gpu)
public decimal BoostCoreClockMhz => gpu.BoostClockFrequencies.GraphicsClock.Frequency / 1000;
public decimal BoostMemoryClockMhz => gpu.BoostClockFrequencies.MemoryClock.Frequency / 1000;



public ValueRange CoreClockOffsetRangeMhz
{
get
Expand Down
42 changes: 42 additions & 0 deletions GPUControl.Lib/GPU/nvidiaimpl/NvidiaDeviceInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using NvAPIWrapper.GPU;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GPUControl.Lib.GPU.nvidiaimpl
{
public class NvidiaDeviceInfo : IDeviceInfo
{
PhysicalGPU gpu;

public NvidiaDeviceInfo(PhysicalGPU gpu)
{
this.gpu = gpu;
}

public string ArchitectureName => gpu.ArchitectInformation.ShortName;

public string PciBusInfo
{
get
{
var info = gpu.BusInformation;
return $"{info.BusType} Bus #{info.BusId}, Slot #{info.BusSlot}, x{info.CurrentPCIeLanes} mode";
}
}

public string BiosVersion => gpu.Bios.VersionString;

public int NumCores => gpu.ArchitectInformation.NumberOfCores;

public int NumRops => gpu.ArchitectInformation.NumberOfROPs;

public int NumConnectedDisplays => gpu.ActiveOutputs.Length;

public int NumAvailableConnections => gpu.GetDisplayDevices().Length;

public int VramSizeMB => gpu.MemoryInformation.PhysicalFrameBufferSizeInkB / 1024;
}
}
7 changes: 7 additions & 0 deletions GPUControl.Lib/GPU/nvidiaimpl/NvidiaGpuWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,23 @@ public NvidiaGpuWrapper(PhysicalGPU gpu)
Clocks = new NvidiaClockInfo(gpu);
Power = new NvidiaPowerInfo(gpu);
Temps = new NvidiaTempInfo(gpu);
Utilization = new NvidiaUtilizationInfo(gpu);
Device = new NvidiaDeviceInfo(gpu);
}

public override uint GpuId => gpu.GPUId;

public override IClockInfo Clocks { get; }
public override IPowerInfo Power { get; }
public override ITempInfo Temps { get; }
public override IUtilizationInfo Utilization { get; }
public override IDeviceInfo Device { get; }

public override string Label => $"{gpu.FullName} #{GpuId}";

public int NumDisplays => gpu.ActiveOutputs.Length;
public int NumDisplayDevices => gpu.GetDisplayDevices().Length;

public override void ApplyOC(Model.GpuOverclock oc)
{
#region Power target
Expand Down
29 changes: 29 additions & 0 deletions GPUControl.Lib/GPU/nvidiaimpl/NvidiaUtilizationInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NvAPIWrapper.GPU;

namespace GPUControl.Lib.GPU.nvidiaimpl
{
public class NvidiaUtilizationInfo : IUtilizationInfo
{
PhysicalGPU gpu;

public NvidiaUtilizationInfo(PhysicalGPU gpu)
{
this.gpu = gpu;
}

public string CurrentPerformanceState => gpu.PerformanceStatesInfo.CurrentPerformanceState.StateId.ToString();

public string PerformanceLimit => gpu.PerformanceControl.CurrentActiveLimit.ToString();

public uint BusUsagePercent => (uint)gpu.UsageInformation.BusInterface.Percentage;

public uint MemoryUsagePercent => (uint)gpu.UsageInformation.FrameBuffer.Percentage;

public uint GpuUsagePercent => (uint)gpu.UsageInformation.GPU.Percentage;
}
}
95 changes: 76 additions & 19 deletions ezgpuctl/Controls/GpuStatusView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="600" d:Background="White"
d:DataContext="{d:DesignInstance Type=vm:GpuStatusViewModel, IsDesignTimeCreatable=True}"
MinWidth="300"
>
<UserControl.DataContext>
<vm:GpuStatusViewModel />
Expand All @@ -19,36 +20,43 @@
</Grid.RowDefinitions>
<TextBlock x:Name="GpuName" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding GpuName}" VerticalAlignment="Center" FontSize="20" Margin="10,0,0,0" />
<WrapPanel Grid.Row="1">
<GroupBox Header="Clocks" HorizontalAlignment="Left" Width="200">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<GroupBox Header="Current Clocks" MinWidth="140">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<Label Content="Current" Grid.Column="1" FontStyle="Italic" />
<Label Content="Base" Grid.Column="2" FontStyle="Italic" />

<StackPanel Grid.Column="0" Grid.Row="1" Margin="0,0,5,0">

<StackPanel Grid.Column="0" Margin="0,0,5,0">
<TextBlock FontWeight="Bold">Core</TextBlock>
<TextBlock FontWeight="Bold">Memory</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" Grid.Row="1">
<TextBlock Text="{Binding State.MemoryBaseClockString}" />

<StackPanel Grid.Column="1" HorizontalAlignment="Right">
<TextBlock Text="{Binding State.CoreClockString}" />
<TextBlock Text="{Binding State.MemoryClockString}" />
</StackPanel>
<StackPanel Grid.Column="2" Grid.Row="1">
</Grid>
</GroupBox>
<GroupBox Header="Base Clocks" MinWidth="140">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<StackPanel Grid.Column="0" Margin="0,0,5,0">
<TextBlock FontWeight="Bold">Core</TextBlock>
<TextBlock FontWeight="Bold">Memory</TextBlock>
</StackPanel>

<StackPanel Grid.Column="1" HorizontalAlignment="Right">
<TextBlock Text="{Binding State.CoreBaseClockString}" />
<TextBlock Text="{Binding State.MemoryBaseClockString}" />
</StackPanel>
</Grid>
</GroupBox>
<GroupBox Header="Targets" Width="157">
<GroupBox Header="Targets" MinWidth="160">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
Expand All @@ -59,14 +67,63 @@
<TextBlock FontWeight="Bold">Power</TextBlock>
<TextBlock FontWeight="Bold">Temperature</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" Margin="5,0,0,0">
<StackPanel Grid.Column="1" Margin="5,0,0,0" HorizontalAlignment="Right">
<TextBlock Text="{Binding State.PowerTargetString}" />
<TextBlock Text="{Binding State.TempTargetString}" />
</StackPanel>
</Grid>
</GroupBox>
<GroupBox Header="Info">

<GroupBox Header="Utilization" MinWidth="180">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="100*"/>
</Grid.ColumnDefinitions>

<StackPanel Grid.Column="0">
<TextBlock FontWeight="Bold">Performance State</TextBlock>
<TextBlock FontWeight="Bold">Performance Limit</TextBlock>
<TextBlock FontWeight="Bold">GPU Usage</TextBlock>
<TextBlock FontWeight="Bold">Memory Usage</TextBlock>
<TextBlock FontWeight="Bold">Bus Usage</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" Margin="5,0,0,0" HorizontalAlignment="Right">
<TextBlock Text="{Binding State.CurrentPerformanceState}" />
<TextBlock Text="{Binding State.PerformanceLimit}" />
<TextBlock Text="{Binding State.GpuUsageString}" />
<TextBlock Text="{Binding State.MemoryUsageString}" />
<TextBlock Text="{Binding State.BusUsageString}" />
</StackPanel>
</Grid>
</GroupBox>
<GroupBox Header="Info" MinWidth="200">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="100*"/>
</Grid.ColumnDefinitions>

<StackPanel Grid.Column="0">
<TextBlock FontWeight="Bold">Architecture</TextBlock>
<TextBlock FontWeight="Bold">PCI Bus</TextBlock>
<TextBlock FontWeight="Bold">BIOS Version</TextBlock>
<TextBlock FontWeight="Bold">VRAM Size</TextBlock>
<TextBlock FontWeight="Bold"># Cores</TextBlock>
<TextBlock FontWeight="Bold"># ROPs</TextBlock>
<TextBlock FontWeight="Bold"># Displays</TextBlock>
<TextBlock FontWeight="Bold">Max Displays</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" Margin="5,0,0,0" HorizontalAlignment="Right">
<TextBlock Text="{Binding State.Architecture}" />
<TextBlock Text="{Binding State.PciBusInfo}" />
<TextBlock Text="{Binding State.BiosVersion}" />
<TextBlock Text="{Binding State.VramSizeString}" />
<TextBlock Text="{Binding State.NumCores}" />
<TextBlock Text="{Binding State.NumRops}" />
<TextBlock Text="{Binding State.NumDisplays}" />
<TextBlock Text="{Binding State.NumDisplayConnections}" />
</StackPanel>
</Grid>
</GroupBox>
</WrapPanel>
</Grid>
Expand Down
4 changes: 3 additions & 1 deletion ezgpuctl/MainPanes/GpuStatusPane.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<controls:GpuStatusView Grid.Column="1" DataContext="{Binding SelectedGpu}" />
<ScrollViewer Grid.Column="1" VerticalScrollBarVisibility="Auto">
<controls:GpuStatusView DataContext="{Binding SelectedGpu}" />
</ScrollViewer>
</Grid>
</UserControl>
Loading

0 comments on commit 7618ee2

Please sign in to comment.