Title: LARD simulation system: LARD to C translation
1LARD simulation system LARD to C translation
Behavioralsimulation
Balsa
LARD
synthesis
circuits
2LARD example
Divide_and_apply( minval(Ttype), maxval(T) )
expr(void) ( if (max-mingtMAX_diff) then
( middlevar(T). middle
(minmax)/2 Divide_and_apply( min,
middle) Divide_and_apply( middle, max
) ) else f( middlevar(T)
(minmax)/2. fct(middle) ) )
31) Block declarations2) Threads3) Types
( ( ( ) )
forever ( ) )
41) Block declarations2) Threads some figures3)
Types
- LARD code simulation
- Dhrystone benchmark (15000 instructions)
- 495,404 thread creations
- 34,767,587 thread switching
- BALSA code simulation
- hello world with spamulet (130 instructions)
- 51,480 thread creations
- 25,563,604 thread switching
Jabez 2 min
Jabez 1 min
51) Block declarations2) Threads thread
switching3) Types
F( ) sub_1b( ) ... ...
forever( sub_1b ) ... forever( expr )
while (1) expr( )
Method 1 switch stacks and
registers
61) Block declarations2) Threads thread
switching3) Types
Method 2
F( ) sub_1b( ) ... ...
forever( sub_1b ) ... forever( expr )
while (1) expr( )
Yield( )
Save sub_1b position
Save F position
Save expr, forever position
71) Block declarations2) Threads thread
switching3) Types
- Method 2 saverestore sub-function
states - Typical sub-routines chain
- lt ? while ? function ? channel_send ? yield
gt - switching cost
- 4 saves 4 loads 4 function returns 4
function calls
81) Block declarations2) Threads methods
comparison3) Types
- Method 1 Method 2
- stack switch sub-fonction state
- saverestore
? switch speed 5x faster ?
? on the stack local vars difficult ?
already done ?
not optimal speed ?
? difficult getting thread info easy ?
91) Block declarations2) Threads Switching
method 23) Types
( ( ( ) )
forever ( ... Yield ) )
- Analyse each fct and sub-fct
- Need to saverestore thread?
- Need debugging information?
- Optimise argument passing
101) Block declarations2) Threads Results3) Types
Old
( Total 1545 s )
Lard2c
( Total 100 s )
( Total 61 s )
111) Block declarations2) Threads Conclusions3)
Types
- Is it possible to switch threads faster ?
- How to get debugging information ?
- Easy variable control OR speed ?
Method 1 seems promising but
121) Block declarations2) Threads3) Types
- Types represented by their size
- string and mpint pointers to external
structures - need to be explicitly initialised and destroyed
- cant use generic functions
Divide_and_apply( minval(Ttype), maxval(T) )
expr(void) ( if (max-mingtMAX_diff) then
( middlevar(T). middle
(minmax)/2 Divide_and_apply( min,
middle) Divide_and_apply( middle, max
) ) else f( middlevar(T)
(minmax)/2. fct(middle) ) )
gt Need a new representation for types
13Conclusions
- Thread creation and switching can still be
improved - Need new system for handling types
- To get
- Faster simulation
- More robust (Types)
- Saverestore simulations