for Enhancing the Cost-Efficiency of Behavior-Oriented ...

47
Adaptive Software Speculation for Enhancing the Cost-Efficiency of Behavior-Oriented Parallelization Yunlian Jiang Xipeng Shen The College of William and Mary

Transcript of for Enhancing the Cost-Efficiency of Behavior-Oriented ...

Adaptive Software Speculation for Enhancing the Cost-Efficiency of Behavior-Oriented Parallelization

Yunlian JiangXipeng Shen

The College of William and Mary

2

High-level Parallelism

Parallel computing is becoming ubiquitous High-level parallelism exists in many

programs E.g. utilities, interpreters, scientific computations Difficult to parallelize

Bit-level operations, unrestricted pointers,exception handling, custom mem. management,third-party libraries

Example*: while ( s=nextSentence() ) { parse(s); if ( isCommand(s) )

updateParsingEnv(s); }

Complexity in the code Uncertain parallelism

3

Software Behavior-Oriented Parallelization [Ding+:PLDI07]

Speculatively execute programs in parallel Efficiently detect dependence during runtime But, blind speculation causes

cost-inefficiency.

4

Cost and Speedup

0

1

2

3

1 0.9 0.42 0.12

Speculation Success Rate

Cost

SpeedUp

5

Cost and Speedup

0

0.5

1

1.5

2

1 0.9 0.42 0.12

Speculation Success Rate

Cost

SpeedUp

6

Outline

Introduction to BOP

Adaptive BOP

Experimental Result

Conclusion

7

Outline

Introduction to BOP

Adaptive BOP

Experimental Result

Conclusion

8

Behavior-Oriented Parallelization(BOP)

A tool for parallelizing sequential programs Need no parallel programming or debugging Basic scheme: software speculation Correctness protected through runtime system

9

Basic Scheme of BOP

. . . . . .While (S= ReadSentence()){

Parse(S);}. . . . . .

Ctrl

Main

Spec

PossiblyParallelRegion (PPR)

Two reason for failed speculation:1. Dependence violation2. Spec runs too slow

Parser

BeginPPR();

EndPPR();

10

Problem to tackle

Cost inefficiency BOP blindly speculates every PPR instance Failed speculation may Cause slowdown to applications Protection overhead Resource (cache, bus) contention

Waste computing resources CPU --- multi-programming environment Power --- Mobile computing

11

Outline

Introduction to BOP

Adaptive BOP

Experimental Result

Conclusion

12

Solution: Adaptive Speculation

Basic strategy Predict profitability of PPR Speculate only likely profitable ones

Prediction approaches Extended last-value-based Decayed-history-based

13

Extended last-value-based prediction Speculate or not? Speculate only if PPRsToSkip == 0.

Adjust PPRsToSkip If this PPR is not speculated PPRsToSkip - -

On a failed speculation PPRsToSkip = NextPenalty; NextPenalty *= α; (increase penalty exponentially)

On a successful speculation NextPenalty = 1; (reset the penalty on the next failure)

14

Extended last-value-based prediction

| | | | | | | | | | | | | | | | | |

•PPRsToSkip=0•NextPenalty=1•α=2

Speculation!Success

NextPenalty = 1

| : Profitable PPR | : Unprofitable PPR

15

| | | | | | | | | | | | | | | | | |

•PPRsToSkip=0•NextPenalty=1•α=2

Speculation!Failed

PPRsToSkip = 1NextPenalty = 2

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

16

| | | | | | | | | | | | | | | | | |

•PPRsToSkip=1•NextPenalty=2•α=2

No Speculation!PPRsToSkip = 0

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

17

| | | | | | | | | | | | | | | | | |

•PPRsToSkip=0•NextPenalty=2•α=2

Speculation!Failed

PPRsToSkip = 2NextPenalty = 4

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

18

| | | | | | | | | | | | | | | | | |

•PPRsToSkip=2•NextPenalty=4•α=2

No Speculation!PPRsToSkip = 1

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

19

| | | | | | | | | | | | | | | | | |

•PPRsToSkip=1•NextPenalty=4•α=2

No Speculation!PPRsToSkip = 0

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

20

| | | | | | | | | | | | | | | | | |

•PPRsToSkip=0•NextPenalty=4•α=2

Speculation!Success

NextPenalty = 1

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

21

| | | | | | | | | | | | | | | | | |

•PPRsToSkip=0•NextPenalty=1•α=2

Speculation!Success

NextPenalty = 1

...

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

22

Extended last-value-based prediction Limitations Can not keep history well Successful speculation

clean history

Phase changes

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

23

Decayed-history-based prediction Cumulative gain (CG)

cg = γ*g + (1-γ) * cg

Expected Profitability (EP) EP = cg + SkippedPPRs *β Speculate only if EP > THEP

g=

1 : success

0: failed

* THEP : threshold of speculation;* SkippedPPRs: reset to 0 on a success

increase by 1 on a non-speculated PPR

