Wednesday, May 22, 2013

Upgrading the CPU in an old motherboard

My primary desktop computer at home is now five years old... well, at least the CPU, motherboard are.  It's a custom-built system that gets upgraded piece by piece.  Anyway, the dual-core AMD processor has really started to show its age during all the photo editing I've been doing.  I looked into replacing the CPU/mobo/RAM, but couldn't bring myself to pay the $600 it would cost to buy a new setup that I'd be happy with.  It eventually occurred to me that my current motherboard could hold a much faster CPU than I had, so after an $84 eBay purchase, I had a used CPU en route that would (according to the published benchmarks) be three times faster than my old one.  Of course, nothing is ever as easy as it should be, and this purchase set in motion a whole slough of problems that required many hours over nearly a week to get resolved.

The motherboard, which I kept, is an Asus M2N-SLI Deluxe.  It has an AMD AM2/2+ CPU socket, which is physically compatible with the newer (but still discontinued) AM3 processors.  The M2N series were relatively popular for Asus, and have a decent following on the web.  The CPU that I originally used was an AMD Athlon 64 X2 5000+ Black Edition, which is a dual-core, 2.6 GHz chip.  When I bought it back in 2008, I spent an extra $10 on the Black Edition because it came with an unlocked CPU multiplier, which makes overclocking easier.  Alas, I never dabbled with overclocking it, despite my recent complaints of its slow speed.

Out with the old (left), in with the new (right)

The fastest CPU that AMD ever made for the AM3 socket was the Phenom II X4 980 (3.7 GHz). Those had a very small production run and are now relatively rare and expensive, so I settled instead for its little brother, the 970 (3.5 GHz).  I would also have been happy with the 965 or 975 if I'd found any at good prices.  The X4's are, of course, quad-core chips.  According to CPUBenchmark.net, the Phenom II 970 should be more than triple the speed of my old Athlon, which would be a welcome upgrade for under $100 and a 15-minute install process... or so I thought.

Benchmarks

Before I removed the old Athlon, I ran a handful of CPU benchmarks on the system so that I'd have some empirical data showing how much faster it was.  Because my desktop computer runs Ubuntu Linux 12.10, I installed "hardinfo" and "sysbench" for my benchmarking purposes.

Hardinfo is a GUI program that shows all kinds of system information and runs five different CPU benchmarks.  The results can be saved to disk in an HTML-formatted report.

Sysbench is a command line program that can run several different kinds of tests.  Since I was increasing the number of cores, I ran these tests with 16 threads to maximize all the cores.  I ran both CPU and file I/O tests, but the file I/O didn't change with the new CPU (not surprisingly).  Here's the command I ran for sysbench:

# sysbench --test=cpu --cpu-max-prime=50000 --num-threads=16 run

In the resulting output, the important line is "execution time" (the last line).  Lower times mean the test ran faster.

Swapping CPU's

The CPU is still attached to the cooler
The AMD Phenom II X4 970 Black Edition from eBay cost me $84 shipped to my door, which was a pretty good price, even by eBay standards.  The 980's tend to cost about $120.  I spent about $15 at Best Buy on a syringe of Antec thermal compound (something I didn't think about until the day the CPU arrived), so my total outlay was less than $100.

This is where the problems began.

When removing the old CPU, the 5-year-old thermal paste had glued the heat sink to the Athlon CPU so securely that, rather than pulling the heat sink off the CPU, I pulled the entire CPU out of the socket without having to unlock it.  I don't swap CPU's often, so I'd forgotten that this locking lever even existed.  I spent a couple hours of frustration before I realized that the reason my mobo wouldn't POST with either CPU was that I hadn't locked them in place when reinstalling them.  DOH!

With the CPU finally installed properly, I found that my motherboard's BIOS would now POST just fine, but couldn't identify the CPU or boot using it.  A little research revealed that although the Phenom would fit into the motherboard just fine, Asus didn't officially support these faster processors in this mobo.  I had been running BIOS version 1701 (the most recent production BIOS, from 2009), which didn't support them.  The beta-released BIOS version 5001 from 2010 supported most of the slower Phenom II chips (up through the 95W version of the 945, at 3.0 GHz), but still didn't officially support the 970 I had bought.  Yippee.  This is why I normally research things to death before I buy anything.  Whenever I don't, stuff like this jumps out and bites me.

