dockerfile/examples/omnivore/content-fetch/readabilityjs/test/test-pages/erik-engheim/expected.html

310 lines
58 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div id="readability-page-1" class="page">
<div>
<div>
<div>
<h2 id="d808"> Real-world experience with the new M1 Macs has started ticking in. They are fast. Real fast. But why? What is the magic? </h2>
</div>
<figure>
<div role="button" tabindex="0">
<p><img alt="Image for post" src="https://miro.medium.com/max/5760/1*thz7gKafCYxWoA0h8aGjcg.jpeg" width="2880" height="1620" srcset="https://miro.medium.com/max/552/1*thz7gKafCYxWoA0h8aGjcg.jpeg 276w, https://miro.medium.com/max/1104/1*thz7gKafCYxWoA0h8aGjcg.jpeg 552w, https://miro.medium.com/max/1280/1*thz7gKafCYxWoA0h8aGjcg.jpeg 640w, https://miro.medium.com/max/1400/1*thz7gKafCYxWoA0h8aGjcg.jpeg 700w" sizes="700px" data-old-src="https://miro.medium.com/max/2880/1*thz7gKafCYxWoA0h8aGjcg.jpeg" data-old-srcset="https://miro.medium.com/max/276/1*thz7gKafCYxWoA0h8aGjcg.jpeg 276w, https://miro.medium.com/max/552/1*thz7gKafCYxWoA0h8aGjcg.jpeg 552w, https://miro.medium.com/max/640/1*thz7gKafCYxWoA0h8aGjcg.jpeg 640w, https://miro.medium.com/max/700/1*thz7gKafCYxWoA0h8aGjcg.jpeg 700w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> Image: Apple </figcaption>
</figure>
<p id="8eb8" data-selectable-paragraph="">
<span>On</span> YouTube, I watched a Mac user who had bought an iMac last year. It was maxed out with 40 GB of RAM costing him about $4,000. He watched in disbelief how his hyperexpensive iMac was being demolished by his new M1 Mac Mini, which he had paid a measly $700 for.
</p>
<p id="1408" data-selectable-paragraph=""> In real-world test after test, the M1 Macs are not merely inching past top-of-the-line Intel Macs, they are destroying them. In disbelief, people have started asking how on earth this is possible? </p>
<p id="71b6" data-selectable-paragraph=""> If you are one o<span id="rmm"><span id="rmm"><span id="rmm"><span id="rmm"><span id="rmm"><span id="rmm"><span id="rmm"><span id="rmm"><span id="rmm">f</span></span></span></span></span></span></span></span></span> those people, you have come to the right place. Here I plan to break it down into digestible pieces exactly what it is that Apple has done with the M1. Specifically the questions I think a lot of people have are: </p>
<ol>
<li id="89bf" data-selectable-paragraph="">What are the technical reasons this M1 chip is so fast? </li>
<li id="c5cb" data-selectable-paragraph="">Has Apple made some really exotic technical choices to make this possible? </li>
<li id="03e6" data-selectable-paragraph="">How easy will it be for the competition such as Intel and AMD to pull the same technical tricks? </li>
</ol>
<p id="6e93" data-selectable-paragraph=""> Sure you could try to Google this, but if you try to learn what Apple has done beyond the superficial explanations, you will quickly get buried in highly technical jargon such as M1 using very wide instruction decoders, enormous reorder buffer (ROB), etc. Unless you are a CPU hardware geek, a lot of this will simply be gobbledygook. </p>
<p id="ecc7" data-selectable-paragraph=""> To get the most out of this story I advise reading my earlier piece: “<a href="https://medium.com/swlh/what-does-risc-and-cisc-mean-in-2020-7b4d42c9a9de" target="_blank" rel="noopener">What Does RISC and CISC mean in 2020</a>?” There I explain what a microprocessor (CPU) is as well as various important concepts such as: </p>
<ul>
<li id="4638" data-selectable-paragraph="">Instruction set architecture (ISA) </li>
<li id="e7aa" data-selectable-paragraph="">Pipelining </li>
<li id="69ae" data-selectable-paragraph="">Load/store architecture </li>
<li id="f37f" data-selectable-paragraph="">Microcode vs. micro-operations </li>
</ul>
<p id="85a3" data-selectable-paragraph=""> But if you are impatient, I will do a quick version of the material you need to understand to grasp my explanation of the M1 chip. </p>
<h2 id="a207" data-selectable-paragraph=""> What is a microprocessor (CPU)? </h2>
<p id="285c" data-selectable-paragraph=""> Normally when speaking of chips from Intel and AMD we talk about central processing units (CPUs) or microprocessors. As you can read more about in my <a href="https://medium.com/swlh/what-does-risc-and-cisc-mean-in-2020-7b4d42c9a9de" target="_blank" rel="noopener">RISC vs. CISC story</a>, these pull in instructions from memory. Then each instruction is typically carried out in sequence. </p>
<figure>
<p><img alt="A very basic RISC CPU, not the M1" src="https://miro.medium.com/proxy/1*3G7uz4l1GnFacxz6InrLLw.png" />
</p>
<figcaption data-selectable-paragraph=""> A very basic RISC CPU, not the M1. Instructions are moved from memory along <strong>blue</strong> arrows into the instruction register. There a decoder figures out what the instruction is and enables different parts of the CPU through the <strong>red</strong> control lines. The ALU adds and subtracts numbers placed in the registers. </figcaption>
</figure>
<p id="5525" data-selectable-paragraph=""> A CPU at its most basic level is a device with a number of named memory cells called registers and a number of computational units called arithmetic logic units (ALU). The ALUs perform things like addition, subtraction, and other basic math operations. However, these are only connected to the CPU registers. If you want to add up two numbers, you have to get those two numbers from memory and into two registers in the CPU. </p>
<p id="db6e" data-selectable-paragraph=""> Here are some examples of typical instructions that a RISC CPU as found on the M1 carries out. </p>
<pre><span id="9500" data-selectable-paragraph="">load r1, 150<br/>load r2, 200<br/>add r1, r2<br/>store r1, 310</span></pre>
<p id="d5bb" data-selectable-paragraph=""> Here <code>r1</code> and <code>r2</code> are the registers I talked about. Modern RISC CPUs cannot do operations on numbers that are not in a register like this. For example, it cannot add two numbers residing in RAM in two different locations. Instead, it has to pull these two numbers into a separate register. That is what we do in this simple example. We pull in the number at memory location 150 in the RAM and put it into register <code>r1</code> in the CPU. Next, we put the contents of address 200 into register <code>r2</code>. Only then can the numbers be added with the <code>add r1, r2</code> instruction. </p>
<figure>
<div>
<p><img alt="Image for post" src="https://miro.medium.com/max/800/1*kDqSqtumOzNFZdpixUW0IQ.jpeg" width="400" height="223" srcset="https://miro.medium.com/max/552/1*kDqSqtumOzNFZdpixUW0IQ.jpeg 276w, https://miro.medium.com/max/800/1*kDqSqtumOzNFZdpixUW0IQ.jpeg 400w" sizes="400px" data-old-src="https://miro.medium.com/max/400/1*kDqSqtumOzNFZdpixUW0IQ.jpeg" data-old-srcset="https://miro.medium.com/max/276/1*kDqSqtumOzNFZdpixUW0IQ.jpeg 276w, https://miro.medium.com/max/400/1*kDqSqtumOzNFZdpixUW0IQ.jpeg 400w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> An old mechanical calculator with two registers: the accumulator and input register. Modern CPUs typically have more than a dozen registers, and they are electronic rather than mechanical. </figcaption>
</figure>
<p id="7146" data-selectable-paragraph=""> The concept of registers is old. For example, on this old mechanical calculator, the <em>register</em> is what holds the numbers you are adding. Likely the origin of the term <em>cash register</em>. The register is where you registered input numbers. </p>
<h2 id="22f2" data-selectable-paragraph=""> The M1 is not a CPU! </h2>
<p id="d450" data-selectable-paragraph=""> But here is a very important thing to understand about the M1: </p>
<p id="777f" data-selectable-paragraph=""> The M1 is not a CPU, it is a whole system of multiple chips put into one large silicon package. The CPU is just one of these chips. </p>
<p id="69f0" data-selectable-paragraph=""> Basically, the M1 is one whole computer onto a chip. The M1 contains a CPU, graphical processing unit (GPU), memory, input and output controllers, and many more things making up a whole computer. This is what we call a system on a chip (SoC). </p>
<figure>
<div role="button" tabindex="0">
<p><img alt="Image for post" src="https://miro.medium.com/max/2400/1*c4EYUAVj4k7n6wWLoWUVdA.png" width="1200" height="360" srcset="https://miro.medium.com/max/552/1*c4EYUAVj4k7n6wWLoWUVdA.png 276w, https://miro.medium.com/max/1104/1*c4EYUAVj4k7n6wWLoWUVdA.png 552w, https://miro.medium.com/max/1280/1*c4EYUAVj4k7n6wWLoWUVdA.png 640w, https://miro.medium.com/max/1400/1*c4EYUAVj4k7n6wWLoWUVdA.png 700w" sizes="700px" data-old-src="https://miro.medium.com/max/1200/1*c4EYUAVj4k7n6wWLoWUVdA.png" data-old-srcset="https://miro.medium.com/max/276/1*c4EYUAVj4k7n6wWLoWUVdA.png 276w, https://miro.medium.com/max/552/1*c4EYUAVj4k7n6wWLoWUVdA.png 552w, https://miro.medium.com/max/640/1*c4EYUAVj4k7n6wWLoWUVdA.png 640w, https://miro.medium.com/max/700/1*c4EYUAVj4k7n6wWLoWUVdA.png 700w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> M1 is a system on a chip. Meaning all the parts making up a computer are placed on one silicon chip. </figcaption>
</figure>
<p id="fce1" data-selectable-paragraph=""> Today if you buy a chip — whether from Intel or AMD — you actually get what amounts to <em>multiple</em> microprocessors in one package. In the past computers would have multiple physically separate chips on the motherboard of the computer. </p>
<figure>
<div>
<p><img alt="Image for post" src="https://miro.medium.com/max/1200/1*GBrG4D2YCEVYREXAHIiJnQ.png" width="600" height="418" srcset="https://miro.medium.com/max/552/1*GBrG4D2YCEVYREXAHIiJnQ.png 276w, https://miro.medium.com/max/1104/1*GBrG4D2YCEVYREXAHIiJnQ.png 552w, https://miro.medium.com/max/1200/1*GBrG4D2YCEVYREXAHIiJnQ.png 600w" sizes="600px" data-old-src="https://miro.medium.com/max/600/1*GBrG4D2YCEVYREXAHIiJnQ.png" data-old-srcset="https://miro.medium.com/max/276/1*GBrG4D2YCEVYREXAHIiJnQ.png 276w, https://miro.medium.com/max/552/1*GBrG4D2YCEVYREXAHIiJnQ.png 552w, https://miro.medium.com/max/600/1*GBrG4D2YCEVYREXAHIiJnQ.png 600w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> Example of a computer motherboard. Memory, CPU, graphics cards, IO controllers, network cards, and many other components can be attached to the motherboard to communicate with each other. </figcaption>
</figure>
<p id="9cf5" data-selectable-paragraph=""> However because we are able to put so many transistors on a silicon die today, companies such as Intel and AMD began putting multiple microprocessors onto one chip. Today we refer to these chips as CPU cores. One core is basically a full independent chip that can read instructions from memory and perform calculations. </p>
<figure>
<div>
<p><img alt="Image for post" src="https://miro.medium.com/max/850/1*XZsBJV_v4WybnUFYjJJiPQ.gif" width="425" height="267" srcset="https://miro.medium.com/max/552/1*XZsBJV_v4WybnUFYjJJiPQ.gif 276w, https://miro.medium.com/max/850/1*XZsBJV_v4WybnUFYjJJiPQ.gif 425w" sizes="425px" data-old-src="https://miro.medium.com/max/425/1*XZsBJV_v4WybnUFYjJJiPQ.gif" data-old-srcset="https://miro.medium.com/max/276/1*XZsBJV_v4WybnUFYjJJiPQ.gif 276w, https://miro.medium.com/max/425/1*XZsBJV_v4WybnUFYjJJiPQ.gif 425w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> A microchip with multiple CPU cores. </figcaption>
</figure>
<p id="18a4" data-selectable-paragraph=""> This has for a long time been the name of the game in terms of increasing performance: Just add more general-purpose CPU cores. But there is a disturbance in the force. There is one player in the CPU market which is deviating from this trend. </p>
<h2 id="cff4" data-selectable-paragraph=""> Apples not so secret heterogeneous computing strategy </h2>
<p id="8feb" data-selectable-paragraph=""> Instead of adding ever more general-purpose CPU cores, Apple has followed another strategy: They have started adding ever more specialized chips doing a few specialized tasks. The benefit of this is that specialized chips tend to be able to perform their tasks significantly faster using much less electric current than a general-purpose CPU core. </p>
<p id="e379" data-selectable-paragraph=""> This is not entirely new knowledge. For many years already specialized chips such as the graphical processing units (GPUs) have been sitting in Nvidia and AMD graphics cards performing operations related to graphics much faster than general-purpose CPUs. </p>
<p id="866e" data-selectable-paragraph=""> What Apple has done is simply to take a more radical shift toward this direction. Rather than just having general-purpose cores and memory, the M1 contains a wide variety of specialized chips: </p>
<ul>
<li id="6e0e" data-selectable-paragraph="">Central processing unit (CPU) — the “brains” of the SoC. Runs most of the code of the operating system and your apps. </li>
<li id="037c" data-selectable-paragraph="">Graphics processing unit (GPU) — handles graphics-related tasks, such as visualizing an apps user interface and 2D/3D gaming. </li>
<li id="9a44" data-selectable-paragraph="">Image processing unit (ISP) — can be used to speed up common tasks done by image processing applications. </li>
<li id="c654" data-selectable-paragraph="">Digital signal processor (DSP) — handles more mathematically intensive functions than a CPU. Includes decompressing music files. </li>
<li id="1cac" data-selectable-paragraph="">Neural processing unit (NPU) — used in high-end smartphones to accelerate machine learning (A.I.) tasks. These include voice recognition and camera processing. </li>
<li id="ce8d" data-selectable-paragraph="">Video encoder/decoder — handles the power-efficient conversion of video files and formats. </li>
<li id="d9a8" data-selectable-paragraph="">Secure Enclave — encryption, authentication, and security. </li>
<li id="2d2b" data-selectable-paragraph="">Unified memory — allows the CPU, GPU, and other cores to quickly exchange information. </li>
</ul>
<p id="967a" data-selectable-paragraph=""> This is part of the reason why a lot of people working on images and video editing with the M1 Macs are seeing such speed improvements. A lot of the tasks they do can run directly on specialized hardware. That is what allows a cheap M1 Mac Mini to encode a large video file without breaking a sweat while an expensive iMac has all its fans going full blast and still cannot keep up. </p>
<p id="39d6" data-selectable-paragraph=""> Read more about heterogeneous computing: <a href="https://erik-engheim.medium.com/apple-m1-foreshadows-risc-v-dd63a62b2562" target="_blank" rel="noopener">Apple M1 foreshadows Rise of RISC-V</a>. </p>
<figure>
<div>
<p><img alt="Image for post" src="https://miro.medium.com/max/1152/1*SpFJ9g-taH9a-TvXdnaq2w.png" width="576" height="324" srcset="https://miro.medium.com/max/552/1*SpFJ9g-taH9a-TvXdnaq2w.png 276w, https://miro.medium.com/max/1104/1*SpFJ9g-taH9a-TvXdnaq2w.png 552w, https://miro.medium.com/max/1152/1*SpFJ9g-taH9a-TvXdnaq2w.png 576w" sizes="576px" data-old-src="https://miro.medium.com/max/576/1*SpFJ9g-taH9a-TvXdnaq2w.png" data-old-srcset="https://miro.medium.com/max/276/1*SpFJ9g-taH9a-TvXdnaq2w.png 276w, https://miro.medium.com/max/552/1*SpFJ9g-taH9a-TvXdnaq2w.png 552w, https://miro.medium.com/max/576/1*SpFJ9g-taH9a-TvXdnaq2w.png 576w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> In <strong>blue</strong> you see multiple CPU cores accessing memory, and in <strong>green</strong> you see large numbers of GPU cores accessing memory. </figcaption>
</figure>
<h2 id="d906" data-selectable-paragraph=""> What is Special About Apples Unified Memory Architecture? </h2>
<p id="956a" data-selectable-paragraph=""> Apples “Unified Memory Architecture” (UMA) is a bit tricky to wrap your head around (I got it wrong first time I wrote it down here). </p>
<p id="8cb3" data-selectable-paragraph=""> To explain why, we need to take a few steps back. </p>
<p id="b7a7" data-selectable-paragraph=""> For a long time cheap computer systems have had the CPU and GPU integrated into the same chip (same silicon die). These have been famously slow. In the past saying “integrated graphics” was essentially the same as saying “slow graphics.” </p>
<p id="a598" data-selectable-paragraph=""> These where slow for severals reasons: </p>
<p id="1d41" data-selectable-paragraph=""> Separate areas of this memory got reserved for the CPU and GPU. If the CPU had a chunk of data it wanted the GPU to use, it couldnt say “here have some of my memory.” No, the CPU had to explicitly copy the whole chunk of data over the memory area controlled by the GPU. </p>
<figure>
<div>
<p><img alt="Image for post" src="https://miro.medium.com/max/1280/1*7c67HhuDWVFM3Pi-mO5boA.jpeg" width="640" height="321" srcset="https://miro.medium.com/max/552/1*7c67HhuDWVFM3Pi-mO5boA.jpeg 276w, https://miro.medium.com/max/1104/1*7c67HhuDWVFM3Pi-mO5boA.jpeg 552w, https://miro.medium.com/max/1280/1*7c67HhuDWVFM3Pi-mO5boA.jpeg 640w" sizes="640px" data-old-src="https://miro.medium.com/max/640/1*7c67HhuDWVFM3Pi-mO5boA.jpeg" data-old-srcset="https://miro.medium.com/max/276/1*7c67HhuDWVFM3Pi-mO5boA.jpeg 276w, https://miro.medium.com/max/552/1*7c67HhuDWVFM3Pi-mO5boA.jpeg 552w, https://miro.medium.com/max/640/1*7c67HhuDWVFM3Pi-mO5boA.jpeg 640w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> CPUs dont need a lot of data served, but they want it <strong>fast</strong>. </figcaption>
</figure>
<p id="f669" data-selectable-paragraph=""> CPUs and GPUs dont want their memory served the same way. Let us do a silly food analogy: CPUs want their plate of data served very quickly by the waiter, but they are totally cool with small portion sizes. Imagine a fancy French restaurant with waiters on rollerblades to serve you really quickly. </p>
<figure>
<div>
<p><img alt="Image for post" src="https://miro.medium.com/max/1100/1*ethYaJsPETw2zxF7Xm0Z0w.jpeg" width="550" height="366" srcset="https://miro.medium.com/max/552/1*ethYaJsPETw2zxF7Xm0Z0w.jpeg 276w, https://miro.medium.com/max/1100/1*ethYaJsPETw2zxF7Xm0Z0w.jpeg 550w" sizes="550px" data-old-src="https://miro.medium.com/max/550/1*ethYaJsPETw2zxF7Xm0Z0w.jpeg" data-old-srcset="https://miro.medium.com/max/276/1*ethYaJsPETw2zxF7Xm0Z0w.jpeg 276w, https://miro.medium.com/max/550/1*ethYaJsPETw2zxF7Xm0Z0w.jpeg 550w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> This is how your GPU wants their memory: <strong>huge</strong> portions. The more the merrier. </figcaption>
</figure>
<p id="9c14" data-selectable-paragraph=""> GPUs in contrast are cool with the waiter being slow to serve the data. But the GPUs want enormous servings. They gobble massive amounts of data because they are massive parallel machines, that can chew through lots of data in parallel. Imagine an American junk food place, where the food takes some time to arrive because they are pushing a whole trolley of food to your seating area. </p>
<p id="812f" data-selectable-paragraph=""> With such different needs, putting CPUs and GPUs on the same physical chip was not a great idea. The GPUs would sit there starving while given small French servings. The result was that there was no point in putting powerful GPUs on an SoC. The tiny portions of data served up, could easily be chewed up by a weak little GPU. </p>
<p id="d539" data-selectable-paragraph=""> The second problem was that large GPUs produce a lot of heat and thus you cannot integrate them with the CPU without getting problems ridding yourself of the heat produced. Thus discrete graphics cards tend to look like the one below: Large beasts with massive cooling fans. They have special dedicated memory designed to serve the greedy cards massive amounts of data. </p>
<figure>
<div>
<p><img alt="Image for post" src="https://miro.medium.com/max/778/1*gQcbAlaUXNtjJi6OAUzMsg.jpeg" width="389" height="209" srcset="https://miro.medium.com/max/552/1*gQcbAlaUXNtjJi6OAUzMsg.jpeg 276w, https://miro.medium.com/max/778/1*gQcbAlaUXNtjJi6OAUzMsg.jpeg 389w" sizes="389px" data-old-src="https://miro.medium.com/max/389/1*gQcbAlaUXNtjJi6OAUzMsg.jpeg" data-old-srcset="https://miro.medium.com/max/276/1*gQcbAlaUXNtjJi6OAUzMsg.jpeg 276w, https://miro.medium.com/max/389/1*gQcbAlaUXNtjJi6OAUzMsg.jpeg 389w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> GeForce RTX 3080 </figcaption>
</figure>
<p id="14fa" data-selectable-paragraph=""> That is why these cards have high performance. But they have an achilles heel: Whenever they have to get data from the memory used by the CPU, this happens over a set of copper traces on the computer motherboard called a PCIe bus. Try chugging water through a super thin straw. It may get to your mouth fast, but the throughput is totally inadequate. </p>
<p id="5fca" data-selectable-paragraph=""> Apples <em>Unified Memory Architecture</em> tries to solve all these problems without having the disadvantages of old school shared memory. They achieve this in the following ways: </p>
<ol>
<li id="dade" data-selectable-paragraph="">There is no special area reserved just for the CPU or just the GPU. Memory is allocated to both processors. They can both use the same memory. No copying is needed. </li>
<li id="4c61" data-selectable-paragraph="">Apple uses memory which serves both large chunks of data and serves it fast. In computer speak that is called low latency and high throughput. Thus the need to be connected to separate types of memory is removed. </li>
<li id="2508" data-selectable-paragraph="">Apple has gotten the watt usage of the GPU down, so that a relatively powerful GPU can be integrated without overheating the SoC. And ARM chips produce less heat, allowing the GPU to have a higher heat budget than a GPU on the same silicon die as an AMD or Intel CPU. </li>
</ol>
<p id="ba08" data-selectable-paragraph=""> Some will say unified memory is not entirely new. It is true that different systems have had it in the past. But then the difference in memory requirements may not have been as large. Secondly what Nvidia calls Unified Memory is not really the same thing. In the Nvidea world Unified Memory simply means that there is software and hardware which takes care of automatically copying data back and forth between the separate CPU and GPU memory. Thus from a programmers perspective Apple and Nvidia Unified Memory may look the same, but it is not the same in a physical sense. </p>
<p id="2fcb" data-selectable-paragraph=""> There is of course a tradeoff in this strategy. Getting this high bandwidth memory (big servings) require full integration which means you take away the opportunity from customers to upgrade their memory. But Apple seeks to minimize this problem by making the communication with the SSD disks so fast, that they essentially work like old fashion memory. </p>
<figure>
<div role="button" tabindex="0">
<p><img alt="Image for post" src="https://miro.medium.com/max/1668/1*IJFHpc1CrblUt09PSzaTyg.png" width="834" height="472" srcset="https://miro.medium.com/max/552/1*IJFHpc1CrblUt09PSzaTyg.png 276w, https://miro.medium.com/max/1104/1*IJFHpc1CrblUt09PSzaTyg.png 552w, https://miro.medium.com/max/1280/1*IJFHpc1CrblUt09PSzaTyg.png 640w, https://miro.medium.com/max/1400/1*IJFHpc1CrblUt09PSzaTyg.png 700w" sizes="700px" data-old-src="https://miro.medium.com/max/834/1*IJFHpc1CrblUt09PSzaTyg.png" data-old-srcset="https://miro.medium.com/max/276/1*IJFHpc1CrblUt09PSzaTyg.png 276w, https://miro.medium.com/max/552/1*IJFHpc1CrblUt09PSzaTyg.png 552w, https://miro.medium.com/max/640/1*IJFHpc1CrblUt09PSzaTyg.png 640w, https://miro.medium.com/max/700/1*IJFHpc1CrblUt09PSzaTyg.png 700w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> How Macs used GPUs before unified memory. There was even an option of having graphics cards outside the computer using a Thunderbolt 3 cable. There is some speculation that this may still be possible in the future. </figcaption>
</figure>
<h2 id="d329" data-selectable-paragraph=""> If SoCs Are So Smart, Why Dont Intel and AMD Copy This Strategy? </h2>
<p id="f5e0" data-selectable-paragraph=""> If what Apple is doing is so smart, why is not everybody doing it? To some extent they are. Other ARM chip makers are increasingly putting in specialized hardware. </p>
<p id="2bdd" data-selectable-paragraph=""> AMD has also started putting stronger GPUs on some of their chips and moving gradually toward some form of SoC with the accelerated processing units (APU) which are basically CPU cores and GPU cores placed on the same silicon die. </p>
<figure>
<div role="button" tabindex="0">
<p><img alt="Image for post" src="https://miro.medium.com/max/1800/1*vutPH0zsrwSzGgFWomL61A.jpeg" width="900" height="540" srcset="https://miro.medium.com/max/552/1*vutPH0zsrwSzGgFWomL61A.jpeg 276w, https://miro.medium.com/max/1104/1*vutPH0zsrwSzGgFWomL61A.jpeg 552w, https://miro.medium.com/max/1280/1*vutPH0zsrwSzGgFWomL61A.jpeg 640w, https://miro.medium.com/max/1400/1*vutPH0zsrwSzGgFWomL61A.jpeg 700w" sizes="700px" data-old-src="https://miro.medium.com/max/900/1*vutPH0zsrwSzGgFWomL61A.jpeg" data-old-srcset="https://miro.medium.com/max/276/1*vutPH0zsrwSzGgFWomL61A.jpeg 276w, https://miro.medium.com/max/552/1*vutPH0zsrwSzGgFWomL61A.jpeg 552w, https://miro.medium.com/max/640/1*vutPH0zsrwSzGgFWomL61A.jpeg 640w, https://miro.medium.com/max/700/1*vutPH0zsrwSzGgFWomL61A.jpeg 700w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> AMD Ryzen Accelerated Processing Unit (APU) which combines CPU and GPU (Radeon Vega) on one silicon chip. Does however not contain other co-processors, IO-controllers, or unified memory. </figcaption>
</figure>
<p id="279e" data-selectable-paragraph=""> Yet there are important reasons why they cannot do this. An SoC is essentially a whole computer on a chip. That makes it a more natural fit for an actual computer-maker, such as HP and Dell. Let me clarify with a silly car analogy: If your business model is to build and sell car engines, it would be an unusual leap to begin manufacturing and selling whole cars. </p>
<p id="04e1" data-selectable-paragraph=""> For ARM, in contrast, this isnt an issue. Computer makers such as Dell or HP could simply license ARM intellectual property and buy IP for other chips, to add whatever specialized hardware they think their SoC should have. Next, they ship the finished design over to a semiconductor foundry such as <a href="https://en.wikipedia.org/wiki/GlobalFoundries" target="_blank" rel="noopener nofollow">GlobalFoundries</a> or <a href="https://www.tsmc.com/english" target="_blank" rel="noopener nofollow">TSMC</a>, which manufactures chips for AMD and Apple today. </p>
<figure>
<div role="button" tabindex="0">
<p><img alt="Image for post" src="https://miro.medium.com/max/1496/1*d88lw8YMonKgdDWQLC1jXQ.jpeg" width="748" height="460" srcset="https://miro.medium.com/max/552/1*d88lw8YMonKgdDWQLC1jXQ.jpeg 276w, https://miro.medium.com/max/1104/1*d88lw8YMonKgdDWQLC1jXQ.jpeg 552w, https://miro.medium.com/max/1280/1*d88lw8YMonKgdDWQLC1jXQ.jpeg 640w, https://miro.medium.com/max/1400/1*d88lw8YMonKgdDWQLC1jXQ.jpeg 700w" sizes="700px" data-old-src="https://miro.medium.com/max/748/1*d88lw8YMonKgdDWQLC1jXQ.jpeg" data-old-srcset="https://miro.medium.com/max/276/1*d88lw8YMonKgdDWQLC1jXQ.jpeg 276w, https://miro.medium.com/max/552/1*d88lw8YMonKgdDWQLC1jXQ.jpeg 552w, https://miro.medium.com/max/640/1*d88lw8YMonKgdDWQLC1jXQ.jpeg 640w, https://miro.medium.com/max/700/1*d88lw8YMonKgdDWQLC1jXQ.jpeg 700w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> TSMC semiconductor foundry in Taiwan. TSMC manufactures chips for other companies such as AMD, Apple, Nvidia, and Qualcomm. </figcaption>
</figure>
<p id="a601" data-selectable-paragraph=""> Here we get a big problem with the Intel and AMD business model. Their business models are based on selling general-purpose CPUs, which people just slot onto a large PC motherboard. Thus computer-makers can simply buy motherboards, memory, CPUs, and graphics cards from different vendors and integrate them into one solution. </p>
<p id="7f77" data-selectable-paragraph=""> But we are quickly moving away from that world. In the new SoC world, you dont assemble physical components from different vendors. Instead, you assemble IP (intellectual property) from different vendors. You buy the design for graphics cards, CPUs, modems, IO controllers, and other things from different vendors and use that to design an SoC in-house. Then you get a foundry to manufacture this. </p>
<p id="2fba" data-selectable-paragraph=""> Now you got a big problem, because neither Intel, AMD, or Nvidia are going to license their intellectual property to Dell or HP for them to make an SoC for their machines. </p>
<p id="b24c" data-selectable-paragraph=""> Sure Intel and AMD may simply begin to sell whole finished SoCs. But what are these to contain? PC-makers may have different ideas of what they should contain. You potentially get a conflict between Intel, AMD, Microsoft, and PC-makers about what sort of specialized chips should be included because these will need software support. </p>
<p id="558d" data-selectable-paragraph=""> For Apple this is simple. They control the whole widget. They give you, for example, the Core ML library for developers to write <a href="https://developer.apple.com/machine-learning/" target="_blank" rel="noopener nofollow">machine learning</a> stuff. Whether Core ML runs on Apples CPU or the Neural Engine is an implementation detail developers dont have to care about. </p>
<h2 id="711f" data-selectable-paragraph=""> The fundamental challenge of making any CPU run fast </h2>
<p id="f11c" data-selectable-paragraph=""> So heterogeneous computing is part of the reason but not the sole reason. The fast general-purpose CPU cores on the M1, called Firestorm, are genuinely fast. This is a major deviation from ARM CPU cores in the past which tended to be very weak compared to AMD and Intel cores. </p>
<p id="b74c" data-selectable-paragraph=""> Firestorm, in contrast, beats most Intel cores and almost beats the fastest AMD Ryzen cores. Conventional wisdom said that was not going to happen. </p>
<p id="ab49" data-selectable-paragraph=""> Before talking about what makes Firestorm fast it helps to understand what the core idea of making a fast CPU is really about. </p>
<p id="92fc" data-selectable-paragraph=""> In principle you accomplish in a combination of two strategies: </p>
<ol>
<li id="68be" data-selectable-paragraph="">Perform more instructions in a sequence faster. </li>
<li id="5f98" data-selectable-paragraph="">Perform lots of instructions in parallel. </li>
</ol>
<p id="bd92" data-selectable-paragraph=""> Back in the 80s, it was easy. Just increase the clock frequency and the instructions would finish faster. Every clock cycle is when the computer does something. But this <em>something</em> can be quite little. Thus an instruction may require multiple clock cycles to finish because it is made up of several smaller tasks. </p>
<p id="905f" data-selectable-paragraph=""> However, today increasing the clock frequency is next to impossible. That is the whole “End of Moores Law” that people have been harping on for over a decade now. </p>
<p id="2133" data-selectable-paragraph=""> Thus it is really about executing as many instructions as possible in parallel. </p>
<h2 id="1f1b" data-selectable-paragraph=""> Multi-core or Out-of-Order processors? </h2>
<p id="9966" data-selectable-paragraph=""> There are two approaches to this. </p>
<ul>
<li id="23a9" data-selectable-paragraph="">Add more CPU cores. Each core works independent and in parallel. </li>
<li id="1299" data-selectable-paragraph="">Make each CPU core execute multiple instructions in parallel. </li>
</ul>
<p id="6553" data-selectable-paragraph=""> For a software developer, adding cores is like adding <em>threads</em>. Every CPU core is like a hardware thread. </p>
<p id="5a7a" data-selectable-paragraph=""> If you dont know what a thread is, then you can think of it as the process of carrying out a task. With two cores, a CPU can carry out two separate tasks concurrently: two threads. The tasks could be described as two separate programs stores in memory or it could actually be the same program performed twice. Each thread needs some bookkeeping, such as <em>where</em> in a sequence of program instructions the thread is currently at. Each thread may store temporary results which should be kept separate. </p>
<p id="8059" data-selectable-paragraph=""> In principle, a processor can have just one core and run multiple threads. In this case, it simply halts one thread and stores current progress before switching to another. Later it switches back. This doesnt bring much of a performance enhancement unless the thread has to frequently halt to: </p>
<ul>
<li id="e4a8" data-selectable-paragraph="">Wait for input from the user </li>
<li id="468b" data-selectable-paragraph="">Data from a slow network connection, etc. </li>
</ul>
<p id="5f6f" data-selectable-paragraph=""> Let us call these software threads. Hardware threads mean you have actual physical CPU cores at your disposal to speed up things. </p>
<figure>
<div>
<p><img alt="Image for post" src="https://miro.medium.com/max/1200/1*2mDUgCX9a49EldiCTbL6fA.png" width="600" height="377" srcset="https://miro.medium.com/max/552/1*2mDUgCX9a49EldiCTbL6fA.png 276w, https://miro.medium.com/max/1104/1*2mDUgCX9a49EldiCTbL6fA.png 552w, https://miro.medium.com/max/1200/1*2mDUgCX9a49EldiCTbL6fA.png 600w" sizes="600px" data-old-src="https://miro.medium.com/max/600/1*2mDUgCX9a49EldiCTbL6fA.png" data-old-srcset="https://miro.medium.com/max/276/1*2mDUgCX9a49EldiCTbL6fA.png 276w, https://miro.medium.com/max/552/1*2mDUgCX9a49EldiCTbL6fA.png 552w, https://miro.medium.com/max/600/1*2mDUgCX9a49EldiCTbL6fA.png 600w" />
</p>
</div>
</figure>
<p id="3d7f" data-selectable-paragraph=""> The problem with threads is that software developers have to write so called multi-threaded code. That is often difficult. In the past, this was some of the hardest code to write. However making <em>server software</em> multi-threaded tends to be easy. It is simply a matter of handling each user request on a separate thread. Thus in this case having lots of cores, is an obvious advantage. Especially for cloud services. </p>
<figure>
<div>
<p><img alt="Image for post" src="https://miro.medium.com/max/716/1*X5ZTLTHUYBdw0t25TemHcQ.png" width="358" height="309" srcset="https://miro.medium.com/max/552/1*X5ZTLTHUYBdw0t25TemHcQ.png 276w, https://miro.medium.com/max/716/1*X5ZTLTHUYBdw0t25TemHcQ.png 358w" sizes="358px" data-old-src="https://miro.medium.com/max/358/1*X5ZTLTHUYBdw0t25TemHcQ.png" data-old-srcset="https://miro.medium.com/max/276/1*X5ZTLTHUYBdw0t25TemHcQ.png 276w, https://miro.medium.com/max/358/1*X5ZTLTHUYBdw0t25TemHcQ.png 358w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> The Ampere Altra Max ARM CPU with 128 cores designed for cloud computing, where a lot of hardware threads is a benefit. </figcaption>
</figure>
<p id="f30f" data-selectable-paragraph=""> That is the reason why you see ARM CPU-makers such as Ampere making CPUs such as the <a href="https://www.networkworld.com/article/3564514/ampere-announces-128-core-arm-server-processor.html" target="_blank" rel="noopener nofollow">Altra Max</a> which has a crazy 128 cores. This chip is specifically made for the cloud. You dont need crazy single-core performance, because in the cloud it is all about having as many threads as possible per watt to handle as many concurrent users as possible. </p>
<p id="e162" data-selectable-paragraph=""> Read more about ARM CPUs with many cores: <a href="https://erik-engheim.medium.com/are-servers-next-for-apple-7992213d72c9" target="_blank" rel="noopener">Are Servers Next for Apple?</a>
</p>
<p id="6ead" data-selectable-paragraph=""> Apple, in contrast, is on the complete opposite end of the spectrum. They make single-user devices. Lots of threads is not an advantage. Their devices are used for gaming, video editing, development, etc. They want desktops with beautiful responsive graphics and animations. </p>
<p id="e3ca" data-selectable-paragraph=""> Desktop software is generally not made to utilize lots of cores. For example, computer games will likely benefit from eight cores, but something like 128 cores would be a total waste. Instead, you would want fewer but more powerful cores. </p>
<h2 id="8ac1" data-selectable-paragraph=""> How Out-of-Order Execution Works </h2>
<p id="4cc9" data-selectable-paragraph=""> To make a more powerful core we need it to execute more instructions in parallel. <a href="https://en.wikipedia.org/wiki/Out-of-order_execution" target="_blank" rel="noopener nofollow">Out-of-Order execution</a> (OoOE) is a way to execute more instructions in parallel but without exposing that capability as multiple threads. </p>
<p id="4f36" data-selectable-paragraph=""> For an alternative solution read: <a href="https://erik-engheim.medium.com/very-long-instruction-word-microprocessors-17262def3037" target="_blank" rel="noopener">Very Long Instruction Word Microprocessors</a>
</p>
<p id="db59" data-selectable-paragraph=""> Developers dont have to code their software specifically to take advantage of OoOE. Seen from the developers perspective it just looks like each core runs faster. Please note it is not a direct alternative to hardware threads. You want to use both, depending on the particular problem you are solving. </p>
<p id="2402" data-selectable-paragraph=""> To understand how OoOE works, you need to understand some things about memory. Asking for data in one particular memory location is slow. But the CPU is capable of getting getting many bytes at the same time. Hence getting 1 specific byte in memory, takes no less time than getting 100 more bytes following that byte in memory. </p>
<figure>
<div role="button" tabindex="0">
<p><img alt="Image for post" src="https://miro.medium.com/max/1980/1*IbuGfelqOOtcyX8NwTh-tw.jpeg" width="990" height="556" srcset="https://miro.medium.com/max/552/1*IbuGfelqOOtcyX8NwTh-tw.jpeg 276w, https://miro.medium.com/max/1104/1*IbuGfelqOOtcyX8NwTh-tw.jpeg 552w, https://miro.medium.com/max/1280/1*IbuGfelqOOtcyX8NwTh-tw.jpeg 640w, https://miro.medium.com/max/1400/1*IbuGfelqOOtcyX8NwTh-tw.jpeg 700w" sizes="700px" data-old-src="https://miro.medium.com/max/990/1*IbuGfelqOOtcyX8NwTh-tw.jpeg" data-old-srcset="https://miro.medium.com/max/276/1*IbuGfelqOOtcyX8NwTh-tw.jpeg 276w, https://miro.medium.com/max/552/1*IbuGfelqOOtcyX8NwTh-tw.jpeg 552w, https://miro.medium.com/max/640/1*IbuGfelqOOtcyX8NwTh-tw.jpeg 640w, https://miro.medium.com/max/700/1*IbuGfelqOOtcyX8NwTh-tw.jpeg 700w" />
</p>
</div>
<figcaption data-selectable-paragraph=""> Robot pickers in a Warehouse for Komplett.no, an online store in Norway </figcaption>
</figure>
<p id="170f" data-selectable-paragraph=""> Here is an analogy: Consider pickers in a warehouse. Could be the little red robots in the picture above. Moving to multiple locations spread all over takes time. But picking up items from slots adjacent to each other is quick. Computer memory is very similar. You can quickly fetch content of memory cells which are adjecent. </p>
<p id="4d52" data-selectable-paragraph=""> Data is sent across what we call a databus. You can think of it as a road or pipe between memory and different parts of the CPU where data gets pushed through. In reality, it is of course just some copper tracks conducting electricity. If the databus is wide enough you can get multiple bytes at the same time. </p>
<p id="2053" data-selectable-paragraph=""> Thus CPUs get a whole chunk of instructions at a time to execute. But they are written to be executed one after the other. Modern microprocessors do what we call Out-of-Order execution (OoOE). </p>
<p id="de65" data-selectable-paragraph=""> That means they are able to analyze a buffer of instructions quickly and see which ones depend on which. Look at the simple example below: </p>
<pre><span id="4de2" data-selectable-paragraph="">01: mul r1, r2, r3 // r1 ← r2 × r3<br/>02: add r4, r1, 5 // r4 ← r1 + 5<br/>03: add r6, r2, 1 // r6 ← r2 + 1</span></pre>
<p id="d5a8" data-selectable-paragraph=""> Multiplication tends to be a slow process. So say it takes multiple clock cycles to perform. The second instruction will simply have to wait because its calculation depends on knowing the result that gets put into the <code>r1</code> register. </p>
<p id="d3b8" data-selectable-paragraph=""> However, the third instruction at line <code>03</code> doesnt depend on calculations from previous instructions. Hence an Out-of-Order processor can begin calculating this instruction in parallel. </p>
<p id="deba" data-selectable-paragraph=""> However more realistically we are talking about hundreds of instructions. The CPU is able to figure out all the dependencies between these instructions. </p>
<p id="b30b" data-selectable-paragraph=""> It analyses the instructions by looking at the inputs to each instruction. Do the inputs depend on output from one or more other instructions? By input and output, we mean registers containing results from previous calculations. </p>
<p id="d5b1" data-selectable-paragraph=""> For example, the <code>add r4, r1, 5</code> instruction depends on input from <code>r1</code> which is produced by <code>mul r1, r2, r3</code> . We can chain together these relationships into long elaborate graphs that the CPU can work through. The nodes are the instructions and the edges are the registers connecting them. </p>
<p id="621d" data-selectable-paragraph=""> The CPU can analyze such a graph of nodes and determine which instructions it can perform in parallel and where it needs to wait for the results from multiple dependent calculations before carrying on. </p>
<p id="46ee" data-selectable-paragraph=""> Many instructions will finish early but we cannot make their results official. We cannot commit them; otherwise, we supply the result in the wrong order. To the rest of the world, it has to look as if the instructions were carried out in the same sequence as they were issued. </p>
<p id="8815" data-selectable-paragraph=""> Like a stack, the CPU will keep popping done instructions from the top, until hitting an instruction that is not done. </p>
<p id="0770" data-selectable-paragraph=""> Basically you got two forms of parallelism: One that the developer must deal with explicitly when writing code and one that is entirely transparent. Of course the latter relies on lots of transistors on the CPU dedicated to Out-of-Order Execution magic. This is not a viable solution for small CPUs with few transistors. </p>
<p id="01ee" data-selectable-paragraph=""> It is the superior Out-of-Order execution that is making the Firestorm cores on the M1 kick ass and take names. It is in fact much stronger than anything from Intel or AMD and they may never be able to catch up. To understand why, we need to get into some more technical details. </p>
<h2 id="52fe" data-selectable-paragraph=""> ISA Instructions vs Micro-Operations </h2>
<p id="c057" data-selectable-paragraph=""> Previously I skipped some details on how Out-of-Order Execution (OoOE) works. </p>
<p id="5a6b" data-selectable-paragraph=""> Programs loaded into memory are made up of machine code instructions designed for specific Instruction-Set Architectures (ISA) such as x86, ARM, PowerPC, 68K, MIPS, AVR etc. </p>
<p id="c8b7" data-selectable-paragraph=""> For instance the x86 instruction to fetch a number from memory location 24 into a register you may write: </p>
<pre><span id="bc03" data-selectable-paragraph="">MOV ax, 24</span></pre>
<p id="c6bc" data-selectable-paragraph=""> x86 have registers named <code>ax</code>, <code>bx</code>, <code>cx</code> and <code>dx</code>(remember these are the memory cells inside the CPU you perform operations on). However the equivalent ARM instruction would look like this: </p>
<pre><span id="64d0" data-selectable-paragraph="">LDR r0, 24</span></pre>
<p id="4cd1" data-selectable-paragraph=""> AMD and Intel processors understand the x86 ISA, while Apple Silicon chips, such as M1, understand the ARM Instruction-Set Architecture (ISA). </p>
<p id="2266" data-selectable-paragraph=""> However internally the CPU works on an entirely different instruction-set invisible to the programmer. We call these micro-operations (micro-ops or μops). These are the instructions the Out-of-Order hardware works with. </p>
<p id="a998" data-selectable-paragraph=""> But why cant the OoOE hardware work with regular machine code instructions? Because the CPU needs to attach lots of different information to the instructions to be able to run them in parallel. </p>
<p id="8d96" data-selectable-paragraph=""> Thus while a normal ARM instruction may be 32-bit (32 digits of 0 and 1), a micro-op can be much longer. It contains information about its order. </p>
<pre><span id="a55d" data-selectable-paragraph="">01: mul r1, r2, r3 // r1 ← r2 × r3<br/>02: add r4, r1, 5 // r4 ← r1 + 5<br/>03: add r1, r2, 1 // r1 ← r2 + 1</span></pre>
<p id="0c5e" data-selectable-paragraph=""> Consider if we run instruction <code>01: mul</code> and <code>03: add</code> in parallel. Both store their result in register <code>r1</code> . If we write the result of instruction <code>03: add</code> before <code>01: mul</code>, then instruction <code>02: add</code> will get the wrong input. Hence it is very important to keep track of instruction order. The order is stored with each micro-op. It also stores e.g. that instruction <code>02: add</code> depends on output from <code>01: mul</code>. </p>
<p id="64b5" data-selectable-paragraph=""> That is why we cannot have programs written using micro-ops. They contain lots of details specific to the internals of each microprocessor. Two ARM processors could have very different micro-ops internally. </p>
<p id="31fb" data-selectable-paragraph=""> Read more about CPUs with micro-ops like instructions: <a href="https://erik-engheim.medium.com/very-long-instruction-word-microprocessors-17262def3037" target="_blank" rel="noopener">Very Long Instruction Word Microprocessors.</a>
</p>
<p id="3180" data-selectable-paragraph=""> Also, micro-ops are usually easier to work with for the CPU. Why? Because they each do <em>one</em> simple limited task. Regular ISA instructions can be more complex causing a bunch of stuff to happen and thus frequently translate to multiple micro-ops. Thus the name “micro” comes from the small task they do, not the length of the instruction in memory. </p>
<p id="ff1f" data-selectable-paragraph=""> For CISC CPUs there is usually no alternative but to use micro-ops otherwise the large complex CISC instructions would make pipelines and OoOE next to impossible to achieve. </p>
<p id="4d71" data-selectable-paragraph=""> Read more: <a href="https://erik-engheim.medium.com/microprocessor-pipelining-f63df4ee60cf" target="_blank" rel="noopener">Why Pipeline a Microprocessor?</a>
</p>
<p id="9da7" data-selectable-paragraph=""> RISC CPUs have a choice. So, for example, smaller ARM CPUs dont use micro-ops at all. But that also means they cannot do things such as OoOE. </p>
</div>
<div>
<h2 id="b27b" data-selectable-paragraph=""> Why is AMD and Intel Out-of-Order execution inferior to M1? </h2>
<p id="cd20" data-selectable-paragraph=""> But you wonder, why does any of this matter? Why is this detail important to know to understand why Apple has the upper hand on AMD and Intel? </p>
<p id="8286" data-selectable-paragraph=""> It is because the ability to run fast depends on how quickly you can fill up a buffer of micro-operations. If you got a large buffer then the OoOE hardware will have an easier time to locate two or more instructions which it can run in parallel. But there is no point in having a large instruction buffer if you cannot refill it fast enough after instructions get picked and executed. </p>
<p id="5cf7" data-selectable-paragraph=""> The ability to refill the instruction buffer quickly relies on the ability to quickly chop machine code instruction into micro-ops. The hardware units that does this are called <em>decoders</em>. </p>
<p id="d0d8" data-selectable-paragraph=""> And finally we get to the killer feature of the M1. The biggest and meanest Intel and AMD microprocessor have a total of four decoders busy cutting machine code instructions into micro-ops. </p>
<p id="8622" data-selectable-paragraph=""> But this is no match for the M1, which has an absolutely unheard of number of decoders: Eight. Significantly more than anybody else in the industry. That means it can fill up the instruction buffer much quicker. </p>
<p id="0669" data-selectable-paragraph=""> To deal with this the M1 also has an instruction buffer which is 3x times larger than what is normal in the industry. </p>
<h2 id="59ff" data-selectable-paragraph=""> Why cant Intel and AMD add more instruction decoders? </h2>
<p id="4735" data-selectable-paragraph=""> This is where we finally see the revenge of RISC, and where the fact that the M1 Firestorm core has an ARM RISC architecture begins to matter. </p>
<p id="fca4" data-selectable-paragraph=""> You see, an x86 instruction can be anywhere from 115 bytes long. RISC instructions have fixed length. Every ARM instruction is 4 bytes long. Why is that relevant in this case? </p>
<p id="d102" data-selectable-paragraph=""> Because splitting up a stream of bytes into instructions to feed into eight different decoders in parallel becomes trivial if every instruction has the same length. </p>
<p id="b4e4" data-selectable-paragraph=""> However, on an x86 CPU, the decoders have no clue <em>where</em> the next instruction starts. It has to actually analyze each instruction in order to see how long it is. </p>
<p id="e842" data-selectable-paragraph=""> The brute force way Intel and AMD deal with this is by simply attempting to decode instructions at every possible starting point. That means x86 chips have to deal with lots of wrong guesses and mistakes which has to be discarded. This creates such a convoluted and complicated decoder stage that it is really hard to add more decoders. But for Apple, it is trivial in comparison to keep adding more. </p>
<p id="499d" data-selectable-paragraph=""> In fact, adding more causes so many other problems that four decoders according to AMD itself is basically an upper limit for them. </p>
<p id="bb2e" data-selectable-paragraph="">
<mark>This is what allows the M1 Firestorm cores to essentially process</mark> <mark><strong>twice</strong></mark> <mark>as many instructions as AMD and Intel CPUs at the</mark> <mark><em>same</em></mark> <mark>clock frequency.</mark>
</p>
<p id="327e" data-selectable-paragraph=""> One could argue as a counterpoint that CISC instructions turn into more micro-ops. For instance if every x86 instruction turned into 2 micro-ops while every ARM instruction turned into 1 micro-op, then four x86 decoders would produce the same number of micro-ops per clock cycle as an ARM CPU with 8 decoders. </p>
<p id="b2f1" data-selectable-paragraph=""> Except this is not the case in the real world. Highly optimized x86 code rarely uses complex CISC instructions, which would translate into many micro-ops. In fact most will only translate into 1 micro-op. </p>
<p id="8792" data-selectable-paragraph=""> However all these simple x86 instructions dont help Intel or AMD. Because even if those 15 byte long instructions are rare, the decoders have to be made to handle them. This incurs complexity that blocks AMD and Intel from adding more decoders. </p>
<h2 id="26e4" data-selectable-paragraph=""> But AMDs Zen3 cores are still faster right? </h2>
<p id="7106" data-selectable-paragraph=""> As far as I remember from performance benchmarks, the newest AMD CPU cores, the ones called Zen3 are slightly faster than Firestorm cores. But here is the kicker: That only happens because the Zen3 cores are clocked at 5 GHz. Firestorm cores are clocked at 3.2 GHz. The Zen3 is just barely squeezing past Firestorm despite having almost 60% higher clock frequency. </p>
<p id="da9f" data-selectable-paragraph=""> So why doesnt Apple increase the clock frequency too? Because higher clock frequency makes the chips run hotter. That is one of Apples key selling points. Their computers — unlike Intel and AMD offerings — barely need cooling. </p>
<p id="f640" data-selectable-paragraph=""> In essence, one could say Firestorm cores really are superior to Zen3 cores. Zen3 only manages to stay in the game by drawing a lot more current and getting a lot hotter. Something Apple simply chooses not to do. </p>
<p id="6302" data-selectable-paragraph=""> If Apple wants higher performance they are simply going to add more cores. That lets them keep watt usage down while offering more performance. </p>
<h2 id="e95d" data-selectable-paragraph=""> The future </h2>
<p id="9450" data-selectable-paragraph=""> It seems AMD and Intel have painted themselves into a corner on two fronts: </p>
<ul>
<li id="9af9" data-selectable-paragraph="">They dont have a business model that makes it easy to pursue heterogeneous computing and SoC designs. </li>
<li id="7c75" data-selectable-paragraph="">Their legacy x86 CISC instruction set is coming back to haunt them, making it hard to improve OoO performance. </li>
</ul>
<p id="8380" data-selectable-paragraph=""> Read more: <a href="https://erik-engheim.medium.com/intel-arm-and-the-innovators-dilemma-a9ebd20ea200" target="_blank" rel="noopener">Intel, ARM and the Innovators Dilemma</a>
</p>
<p id="0ff6" data-selectable-paragraph=""> It doesnt mean game over. They can increase the clock frequency and use more cooling, throw in more cores, beef up the CPU caches, etc. But they are both at a disadvantage. Intel is in the worst situation, as their cores are already soundly beaten by Firestorm, and they have weak GPUs to integrate with an SoC solution. </p>
<p id="cd04" data-selectable-paragraph=""> The problem with throwing in more cores is that for typical desktop workloads you reach diminishing returns with too many cores. Sure lots of cores are great for servers. </p>
<p id="2a88" data-selectable-paragraph=""> However here companies such as Amazon and Ampere are attacking with monster CPUs with 128 cores. This is like fighting the western and eastern front at the same time. </p>
<p id="7fce" data-selectable-paragraph=""> But fortunately for AMD and Intel, Apple doesnt sell their chips on the market. So PC users will simply have to put up with whatever they are offering. PC users may jump ship, but that is a slow process. You dont leave immediately a platform you are heavily invested in. </p>
<p id="731a" data-selectable-paragraph=""> But young professionals, with money to burn without too deep investments in any platform, may increasingly turn to Apple in the future, beefing up their hold on the premium market and consequently their share of the total profit in the PC market. </p>
</div>
</div>
</div>