23
Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere University of Cyprus

Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Embed Size (px)

DESCRIPTION

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June 4, Return-Address-Stack (RAS) return from printf main(): my_printf() my_function() my_printf() return main: my_printf() my_function() my_printf() return function calls push return address on RAS 1 my_printf() RAS return from printf my_printf: for(condition){ printf() } return printf() TOS printf: /* print */ return returns predicted by popping from RAS 2 return from my_printf return from my_printf return from my_function return from main my_function: /* fun */ return my_function()

Citation preview

Page 1: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Correct Alignment of a RAS after Call and Return Mispredictions

Ghent University

Veerle DesmetYiannakis Sazeides

Constantinos KourouyiannisKoen De Bosschere

University of Cyprus

Page 2: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 2

MotivationReturn-Address-Stack (RAS)

1. Correct alignment2. Effect deeper pipelines

byVeerle Desmet

Ghent University

Page 3: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 3

Return-Address-Stack (RAS)

return fromprintf

main():my_printf()my_function()

my_printf()return

main: my_printf() my_function() my_printf()return

function calls pushreturn address on RAS

1

my_printf()

RAS

return fromprintf

my_printf: for(condition){

printf() }return

printf()

TOS

printf: /* print */return

returns predicted by popping from RAS

2return frommy_printf

return frommy_printf

return frommy_functionreturn from

main

my_function: /* fun */return

my_function()

Page 4: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 4

Mispredictionsfe

tch

chec

kpoi

nt

RASreturn from

printfTOS return from

my_printfreturn from

main

recovery

wrong path

Speculative RAS updates due to wrong path calls

Page 5: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 5

Bottlenecks for RAS performance

De-alignment`unbalanced # of

call/return’

Corruption`RAS content

overwritten by wrong path calls’

Overflow`call depth exceeds stack

size’

return frommain

return fromprintf

RAS

return frommy_printf

return frommy_printf

TOS TOS

Page 6: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 6

Correct Alignment…

RAS

return fromprintf

return frommain

TOS

Checkpoint TOS1

Conditional branch misprediction2

Wrong path3

Recovery to checkpointed TOS4

return fromwrong path

e.g. 1 misspeculated call

return fromwrong pathreturn frommy_function

Page 7: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 7

… after Call Mispredictions

RAS

return fromprintf

return frommain

TOS

Checkpoint TOS1

Call target misprediction + RAS update2

Wrong path3

Recovery to checkpointed TOS4

e.g. 1 misspeculated call

return frommy_function

return fromwrong pathreturn fromwrong pathreturn frommispr. call

Page 8: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 8

… after Return Mispredictions

RAS

return fromprintf

TOS

Checkpoint TOS1

Return target misprediction + RAS update2

Wrong path3

Recovery to checkpointed TOS4

e.g. no misspeculated calls or returns

return frommispr returnreturn frommispr returnreturn from

main

Page 9: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 9

return fromprintf

TOS

return frommispred call

Correct Alignment Incorrect Alignment

Correct Alignment

TOS TOS mispred.return addr

Conditional branch misprediction

Callmisprediction

Returnmisprediction

RAS RAS RAS

Page 10: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 10

Correct Alignment

0%5%

10%15%20%

25%30%

com

pres

s95

gcc9

5

go95

ijpeg

95 li95

m88

ksim

95

vorte

x95

mcf

00

pars

er00

vorte

x00

mes

a00

aver

age

RAS misprediction rate

0,940,960,981,001,021,041,061,081,101,12

com

pres

s95

gcc9

5

go95

ijpeg

95 li95

m88

ksim

95

vorte

x95

mcf

00

pars

er00

vorte

x00

mes

a00

aver

age

Speedup

Incorrect Alignment

Correct AlignmentSpeedup can be affected by up to 10%

Page 11: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 11

A lot of published work…SimpleScalar

HydraScalar

Yeh, Intel patent

SimWattchSimca

Jourdan Eickemeyer,Hoyt,

Hummel,McDonald,McMahan

Steely

INCORRECT=

LOWER PERFORMING

CORRECTUNCLEAR

Page 12: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 12

Bottlenecks for RAS performance

De-alignment`unbalanced # of

