Erlang - PowerPoint PPT Presentation

About This Presentation
Title:

Erlang

Description:

... OpenMP C Fortran ... Python: ML, Scala, Matlab, Perl, Python, C# ... – PowerPoint PPT presentation

Number of Views:145
Avg rating:3.0/5.0
Slides: 31
Provided by: kis134
Category:
Tags: erlang | matlab | openmp

less

Transcript and Presenter's Notes

Title: Erlang


1
????????? ?????? ????????????? ????????????????
  • Erlang
  • Chapel

2
??????? ? ?????????? ???????????? ????????
  • ????????????? ????????? ??? ???????????? ??????
    ???????????????? MPI ??? C ? Fortran ??? ??????
    ? ?????????????? ???????
  • ????????????? ???????????? ??????? (????????,
    ????????????) OpenMP ??? C ? Fortran ??? ??????
    ? ????? ???????
  • ?????????? ???????????? ?????? ????????????????
    ????????, UPC
  • ???????? ????? ???????????? ??????
    ???????????????? ????????, Chapel, X10,
    Fortress,

3
?????? ????????????????
- ??????? (????)
- ???????? ????????????
???????? ?????????
??????????? ??????
??????????? ?????????-?????????? ????????????
(PGAS)
4
PGAS ??????
  • ???????????? ???? ? ??????????? ????? ???????
  • ?????? ?????? ?i ????????????? ???? Thi
  • ?????
  • - ?????? ?????????? ??????
  • - ????????????? ?????? ????????, ?. ?.
    ???? ????? ???????? ????????????
  • ??????
  • ????????????? ?????????? ? ????????????? ??
    ???????? ?? ?????????????
  • ???????????? ?????????? ????????????????
    ????????? ? ????? ??????

Th0
Thn-2
Thn-1

?n-2
?n-1
?0
- ??????? (????)
- ???????? ????????????
- ?????? ??????
5
Erlang
  • ??????????? Ericsson Computer Science Laboratory
  • ???????? ? 1987 ???? (open source ? 1998)
  • ????? Erlang/OTP R13B04 (24 ??????? 2010)
  • ????????? ?????????????? ????????????????

6
?????????
  • ????????? ??????????? ?? Prolog.
  • ????????????
  • ??????
  • ??????????? ???????
  • ????????? ???????
  • ???????? ???????????
  • ?????????
  • ????????? ??????????
  • ??????????? ????????? ????????.

7
?????????
  • ???????? ???????????
  • ????? 2, 5.5, 2101
  • ?????????? X, Y, Z
  • ????? red, green, blue
  • ??????? red, 255
  • ?????? 2, red, red,255, 1,2
  • ?????? Hello, world!
  • ???????? ??????. ltlt104,101,108,108gtgt

8
?????????
  • ?????? ?????????
  • -module(prog).
  • -export(fac/1).
  • fac(1) -gt
  • 1
  • fac(N) -gt
  • N fac(N - 1).
  • ??????
  • 5gt c(prog).
  • ok, prog
  • 6gt progfac(4).
  • 24

9
?????? ? ??????????
  • ?????? ??????????? ?????????.
  • Erlang ?????????? ??????????? ????????, ??
    ????????????? ?????? ???????????? ???????.
  • ??????? ?????? ???????? let it crash (??????
    ??????).
  • ???????? ??????, ???????? ???????? ???????? ??
    ?????? ????????, ??? ????? ???????.

10
?????? ? ??????????
  • ??????????? ????? ??????????? .
  • ???????????? ???????? ?????????????? ?????????
    ???????? ??????????? ????? ???????????. ???????
    ????? ???? ???????? ????, ?????? ?? ???????
    ?????? ?????????, ??????????? ?? ? ????????. ????
    ?? ???? ?????? ?? ????????, ?????????
    ????????????.
  • ????? ???????? ????????? ??????? ????? ??????????
    ??????, ?? ????????? ?????????????.

11
?????? ? ??????????
  • ???????? ????????
  • Pid spawn (fun operate/0)
  • spawn(M,F,A) ??????, ???????, ?????????
  • self() - PID ???????? ????????
  • ??????? ????????
  • exit(Pid, Reason)
  • ??????? ????????? ????????
  • Pid ! msg
  • ??????? ????????
  • register(atom, Pid) ?????????? ???????? ?????
  • whereis(atom) -gt Pid ????????? PID ?? ?????
  • atom ! Msg ???????? ????????? ?? ?????

