Presentation is loading. Please wait.

Presentation is loading. Please wait.

An Efficient Compilation Framework for Languages Based on a Concurrent Process Calculus Yoshihiro Oyama Kenjiro Taura Akinori Yonezawa Yonezawa Laboratory.

Similar presentations


Presentation on theme: "An Efficient Compilation Framework for Languages Based on a Concurrent Process Calculus Yoshihiro Oyama Kenjiro Taura Akinori Yonezawa Yonezawa Laboratory."— Presentation transcript:

1

2 An Efficient Compilation Framework for Languages Based on a Concurrent Process Calculus Yoshihiro Oyama Kenjiro Taura Akinori Yonezawa Yonezawa Laboratory Department of Information Science University of Tokyo

3 implementation is difficult analysis is not general Compiling Programming Languages machine code surface language many primitives implementation becomes easy analysis becomes general several essential primitives intermediate language

4 Intermediate Languages n Sequential languages –Quadruple –Lambda calculus –Continuation Passing Style (CPS) [Appel 92] n Concurrent languages –Pi-calculus [Milner 93] –HACL [Kobayashi et al. 94] process calculus

5 Concurrent Process Calculus n Key component of calculation –Asynchronous process –Communication channel n Advantages –Clear syntax and clear semantics –Many theoretical results for optimization P P P P C P 3 3

6 Goal n Efficient implementation of a process calculus ML-like code Schematic code HACL code ….. focus of our research straightforward translation traditional techniques

7 Motivation Process calculus has some overheads which are not in sequential languages –Dynamic process scheduling –Channel communication Low efficiency with naïve implementation A demand on a sophisticated implementation reducing the overheads

8 Contribution n A framework for compiling process calculus efficiently n Optimization techniques applicable for software multithreading

9 Overview of This Presentation n Target language HACL n A basic execution n Our enhanced execution –To reduce scheduling overhead –To reduce communication overhead n Experimental results

10 Target Language HACL e ::= x | c | op ( e 1, …, e n ) expression P ::= P 1 | P 2 $ x. P$ x. P e ( x )=> P e 1 <= e 2 if e then P 1 else P 2 e 0 ( e 1, …, e n ) parallel execution channel creation receive from e send e 2 to e 1 process instantiation conditional process expression x 0 ( x 1, …, x n ) = P process definition

11 Basic Execution Model (1/2) - process scheduling - P 1 | P 2 ……… dynamic process creation P1P1 P2P2 both schedulable scheduling pool | P P P continuing execution P2P2 schedulable process

12 Basic Execution Model (2/2) - channel - channel ⇔ pointer to memory space r Q r ( y )=> Q r <= 8 r <= 12 r ( x )=> P r <= 12 r ( x )=> Pr ( y )=> Q r <= 8 12 value queue process queue { 12 / x } P {8 / y} Q

13 Inefficiencies of Basic Model n Scheduling overhead –Scheduling pool is manipulated every time a process is created n Communication overhead –Channel communication is always performed through memory

14 Our Enhanced Execution Model n Static process scheduling –reduces the frequency of the runtime scheduling pool manipulation –lines up code fragments for multiple process expressions n Unboxed channel framework –enables us to communicate values without memory –initially creates a channel on register –later allocates a channel on heap as necessary

15 Compilation Overview HACL program ML-like program translation rule execution flow scheduling pool execution flow scheduling pool = explicit = implicit F { P 1, P 2,..., P n } = a sequential ML-like program which schedules P 1, P 2,..., P n a set of schedulable process expressions

16 Compilation with Static Scheduling (1/2) = F P1P1 P2P2 P3P3 code fragment for P 1 F P2P2 P3P3 code fragment for P 2 F P3P3 code fragment for P 3

17 Compilation with Static Scheduling (2/2) = F P2P2 P1’P1’ r ( x )=> if (r has a value) then (* get the value from r *) else (* allocate a closure for on heap *) F P1’P1’P2P2 F P2P2 P1’P1’ code fragment for P 1 ’ F P2P2 code fragment for P 2

18 F { (r P) } F { ( $ r.( r P ) ) } F { r ( x )=> P } Compilation Example $ r.( r P ) r = new_channel(); if (r has a value) then x = get_value( r ); F { P } else (* allocate a closure P in heap and... *) F { } F { ( r P) } if (r has a waiting process) then (* wake up the process and … *) else put_value( r, 5 ) ;

19 Unboxed Channel Scheme n Unboxed channel = channel allocated on register –No memory access to manipulate an unboxed channel n All channels are created as an unboxed channel n An unboxed channel is elevated to a heap-allocated one as necessary

20 Example r = new_channel(); if (r has a process) then... else put_value( r, 5 ); if (r has a value) then x = get_value( r ); F { P } else... r = EMPTY_CHANNEL; if (...) {... } else { r = 5 + VAL_TAG; if (...) { x = r - VAL_TAG;... } else {... }... } ML-like codeCorresponding C code Channel allocation and communication on a register

21 When to allocate a space on heap? 6 8 P1P1 P2P2 123 two values are sent an unboxed channel is duplicated ???

22 Experimental Results (1/2) n HACL is used as an intermediate language of Schematic [Taura et al. 96] n ML-like program is compiled to assembly-like C n A native code is generated by GNU C compiler n Runtime type checks are omitted n SS20 (HyperSparc 150MHz) n Now implementing on a large-scale SMP

23 Experimental Results (2/2)

24 Related Work (1/2) n Id [Schauser et al. 95], Fleng [Araki et al. 97] –Static scheduling ≒ sequentialization –A does not depend on B ⇒ A | B → A ; B n Pict [Turner 96] –All channel communications need memory operation –A receive (input) expression always allocate a closure whether a value is present or not

25 Related Work (2/2) n StackThreads [Taura et al. 94, 97] –An original proposal of unboxed channel n Linear channel [Kobayashi et al. 96, Igarashi 97] –Linear channel = channel used only once –Some communications for linear channel is statically eliminated n CPS [Appel 92] –A compilation framework for sequential language

26 Conclusion n We proposed a framework compiling process calculus efficiently –Static scheduling –Unboxed channel n A language based on a process calculus is executed only a few times slower than C

27 Surface Languages for Process Calculi surface language intermediate language machine code concurrent functional language, concurrent OO language, etc... Schematic [Taura et al. 96] Pict [Turner 96] process calculus HACL Pi-calculus

28 A Schedulable Closure and The Scheduling Stack F { f ( r, x ), P } schedule f ( r, x ) first Can we schedule f and P statically ??? scheduling stack ≒ a set of schedulable closures Difficult. The scheduling pool is still necessary. P f(r, x)f(r, x)


Download ppt "An Efficient Compilation Framework for Languages Based on a Concurrent Process Calculus Yoshihiro Oyama Kenjiro Taura Akinori Yonezawa Yonezawa Laboratory."

Similar presentations


Ads by Google