Presentation is loading. Please wait.

Presentation is loading. Please wait.

2015-6-25 1 Distributed Meta- Programming (To appear GPCE’06) Rui Shi, Chiyan Chen and Hongwei Xi Boston University.

Similar presentations


Presentation on theme: "2015-6-25 1 Distributed Meta- Programming (To appear GPCE’06) Rui Shi, Chiyan Chen and Hongwei Xi Boston University."— Presentation transcript:

1 2015-6-25 1 Distributed Meta- Programming (To appear GPCE’06) Rui Shi, Chiyan Chen and Hongwei Xi Boston University

2 2 2015-6-25 Outline MP vs. DMP Typeful Code Representation The Language dist The Language + dist Conclusion

3 3 2015-6-25 Meta-Programming (define (run code) (eval code nil)) (define (power n x) (if (= n 0) 1 `(*,x,(power (- n 1) x)))) ;;; (power 2 ‘x) yields (* x (* x 1)) (define square (run `(lambda (x),(power 2 ‘x)))) ;;; (power 3 ‘y) yields (* y (* y (* y 1))) (define cube (run `(lambda (y),(power 3 ‘y))))

4 4 2015-6-25 Distributed Meta-Programming Cod e Run-time code generation Distributed execution

5 5 2015-6-25 Outline MP vs. DMP Typeful Code Representation The Language dist The Language + dist Conclusion

6 6 2015-6-25 `(“abc” + 10) (ill-typed) `(( y.x) 10) (open code) Un-typed Code Representation No guarantee on the safety of generated code.  Code can be syntactically ill-formed or ill-typed, which leads to run-time errors when executed at remote sites.  Issues of locality and heterogeneity of resources Different sites may have different resources and thus likely to provide different services. f : (Int ! Int)@L L `(f 100) L’

7 7 2015-6-25 Typeful Code Representation (T.C.R) The type of an object program can be reflected in the type of code which represents the program  E.g. code of type h , T i represents an object program of type T under the type environment . The type of the code also reflects where it should be sent for execution.  E.g. code of type h L, , T i can be sent to location L for execution. The compiler can statically guarantee that only well-typed code can be constructed at run-time and sent to proper locations for execution.

8 8 2015-6-25 Outline MP vs. DMP Typeful Code Representation The Language dist The Language + dist Conclusion

9 9 2015-6-25 The Language dist - Syntax

10 10 2015-6-25 The Language dist – Types (1) Given a location L, we use loc(L) as a singleton type for locations  The only value in loc(L) is L itself.  here always refers to the location where the program is executed (dynamic binding). Name type: T@L for the type of values referring some value of type T at location L.  rget T returns a local value through a name, which is of type 8 L. (loc(L), T@L) ) T

11 11 2015-6-25 The Language dist – Types (2) Message Type: msg(L,T) for the type of values that can be interpreted at location L to yield a value of type T.  n2m turns a name to a message, which is of type  Constant Messages: refer to the messages which can be interpreted at all locations. E.g. $plus is a constant message of type 8 L.8 T. (T@L) ) msg(L,T) 8 L.msg(L, int ! int ! int)

12 12 2015-6-25 First-Order Code Constructors For example, the term x. y. y (x) can be represented as: which can be of type (with static variables properly instantiated) Lam (Lam (App (One, Shi (One)))) 8 L. h L, , int ! (int ! int) ! int i

13 13 2015-6-25 An Example in dist rexec is to execute code remotely, which is of the following type: 8 L.8 T. (loc(L), h L, , T i) ) T@L f : (int ! int) @ L L `(f 100) rget int (L, rexec (L, App (Lift (n2m f), Lift 100) )) of type h L, , int i

14 14 2015-6-25 Outline MP vs. DMP Typeful Code Representation The Language dist The Language + dist Discussion and Conclusion

15 15 2015-6-25 The Language + dist We extend dist to + dist with some language constructs adopted from meta-programming (supported in Scheme and MetaML):  `(e) for the code representation of e  ^(e) for splicing the code e into the enclosing context  %(¢) is a shorthand for ^(Lift(¢))

16 16 2015-6-25 More on + dist We have a transformation scheme from + dist to dist to justify the type soundness of + dist. + dist is implemented as a part of ATS (Applied Type System) framework. Programmers use the concrete syntax (ML-like) to write distributed meta-programs. We have a process to elaborate programs (partial type inference) in the concrete syntax to the formal syntax of + dist

17 17 2015-6-25 An Example in Concrete Syntax of + dist typedef CodeType (L: loc) = int) -> int> fun rZeroFind {L:loc} (L:loc(L)) (n: (int -> int) @ L) : int = let val zeroFindCode : CodeType (L) = `(lam f => (fix aux i => if f (i) = 0 then i else aux (i+1)) 0) in rget_int (rexec (L, `(^zeroFindCode %(n2m n)))) end

18 18 2015-6-25 Outline MP vs. DMP Typeful Code Representation The Language dist The Language + dist Conclusion

19 19 2015-6-25 Conclusion A simple and general approach to support typed mobile computing. Combines meta-programming with distributed programming in a coherent manner. In future, we are planning to study issues such as exception handling and distributed garbage collection in this context.

20 20 2015-6-25 Thank You!


Download ppt "2015-6-25 1 Distributed Meta- Programming (To appear GPCE’06) Rui Shi, Chiyan Chen and Hongwei Xi Boston University."

Similar presentations


Ads by Google