I debated just reselling the 970 and buying the slower Phenom II X4 945, which would have been a drop-in replacement with the 5001 BIOS thanks to its lower 95W power requirements.  The faster Phenom II's are all 125W processors.  I wouldn't even both trying any 140W processors in this mobo.  However, since I already had the 970 in hand, I figured I'd give it a shot to see if I could make it work.  I ended up spending way more time dinking with this than I should have, given my to-do list, but I eventually got it going.

Making the 970 work

The BIOS finally recognizes the new CPU
When I finally got my computer to boot off the 970, it still felt dreadfully slow.  Re-running my benchmarks confirmed that my new 4-core, 3.5 GHz processor was still roughly the same speed as my old 2-core, 2.6 GHz processor was.  Many of the OS utilities reported that the clock speed was indeed 3.5 GHz, but they were lying.  Running "cat /proc/cpuinfo" showed that the cores were actually running at only 800 MHz since this CPU was unsupported by this BIOS.

The fact that my M2N-SLI Deluxe motherboard was a popular item in its day really saved me, because there is still a fairly active forum dedicated to it on Overclock.net.  Several people there reported success running the 970 on this mobo, but most of those folks run Windows.  I run Linux, so I don't have all the same tools at my disposal.  I'll spare you the soap opera that my research involved and jump straight to the solution that eventually worked for me.

First, download the 5001 BIOS from Asus.  Throw it on a USB thumb drive.  Boot the computer into the BIOS setup.  Under Tools, select EZ Flash.  Select the drive letter representing your thumb drive.  Select the binary to install.  Reboot, and the new BIOS should now correctly identify the 970, but you'll find it's running at 800 MHz.

Change these parameters in the BIOS
In the BIOS' Advanced heading, choose JumperFree Configuration, and set the AI Tuning to "manual."  Leave the CPU (FSB) Frequency at 200 MHz.  Set the CPU Voltage to 1.35V (or higher, if you want to overclock this CPU beyond its 3.5 GHz rating).  Set the CPU Multiplier to 17.5 (that's the 3.5 GHz CPU speed divided by the 200 MHz FSB speed).  Higher multipliers result in higher CPU clock speeds with a higher chance of instability.  Having a Black Edition CPU makes this easy, because you can simply change the CPU multiplier.  With most CPU's, you have to change the FSB speed to overclock the system, and that has trickle-down effects with your RAM as well.

In the BIOS, choose Advanced, then CPU Configuration, then DRAM Configuration, and make sure the DRAM Ganged Mode is set to "auto" or "disabled."   "Ganged" works well for dual-core CPU's, but not so much when you have more than two cores.  My machine correctly ungangs the RAM in the "auto" setting.

Save the BIOS settings and exit.

Once the computer boots into the full OS, install the "k10ctl" program, which will allow you to modify the clock speed after boot.  Apparently, the multiplier set in the BIOS is merely an upper bound, and won't actually take effect until you run another program from within the OS.  On Windows, that program is the Nvidia System Tools.  On Linux, it's k10ctl.  "K10" refers to the AMD Phenom line (K8 was the Athlon line).  If you've got a different CPU, you'll need to find a different utility.

Pretty much all of the following commands need to be run as root (or sudo).

K10ctl requires the "msr" module to be loaded.  Add it to "/etc/modules", and if you don't want to wait for a reboot, type "modprobe msr" to activate it right away.

To get the full clock speed you already set in the BIOS, you have to jump through some hoops with k10ctl that seem like complete black magic to me.  If any of you gentle readers can explain why they're necessary, please do so in the comments below.

First, view the settings for the first CPU core:

root# k10ctl 0
VID interface mode: parallel
CPU0
Current P-State: 0      Fastest P-State: 0
            NbVid NbDid CpuVid CpuDid CpuFid      UNb  CpuMult     UCpu  PCore
P-State 0:     38     0     38      0     19  687.5mV 17.50000  687.5mV 7425mW
Low Limit:    124     1    124                375.0mV  0.50000  375.0mV
High Limit:     0     1      0               1550.0mV  0.00000 1550.0mV
Target:        38     0     38      0     19  687.5mV 17.50000  687.5mV
Current:       38     0     38      1      0  687.5mV  4.00000  687.5mV

You'll note that there is only one P-State (power state), and while it seems to be set to the proper multiplier (17.5), and while 0 is reported to be the current P-State, the Current setting (bottom line) is still only 800 MHz (a 4.0 multiplier).  Telling k10ctl to switch to P-State 0 has no effect.