24

| | | | | | | | | | | | | | | | | |

•THEP=0.6•β=0.2•γ = 0.5•SkippedPPRs=0•cg=1•EP =1

Speculation!Successcg = 1EP = 1

Decayed-history-based prediction

| : Profitable PPR | : Unprofitable PPR

25

| | | | | | | | | | | | | | | | | |

•THEP=0.6•β=0.2•γ = 0.5•SkippedPPRs=0•cg=1•EP =1

Speculation!Failed

cg = 0.5EP = 0.5

Decayed-history-based prediction

| : Profitable PPR | : Unprofitable PPR

26

| | | | | | | | | | | | | | | | | |

•THEP=0.6•β=0.2•γ = 0.5•SkippedPPRs=0•cg=0.5•EP =0.5

No Speculation!SkippedPPRs=1

EP = 0.7

Decayed-history-based prediction

| : Profitable PPR | : Unprofitable PPR

27

| | | | | | | | | | | | | | | | | |

•THEP=0.6•β=0.2•γ = 0.5•SkippedPPRs=1•cg=0.6•EP =0.7

Speculation!Success

SkippedPPRs=0cg = 0.8EP = 0.8

Decayed-history-based prediction

| : Profitable PPR | : Unprofitable PPR

28

| | | | | | | | | | | | | | | | | |

•THEP=0.6•β=0.2•γ = 0.5•SkippedPPRs=0•cg=0.8•EP =0.8

Speculation!Failed

cg = 0.4EP = 0.4

Decayed-history-based prediction

| : Profitable PPR | : Unprofitable PPR

29

| | | | | | | | | | | | | | | | | |

•THEP=0.6•β=0.2•γ = 0.5•SkippedPPRs=0•cg=0.4•EP =0.4

No Speculation!SkippedPPRs = 1

EP = 0.6

Decayed-history-based prediction

| : Profitable PPR | : Unprofitable PPR

30

| | | | | | | | | | | | | | | | | |

•THEP=0.6•β=0.2•γ = 0.5•SkippedPPRs=1•cg=0.4•EP =0.6

Speculation!Success

SkippedPPRs = 0EP = 0.7

Decayed-history-based prediction

| : Profitable PPR | : Unprofitable PPR

...

31

Outline

Introduction

Adaptive-Algorithms

Experimental Result

Conclusion

32

Experimental Result Prediction Accuracy Choose the best parameters for the algorithms Evaluate two algorithms

Computation Efficiency Finishing time Time spent on all CPUs (Cost)

33

Accuracy for Last-value-based

Adjust non-speculate numbers Non-speculation PPRsToSkip -1

Success Speculation NextPenalty= 1

Failed Speculation PPRsToSkip = NextPenalty NextPenalty *= α

34

Accuracy for Last-value-based

α=1.4Accuracy=81.6

35

Accuracy for Decayed history based G_TH : gain threshold Current state weight gain+ quota*β Non-speculative execution quota++

Speculative execution gain = γ*g + (1-γ) * gain quota 0

36

Accuracy for Decayed history based Cumulative gain (CG)

cg = γ*g + (1-γ) * cg

Expected Profitability (EP) EP = cg + SkippedPPRs *β Speculate only if EP > THEP

g=

1 : success

0: failed

* THEP : threshold of speculation;* SkippedPPRs: reset to 0 on a success

increase by 1 on a non-speculated PPR

37

Accuracy for Decayed history based

THEP = 0.25 β= 0.0075 γ = 0.4

Accuracy = 85.6%

38

Computation Efficiency

Machine: Intel Pentium-D dual-core processors Compiler: gcc4.1 Benchmarks Gzip, Parser, Reduction

Metrics Cost Total running time of all the processes

Time Finishing time of a program

39

Efficiency comparison on gzip

010203040

1.6MB 320KB 192KBBuffer size

Cost(s)

seqorg-bopadapt-bop

40

Efficiency comparison on gzip

05

101520

1.6MB 320KB 192KBBuffer size

Time(s)

seqorg-bopadapt-bop

41

Efficiency comparison on parser

010203040

50 10 2

Num of Sentences

Cost

(s)

seqorg-bopadapt-bop

42

Efficiency comparison on parser

05

101520

50 10 2

Num of Sentences

Time(S)

seqorg-bopadapt-bop

43

Efficiency comparison on Reduction

01020304050

0 10% 50% 90%

Denpendence

Cost(s)

seqorg-bopadapt-bop

44

Efficiency comparison on Reduction

0

10

20

30

0 10% 50% 90%

Denpendence

Time

(s)

seqorg-bopadapt-bop

45

Outline

Introduction to BOP

Adaptive Algorithms

Experimental Result

Conclusion

46

Conclusions Failed Speculation is a problem Two adaptive algorithms Last-value-based prediction Decayed-history-based prediction

Performance High accurate prediction Keep fast running speed Reduce cost

47

Questions?

Thanks!