Apple's Swift: Pipeline Depth & Memory Latency

Section by Anand Shimpi

For the first time since the iPhone's introduction in 2007, Apple is shipping a smartphone with a CPU clock frequency greater than 1GHz. The Cortex A8 in the iPhone 3GS hit 600MHz, while the iPhone 4 took it to 800MHz. With the iPhone 4S, Apple chose to maintain the same 800MHz operating frequency as it moved to dual-Cortex A9s. Staying true to its namesake, Swift runs at a maximum frequency of 1.3GHz as implemented in the iPhone 5's A6 SoC. Note that it's quite likely the 4th generation iPad will implement an even higher clocked version (1.5GHz being an obvious target).

Clock speed alone doesn't tell us everything we need to know about performance. Deeper pipelines can easily boost clock speed but come with steep penalties for mispredicted branches. ARM's Cortex A8 featured a 13 stage pipeline, while the Cortex A9 moved down to only 8 stages while maintining similar clock speeds. Reducing pipeline depth without sacrificing clock speed contributed greatly to the Cortex A9's tangible increase in performance. The Cortex A15 moves to a fairly deep 15 stage pipeline, while Krait is a bit more conservative at 11 stages. Intel's Atom has the deepest pipeline (ironically enough) at 16 stages.

To find out where Swift falls in all of this I wrote two different codepaths. The first featured an easily predictable branch that should almost always be taken. The second codepath featured a fairly unpredictable branch. Branch predictors work by looking at branch history - branches with predictable history should be, well, easy to predict while the opposite is true for branches with a more varied past. This time I measured latency in clocks for the main code loop:

Branch Prediction Code
  Apple A3 (Cortex A8 @ 600MHz Apple A5 (2 x Cortex A9 @ 800MHz Apple A6 (2 x Swift @ 1300MHz
Easy Branch 14 clocks 9 clocks 12 clocks
Hard Branch 70 clocks 48 clocks 73 clocks

The hard branch involves more compares and some division (I'm basically branching on odd vs. even values of an incremented variable) so the loop takes much longer to execute, but note the dramatic increase in cycle count between the Cortex A9 and Swift/Cortex A8. If I'm understanding this data correctly it looks like the mispredict penalty for Swift is around 50% longer than for ARM's Cortex A9, and very close to the Cortex A8. Based on this data I would peg Swift's pipeline depth at around 12 stages, very similar to Qualcomm's Krait and just shy of ARM's Cortex A8.

Note that despite the significant increase in pipeline depth Apple appears to have been able to keep IPC, at worst, constant (remember back to our scaled Geekbench scores - Swift never lost to a 1.3GHz Cortex A9). The obvious explanation there is a significant improvement in branch prediction accuracy, which any good chip designer would focus on when increasing pipeline depth like this. Very good work on Apple's part.

The remaining aspect of Swift that we have yet to quantify is memory latency. From our iPhone 5 performance preview we already know there's a tremendous increase in memory bandwidth to the CPU cores, but as the external memory interface remains at 64-bits wide all of the changes must be internal to the cache and memory controllers. I went back to Nirdhar's iOS test vehicle and wrote some new code, this time to access a large data array whose size I could vary. I created an array of a finite size and added numbers stored in the array. I increased the array size and measured the relationship between array size and code latency. With enough data points I should get a good idea of cache and memory latency for Swift compared to Apple's implementation of the Cortex A8 and A9.

At relatively small data structure sizes Swift appears to be a bit quicker than the Cortex A8/A9, but there's near convergence around 4 - 16KB. Take a look at what happens once we grow beyond the 32KB L1 data cache of these chips. Swift manages around half the latency for running this code as the Cortex A9 (the Cortex A8 has a 256KB L2 cache so its latency shoots up much sooner). Even at very large array sizes Swift's latency is improved substantially. Note that this data is substantiated by all of the other iOS memory benchmarks we've seen. A quick look at Geekbench's memory and stream tests show huge improvements in bandwidth utilization:

Couple the dedicated load/store port with a much lower latency memory subsystem and you get 2.5 - 3.2x the memory performance of the iPhone 4S. It's the changes to the memory subsystem that really enable Swift's performance.

 

Apple's Swift: Visualized Six Generations of iPhones: Performance Compared
Comments Locked

276 Comments

View All Comments

  • Spunjji - Friday, October 19, 2012 - link

    Incorrect. See HP Elitebook, Sony Vaio S15, Asus Zenbook, etc... that does depend on your definition of "trackpad that doesn't suck", but personally I'd take an Elitebook with actual buttons over the Apple effort any day, so that bit really is swings and roundabouts.
  • doobydoo - Friday, October 19, 2012 - link

    'so that bit really is swings and roundabouts'

    That's like saying a Ferrari is overpriced because you prefer cup holders so therefore you get more car for less when you buy a Skoda.

    Also, you have to consider size, weight, battery life and performance.

    You can't find a single laptop which matches the air on all of the above.
  • Sufo - Tuesday, October 16, 2012 - link

    You're right to an extent, however it's worth mentioning that it's a lot easier to find unlocked non-apple phones at good prices on auction sites etc. It's very hard to get much less than list price on iphones, even several months after release.

    As for Macs, it depends entirely on which country you buy them in - in the UK for example, it is cheaper to buy a plane ticket to the States and buy a 15" w/ retina there than it is to buy one locally - the same could not be said for similarly specced PCs.
  • Spunjji - Friday, October 19, 2012 - link

    Truth. Unfortunately Apple prices are subject to the perception that Apple products hold their value better, which in a purely practical sense really isn't any more true than for any other product. But the market does as the market does. :)
  • Spunjji - Friday, October 19, 2012 - link

    People who defend Apple's prices with fake numbers just want to whine about people who don't like Apple... see how easy that argument is to return? Please.
  • A5 - Tuesday, October 16, 2012 - link

    I'd say the smartphone market does a fairly good job of dropping prices on products that need it.

    The only product I can really think of that is an outstanding "value" proposition would be the $350 unlocked GNex combined with a prepaid plan. The current high-end devices (One X, GS3, iP5) all seem to be fairly priced relative to each other.
  • steven75 - Wednesday, October 17, 2012 - link

    When I was looking at what I should price my 2.5 year old iPhone 4 at, I found the GS3 is already down to iPhone 4S prices on the resale market.

    Android phones just don't hold resale value vs iPhones, even the flagships, it's Mac vs PC all over again in that area. ;)
  • pseudonymmster - Tuesday, October 16, 2012 - link

    "A processor license gives you the right to taken an ARM designed CPU core..."
    I think "taken" should've been "take" :D
  • karasaj - Tuesday, October 16, 2012 - link

    Nice review guys... all I have to say :P
  • jjj - Tuesday, October 16, 2012 - link

    On the scuffing, would you buy a car that rusts if you drive in the rain? This is clearly a design flaw, a sane company would recall the product and use a more apropriate material.You shouldn't be telling people to deal with it (except the ones that are happy to own the first colour changing phone).
    The size of the SoC in phones matters less and less as we go forward,more integration,more specialized cores,just because it's there it doesn't mean that much of the area is powered at the same time and the cost of silicon is less of a problem too.The limitation is power and /heat not area.

    " if everyone moves to Cortex A15 based designs." - everybody ,in the high end, moves to quad Krait since A15 is likely to be just dual core for a while.

    Nice review overall but,as always, your battery of benchmarks is misleading and no storage perf,really hoped for more to better understand this new core.

Log in

Don't have an account? Sign up now