-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGPUClock_Management.cs
83 lines (67 loc) · 2.18 KB
/
GPUClock_Management.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using Handheld_Hardware_Tools.Classes.Devices;
using SharpDX;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;
namespace Handheld_Hardware_Tools.Classes
{
public class GPUClock_Management
{
private static GPUClock_Management _instance = null;
private static readonly object lockObj = new object();
private GPUClock_Management()
{
}
public static GPUClock_Management Instance
{
get
{
if (_instance == null )
{
lock (lockObj)
{
if (_instance == null)
{
_instance = new GPUClock_Management();
}
}
}
return _instance;
}
}
//Start the actual code and not just singleton stuff
private string appDir = AppDomain.CurrentDomain.BaseDirectory;
private int gpuClock = -1;
public int ReturnGPUClock()
{
//does not READ TDP just returns value
return gpuClock;
}
public void ChangeGPUClock(int gpuCLK)
{
string processRyzenAdj = "";
string result = "";
string commandArguments = "";
try
{//small fail safe to prevent an accidental way overclock
if (gpuCLK > 3000) { gpuCLK = 3000; }
processRyzenAdj = appDir + "\\Resources\\AMD\\RyzenAdj\\ryzenadj.exe";
//set the limits one at a time to prevent crash or glitches, put 30 ms delay to prevent errors
commandArguments = " --gfx-clk=" + (gpuCLK).ToString();
result = Run_CLI.Instance.RunCommand(commandArguments, true, processRyzenAdj);
Thread.Sleep(30);
gpuClock = gpuCLK;
}
catch (Exception ex)
{
}
}
}
}