Docsity

Basic Instructions Level Parallelism in Computer Architecture | CS 6290, Study notes of Computer Science

Partial preview of the text

Download Basic Instructions Level Parallelism in Computer Architecture | CS 6290 and more Study notes Computer Science in PDF only on Docsity!

CS 6290

Instruction Level Parallelism

Instruction Level Parallelism (ILP) • Basic idea:

Execute several instructions in parallel

  • We already do pipelining…
    • But it can only push thtough at most 1 inst/cycle
      • We want multiple instr/cycle
        • Yes, it gets a bit complicated

•More transistors/logic

  • That’s how we got from 486 (pipelined)

to Pentium and beyond

It’s legal if we don’t get caught… • How about pipelining?

  • already breaks the “rules”

•we fetch I2 before I1 has finished

  • Parallelism exists in that we perform different

operations (fetch, decode, …) on severaldifferent instructions in parallel– as mentioned, limit of 1 IPC

Define “not get caught” • Program executes correctly• Ok, what’s “correct”?

  • As defined by the ISA– Same processor state (registers, PC, memory) as

if you had executed one-at-a-time

•You can squash instructions that don’t correspond to

the “correct” execution (ex. misfetched instructionsfollowing a taken branch, instructions after a pagefault)

Illusion of Sequentiality • So long as everything looks OK to the outside

world you can do whatever you want!– “Outside Appearance” = “Architecture” (ISA)– “Whatever you want” = “Microarchitecture”–

μ

Arch basically includes everything not explicitly defined in the ISA

•pipelining, caches, branch prediction, etc.

Back to ILP… But how? • Simple ILP recipe

  • Read and decode a few instructions each cycle

•can’t execute > 1 IPC if we’re not fetching > 1 IPC

  • If instructions are independent, do them at the

same time

  • If not, do them one at a time

Ex. Original Pentium

Fetch Decode

Decode

Decode

Execute

ExecuteWriteback

Writeback

Decode up to 2 insts

Read operands andCheck dependencies

Fetch up to 32 bytes

Repeat Example for Pentium-likeCPU • A: ADD R1 = R2 + R3• B: SUB R4 = R1 – R5• C: XOR R6 = R7 ^ R8• D: Store R

Æ

0[R4]

• E: MUL R3 = R5 * R9• F: ADD R7 = R1 + R6• G: SHL R8 = R7 << R

Scheduling • Central problem to ILP processing

  • need to determine when parallelism (independent

instructions) exists

  • in Pentium example, decode stage checks for

multiple conditions:

•is there a data dependency?

  • does one instruction generate a value needed by the other?– do both instructions write to the same register? •is there a structural dependency? - most CPUs only have one divider, so two divides cannot

execute at the same time

Scheduling • How many instructions are we looking for?

  • 3-6 is typical today– A CPU that can ideally* do N instrs per cycle

is called “N-way superscalar”, “N-issue superscalar”, orsimply “N-way”, “N-issue” or “N-wide”

•*Peak execution bandwidth•This “N” is also called the “issue width”

Data Dependencies • Register dependencies

  • RAW, WAR, WAW, based on register

number

  • Memory dependencies
    • Based on memory

address

  • This is harder

•Register names known at decode•Memory addresses not known until execute

Hazards • When two instructions that have one or more

dependences between them occur closeenough that changing the instruction orderwill change the outcome of the program

  • Not all dependencies lead to hazards!

Dynamic (Out-of-Order) Scheduling

Program code I1: ADD R1, R2, R3I2: SUB R4, R1, R5I3: AND R6, R1, R7I4: OR R8, R2, R6I5: XOR R10, R2, R

  • Cycle 1
    • Operands ready? I1, I5.– Start I1, I5.
      • Cycle 2
        • Operands ready? I2, I3.– Start I2,I3.
          • Window size (W):

how many instructions ahead do we look.– Do not confuse with “issue width” (N).– E.g. a 4-issue out-of-order processor can have a 128-entry

window (it can look at up to 128 instructions at a time).

Ordering?^ • In previous example, I5 executed before I2, I

and I4!

  • How to maintain the illusion of sequentiality?

5s

30s

5s

5s Hands toll-boothagent a $100 bill;takes a while tocount the change

One-at-a-time = 45s

With a “4-Issue” Toll Booth

L1 L2 L3 L

OOO = 30s