Instead, you need to create a second P-State that represents the 800 MHz setting, then switch to it first.  After that, when you switch back to P-State 0, k10ctl will do as you ask, and your system will run at 3.5 GHz.  Here's the command sequence to make this happen.  Note that the specific values listed may be different on your system.  This is just what worked for me.

root# k10ctl 0-3 1 -nv 38 -nd 0 -cv 38 -cd 1 -cf 0
root# k10ctl 0
VID interface mode: parallel
CPU0
Current P-State: 0      Fastest P-State: 0
            NbVid NbDid CpuVid CpuDid CpuFid      UNb  CpuMult     UCpu  PCore
P-State 0:     38     0     38      0     19  687.5mV 17.50000  687.5mV 7425mW
P-State 1:     38     0     38      1      0  687.5mV  4.00000  687.5mV 7425mW
Low Limit:    124     1    124                375.0mV  0.50000  375.0mV
High Limit:     0     1      0               1550.0mV  0.00000 1550.0mV
Target:        38     0     38      0     19  687.5mV 17.50000  687.5mV
Current:       38     0     38      1      0  687.5mV  4.00000  687.5mV

root# k10ctl 0-3 1

root# k10ctl 0
VID interface mode: parallel
CPU0
Current P-State: 1      Fastest P-State: 0
            NbVid NbDid CpuVid CpuDid CpuFid      UNb  CpuMult     UCpu  PCore
P-State 0:     38     0     38      0     19  687.5mV 17.50000  687.5mV 7425mW
P-State 1:     38     0     38      1      0  687.5mV  4.00000  687.5mV 7425mW
Low Limit:    124     1    124                375.0mV  0.50000  375.0mV
High Limit:     0     1      0               1550.0mV  0.00000 1550.0mV
Target:        38     0     38      1      0  687.5mV  4.00000  687.5mV
Current:       38     0     38      1      0  687.5mV  4.00000  687.5mV

root# k10ctl 0-3 0

root# k10ctl 0
VID interface mode: parallel
CPU0
Current P-State: 0      Fastest P-State: 0
            NbVid NbDid  CpuVid CpuDid CpuFid      UNb  CpuMult     UCpu  PCore
P-State 0:     38     0     38      0     19  687.5mV 17.50000  687.5mV 7425mW
P-State 1:     38     0     38      1      0  687.5mV  4.00000  687.5mV 7425mW
Low Limit:    124     1    124                375.0mV  0.50000  375.0mV
High Limit:     0     1      0               1550.0mV  0.00000 1550.0mV
Target:        38     0     38      0     19  687.5mV 17.50000  687.5mV
Current:       38     0     38      0     19  687.5mV 17.50000  687.5mV

You can see on the bottom line that the currently-operating CPU multiplier is finally 17.5, equating to the 3.5 GHz clock speed that I wanted.  To make these commands run at boot time, I created a script in "/etc/init.d" and then installed it with "update-rc.d".  Here's the important bits from the "start)" section of that script:

log_daemon_msg "Starting AMD Phenom II 970 overclocking"
# Create a second P-state (#1) representing the 800 MHz setting
k10ctl 0-3 1 -nv 38 -nd 0 -cv 38 -cd 1 -cf 0
# Set the current P-state to the slower setting first, then the faster setting
k10ctl 0-3 1
k10ctl 0-3 0

My cooling fan (left) vs the stock cooler (right)
Re-running the benchmark utilities shows a remarkable improvement in CPU speed.  Even single-threaded programs are noticeably faster, and my multi-threaded photo editing software (Corel AfterShot Pro) just screams.

You should, of course, ensure that you've got adequate cooling to handle the faster CPU.  I've got a pretty good "Cooler Master" CPU cooler already, so my CPU hovers around 37C at idle and stays below 45C at reasonably heavy load.  After stress testing the system for an hour using the "stress" utility, my CPU core temperature peaked at 59C, which is about as high as you want it to go.  If you've got the lm-sensors package installed, you can check your cooling numbers with the "sensors" command.

Again, if any of you overclocking experts can fill in a few more details, please do so in the comments.  This was my first foray into overclocking, and I'm still very much a newbie.  I just had a horribly hard time finding the above information, so I wanted to share it with anybody else who will listen.

No comments:

Post a Comment

Please leave your comment below. Comments are moderated, so don't be alarmed if your note doesn't appear immediately. Also, please don't use my blog to advertise your own web site unless it's related to the discussion at hand.