call/return’

Corruption`RAS content

overwritten by wrong path calls’

Overflow`call depth exceeds stack

size’

return frommain

return fromprintf

RAS

return frommy_printf

return frommy_printf

TOS TOS

Page 13: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 13

RAS content recovery

0,900,95

1,001,051,10

1,151,20

com

pres

s95

gcc9

5

go95

ijpeg

95 li95

m88

ksim

95

vorte

x95

mcf

00

pars

er00

vorte

x00

mes

a00

aver

age

Speedup

Incorrect Alignment

Correct Alignment

Also checkpoints/recoverstop of stack data

2% speedup on average

[Skadron et al. @ MICRO 1998]

top of stackdata

Page 14: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 14

MotivationReturn-Address-Stack (RAS)

1. Correct alignment2. Effect deeper pipelines

byVeerle Desmet

Ghent University

Page 15: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 15

Deeper Pipelines…

0,880,900,920,940,960,981,00

5 10 15 20 25 30pipeline stages

relative IPC to full RAS recovery

32-entry RAS16-entry RAS

8-entry RAS

64-entry RAS

On average, reasonable scaling…

Independence on RAS size

Page 16: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 16

But... per benchmark

0,88

0,9

0,92

0,94

0,96

0,98

1

1,02

com

pres

s95

gcc9

5

go95

ijpeg

95 li95

m88

ksim

95

vorte

x95

mcf

00

parser00

vorte

x00

mes

a00

aver

age

rela

tive

IPC

to fu

ll RA

S re

cove

ry

-7% -5%32-entry RAS 15 stages

10 stages5 stages

20 stages25 stages30 stages

Page 17: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 17

RAS

Corruptions per kilo instructions

tos tos tos tos tos tos1 1 1 1 1 130 30 30 30 30 303131 31 31 31 31

0

1

2

3

4

5

6

7

8

5 10 15 20 25 30

pipeline stages

32-entry RAS

Backward (tos,1,…) more destructive

than forward corruption (31,30,…)

31tos12

34

30

corruptiondistance

1

Page 18: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 18

Individual benchmarks

tos tos

tos

tostos tos tos

tos

11

1

223

2829

30 30

30

3131

31

31

31

31

31

tos

11

129

30

30

31 310

1

2

3

4

5

6

7

8co

mpr

ess9

5

gcc9

5

go95

ijpeg

95 li95

m88

ksim

95

vorte

x95

mcf

00

pars

er00

vorte

x00

mes

a00R

AS

cor

rupt

ions

per

kilo

inst

ruct

ions 32-entry RAS

20 stage pipeline

Page 19: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 19

TOS behavior

time li95gcc95 time

32-entry RAS20 stage pipeline

Mainly forward corruption More backward corruption

wrong path RAS updates

Page 20: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 20

Bottlenecks for RAS performance

De-alignment`unbalanced # of

call/return’

Corruption`RAS content

overwritten by wrong path calls’

Overflow`call depth exceeds stack

size’

return frommain

return fromprintf

RAS

return frommy_printf

return frommy_printf

TOS TOS

Page 21: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 21

TOS Behaviorno overflow

32-entry RAS20 stage pipeline

timetime li95gcc95

overflow

Page 22: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Workshop on Duplicating Deconstructing and Debunking (WDDD 2005) --- June

4, 2005 22

Summary Correct Aligned RAS

Return misprediction decrease with 40% Speedup of up to 10%

Deeper Pipelines One of the best performing RAS recovery techniques

Satisfactory on average Performance decrease up to 7% for some programs

May need to checkpoint more content Paper:

Possible implementations Call uncorruption optimization for free How to fix correct alignment in SimpleScalar

Page 23: Correct Alignment of a RAS after Call and Return Mispredictions Ghent University Veerle Desmet Yiannakis Sazeides Constantinos Kourouyiannis Koen De Bosschere

Correct Alignment of a RAS after Call and Return Mispredictions

Ghent University

Veerle DesmetYiannakis Sazeides

Constantinos KourouyiannisKoen De Bosschere

University of Cyprus