-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAffinity1.ps1
76 lines (75 loc) · 4.37 KB
/
Affinity1.ps1
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
# made by hone (im benchmarking)
# i feel if less than 4 cores, it shouldnt apply affinity
$NumberOfCores = (Get-WmiObject Win32_Processor | Select-Object -ExpandProperty NumberOfCores)
$NumberOfThreads = (Get-WmiObject Win32_Processor | Select-Object -ExpandProperty NumberOfLogicalProcessors)
if ($NumberOfCores -gt 4) {
# More Than 4 Cores
# AllProcessorsInMachine
# No Mask
Get-WmiObject Win32_VideoController | ForEach-Object {
if ($_.PNPDeviceID -like "*PCI\VEN_*") {
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "3" /f > $null 2>&1
Reg Delete "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /f > $null 2>&1
}
}
# SpreadMessagesAcrossAllProcessors
# No Mask
Get-WmiObject Win32_NetworkAdapter | ForEach-Object {
if ($_.PNPDeviceID -like "*PCI\VEN_*") {
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "5" /f > $null 2>&1
Reg Delete "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /f > $null 2>&1
}
}
} elseif (($NumberOfThreads -ne $NumberOfCores) -and ($NumberOfCores -gt 2)) {
# 3-4 cores, Hyperthreading ON
# SpecifiedProcessors
# CPU 6-7
Get-WmiObject Win32_USBController | ForEach-Object {
if ($_.PNPDeviceID -like "*PCI\VEN_*") {
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "4" /f > $null 2>&1
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /t REG_BINARY /d "C0" /f > $null
}
}
# SpecifiedProcessors
# CPU 6-7
Get-WmiObject Win32_VideoController | ForEach-Object {
if ($_.PNPDeviceID -like "*PCI\VEN_*") {
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "4" /f > $null 2>&1
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /t REG_BINARY /d "C0" /f > $null
}
}
# SpecifiedProcessors
# CPU 4-5
Get-WmiObject Win32_NetworkAdapter | ForEach-Object {
if ($_.PNPDeviceID -like "*PCI\VEN_*") {
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "4" /f > $null 2>&1
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /t REG_BINARY /d "30" /f > $null
}
}
} else {
# 1-4 cores, Hyperthreading OFF
# SpecifiedProcessors
# CPU 3
Get-WmiObject Win32_USBController | ForEach-Object {
if ($_.PNPDeviceID -like "*PCI\VEN_*") {
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "4" /f > $null 2>&1
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /t REG_BINARY /d "08" /f > $null
}
}
# SpecifiedProcessors
# CPU 1
Get-WmiObject Win32_VideoController | ForEach-Object {
if ($_.PNPDeviceID -like "*PCI\VEN_*") {
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "4" /f > $null 2>&1
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /t REG_BINARY /d "02" /f > $null
}
}
# SpecifiedProcessors
# CPU 2
Get-WmiObject Win32_NetworkAdapter | ForEach-Object {
if ($_.PNPDeviceID -like "*PCI\VEN_*") {
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "4" /f > $null 2>&1
Reg Add "HKLM\System\CurrentControlSet\Enum\$($_.PNPDeviceID)\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /t REG_BINARY /d "04" /f > $null
}
}
}