tanguy risset 1 formal bit with determination for nested loop programs david cachera, tanguy risset,...

21
Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Upload: harold-peters

Post on 06-Jan-2018

219 views

Category:

Documents


0 download

DESCRIPTION

Tanguy Risset 3 Context and Motivations Context: –High level synthesis (hardware compilation from functional specification) –How to go (safely) from algorithmic description to finite precision implementation Specific motivations: –Parameterized loop nests programs –MMAlpha methodology

TRANSCRIPT

Page 1: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 1

Formal Bit With Determination for Nested Loop Programs

David Cachera, Tanguy Risset,

Djamel Zegaoui

Page 2: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 2

Outline

• Introduction/motivation

• Explaining the methodology

• Solving the Bit Width equation with (max,+)

Page 3: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 3

Context and Motivations

• Context:– High level synthesis (hardware compilation

from functional specification)– How to go (safely) from algorithmic

description to finite precision implementation• Specific motivations:

– Parameterized loop nests programs– MMAlpha methodology

Page 4: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 4

Context and Motivations: MMAlpha

• Provide a formal methodology based on the strong semantic properties of the Alpha language

• But still ! Keep applicability for effective VHDL generation

FPGA

ASIC

Uniformization

RTL Derivation

Scheduling/MappingAlphaVHDL

Page 5: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 5

BW determination: state of the art• Formal methods :

– Provide abstract framework for solving the problem (Gaut, Ptolemy, DeepC)

– Limited applicability• Simulation based methods:

– Based on probabilistic models for input data (Ptolemy, Imec,etc.)

– Time consuming processes• Ideally: provide formal methods to speed up the

simulation.

Page 6: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 6

Our methodology

• Start from loop nest specification (in Alpha)• Schedule and Place (SIMD-like specification)• Bit Width determination:

– problem modeling– BW equation generation– BW equation solving

• Hardware generation (VHDL)

Page 7: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 7

Example: … the FIR !

system fir : {N,M | 3<=N<=M-1} (x : {n | 1<=n<=M} of integer; w : {i | 0<=i<=N-1} of integer) returns (res : {n | N<=n<=M} of integer); var Y : {n,i | N<=n<=M; -1<=i<=N-1} of integer;let Y[n,i] = case { | i=-1} : 0[]; { | 0<=i} : Y[n,i-1] +w[i] * x[n-i]; esac; res[n] = Y[n,N-1];tel;

1

0

,1N

i

iwinxnyNn

Page 8: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 8

Problem modeling: error signal• « Formal » signal s(n), implementation š(n)• Noise signal: e(n)=s(n)- š(n)• Noise Standard deviation:

• Signal to Noise ratio (SNR): • Good bit width if Rs is greater than a given value

2

1 1

)(1)(1

M

i

M

jsss je

Mie

M

210

110s

s LogR

Page 9: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 9

Operators modeling [Tou99]

• Let X be a signal encoded on m+n+1 bits

• Generated error: where q=2-n

• Error propagation:– Addition: – Multiplication:

bm ... b0 b-1 ... b-n b-n+1 ....

12

2qX

22YXYX

22max

22max* YXYX XY

Page 10: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 10

Architectural description in Alpha W[t,p] = case { | t=p+1} : w[t-1]; { | p+2<=t} : W[t-1,p]; esac; XP[t,p] = case { | p=0} : x[t+N-1]; { | 1<=p} : XP[t-2,p-1]; esac; Y[t,p] = case { | p=-1} : 0[]; { | 0<=p} : Y[t-1,p-1] +

W[t-1,p] * XP[t-1,p]; esac;

Page 11: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 11

Generation of BW equation

• Simple projection of Alpha equation on space (p index) (BWA=A

2):

BWW[p] = Max(BWw[]BWW[p])

BWXP[p] =case { | p=0} : BWx[] { | 1<=p} : BWXP[p-1] esacBWY[p] = case { | p=-1} : 0[]; { | 0<=p} : q2/12+max(BWY[p-1] + q2/12, BWW*XP[p]+q2/12) esac;

W[t,p] = case { | t=p+1} : w[t-1]; { | p+2<=t} : W[t-1,p]; esac; XP[t,p] = case { | p=0} : x[t+N-1]; { | 1<=p} : XP[t-2,p-1]; esac; Y[t,p] = case { | p=-1} : 0[]; { | 0<=p} : Y[t-1,p-1] +

W[t-1,p] * XP[t-1,p]; esac;

Page 12: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 12

Solving the BW equations (FIR)

• Here the solution can be easily provided by a symbolic solver (q=2-n):

pp xX 0)(

pp wW 0)(

pqppY 6

)1()(2

))(ln(

6

110210 NnR

qNLogRSNR

Page 13: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 13

Solving the BW equations...

• In general, we solve successively the strongly connected component of the reduced dependence graph

Y

WX

Fir (3 SCC)

V3

V2V1

inputinput

Other example: 1 SCC

Page 14: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 14

Solving BW Eq for 1 SCC

V1[t,p] = case { | p=0} : Input[] { | p>=1} : V1[t-1,p-1]-

V3[t-2,p-1]; esac; V2[t,p] = case { | p=0} : Input[]; { | 1<=p} : V2[t-2,p-1]+

V3[t-1,p-1]; esac; V3[t,p] = case { | p=0} : Input[]; { | 1<=p} : V1[t-1,p-1]+

V2[t-3,p-1] esac;

V3

V2V1

input

BWV1[p] = case { | p=0} : 0 { | p>=1} : max(BWV1[p-1]+ , BWV3[p-1] ]+ ); esac; BWV2[p] = case { | p=0} : 0 { | 1<=p} : max(BWV2[p-1]+ , BWV3[p-1] ]+ ); esac; BWV3[p] = case { | p=0} : 0 { | 1<=p} : max(BWV1[p-1]+ , BWV2[p-1] ]+ ); esac;

