Ordering Instructions around Dependencies

Luckily, there are solutions to the problem of dependencies in code; one tackles the problem in hardware, the other tackles the problem in software.

The software compiler is responsible for producing the assembly code that is sent to the CPU for execution.   Thus, with an intimate knowledge of the inner workings of the CPU, the compiler can, generally speaking, produce code that minimizes data dependencies.

There are microprocessor architectures that are dependent entirely on the compiler to extract parallelism, on the instruction level, while avoiding dependencies as much as possible.  These architectures are known as in-order microprocessors.

In-Order Architectures

As the name implies, an in-order microprocessor can only execute instructions in the order that they are sent to the CPU.   At best, the CPU can execute multiple instructions in parallel, but it has no ability to reorder the instructions to suit its needs better.

If you have a good enough compiler, then an in-order microprocessor should be just fine.   There are a couple of key limitations, however:

1.      Binaries Compiled for in-order architectures are very architecture specific

Although both the Athlon 64 and the Pentium 4 are fully able to run x86 code, they contain vastly different microarchitectures, with different execution units and very different things that they are “good” at.   If both of the aforementioned chips depended entirely on the compiler to extract parallelism and maximize performance, one would most definitely suffer.   You could always have two versions of every program, but that tends to get large and messy - especially from an update/patches standpoint.   The compiler has to be intimately aware of the architecture that it’s compiling for, which works in cases like a game console where you don’t have multiple vendors providing differently architected CPUs with a common ISA, yet not so well when you look at something like the desktop x86 market.

2.      Unpredictable memory latencies

Cache is a good thing, most of the time.   Cache on a microprocessor does its best to keep frequently used data at hand, so it can be made available to the CPU at very low latencies.   The problem is that cache adds a level of unpredictability to how long it will take to get data from memory.   A cache hit could mean that your data will be ready in 10 - 20 cycles.  A cache miss could mean that it’ll be hundreds of cycles.   With an in-order microprocessor, you can’t reorder instructions based on data availability, so if data isn’t available in cache and the CPU has to wait longer to pull it from main memory, the entire CPU has to sit and wait until that data is brought in from main memory.   Even if other instructions could be executed, an in-order microprocessor has no logic to effectively handle the on-the-fly reordering of instructions to get around unpredictable memory latencies.

If you can find a way around the limitations of an in-order architecture, there are some very tangible benefits:

1.      A much simplified microprocessor

Out-of-Order microprocessors have a significant amount of complexity added to them in order to deal with on-the-fly reordering of instructions.  We will talk about them in greater detail in the next section.   By moving this complexity to the software/compiler side, you greatly reduce the complexity of your microprocessor and save your transistor budget for other things that can yield better performance benefits.   Less complexity also means less power consumed and heat dissipated.

2.      Shorter pipeline

In order to deal with the reordering of instructions, generally speaking, a number of pipeline stages have to be added to the architecture, resulting in higher power consumption and demands for a more accurate branch predictor (thanks to an even higher branch prediction penalty).   While the impact on pipeline depth isn’t as big of a deal for longer pipelined designs, for shorter designs, the increase can be 40% or more.

Historically, the idea of a simple in-order core has been one that’s been abandoned in favor of the obvious alternative: an out-of-order architecture.

Cell's In-Order Architecture Out-of-Order Architectures
Comments Locked

70 Comments

View All Comments

  • faboloso112 - Thursday, March 17, 2005 - link

    ahh i love bedtime stories!
    great read...VERY informative!
  • ksherman - Thursday, March 17, 2005 - link

    sweet article! way over my head, but there were some parts that were dropped down to my level of understanding. Leave it to anand to tell the real story. It will be interesting to see how willing some companies will be to accomidate Sony's ratical processor... bu tas long as theirs money... Do you think that it is possible to (down the road) flop a x86 chip in place of the PPE? wouldn't hat make the Cell compatible with the current processing standards?
  • ProviaFan - Thursday, March 17, 2005 - link

    Describing this as a "sit down read" type of article makes me want to print it out to put it in the magazine rack, because I don't have a laptop + 802.11g to peruse AnandTech while I'm, er... ;)
  • xsilver - Thursday, March 17, 2005 - link

    nice, definitley one of those "sit down reads".... some serious shiznit ;)
  • cosmotic - Thursday, March 17, 2005 - link

    OMG! FIRST POST LOL ROFL LMAO OMG!!! LOOK WHOS COOL!!!
  • Fricardo - Thursday, March 17, 2005 - link

    Finally! Thanks guys.
  • Bawl - Saturday, January 25, 2014 - link

    I just love this deep analysis of one of the most mist-understanding processor of the last decade.

    Too bad that after spending more than a half-of-billion dollars, SonyThoshibaIBM didn't release the presumably outstanding CellTwo.
  • Ferrx - Sunday, December 20, 2015 - link

    Hi, can you help me to understand this ? I don't understand at all about these.
    _______ _________ ______
    |Decode| | Execute | | Write |
    ----------- ---------------- -----------
    | I1 | I2 | | | | | | | |
    | I3 | I4 | | I1 | I2 | | | | |
    | I3 | I4 | | I1 | | | | I2 | |
    | | I4 | | | | | | I1 | I3 |
    | I5 | I6 | | | | I4 | | I4 | |
    | | I6 | | | I5 | | | I5 | |
    | | | | | I6 | | | I6 | |
    _______ _________ ______

    In "Decode", each row has 2 columns. What do First and Second Column mean ?
    same as "Write"
    And in "Execute, each row has 3 columns. What do First, Second and Third column mean ?
    And how is the process ? (The current table is about "In-Order Issue with Out-of-Order Completion").

    I've read it many times, in the "Instruction Level Parallelism". But I still don't have any idea about it.
  • Ferrx - Sunday, December 20, 2015 - link

    Hi, can you help me to understand this ? I don't understand at all about these.
    _______   _________   ______
    |Decode|   | Execute |   | Write |
    -----------   ----------------   -----------
    | I1 | I2 |   | | | |  | | |
    | I3 | I4 |   | I1 | I2 | | | | |
    | I3 | I4 | | I1 | | | | I2 | |
    | | I4 | | | | | | I1 | I3 |
    | I5 | I6 | | | | I4 | | I4 | |
    | | I6 | | | I5 | | | I5 | |
    | | | | | I6 | | | I6 | |
    _______ _________ ______

    In "Decode", each row has 2 columns. What do First and Second Column mean ?
    same as "Write"
    And in "Execute, each row has 3 columns. What do First, Second and Third column mean ?
    And how is the process ? (The current table is about "In-Order Issue with Out-of-Order Completion").
    I've read it many times, in the "Instruction Level Parallelism". But I still don't have any idea about it.
  • Ferrx - Sunday, December 20, 2015 - link

    Aww... Can't do tab-'ing' 0__0

Log in

Don't have an account? Sign up now