www.hurray.isep.ipp.pt
Technical Report A Parallel Programming Model for Ada
Hazem Ali Luís Miguel Pinho HURRAY-TR-110902 Version: Date: 09-13-2011
Technical Report HURRAY-TR-110902
A Parallel Programming Model for Ada
A Parallel Programming Model for Ada Hazem Ali, Luís Miguel Pinho IPP-HURRAY! Polytechnic Institute of Porto (ISEP-IPP) Rua Dr. António Bernardino de Almeida, 431 4200-072 Porto Portugal Tel.: +351.22.8340509, Fax: +351.22.8340509 E-mail:
[email protected],
[email protected] http://www.hurray.isep.ipp.pt
Abstract Over the last three decades, computer architects have been able to achieve an increase in performance for single processors by, e.g., increasing clock speed, introducing cache memories and using instruction level parallelism. However, because of power consumption and heat dissipation constraints, this trend is going to cease. In recent times, hardware engineers have instead moved to new chip architectures with multiple processor cores on a single chip. With multi-core processors, applications can complete more total work than with one core alone. To take advantage of multi-core processors, parallel programming models are proposed as promising solutions for more effectively using multi-core processors. This paper discusses some of the existent models and frameworks for parallel programming, leading to outline a draft parallel programming model for Ada.
© IPP Hurray! Research Group www.hurray.isep.ipp.pt
1
!"#$%$&&'&"#%()%$**+,)"-(.'&"/(%"!.$" " !"#$%&'()&
@9A0&B)?)>>?>5&
(%>=)0$>?)>>?>5& &
!"#$%!&$! "#$%!&'$!()*&!&'%$$!+$,)+$*-!,./01&$%!)%,'2&$,&*!')#$!3$$4!)3($!&.! ),'2$#$!)4!24,%$)*$!24!0$%5.%/)4,$!5.%!*246($!0%.,$**.%*!37-!$868-! 24,%$)*246! ,(.,9! *0$$+-! 24&%.+1,246! ,),'$! /$/.%2$*! )4+! 1*246! 24*&%1,&2.4! ($#$(! 0)%)(($(2*/8! :.;$#$%-! 3$,)1*$! .5! 0.;$%! ,.4*1/0&2.4! )4+! '$)&! +2**20)&2.4! ,.4*&%)24&*-! &'2*! &%$4+! 2*! 6.246! &.!,$)*$8!/$),9.! B$*264-!M&)4+)%+2N)&2.4-!G)461)6$*8!
?)@A+,1.! A+)-! O)47>,.%$! *7*&$/*-! L)%)(($(! 0%.6%)//246-! G26'&;$26'&! &'%$)+*!/.+$(!
BC" DE$%F6G&$DFE/ O1(&2>,.%$! )%,'2&$,&1%$*-! 24&$6%)&246! *$#$%)(! 0%.,$**.%*! .4! )! *246($! ,'20-! )%$! P12,9(7! 3$,./246! ;2+$*0%$)+-! $#$4! 24! */)((! $/3$++$+! *7*&$/*8! ?'2*! ,'$)0(7! )#)2()3($! ,./01&)&2.4)(! 0.;$%! /)9$*! 0)%)(($(! 0%.6%)//246! /.%$! &')4! $#$%! )! ,.4,$%4! 5.%! *.5&;)%$! +$#$(.0$%*-! *24,$! &'$! *$P1$4&2)(! 0%.6%)//246! /.+$(! +.$*!4.&!*,)($!;$((!5.%!*1,'!/1(&2>,.%$!*7*&$/*!DKE8! ?'$!,1%%$4&!&%$4+!&.!1*$!/1(&2>,.%$!0()&5.%/*!;2((!&'1*!4.&!0%.#2+$! 2/0%.#$/$4&*! .4! &'$! 0$%5.%/)4,$! .5! *.5&;)%$-! )4+! /)7! $#$4! 2/0),&! 2&*! %$(2)32(2&7-! 25! 0%.6%)//246! $4#2%.4/$4&*! )%$! 4.&! )(*.! !
L$%/2**2.4!&.!/)9$!+262&)(!.%!')%+!,.02$*!.5!)((!.%!0)%&!.5!&'2*!;.%9!5.%! 0$%*.4)(!.%!,()**%../!1*$!2*!6%)4&$+!;2&'.1&!5$$!0%.#2+$+!&')&!,.02$*!)%$! 4.&! /)+$! .%! +2*&%231&$+! 5.%! 0%.52&! .%! ,.//$%,2)(! )+#)4&)6$! )4+! &')&! ,.02$*! 3$)%! &'2*! 4.&2,$! )4+! &'$! 51((! ,2&)&2.4! .4! &'$! 52%*&! 0)6$8! ?.! ,.07! .&'$%;2*$-! .%! %$013(2*'-! &.! 0.*&! .4! *$%#$%*! .%! &.! %$+2*&%231&$! &.! (2*&*-! %$P12%$*!0%2.%!*0$,252,!0$%/2**2.4!)4+Y.%!)!5$$8! 67812,9::-!a.#$/3$%![JK`-!Q`KK-!B$4#$%-!H.(.%)+.-!bMA8! H.07%26'&!Q`KK!AHO!^\]>K>WZ`C>K`Q]>WYKKYKK888cK`8``8!
!
$#.(#$+! &.! ),,.14&! 5.%! &'$! 4$;! 0)%)+26/! .5! 4)&1%)((7! 0)%)(($(! ')%+;)%$! DQE8! *,)($! 0)%)(($(2*/! 5.14+! 24! /1(&2>,.%$*8! I%)/$;.%9*! *1,'! )*! H2(9! DCE-! $4+$+! P1$1$*-! ;2&'! G)**264/$4&! &70$*! R)(*.! 94.;4! )*! 2//1&)3($*S! 5.%! $@,')46246! +)&)! )4+! *74,'%.42N)&2.4! 3$&;$$4! 0)%)(($(!3(.,9*8!! A5&$%! &')&-! &'$! %$*$)%,'! $#.(#$+! 24! DK[E! 37! +$524246! )! 4$;! 0%.6%)//246!()461)6$!,)(($+!B$,()%)&2#$!A+)!;'$%$!0)%)(($(2*/! 2*!2/0(2,2&8!B$,()%)&2#$!A+)!2*!)!0%.6%)//246!()461)6$!3)*$+!.4! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!! Q
! ?'$%$! 2*! 24+$$+! )! 6$4$%)(! &%$4+! &.! (..9! 3),9! &.! &'$! 0)*&! 24! )((! )%$)*!.5!,./01&$%*!)*!0)%)(($(!0()&5.%/*!3$,./$!;2+$*0%$)+8!
)!L)*,)(>(29$!*13*$&!.5!A+)8!!?'$!+255$%$4,$!!3$&;$$4!!B$,()%)&2#$!! A+)! ! )4+! ! &'$! 0%$#2.1*(7! 0%.0.*$+! $@&$4*2.4! ! 2*! ! &')&! ! )((!! #)%2)3($*! ! )%$! ,.4*2+$%$+! )*! ! *246($>)**264/$4&8! ?'2*! ! ! )((.;*! 2/0(2,2&! 0)%)(($(! $@$,1&2.4! .5! 0%.6%)/*! ;2&'! *74,'%.42N)&2.4! &'%.16'!%14>&2/$!+)&)5(.;8!! A(&'.16'! 24! B$,()%)&2#$! A+)! )((! *&)&$/$4&*! ,)4! 3$! $@$,1&$+! 24! 0)%)(($(-!;$!3$(2$#$!&')&!2&!;2((!4.&!3$!10!&.!&'$!$@0$,&)&2.4*!5%./! &'$! 0.24&! .5! #2$;! .5! 0$%5.%/)4,$8! ?'2*! ,./$*! 5%./! &'$! 5),&! &')&! )((! 0)%)(($(! $@$,1&2.4*! )%$! /)00$+! &.! A+)! &)*9*-! &'1*! ,%$)&246! '26'$%! .#$%'$)+! +1%246! $@$,1&2.4! &')&! ;2((! $(2/24)&$! )47! 6)24$+! *0$$+10! 5%./! 0)%)(($(! $@$,1&2.4! DKWE! O.%$.#$%-! &'2*! #$%7! 524$! 6%)24!0)%)(($(2*/-!;'2,'!,./$*!5%./!&'$!5),&!&')&!$),'!*&)&$/$4&! 2*!)!0)%)(($(!3(.,9-!/)7!($)+!&.!)!/)**!*74,'%.42N)&2.4!.#$%'$)+! 3$&;$$4! +255$%$4&! 0)%)(($(! 3(.,9*8! ?'2*! /$)4*! +$6%)+$+! .#$%)((! 0$%5.%/)4,$8! ?'$! 0%$#2.1*! +2*,1**2.4! +$/.4*&%)&$! &'$! 6%.;246! 4$$+! 5.%! ,.4*&%1,&*! .%! /$&'.+*! &')&! +$524$! &%1$! 0)%)(($(2*/! 24! A+)! );)7! 5%./! &'$! ;$((! 94.;4! &)*9! /.+$(-! ;'2,'! *'.1(+! 3$! 1*$+! 5.%! ,.4,1%%$4,78! A*! e.3$%&! :)%0$%! *&)&$*F! ;*')%246-! ;.%9>*$$9246! )4+! ;.%9> *&$)(246! 514,&2.4)(2&7! &'%.16'! )4! $@&$%4)(! (23%)%78! "1%! 0%.0.*)(-! )(&'.16'! 24! &'$! *)/$! ,.4&$@&-! 2*! +255$%$4&-! 0%.0.*246! &')&! A+)! %$#2*2&*! 2&*! 0)%)(($(! 0%.6%)//246! /.+$(-! 24&$4+246! &.! $@0(.%$! )! ()461)6$! 3)*$+! )00%.),'! &')&! '2+$*! 5%./! &'$! 0%.6%)//$%! &'$! ,.4,%$&$! /)00246! .5! &'$! )00(2,)&2.4! 24&.! &'$! 0)%)(($(! 0()&5.%/! ;'2(*&!)((.;246!'2/Y'$%!&.!+$524$!&'$!0.&$4&2)((7!0)%)(($(!3(.,9*8!
KC" 8!%!::I:/8%F=%!JJDE=/JF6I:#/ *&$)(246!)(6.%2&'/8!
((((((((((((G")H:I''$CG#J:K%2/-*.:;)/ ?'$! $@)/0($! 24! G2*&246! W! 0%.#2+$*! &;.! .5! &'$*$! +2%$,&2#$*8! ?'$! 52%*&-!;'2,'!2*!1*$+!3$5.%$!3.&'!%$,1%*2#$!,)((*!&.!&'$!&*.!514,&2.4!
4.&$*! &'$! 0%$>0%.,$**.%! &')&! &'$! 5.((.;246! 3(.,9! .5! ,.+$! ,)4! 3$! $@$,1&$+! 24! 0)%)(($(8! ?'1*-! &*./+( A( 84! )4+!! &*./+(A(94!,)4!3$!$@$,1&$+!37!&;.!0)%)(($(!&'%$)+*8!?'$!524)(! +2%$,&2#$!,)1*$*!&'$!/)24!&)*9!&.!;)2&!5.%!&'$!$4+!.5!&'$!&)*9*!&')&! 2&!')*!,%$)&$+8!?'$!)Q"#%O/W4!245.%/)&2.4!245.%/*!&'$!,./02($%! &')&! #)%2)3($! W! ;2((! 3$! ),,$**$+! 37! +255$%$4&! &'%$)+*-! &'$%$5.%$! $@,(1*2.4!)(6.%2&'/*!*'.1(+!3$!1*$+8! ?'$! ;.%9! 24! D^E! )(*.! 0%.#2+$*! )! 3%2$5! 0%.0.*)(! '.;! A+)! ,.1(+! ')#$! )! *2/2()%! )00%.),'-! 37! 1*246! )! *$&! .5! !#",U")-! ;2&'! &'$! ,./02($%! ,.4#$%&246! &'$! ,.+$! &.! 1*$! &'$! 6$4$%2,! (23%)%2$*-! &'1*! '2+246!/.%$!,./0($@!0%.6%)//2468!
KCK" :'0*2'*)/3'.)1/'77,+'5;)./ ?'$! 524)(! $@)/0($! 0%$*$4&*! &'$! ()461)6$! 3)*$+! )00%.),'! .5! H2(9! L(1*!DK]E-!)4!$#.(1&2.4!.5!H2(9!DCE!Y!H2(9gg!DK^E-!&')&!0%.#2+$*!)! #$%7! *2/0($! )4+! */)((! *$&! .5! (24612*&2,! $@&$4*2.4*! &.! Hgg! &.! *100.%&! 0)%)(($(! )00(2,)&2.4*-! .4! &.0! .5! (23%)%2$*! )4+! %14&2/$*! 0%.#2+246! ;.%9>*&$)(246! ,)0)32(2&2$*8! V$,)1*$! 2&! 2*! )! */)((! $@&$4*2.4-!0)%)(($(2N246!$@2*&$4&!,.+$!2*!)!#$%7!$)*7!&)*98!! )*!(&*./)*!(+4( S( ((()2(/+(>(94(+(!-+*(+6( ((()*!(W7(J6( ( (((W(?(0)4$8#'"9*(&*./+B846( (((J(?(&*./+B946( ( (((0)4$8#&*06( ( (((+(!-+*(WDJ6( (((V( :-.(-0*/R/L/&->S/IN'97>)// ?'$!
QC" !/8%F8F#!:/MF%/!6!/
?'$! 0%.0.*)(! 24&%.+1,$*! &;.! 4$;! 9$7;.%+*F! !"#"$$%$-! ;'2,'! *0$,252$*! 0.&$4&2)((7! 0)%)(($(! .0$%)&2.4*-! )4+! &323#%-! ;'2,'! *0$,252$*!#)(1$*!;'2,'!)%$!,)(,1()&$+!)*74,'%.4.1*(78!!
QCB" 8','>>)>-T'3>)/3>+5S./ A+)_*! 3(.,9! ,.4*&%1,&! 2*! )! 4)&1%)(! ,)4+2+)&$! 5.%! +$,()%246! 0.&$4&2)((7! 0)%)(($(! ,.+$-! )*! 2&! $4,(.*$*! )! *$P1$4,$! .5! *&)&$/$4&*! 24! )! *246($! *&)&$/$4&! &')&! ,)4! 3$! 0(),$+! )47;'$%$! 24! )4! A+)! 0%.6%)/8!I1%&'$%/.%$-!&'$!#)%2)3($*!24!&'$!+$,()%)&2#$!0)%&!,)4!3$! ,%$)&$+!24!&'$!),&1)(!,.%$!.5!$@$,1&2.4-!*2/2()%!&.!0%2#)&$!#)%2)3($*! 24! "0$4OL-! )((.;246! 5.%! )! 3$&&$%! 1&2(2N)&2.4! .5! &'$! (.,)(! ,),'$*8! G2*&246! [! 0%.#2+$*! &'$! *&%1,&1%$! .5! &'$! 0)%)(($(! 3(.,9-! ;'2,'! 2*! 2+$4&252$+!;2&'!&'$!!"#"$$%$!9$7;.%+8! !!!""!.*#!()2'(!;5'! (((.(04"+(% ((((((Z'
=#=$)?@!
(((.(04"+(% ((((((Z'
>&
L)%)(($(2N)3($!514,&2.4*!
(
>&
L)%)(($(2N)3($!5.%!(..0*!
!!!""!'0%./-$*.*=0!)7)/=#:*.! (((\':E'U%2Q*+,:]$)%6( !!!!
(((^(1?(-323#%:=6(""!A-)!$)0=(#!*+!#-)!(
((((((((((((((((((""!/*3&=#'#:*.!:0!$)B=:$)5!
((((((((((((((((((""!/*3&=#'#:*.!:0!$)B=:$)5!
!!!!!!!!!!!!!!!!!!""!C$*2$'3!9:((!9':#!+*$!!
!!!!!!!!!!!!!!!!!!""!C$*2$'3!9:((!9':#!+*$!!
!!!!!!!!!!!!!!!!!!""!).5!*+!&'$'(()(!+=.#:*.!
!!!!!!!!!!!!!!!!!!""!).5!*+!&'$'(()(!,(*/4!
:-.(-0*/W/L7','>>)>/3>+5S/)N'97>)/
:-.(-0*/W/L7','>>)>/3>+5S/)N'97>)/
QCH" 8','>>)>-T'3>)/V205(-+0./ A!*$,.4+!,.4*&%1,&!0%$*$4&$+!24!&'2*!0)0$%!2*!)!*2/0($!;)7!5.%!&'$! 0%.6%)//$%! &.! *0$,257! &')&! )! 514,&2.4! ,)4! $@$,1&$! 24! 0)%)(($(8! ?'$%$5.%$-! ;'$4! )! ,)((! &.! &'$! 514,&2.4! 2*! 0$%5.%/$+-! &'$! 14+$%(7246!%14&2/$!,)4!+$,2+$!&.!0)%)(($(2N$!&'$!,)((-!25!&'$%$!)%$! $4.16'!)#)2()3($!,.%$*8! I.%!24*&)4,$-!&'$!$@)/0($!24!G2*&246!]!/)0*!&'$!0)%)(($(!I23.4),,2! 514,&2.4-! )*! 0%$*$4&$+! 24! &'$! 0%$#2.1*! *$,&2.4-! ;2&'! &'$! 0)%)(($(! 514,&2.4!,.4*&%1,&8! (((BB(+'2($%,"$(;O"( ((('"+"44(4%2-*0!),*(-*.'+">)>-T'3>)/V+,/>++7./ ?'$!()*&!,.4*&%1,&!&')&!,)4!3$!0)%)(7N$+!2*!&'$!&'#($''!8!a.&$! &')&!24!&'2*!,)*$-!2&!2*!4.&!/)4+)&.%7!&')&!$),'!2&$%)&2.4!.5!&'$!(..0! 2*! $@$,1&$+! 24! 0)%)(($(8! j552,2$4&! %14&2/$*! /)7! 0)%&2&2.4! &'$! +)&)! *$&!24&.!3(.,9*-!)4+!)**264!$),'!3(.,9!&.!)!0.&$4&2)((7!0)%)(($(!142&! R)4! )00%.),'! *2/2()%! &.! ?LG_*! I"#"$$%$C-'#! D\ES8! G2*&246! K`! 0%.#2+$*!)4!$@)/0($!.5!24,%$/$4&246!)((!$($/$4&*!.5!)4!)%%)78! (((""!.*#!()2'(!;5'! (((2,+(R()*(`3&&%#a5"+,%( ('"+"44(4%4,,'( ((((((`3&&%#/R4(1?(`3&&%#/R4(D(86( ((((*.%'"+"44(4%4,,'6( :-.(-0*/BY/L/8,+7+.'>/V+,/'/7','>>)>/>++7/
(((/(1)*%
A!/.%$!,./0($@!)00%.),'!2*!%$P12%$+!25!&'$!5.%!(..0!2*!0$%5.%/246! )4!)66%$6)&2.4!R(..0!2&$%)&2.4*!)%$!4.&!24+$0$4+$4&S8!I.%!$@)/0($-! G2*&246! KK! 0%.#2+$*! )4+! $@)/0($! .5! )! *$P1$4&2)(! &'#( $''!-! 0$%5.%/246! &'$! *1/! .5! )4! )%%)78! "3#2.1*(7-! &'2*! ,)44.&! 3$! 0)%)(($(2N$+!;2&'!&'$!*)/$!)00%.),'!)*!24!G2*&246!^8!
(((((()2(="$3%(>(9(!3(*(
(((E3U(1?(_6(
(((((((((+(!-+*(="$3%6(
(((2,+(R()*(`3&&%#a5"+,%(4,,'(
((((((+8(1?(-*.'+">)>/V205(-+0/ a.&$!&'$!1*$!.5!&'$!!"#"$$%$!9$7;.%+!24!&'$!514,&2.4!*264)&1%$! C -! )4+! &'$! *0$,252,)&2.4! .5! &'$! %$&1%4! #)(1$! )*! )! &323#%-! )*! &'$! 514,&2.4! /)7! 3$! $@$,1&$+! )*74,'%.4.1*(7-! &'1*! &'$! ,)((246! ,.+$! /1*&! ;)2&! 5.%! 2&*! ,./0($&2.4! ;'$4! &'$! %$&1%4! #)(1$! 2*! %$P12%$+! RG2*&246!^S8! ""!.*#!()2'(!;5'! -*.:5%)1(2-!-+((0"23#"$6( /(1)*% -*.:5%)(1?(-*.'+">)>/>++7/A-(;/'**,)*'(-+0/ a.&$!&')&!&'$!,.+$!)5&$%!&'$!!"#"$$%$(&'#($''!!;)2&*!5.%!)((! 0)%)(($(!2&$%)&2.4*!&.!&$%/24)&$-!3$5.%$!3$246!)3($!&.!$@$,1&$8!
QCQ" 6-.52..-+0/ ?'$! ;.%9! 0%$*$4&$+! 24! &'2*! 0)0$%!2*!*&2((!0%$(2/24)%7!)*!&'$%$!)%$! *$#$%)(! 2**1$*! ;'2,'! 4$$+! &.! 3$! ,.4*2+$%$+8! I.%! 24*&)4,$-! &'$! 24&$%),&2.4! .5! 0)%)(($(! ,./01&)&2.4*! )4+! &'$! $@,$0&2.4! /.+$(! .5! A+)! 2*! ,./0($@-! )*! 0)%)(($(! ,./01&)&2.4! /)7! 3$! 0$%5.%/$+! 24! ;.%9$%! &'%$)+*-! &'1*! 24! )! ,.4&$@&! ;'2,'! 2*! 4.&! .5! &'$! $4,(.*246! &)*98! A(*.! $@2&246! 5%./! 3(.,9*! .%! (..0*! 24! %$,1%*2#$! 0)%)(($(! ,./01&)&2.4*! /1*&! &)9$! 24&.! ),,.14&! &'$! 0.&$4&2)(! 4$$+! &.! )3.%&! .&'$%!,./01&)&2.4*!3$246!$@$,1&$+!24!.&'$%!&'%$)+*8!! a$#$%&'$($**-! &'$! &'%$$! 0%.0.*$+! ,.4*&%1,&*! 5.%! 0)%)(($(2*/! /$4&2.4$+! 24! &'$! 0%$#2.1*! *$,&2.4*! R0)%)(($(2N)3($! 3(.,9*-! 514,&2.4*! )4+! 5.%>(..0*S-! ,)4! 3$! &'$! 3)*2*! 5.%! ,%$)&246! )! 0)%)(($(! 0%.6%)//246! /.+$(! 24! A+)8!*')%246! /.+$(8! *')%2468! A4.&'$%! )%$)! ;'2,'! 4$$+*! &.! 3$! ,.4*2+$%$+!2*!&'$!1*$!.5!4.4>3(.,9246!+)&)!*&%1,&1%$*!.%!*.5&;)%$! &%)4*),&2.4*!24*&$)+!.5!(.,9>3)*$+!+)&)!*')%2468!! I24)((7-!&'$!24,.%0.%)&2.4!24!&'$!A+)!%14&2/$!/.+$(!.5!&'$!*100.%&! &.! &'$! 0)%)(($(2N)3($! ,./01&)&2.4)(! 142&*! 2*! )(*.! .5! 0)%)/.14&! 2/0.%&)4,$8!! L.%&161$*$! I.14+)&2.4! 5.%! M,2$4,$! )4+! ?$,'4.(.67-! )4+! &'$! Ae?\W]-!M$0&$/3$%!K^^^8! DKKE&O..%$-!V8-!hA!,./0)%2*.4!.5!;.%9>*')%246-!;.%9>*$$9246-! )4+!;.%9>*&$)(246!0)%)(($(2*/!*&%)&$62$*!1*246!L)%)5524!;2&'! A+)!Q``Zi-!A+)!b*$%!X.1%4)(-!k.(!CQ-!a8!K-!O)%,'!Q`KK8!
:EEG)1!H)IJ&2),##%,5)$"#>'&'#$')"#)!"-*%('&) /$.'#$'!RHMH!U^ZS-!H8!X24*'.46!:;)46!)4+!V$&&7!=8!:;)46! Rj+*8S8!AHO-!a$;!p.%9-!ap-!bMA-!\C>]`-!K^^Z8! B"0)%)(($(!A+)!%14>&2/$! *7*&$/-!*2/1()&2.4!)4+!$/02%2,)(!%$*1(&*i-!L%.,$$+246*!.5! M$#$4&'!G$#$(!L)%)(($(2*/! 24!A+)i-!?%2A+)!^K-!",&.3$%!K^^K!
DK]E&