Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4 from thakyuu/master
Browse files Browse the repository at this point in the history
SMT Off Support
  • Loading branch information
thakyuu authored Nov 27, 2020
2 parents 71c1621 + 40c6bf0 commit 9c97e70
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 11 deletions.
15 changes: 12 additions & 3 deletions .idea/.idea.VrcAffinitySetter/.idea/workspace.xml

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

59 changes: 51 additions & 8 deletions VrcAffinitySetter/VrcAffinitySetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ private static void SetAffinity(string processName,IntPtr affinity)
}

var targetProcess = targetProcesses[0];

Console.WriteLine($"{processName} Detected!");
targetProcess.ProcessorAffinity = affinity;
Console.WriteLine($"{processName} Affinity Change Complete!");
Expand All @@ -35,7 +34,8 @@ public static void Main(string[] args)

var processorName = key.GetValue("ProcessorNameString").ToString();
Console.WriteLine($"Current Processor > {processorName}");

Console.WriteLine($"Current Enable Thread > {Environment.ProcessorCount}");

var affinity = (IntPtr) 1;

if (!Regex.IsMatch(processorName, @" Ryzen", RegexOptions.Singleline))
Expand All @@ -45,27 +45,70 @@ public static void Main(string[] args)
}else if (Regex.IsMatch(processorName, @" [123]600(X|XT|AF)?", RegexOptions.Singleline))
{
// 6C/12T(3C/CCX)
affinity = (IntPtr) 0x0FC0;
if (Environment.ProcessorCount == 12)
{
affinity = (IntPtr) 0x0FC0;
}
else
{
affinity = (IntPtr) 0x0038;
}
}else if (Regex.IsMatch(processorName, @" [123][78]00(X|XT)?", RegexOptions.Singleline))
{
// 8C/16T(4C/CCX)
affinity = (IntPtr) 0xFF00;
if (Environment.ProcessorCount == 16)
{
affinity = (IntPtr) 0xFF00;
}
else
{
affinity = (IntPtr) 0x00F0;
}
}else if (Regex.IsMatch(processorName, @" 3900(X|XT)?", RegexOptions.Singleline))
{
// 12C/24T(3C/CCX)
affinity = (IntPtr) 0x00FC0000;
if (Environment.ProcessorCount == 24)
{
affinity = (IntPtr) 0x00FC0000;
}
else
{
affinity = (IntPtr) 0x0E00;
}
}else if (Regex.IsMatch(processorName, @" 3950(X|XT)?", RegexOptions.Singleline))
{
// 16C/32T(4C/CCX)
affinity = (IntPtr) 0xFF000000;
if (Environment.ProcessorCount == 32)
{
affinity = (IntPtr) 0xFF000000;
}
else
{
affinity = (IntPtr) 0xF000;
}

}else if (Regex.IsMatch(processorName, @" 5900X", RegexOptions.Singleline))
{
// 12C/24T(6C/CCX)
affinity = (IntPtr) 0x00FFF000;
if (Environment.ProcessorCount == 24)
{
affinity = (IntPtr) 0x00FFF000;
}
else
{
affinity = (IntPtr) 0x0FC0;
}
}else if (Regex.IsMatch(processorName, @" 5950X", RegexOptions.Singleline))
{
// 16C/32T(8C/CCX)
affinity = (IntPtr) 0xFFFF0000;
if (Environment.ProcessorCount == 32)
{
affinity = (IntPtr) 0xFFFF0000;
}
else
{
affinity = (IntPtr) 0xFF00;
}
}
else
{
Expand Down

0 comments on commit 9c97e70

Please sign in to comment.