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

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

Jan 19, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 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

Page 2: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 3: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

3

Software Behavior-Oriented Parallelization [Ding+:PLDI07]

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

cost-inefficiency.

Page 4: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

4

Cost and Speedup

0

1

2

3

1 0.9 0.42 0.12

Speculation Success Rate

Cost

SpeedUp

Page 5: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

5

Cost and Speedup

0

0.5

1

1.5

2

1 0.9 0.42 0.12

Speculation Success Rate

Cost

SpeedUp

Page 6: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

6

Outline

Introduction to BOP

Adaptive BOP

Experimental Result

Conclusion

Page 7: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

7

Outline

Introduction to BOP

Adaptive BOP

Experimental Result

Conclusion

Page 8: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 9: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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();

Page 10: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 11: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

11

Outline

Introduction to BOP

Adaptive BOP

Experimental Result

Conclusion

Page 12: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

12

Solution: Adaptive Speculation

Basic strategy Predict profitability of PPR Speculate only likely profitable ones

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

Page 13: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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)

Page 14: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

14

Extended last-value-based prediction

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

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

Speculation!Success

NextPenalty = 1

| : Profitable PPR | : Unprofitable PPR

Page 15: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

15

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

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

Speculation!Failed

PPRsToSkip = 1NextPenalty = 2

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

Page 16: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

16

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

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

No Speculation!PPRsToSkip = 0

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

Page 17: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

17

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

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

Speculation!Failed

PPRsToSkip = 2NextPenalty = 4

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

Page 18: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

18

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

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

No Speculation!PPRsToSkip = 1

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

Page 19: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

19

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

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

No Speculation!PPRsToSkip = 0

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

Page 20: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

20

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

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

Speculation!Success

NextPenalty = 1

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

Page 21: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

21

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

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

Speculation!Success

NextPenalty = 1

...

Extended last-value-based prediction

| : Profitable PPR | : Unprofitable PPR

Page 22: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

22

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

clean history

Phase changes

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

Page 23: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 24: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 25: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 26: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 27: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 28: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 29: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 30: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

...

Page 31: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

31

Outline

Introduction

Adaptive-Algorithms

Experimental Result

Conclusion

Page 32: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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)

Page 33: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

33

Accuracy for Last-value-based

Adjust non-speculate numbers Non-speculation PPRsToSkip -1

Success Speculation NextPenalty= 1

Failed Speculation PPRsToSkip = NextPenalty NextPenalty *= α

Page 34: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

34

Accuracy for Last-value-based

α=1.4Accuracy=81.6

Page 35: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 36: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 37: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

37

Accuracy for Decayed history based

THEP = 0.25 β= 0.0075 γ = 0.4

Accuracy = 85.6%

Page 38: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 39: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

39

Efficiency comparison on gzip

010203040

1.6MB 320KB 192KBBuffer size

Cost(s)

seqorg-bopadapt-bop

Page 40: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

40

Efficiency comparison on gzip

05

101520

1.6MB 320KB 192KBBuffer size

Time(s)

seqorg-bopadapt-bop

Page 41: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

41

Efficiency comparison on parser

010203040

50 10 2

Num of Sentences

Cost

(s)

seqorg-bopadapt-bop

Page 42: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

42

Efficiency comparison on parser

05

101520

50 10 2

Num of Sentences

Time(S)

seqorg-bopadapt-bop

Page 43: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

43

Efficiency comparison on Reduction

01020304050

0 10% 50% 90%

Denpendence

Cost(s)

seqorg-bopadapt-bop

Page 44: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

44

Efficiency comparison on Reduction

0

10

20

30

0 10% 50% 90%

Denpendence

Time

(s)

seqorg-bopadapt-bop

Page 45: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

45

Outline

Introduction to BOP

Adaptive Algorithms

Experimental Result

Conclusion

Page 46: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

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

Page 47: for Enhancing the Cost-Efficiency of Behavior-Oriented ...

47

Questions?

Thanks!