Page 15: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 15

Solving the BW equations...

• General form (under some assumptions) of the BW equation for one SCC with k variables (for i=1..k):

• Example :

011 ,)1(,....,)1()( kki pBWpBWMaxpBW

0311 ,)1(,)1()( pBWpBWMaxpBW

0322 ,)1(,)1()( pBWpBWMaxpBW

0213 ,)1(,)1()( pBWpBWMaxpBW

Page 16: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 16

Using (max,+) notations is the max and is the addition

• Or:

0311 ,)1(,)1()( pBWpBWpBW 0322 ,)1(,)1()( pBWpBWpBW 0213 ,)1(,)1()( pBWpBWpBW

3

2

1

0

0

0

and

0

where

)1()(

BWBWBW

BWM

pBWMpBW

Page 17: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 17

Perron-Frobenius for (max,+)

• Let MRmaxnn be an irreducible matrix in

(max,+) with spectral ray M and cyclicity c(M), there exist an integer N such that :

• Here: c(M)=1, M = and N=1:

kMcM

Mck MMNk )()(

001)0()(

pBWpBW

p

iip

Mi

Page 18: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 18

Result

• If we respect our restrictions, we are able to solve, in a parametric way the bit Width equations for a loop nest program.

• This is the only method that solves this problem in a parametric way (MIT did something with DeepC but they do not handle symbolic parameters)

Page 19: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 19

Restrictions of our methodology

• Linear array architecture• BW equation solvable (i.e. no auto-adaptive

mechanism or complicated convergence property)

• No multiplication in strongly connected component of the graph:

a[0]=xDo i=1,N

a[i]=a[i-1]*a[i-1]Enddo

Page 20: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 20

Conclusion

• First method for parameterized loop nest bit width determination

• Allow reducing the time needed for simulation (probably not much more than previous methods did)

• New typing mechanism introduced in Alpha:– Integer[S,8]– Integer[S,3,6]

– C = Mul8x8-12(A,B)– B = Trunc(C,11)

Page 21: Tanguy Risset 1 Formal Bit With Determination for Nested Loop Programs David Cachera, Tanguy Risset, Djamel Zegaoui

Tanguy Risset 21

Processor variable dependent BW

Rmin N=3 N=10 N=50 N=100 N=200

30dB b=5 b=6 b=7 b=8 b=8

30dBb(p)

b(0)=5b(1-2)=4

b(0)=6b(1-8)=5b(9)=4

b(0-16)=7b(17-49)=6

b(0)=8b(1-76)=7b(77-99)=6

b(0-68)=8b(69-199)=7

50dB b=8 b=9 b=10 b=11 b=12

50dBb(p)

b(0-1)=8b(2)=7

b(0-2)=9b(3-9)=8

b(0-40)=10b(41-49)=9

b(0)=8b(1-99)=10

b(0-162)=11b(163-199)=10