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

  • rarson - Thursday, October 18, 2012 - link

    Me too, other than the stupid proprietary connection that jacks the price of everything up.
  • Spunjji - Friday, October 19, 2012 - link

    I sit pretty firmly in this camp, too. Despite the physical durability flaws, I do find the overall package of the iPhone 4/4S/5 to be superior to most comparable 'Droid handset. I just find the software to be unbearably obstructive to my desired use patterns.
  • steven75 - Wednesday, October 17, 2012 - link

    Maybe some people want a still larger display but keep the industry leading app support, industry leading hardware ecosystem, airplay, apple store support, industry leading resale value, industry leading OS upgrade support, and without any carrier bloatware?

    Seems pretty possible to me.
  • GotThumbs - Tuesday, October 16, 2012 - link

    "we've just got to deal with it." Wrong. You have to "deal with it".

    Believe it or not....everyone does NOT own one of these phones. The idea of getting a brand new item, be it a car, camera, laptop, tablet or phone and having to deal with the fact that that the companies quality controls are sub-standard is one of the lamest things I've heard....Oh! besides the number one example...... "You're holding if wrong" - Steve Jobs.

    I try to not let this kind of monologue that reeks of Apple fanism not bother me...but come on! Talk about romancing about a freaking phone. Please keep it to a level of unemotional comparisons and the feel free to give your personal thoughts and not assume to speak for everyone else.

    The fact that you felt compelled to write 5 or more paragraphs on the anodizing process is just pathetic. I stopped reading about it after the first paragraph and skipped to the bottom. I thought this is supposed to be a phone review, not a discovery channel episode on the anodizing process. I can't speak for you or anyone else, but I'm pretty comfortable telling you most consumers probably don't care about the process of anodizing, they just expect a quality product for their money.

    People are paying good money...in a bad economy and your saying all they can do is "deal with it"? How about having an open mind and mention they have the choice to buy a different phone or wait for Apple to fix it in their next generation. Your only position appears to be....suck it up, its Apple and thats just part of being in the collective.

    Again,,,,, YOU do not speak for everyone so please drop the "WE".

    Rant done.

    Best wishes to all on your choices in life.
  • crankerchick - Tuesday, October 16, 2012 - link

    Talk about overreaction. Keep the statement within the context of the article. iPhone users have to deal with it if they want to remain iPhone users. Anand is an iPhone user as well are more than a few people reading his review--thus the use of the word "we" instead of the use of the term "iPhone users."

    That said, he should take care lose the "we" but wow, what a rant for something that one can easily use common sense and say, "No I'm not stuck with it." Other bloggers and review sites do the same thing.

    LOL, everyone is always looking for someone to point the fanboy finger at.
  • KPOM - Tuesday, October 16, 2012 - link

    Apparently you have never read an AnandTech review. They go into that kind of detail all the time. That's what people like about them. You aren't going to read that in a CNet, The Verge, or Engadget article. You might get some of that at Ars Technica. But AnandTech goes into excruciating detail.
  • VivekGowri - Tuesday, October 16, 2012 - link

    I mean, it's not like Apple is going to radically alter it a month after production starts, so if you want an iPhone 5, your options are to either put a case on it, or suck it up and live with the scratches. Alternatively, you could buy a 4S (if you want iOS) or any other phone that floats your boat.

    I'm a guy that daily drives a Galaxy Nexus, so accusing me of iOS fanboyism isn't necessarily the most productive way of going about your day.
  • phillyry - Sunday, October 21, 2012 - link

    Yes!

    Well said Vivek.

    But ya, Apple should still have the pressure put on them. So, I could see how people might take it the wrong way. 'Cause it could seem like you're just like, "It's all good Apple, we'll just suck it up." When, in actuality, your ideas are as you stated here. As per the OP's rant, I definitely thought it was off-base but could see where he would draw that conclusion, as it came across that way to me too. And, perhaps like me, he has a hard time keeping track of who uses which phone from the podcasts.

    Again, well retorted though.
  • jiffylube1024 - Tuesday, October 16, 2012 - link

    You are seriously complaining about the depth the review went into on the anodizing
    process? You're reading a review of a product and you're complaining that you're being given more information? How about you just skip over that section if it doesn't interest you.

    I lol'ed that you called that kind of serious scientific investigation into the anodizing process (which I found incredibly informative) "pathetic". Real, fact-based journalism apparently bores you; you'd just rather read opinion pieces and pass judgment on them. How high minded of you!

    Other reviews don't even mention anything about the anodizing process other than that it's there. I don't get why you'd even bother reading a review on AnandTECH if you don't care about the technology...

    As for the author's position to "deal with it" (the anodization scratch issue) -- what more can the author do? He can't fix the problem or even address it from a manufacturing standpoint. The review points out the issues with it; the decision making process is up to the consumer and the fixing of the problem is up to the manufacturer.
  • GotThumbs - Wednesday, October 17, 2012 - link

    "Other reviews don't even mention anything about the anodizing process other than that it's there. I don't get why you'd even bother reading a review on AnandTECH if you don't care about the technology..."

    Anodizing a piece of aluminum does not constitute "technology" when compared to the design of a SoC or camera, at least in my opinion. I see it as a finishing process. My point is that a side link to more detailed information on the anodizing process would have sufficed and kept the reader on track with the hardware review.

    I visit Anandtech on a daily basis and have been reading/visiting this site from the early years when Anand was still in High School. I thoroughly enjoy reading/learning about how new technologies in hardware are evolving and when they are compared to other current hardware available in the marketplace. But I feel there has been a growing tendency in Apple product reviews to have a hint of personal/emotional input rather than sticking to an analytical/technical assessment and let each reader digest the information without the personal emotional spin. It's like todays "News" casters interjecting thier personal thoughts/opinions on a news story. I prefer to get the facts and come to my own conclusion.

    In case you haven't realized, more and more in todays society, we are "Marketed to" in ways that are growing exponentially. Todays marketing companies continue to market to us using methods not just like Product Placement in TV shows, Reality shows, Movies, Red Carpet runways. etc., but on FB, Twitter, blogs, and weak "tech reviews" like CNN's (Read more like product ads than a review) etc. Because of this bombardment of marketing from every possible source imaginable and newly evolving, I don't think its wrong to call out a reviewer when I feel there is even a whiff of non-neutrality. They can take it with a grain of salt or ponder on their next review to be sure they are approaching it in a clear and unbiased manner.

    Complacency in a society and lowering on one's expectations is not something to embrace, its to be challenged and called out.

    Listen, no one is perfect and yes I may have been a little high strung in my post, but it was fueled by emotion and passion and I won't apologize for that.

    I do apologize to Vivek Gowri if I offended him in any way. It was not my intent.

    Best wishes

Log in

Don't have an account? Sign up now