Skip to content

Commit

Permalink
Minimal fix to get GraniteRidge going
Browse files Browse the repository at this point in the history
  • Loading branch information
irusanov committed Sep 29, 2024
1 parent ec44458 commit f22a392
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
3 changes: 2 additions & 1 deletion MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 21 additions & 11 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime;
using System.Threading;
using System.Windows.Forms;
using ZenStates.Components;
using ZenStates.Core;
using ZenStates.Properties;
using ZenStates.Utils;

namespace ZenStates
Expand Down Expand Up @@ -67,8 +69,11 @@ private void HandleError(string message, string title = "Error")
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}

private static void ExitApplication()
private void ExitApplication()
{
//cpu?.io?.Close(true);
cpu?.Dispose();

if (Application.MessageLoop)
Application.Exit();
else
Expand Down Expand Up @@ -329,7 +334,7 @@ private void InitManualOc()
manualOverclockItem.Multi = GetCurrentMulti(ocmode);
manualOverclockItem.ProchotEnabled = cpu.IsProchotEnabled();
manualOverclockItem.coreDisableMap = cpu.info.topology.coreDisableMap;
manualOverclockItem.CcxInCcd = cpu.info.family == Cpu.Family.FAMILY_19H ? 1 : 2;
manualOverclockItem.CcxInCcd = (int)(cpu.info.topology.ccds / cpu.info.topology.ccxs);
manualOverclockItem.Cores = (int)cpu.info.topology.physicalCores;
}

Expand Down Expand Up @@ -742,7 +747,7 @@ public AppWindow()
{
HandleError(ex.Message);
Dispose();
Application.Exit();
ExitApplication();
}
}

Expand Down Expand Up @@ -807,7 +812,7 @@ private void NotifyIcon_DoubleClick(object sender, EventArgs e)
private void TrayMenuItemExit_Click(object sender, EventArgs e)
{
Dispose();
Application.Exit();
ExitApplication();
}

static void MinimizeFootprint()
Expand Down Expand Up @@ -857,22 +862,22 @@ private void ManualOverclockItem_SlowModeClicked(object sender, EventArgs e)
{
CheckBox cb = sender as CheckBox;
int cores = cpu.systemInfo.Threads;
int step = cpu.systemInfo.SMT ? cpu.systemInfo.NumCoresInCCX * 2 : cpu.systemInfo.NumCoresInCCX;
uint step = cpu.systemInfo.SMT ? cpu.info.topology.coresPerCcx * 2 : cpu.info.topology.coresPerCcx;
int index = 0;

double[] ccx_frequencies = new double[cpu.systemInfo.CCXCount];
double[] ccx_frequencies = new double[cpu.info.topology.ccxs];

if (cb.Checked)
{
for (var i = 0; i < cores; i += step)
for (uint i = 0; i < cores; i += step)
{
ccx_frequencies[index] = cpu.GetCoreMulti(i);
ccx_frequencies[index] = cpu.GetCoreMulti((int)i);
++index;
}
Storage.Add($"ccx_frequencies", ccx_frequencies);
Storage.Add("oc_vid", manualOverclockItem.Vid);

for (var i = 0; i < cpu.systemInfo.CCXCount; ++i)
for (var i = 0; i < cpu.info.topology.ccxs; ++i)
{
Console.WriteLine($"ccx{i}: " + Storage.Get<double[]>($"ccx_frequencies")[i].ToString());
}
Expand All @@ -889,7 +894,7 @@ private void ManualOverclockItem_SlowModeClicked(object sender, EventArgs e)
}
else
{
int[] masks = new int[cpu.systemInfo.CCXCount];
int[] masks = new int[cpu.info.topology.ccxs];
int coresInCcd = cpu.info.family == Cpu.Family.FAMILY_19H ? 8 : 4;
for (var i = 0; i < cpu.systemInfo.PhysicalCoreCount; i += coresInCcd)
{
Expand All @@ -901,7 +906,7 @@ private void ManualOverclockItem_SlowModeClicked(object sender, EventArgs e)

SetOCVid(Storage.Get<byte>($"oc_vid"));

for (var i = 0; i < cpu.systemInfo.CCXCount; ++i)
for (var i = 0; i < cpu.info.topology.ccxs; ++i)
{
uint targetFreq = Convert.ToUInt32(Storage.Get<double[]>($"ccx_frequencies")[i] * 100.00);
SetFrequencyCCX((uint)masks[i], targetFreq);
Expand All @@ -917,5 +922,10 @@ private void ManualOverclockItem_ProchotClicked(object sender, EventArgs e)
bool res = SetProchot(cb.Checked);
if (res) SetStatus("PROCHOT " + (cb.Checked ? "enabled." : "disabled."));
}

private void AppWindow_FormClosing(object sender, FormClosingEventArgs e)
{
ExitApplication();
}
}
}
6 changes: 3 additions & 3 deletions ZenStatesControlLib/ManualOverclockItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ private void PopulateCoreList(ComboBox.ObjectCollection l)

for (int i = 0; i < Cores; ++i)
{
bool enabled = ((~coreDisableMap >> i) & 1) == 1;
if (enabled)
int mapIndex = i < 8 ? 0 : 1;
if ((~coreDisableMap[mapIndex] >> i % 8 & 1) == 1)
{
int ccd = i / Constants.CCD_SIZE;
int ccx = i / coresInCcx - CcxInCcd * ccd;
Expand Down Expand Up @@ -105,7 +105,7 @@ public ManualOverclockItem()
public event EventHandler ProchotClicked;

#region Properties
public uint coreDisableMap { get; set; }
public uint[] coreDisableMap { get; set; }
public int CcxInCcd { get; set; }

public double Multi
Expand Down

0 comments on commit f22a392

Please sign in to comment.