12
?????? ? ??????????
  • -module(prog1).
  • -export(start/0, say_something/2).
  • say_something(What, 0) -gt
  • done
  • say_something(What, Times) -gt
  • ioformat("pn", What),
  • say_something(What, Times - 1).
  • start() -gt
  • spawn(tut14, say_something, hello, 3),
  • spawn(tut14, say_something, goodbye, 3).
  • ?????????
  • gt prog1start().
  • hello
  • goodbye
  • lt0.63.0gt
  • hello
  • goodbye

13
?????? ? ??????????
  • -module(prog2).
  • -export(start/0, ping/2, pong/0).
  • ping(0, Pong_PID) -gt
  • Pong_PID ! finished,
  • ioformat("???? ???????? ??????n", )
  • ping(N, Pong_PID) -gt
  • Pong_PID ! ping, self(),
  • receive
  • pong -gt
  • ioformat("???? ??????? ????n", )
  • end,
  • ping(N - 1, Pong_PID).
  • pong() -gt
  • receive
  • finished -gt
  • ioformat("???? ???????? ??????n",
    )

14
?????? ? ??????????
  • ????? ????-?????
  • 2gt prog2 start().
  • lt0.36.0gt
  • ???? ??????? ????
  • ???? ??????? ????
  • ???? ??????? ????
  • ???? ??????? ????
  • ???? ??????? ????
  • ???? ??????? ????
  • ???? ???????? ??????
  • ???? ???????? ??????

15
?????? ? ??????????
  • ?????????????? ??????????.
  • ?????????? ????????? ????????? Erlang ??????????
    ????? (node). ???? ????? ??? ? ????? ?
    ????????????? ?????? ????? ?? ?????? ?????? ??? ?
    ????. ???????? ? ?????????????? ????????? ??????
    ????? ?? ?????????? ?? ?????????????? ?????????
    ?????? ????. ??? ???????? ???????? ?? ?????? ????
    ???????? ?????????? ????? ??? ??? ?, ??? ??????
    ?? ?? ?????????, ?? ????? ?? ??????????????
    ?????????? ????????????? ?????????????????? ? ???
    ????????.
  • ????? ???? ???? ???
  • erl -sname my_name

16
?????? ? ??????????
?????????????? ??????????. ????-???? ?? ????
?????.
  • -module(prog3).
  • -export(start_ping/1, start_pong/0, ping/2,
    pong/0).
  • ping(0, Pong_Node) -gt
  • pong, Pong_Node ! finished,
  • ioformat("???? ???????? ??????n", )
  • ping(N, Pong_Node) -gt
  • pong, Pong_Node ! ping, self(),
  • receive
  • pong -gt
  • ioformat("???? ??????? ????n", )
  • end,
  • ping(N - 1, Pong_Node).
  • pong() -gt
  • receive
  • finished -gt

17
?????? ? ??????????
  • ?????? ????-????? ?? ???? ???????

comp1gt erl -sname ping Erlang (BEAM) emulator
version 5.2.3.7 hipe threads0 Eshell
V5.2.3.7 (abort with G) (ping_at_comp1)1gttut17s
tart_ping(pong_at_comp2). lt0.37.0gt ???? ???????
???? ???? ??????? ???? ???? ??????? ???? ????
???????? ??????
comp2gt erl -sname pong Erlang (BEAM) emulator
version 5.2.3.7 hipe threads0 Eshell
V5.2.3.7 (abort with G) (pong_at_comp2)1gtprog3sta
rt_pong(). true (pong_at_gollum)2gt ???? ???????
???? ???? ??????? ???? ???? ??????? ????
???? ???????? ??????
18
???????. Erlang.
  • ??????????????
  • ??????????? ? ?????????? ????????????????
  • ?????? ??????????? ?????????.
  • ????? ???????????.
  • ?????? ??????????????.

19
Chapel
  • ??????????? Cray Inc.
  • ???????? ? 2006 ????
  • ????? ?hapel-1.2.0 (29 ??????? 2010)
  • ????????? ???????????? ????????????????

