Docsity

Parallel Processing - Computation Structures - Lecture Slides, Slides of Computer Fundamentals

Toggle sidebar
bg1
L24– Parallel Processing 1
6.004 Spring 2009 5/7/09
Parallel Processing
modified 5/4/09 10:08 L24– Parallel Processing 2
6.004 Spring 2009 5/7/09
The Home Stretch
TODAY 5/7: Lab 8 (LAST!) due
Friday 5/8 section: LAST QUIZ (#5)!
Tu 5/12: Wrapup (LAST!) Lecture!
Wednesday 5/13:
NO SECTION MEETINGS!
Optional DESIGN PROJECT due
ALL (late) Assignments due
Immense Satisfaction/Rejoicing/Relief/Celebration/Wild
Partying.
L24– Parallel Processing 3
6.004 Spring 2009 5/7/09
Taking a step back
Dynamic
Execution Path
Static Code
Path Length = number of instructions along path
aka “Thread of Execution”
loop:
LD(n, r1)
CMPLT(r31, r1, r2)
BF(r2, done)
LD(r, r3)
LD(n,r1)
MUL(r1, r3, r3)
ST(r3, r)
LD(n,r1)
SUBC(r1, 1, r1)
ST(r1, n)
BR(loop)
done:
L24– Parallel Processing 4
6.004 Spring 2009 5/7/09
We have been building machines to execute
one thread (quickly)
Beta
Processor Memory
Execution Thread
Path Length x Clocks-per-Instruction
Time =
Clocks-per-second
pf3
pf4
pf5

Partial preview of the text

Download Parallel Processing - Computation Structures - Lecture Slides and more Slides Computer Fundamentals in PDF only on Docsity!

L24– Parallel Processing 1

5/7/

Parallel Processing

modified 5/4/09 10:

L24– Parallel Processing 2

6.004 Spring 2009

5/7/

The Home Stretch

TODAY 5/7: Lab 8 (LAST!) dueFriday 5/8 section: LAST QUIZ (#5)!Tu 5/12:

Wrapup (LAST!) Lecture!

Wednesday 5/13:

NO SECTION MEETINGS!

Optional DESIGN PROJECT due

ALL (late) Assignments due

Immense Satisfaction/Rejoicing/Relief/Celebration/WildPartying.

L24– Parallel Processing 3

5/7/

Taking a step back

Dynamic

Execution Path

Static Code

Path Length = number of instructions along path

aka “Thread of Execution”

loop:

LD(n, r1)CMPLT(r31, r1, r2)BF(r2, done)LD(r, r3)LD(n,r1)MUL(r1, r3, r3)ST(r3, r)LD(n,r1)SUBC(r1, 1, r1)ST(r1, n)

BR(loop)

done:

L24– Parallel Processing 4

6.004 Spring 2009

5/7/

We have been building machines to execute

one thread (quickly)

Beta

Processor

Memory

Execution Thread

Path Length x Clocks-per-Instruction

Time

Clocks-per-second

L24– Parallel Processing 5

5/7/

Can we make CPI < 1?

Two Places to Find Parallelism

Instruction Level (ILP) –

Fetch and issue

groups of independent instructions within athread of execution

Thread Level (TLP)

Simultaneously execute

multiple execution streams

…Implies we can complete

more than one instruction each clock cycle!

L24– Parallel Processing 6

6.004 Spring 2009

5/7/

Instruction-Level Parallelism

Sequential Code

This is okay, but smarter coding does better in this example!

loop:

LD(n, r1)CMPLT(r31, r1, r2)BF(r2, done)LD(r, r3)LD(n,r1)MUL(r1, r3, r3)ST(r3, r)LD(n,r4)SUBC(r4, 1, r4)ST(r4, n)

BR(loop)

done:

What if I tried todo multipleiterations atonce?

loop:

LD(n, r1)CMPLT(r31, r1, r2)BF(r2, done)LD(r, r3) LD(n,r1) LD(n,r4)MUL(r1, r3, r3) SUBC(r4, 1, r4)ST(r3, r) ST(r4, n) BR(loop)

done:

“Safe” Parallel Code

L24– Parallel Processing 7

5/7/

Superscalar Parallelism

Popular now, but the limits are near (8-issue)

Multiple instruction dispatch

Speculative execution

L24– Parallel Processing 8

6.004 Spring 2009

5/7/

SIMD Processing

(Single Intruction Multiple Data)

Each datapath has its own local data (Register File)All data paths execute the same instructionConditional branching is difficult…

(What if only one CPU has R1 = 0?)

Conditional operations are common in SIMD machines

if (flag1) Rc = Ra Rb

Global ANDing or ORing of flag registers are used for high-level

Reg File control

ALU

PC

+1 or Branch

Reg File

ALU

Reg File

ALU

Reg File

ALU

Data

Memory

Instruction

Memory

addr

data addr

data

Addressing

Unit

Control

Model: “hide” parallelism in primitives (eg, vector operations)

This sort ofconstruct isalso becomingpopular onmodernuniprocessors

L24– Parallel Processing 13

5/7/

VLIW Variant of SIMD Parallelism

(Very Long Instruction Word)

A single-WIDE instruction controls multiple heterogeneous

datapaths.

Exposes parallelism to compiler (S/W vs. H/W)

Register File

Integer ALU #

Floating Point

Adder

Integer ALU #

Floating Point

Multiplier

FP Regs

Instr. Fetch

& Branch Prediction

Load Store

Unit

Instr

Data

Memory Interface

IOP

1

RC

1

RA

1

RB

1

IOP

2

RC

2

RA

2

RB

2

FOP FD

1

FA

1

FB

1

FD

2

FA

2

FB

2

MemOP

L24– Parallel Processing 14

6.004 Spring 2009

5/7/

Multiple Instruction Streams: MIMD

Exploiting Thread Level Parallelism

All processors share a common main memoryLeverages existing CPU designsEasy to map “Processes (threads)” to “Processors”Share data and programCommunicate through

shared memory

UpgradeableProblems:

ScalabilitySynchronization

Main Memory

SMP – Symmetric Multi-Processor

One thread per processor

L24– Parallel Processing 15

5/7/

Hmmm….does it even work?

P

: x = 1y = 2

Shared Memory, x = 1, y = 2

P

$2: x = 1

y = 2

Process A

x

print(y);

Process B

y =

print(x);

Consider the following trivial processes running on P

and P

L24– Parallel Processing 16

6.004 Spring 2009

5/7/

What are the Possible Outcomes?

SEQUENCE

A prints B prints

x=3; print(y); y=4; print(x);

x=3; y=4; print(y); print(x);

x=3; y=4; print(x); print(y);

y=4; x=3; print(x); print(y);

y=4; x=3; print(y); print(x);

y=4; print(x); x=3; print(y);

Plausible execution sequences:

Process A

x = 3;print(y);

Process B

y

print(x);

$1: x = 1

y = 2

$2: x = 1

y = 2

Hey, we get thesame answer everytime… Let’s gobuild it!

X 3

X 4

L24– Parallel Processing 17

5/7/

Uniprocessor Outcome

But, what are the possible outcomes if we ran Process A and

Process B on a single timed-shared processor?

SEQUENCE

A prints B prints

x=3; print(y); y=4; print(x);

x=3; y=4; print(y); print(x);

x=3; y=4; print(x); print(y);

y=4; x=3; print(x); print(y);

y=4; x=3; print(y); print(x);

y=4; print(x); x=3; print(y);

Plausible Uniprocessor execution sequences:

Process A

x

print(y);

Process B

y =

print(x);

Notice that theoutcome 2, 1does not appearin this list!

L24– Parallel Processing 18

6.004 Spring 2009

5/7/

Sequential Consistency

Semantic constraint:

Result of executing N parallel programs should correspond to

some

interleaved execution on a single processor.

Possible printed values: 2, 3; 4, 3; 4, 1.

(each corresponds to at least one interleaved execution)

IMPOSSIBLE printed values: 2, 1

(corresponds to NO valid interleaved execution).

Process A

x = 3;print(y);

Process B

y

print(x);

Shared Memory

int

x=1,

y=2;

Weren’tcachessupposed tobe invisible toprograms?

L24– Parallel Processing 19

5/7/

Cache Incoherence

PROBLEM: “stale” values in cache ...

Process B

y = 4;print(x);

Process A

x

print(y);

Q: How does B know that A has changed the value of x?

P

1

x=

y=

Shared Memory

P

2

x=

y=

x=3, y=

Does

WRITE-THRU

help?

_______!

NO

The problem isnot thatmemory hasstale values,but that othercaches may!

L24– Parallel Processing 20

6.004 Spring 2009

5/7/

“Snoopy” Caches

P

1

x=

y=

Shared Memory

P

2

x=

y=

x=1,

y=

IDEA:

  • P

writes 3 into x; write-thru cache causes bus transaction.

  • P

, snooping, sees transaction on bus. INVALIDATES or UPDATES its cached

x value.

Presume

WRITE-THRU

caches!

X 3

X 3

X 3