COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort...

15
COMP-25212 Multithreading

Transcript of COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort...

Page 1: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

COMP-25212

Multithreading

Page 2: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

Coarse Grain Multithreading

• Minimal pipeline changes– Need to abort instructions in “shadow” of miss– Resume instruction stream to recover

• Good to compensate for infrequent, but expensive pipeline disruption

Page 3: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

CS25212 Fine Grain Multithreading

• Learning Objectives:– To be able to describe a fine grain multithreading

implementation– To be able to describe performance characteristics– To be able to describe Simultaneous

Multithreading implementations

Page 4: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

Fine-Grain Multithreading

• Switch CPU Threads with minimal (zero?) overhead

• Multithreading now helps resolve fine-grain dependencies (e.g. forwarding?)

1 2 3 4 5 6 7

Inst a IF ID EX MEM WB

Inst M IF ID EX MEM WB

Inst b IF ID EX MEM WB

Inst N IF ID EX MEM

Inst c IF ID EX

Inst P IF ID

Page 5: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

1 2 3 4 5 6 7

Inst a IF ID EX MEM WB

Inst M IF ID EX MEM WB

Inst b IF ID EX MEM WB

Inst N IF ID EX MEM

Inst c IF ID EX

Inst P IF ID

Fine Grain Multithreading

• What about cache misses?

• This has the advantage of simplicity

4 5 6 7

M MISS

EX MEM WB

ID

IF ID EX MEM

IF ID

4 5 6 7

M MISS Miss Miss WB

EX MEM WB

ID (ID) (ID) EX

IF ID EX MEM

IF (IF) (IF)

IF ID

Page 6: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

Fine Grain Multithreading

• Alternatively, if 1 CPU thread stalled, issue every clock from alternate thread

1 2 3 4 5 6 7

Inst a IF ID EX M-MISS Miss Miss WB

Inst M IF ID EX MEM WB

Inst b IF ID (ID) (ID) EX

Inst N IF ID EX MEM

Inst P IF ID EX

Inst Q IF ID

• Fine-grain dependency assistance?• Other comments?

Page 7: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

CPU Support for Fine Grain MT

Data Cache

Fetch Logic

Fetch Logic

Decode Logic

Fetch Logic

Exec Logic

Fetch Logic

Mem

Logic

Write Logic

Inst Cache

PCA

PCB

VA MappingA

VA MappingB

AddressTranslation

GPRsA

GPRsB

Page 8: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

PCA

PCB

Simultaneous Multi-Threading

“permit different threads to occupy the same pipeline stage at the same time”

• This makes most sense with superscalar issue

Inst Issue Logic

Fetch Logic

Decode+

Registers

Inst Cache Data Cache

Fetch Logic

Mem

Logic

Write Logic

Page 9: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

Simultaneous MultiThreading

• Let’s look simply at instruction issue:1 2 3 4 5 6 7 8 9 10

Inst a IF ID EX MEM WB

Inst b IF ID EX MEM WB

Inst M IF ID EX MEM WB

Inst N IF ID EX MEM WB

Inst c IF ID EX MEM WB

Inst P IF ID EX MEM WB

Inst Q IF ID EX MEM WB

Inst d IF ID EX MEM WB

Inst e IF ID EX MEM WB

Inst R IF ID EX MEM WB

Page 10: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

SMT issues

• Asymmetric pipeline stall– One part of pipeline stalls – we want other

pipeline to continue• Overtaking – want unstalled thread to make

progress• Pipeline overcrowding – may need extra wide

pipeline registers (why?)• Existing implementations (mainly) on O-o-O,

register renamed architectures

Page 11: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

How Far Can SMT go?

• From Intel Core i7 description:

From Intel publication 248966-020

Page 12: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

Core i7 Instruction Issue Logic

• Alternate clock cycles to alternate CPU threads• Out-of-Order engine supports up to 128 uOps

Page 13: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

SMT: Glimpse Into The Future?

• Scout threads?– A thread to prefetch memory – reduce cache miss

overhead

• Speculative threads?– Allow a thread to execute speculatively way past

branch/jump/call/miss/etc– Needs revised O-o-O logic– Needs and extra memory support– See Transactional Memory

Page 14: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

CPU Multithreading Summary

• A cost-effective way of finding additional parallelism for the CPU pipeline

• Available in x86, Itanium, Power and SPARC• (Most architectures) Present additional CPU

thread as additional CPU to Operating System• Operating Systems Beware!!! (why?)

Page 15: COMP-25212 Multithreading. Coarse Grain Multithreading Minimal pipeline changes – Need to abort instructions in “shadow” of miss – Resume instruction.

But…

• Performance problems with multithreading?

a) ………………..

b) ………………..

c) ………………..