20
Chapel
  • ???? Chapel (Cascade High Productivity Language)
    ??? ?????????? ? ?????? ??????? ??????, ???
    ??????? ? ????????? DARPA ??????????????????
    ???????????? ???????(HPCS).
  • ????? ???????? ???? ????????? ??????????????
    ????????????????? ??????????, ????? ??????????
    ???????? ???????? ?????? ?????????, ?????? ???
    ????????? ???????????? ?????.
  • ?????????????? ??????????????????
    ????????????????? ????????????? ??????????

21
?????????
  • ? ???????? ????????? ??????????? ?? C ? Modula.
  • ??????? ???????
  • ZPL, HPF ??????????? ??????, ????????? ????????,
    ?????????????? ???????
  • CRAY MTA C/Fortran ??????????? ??????,
    ?????????????
  • CLU, Ruby, Python ?????????
  • ML, Scala, Matlab, Perl, Python, C ??????? ????
  • Java, C ???, ???????????? ?????
  • C ???????

22
????????? ??????????????
  • ???? Chapel ??? ?????? ?? ?????? ??????
    ???????????? ?????????-??????????? ????????????
    (Partitioned Global Address Space).
  • ???????????? ?????????????, ????? ????????? ???
    ?????? ? ????????????
  • ????? ???????? ??? ????????????? ???????? ??
    ?????????????? ????? ???????
  • ???????????? ??? ??????????? ?? ??????, ??? ?
    ??????????? ?????.

23
????????? ??????????????
  • ?????????? ????????????.
  • ???? Chapel ???????????? ?????? ????????????? ?
    ??????????? ???????? ???????????, ??????????
    ???????? (locale).
  • ?????? ?????????? ????????? ????????????? ?
    ?????????? ?????? ???????, ??????? ????????????
    ???????????? ???????? ?? ?????????? ????????,
    ????? ??? ?????????????? ????.
  • ? ???????????? ???? ?????????, ??? ?????????????
    ?????? ?? ???????.

24
????????? ??????????????
  • ??????????? ????? ???????? begin
  • ?????????
  • begin stmt
  • ?????????
  • ??????? ???????????? ?????? ??? ?????????? stmt
  • ?????????? ????????? ???????? ?? ???????????????
  • ??????
  • begin writeln(hello world)
  • writeln(good bye)
  • ????? ????????????.

25
????????? ??????????????
  • ??????????? ????? ???????? cobegin
  • ?????????
  • cobegin stmt-list
  • ?????????
  • ??????? ???????????? ?????? ??? ??????? ?????????
    stmt-list
  • ????????????? ??? ?????????? ?????
  • ??????
  • cobegin
  • consumer(1)
  • consumer(2)

26
????????? ??????????????
  • ??????????? ????? ???????? coforall
  • ?????????
  • coforall index-expr in iterator-expr stmt
  • ?????????
  • ????????? ???????????? ?????? ??? ?????? ????????
    ?????
  • ????????????? ??? ?????????? ?????
  • ??????
  • begin producer()
  • coforall i in 1..numConsumers
  • consumer(i)

27
????????? ??????????????
  • ???????? ?????? ???????? reduce
  • ?????????
  • reduce-op reduce iterator-expr
  • ?????????
  • ????????? ??? ??????? ???????? ?????? ????????
    reduce-op
  • ??????
  • bigDiff max reduce i in 1..100 abs(A(i)
    B(i)

28
????????? ??????????????
  • ?????? ? ????????. ??????.
  • var x, y real // x ? y ?? locale 0
  • on Locales(1)
  • // migrate task to locale 1
  • var z real // z ?? locale 1
  • z x y // ????????? ?????? ? x ? y
  • on Locales(0) do // ??????? ?? locale 0
  • z x y // ????????? ?????? ? z
  • // ??????? ?? locale 1
  • on x do // ??????? ?? locale 0
  • z x y // ????????? ?????? ? z
  • // ??????? ?? locale 1
  • // ??????? ?? locale 0

29
???????. Chapel.
  • ?????? ??????????? ?????????-?????????? ??????
  • ??????????? ??????? ???????????, ???????????? ??
    ???????? ?????????????? ????
  • ????????? ???????????? ???????????? ?? ?????? ?
    ?? ????????
  • ??????????? ????????? ??? ??? ???????????? ??????
    (???????????? ?????? ? ???????, ?????????? ??????)

30
??????? ?? ????????.
Write a Comment
User Comments (0)
About PowerShow.com