The first smartphones with dual-core processors reached the market in 2010. Before that smartphones used single-core processors maxing out at around 1.4GHz. Since then the number of cores has grown and the norm today is eight cores, however, six-core and four-core processors are still used.
Ignoring (for a moment) the Heterogeneous Multi-Processing (HMP) aspects of these processors via tech like big.LITTLE and DynamIQ, today’s smartphones have up to eight individual CPUs which can independently run tasks inside their own virtualized memory space. Eight engines, ready and able to run your apps. But why? Why use multi-cores in the first place? What are the advantages and disadvantages? Let me explain!
Single-core vs multi-core processors, explained
On mobile, power efficiency is paramount. While chipmakers are striving for grater importance, the constraints of running in a thermally limited environment, from a battery, can never be removed. The power that a mobile processor uses is determined by three main factors. The capacitance of the circuits, the voltage of the circuits and the clock frequency. The exact formula is P=CV2f. Up the frequency and you increase the power usage. Alter the voltage and the power level changes dramatically (since it is Voltage2).
If we start a hypothetical single-core processor, we can insert “1” for each of the values, so C is 1, V is 1, f is 1. This is a mathematical exercise, not a real-world example. The total power used is 1. To see the relationship between a dual-core processor and a single-core processor we can now insert the rough values for a dual-core processor, but one running at half the clock frequency. The capacitance goes up because there is more circuitry. Going from single-core to dual-core could alter the C from 1 to 2, but we will use 2.2 to cover any other miscellaneous circuitry and change that using dual-core implies. The voltage can go down, as the frequency will be lower. To err on the side of caution, we will set the voltage to 0.6. Finally, the frequency — this will be half of the original single-core processor, so 0.5. P = 2.2 * 0.62 * 0.5. Do the math and P = 0.396, in other words, 0.4.
In terms of raw processing power, this dual-core processor can perform the same number of calculations as a single-core processor running at twice the clock speed, but as you can see it uses 60% less power. That is the attractiveness of multi-core solutions.
The Raspberry Pi experiment
To test the hypothesis that a half-speed dual-core processor can compute at the same levels as a single-core processor running at “full-speed,” I used a Raspberry Pi and a prime number benchmark that I wrote. The advantage of the Raspberry Pi is that you can disable and enable cores, as well as alter the clock frequency of those core. That makes it perfect for testing out this theory.
Using my test tool to calculate the primes up to 5,000,000 using two threads (meaning it will run on two cores simultaneously), a normal Raspberry Pi 4 can complete the task in 12 seconds. This is our baseline. Now running the same test with just one core activated, but still two threads running, the Pi completes the task in 24 seconds. Since there is no longer a second physical core for the program to use, all the calculations happen on the only active core and it takes twice as long.
Then I activated an additional core, but dropped the clock frequency from 1.5GHz (the default) to just 750MHz. So, two cores running at half the speed. The test completes in 24 seconds. This means that the test completes in the same time when using a single core at 1.5GHz and when using two cores at 750MHz. But the dual-core example used 60% less power.
The tests didn’t actually finish in 24.0 seconds each, there was a fraction of a second difference between the two test runs. I start a long test, one that would take over three minutes to complete. Running that test in the same way as above, I found that a single-core processor running at 1.5GHz is fractionally slower than a dual-core half-speed configuration. Over three minutes the dual-core setup is faster by 1.5 seconds, which is less than 1%. A small difference, but interesting to note.
Multitasking, Multithreading, and Multiprocessing
The key to this testing is that the test tools runs two threads. That is the way it is designed. Not all software can be written in a pure “multi-threaded” way, but most software can benefit from the addition of threading for things like UI responsiveness, background network activity, parallel IO, and more. For more information on all these terms check out my video above.
Not all cores are equal
One final thing to note is that not all cores are equal. Everything discussed here assumes that the same CPU design is used throughout. In real life, it is a little more complicated. As I mentioned earlier, HMP is used in modern mobile processors. This means that the processor will have energy-efficient cores, which have less performance, and high-performance cores, which use more energy but offer greater performance. In a typical octa-core processor, there will be four of each.
Apple’s processors are slightly different. It uses two high-performance cores and four energy-efficient cores, six in total. The way Apple maintains a high level of performance is that those two high-performance cores are quite “big” and achieve higher levels of performance per core than processors from Qualcomm or Samsung. This comes at the expense of higher power usage, which is why Apple’s CPU cores tend to be clocked at a lower frequency than its rivals. It is also why Apple leads the way in terms of single-core performance, however, for multi-core performance the competition is nipping at its heels.
Which would you prefer?
So the question remains, which would you prefer? A single-core processor at higher clocks speeds, that uses more power? Or a dual-core setup, running at half the speed, and using 60% less power. You can, of course, tweak that question into different variations, dual-core vs quad-core, hexa-core vs octa-core, and so on. Please let me know your thoughts in the comments below.