Committed-Choice JKL Fleng PNOQRSVUMTI]d lf, tm Ax}k [F}uzb 7{3{1XY Fleng ¥, ¶Á´¹ÀÁ~¤\®i¬¡£ª«, ºÀ±½¼£a¬§¤{ÃÆ®nÉ¬¡E ¬. , È^¤ÂvwÅ£`©,°Á¸Á»µ·k. {Ãv®oB¢qv£ºÀ±½¼¤Âv®k¬¡­¦, °Á¸Á»µ·®oW¬¡ ¬. , Fleng £Âv®ºÀ±½¼¤?
c®|£k¬¡¥h@ ¥¢. b¥, Committed-Choice XY Fleng £, ºÀ±½¼¤?c®|£¤Âv®_sC¬¡®er¡, ¯¿²¾³¼¤p>, Èj®^¢. ¨, {ÃÇÄ yD®^¢¡£ª«¤gZÆ®©.
Committed-Choice

A static granularity optimization method of a committed-choicelanguage FlengTakuya ARAKI, Hidehiko TANAKA
School of Engineering, the University of Tokyo
7{3{1 Hongo, Bunkyo-Ku, TokyoA committed-choice language Fleng can extract maximum parallelism from any programs using
data ow synchronization. But there is large overhead because the granularity of execution isvery ne. If granularity of a program is coarsened, such overhead can be reduced; but it is noteasy to make a Fleng program coarse because it may change behavior of a program. In thispaper, we propose a granularity optimization algorithm of Fleng programs. We implemented
this algorithm and evaluated it on a parallel computer.

11=ó87. 8, %¬ö, mul %& B %?9ÙI7. =ó7!& #4. %45#¬ö,add %=ó9C" B %?9Ù.7. , mul &=ó;A> (]^hnc) , add %=ó9C" B %?9ÙI7!, =ó;ûó (W[`XgYb) 7. %0ñ
; # =å70, ¸&=*u 36, ¤ù67!& #4. ¸&?9Ù.4#48Ù
.478% 2 %°t;1, *UÙ..6', %?9:7!&94. ¸%?;Ù07!
;yw=7!45.
þ&8%45$.

ÊÌÖæì Fleng[2] &, =*u¸! ÓïÏÚìï}ÿ%0ñ;47!$46, Èïê û¸ ú$S7*¹;ü0, ÜìÆèä$07
+%*¹;BI7!98 37. 9, Fn07@$ø, '$w$%*¹;BI 7.
8, =ó%!U9­$þ840, Èïê%ÚÂïÅ, ÌëÑÕú%ÇîÒÅÌÔÌÀÑÐ, }ÿ, G±!4, *¡$7ÃïØïÝÑÕ9w#7. 9, %ÃïØïÝÑÕ%2ä9, î
M#=h%á!#7.
ÃïØïÝÑÕ%?#ã+&, =ó%!U9þ8;
7!$37. 9, *U;H3#4K
U$ÜìÆèä%!U;w 7!9 8', ÃïØïÝÑÕ;Hä7!9 7. 8, Fleng $74, !U;ÜìÆèä%&8;6$w 7
!&' &#4. !'$ÜìÆèä;ð7!,ÓÑÕìÑÅ;, 40 37.
6ßÎ&, Committed-Choice Öæì Fleng $74
, ÜìÆèä%&8;6$%!U;üN47!;M!, ¾êÈéÍä%J", =h, 7;ó#.
Committed-Choice,()foo(true,R):- R = 1.
foo(false,R):- R = 0.

%ÜìÆèä&x*,¸9 true #5' R = 1, false#5' R = 0 ;=ó7ÜìÆèä 37. %¬ö,
 ,"!}$, x*,¸9 .7. ÉÌßîÕ,?9Ù.!9 ¾ÅÒ¿ÞÀÔ8, %?$4
þ;ó#5.
., .J0.&add(#A,#B,R):- compute(+,A,B,R).

%45I5847.  `#' %4¸&Ôq
487. s!;. ., `compute' &ÉÌßîÕ$=ó, ,-¾ÎîÛéæì% add ($ÇîÙÀê8745#1% 37. 9, compute;47ÿ& # $4?9Ôq4847!;©# 8'#5#4.

NRS Fleng
Fleng &+Öæì;d^!7*3õ¡æì
37. ÊîÏÑÅÌ& Prolog %1%!# 4479, ØÑÅÔèÑÅ;ó#:#4!45Q , ÎãîÒ¿ÅÌ&w (#7. Committed-Choice Öæì$&,o$ GHC, KL1 #"937.
Fleng &, +%Èïê;*$=ó7.
 =*u¸;4ÓïÏÚìï}ÿ;!7.
!$46, þ!U, ô*#ÜìÆèä%=ó98
37. %Q9 Fleng %w #E$#47. #3$);3#95\ 7.
2

Committed-Choice}UÜìÆèä%!U;w 7@!, Èïêö;47. Èïêö!&, ¸%Èïê; 1 %
Èïê$.!07!$4!U;w 7@
37. #3$Èïêö%@$4K+7.
3}UÈïêö;ó#5¬ö&, 8;N7!$
4ÜìÆèä%&894#4!;©#8'#5#4. %I&8,"'#! &#4.
 $);37.
3.1

foo(A,R):- add(A,1,B), mul(B,2,R).

%ÜìÆèä& R = (A + 1) * 2 ;=ó71% 37. `:-' %új;f_c, -j;iaX!44, cq ors!é). Fleng %ÜìÆèä&%45#I
5[%D.6 37. Fleng $7 7Ø.%=$&\xm!é'87. %ÜìÆèä%¬ö, foo(A,R) !45¢ÿÈïê96587!, add(A,1,B), mul(B,2,R)!45 2 %Èïê$¤ ù658, 889*$

foo(U,V,R,S):- add(U,U,R), mul(V,V,S).

%ÜìÆèä$74, foo 85é(I847 add ! mul ;ö,foo(U,V,R,S):- add_mul(U,V,R,S).
add_mul(#U,#V,R,S):compute(+,U,U,R), compute(*,V,V,S).

2!7!&.
);4\ 7. ¶ 2%45#ÓïÏÚìïÆ
!45é(I;ó#¬ö, èÚ 35:87ÜìÆèä;ò67.
1!%%ÜìÆèä &, add & Tmp = 2 ;I&, mul& Tmp ;&! S = 4 !45Ú9;. 8,ðë%ÜìÆèä & add mul(1,Tmp,Tmp,S) 9 Tmp%?9Ù.7%;sm 70ÓÑÕìÑÅ7.
9Èïê;ö7!$4ÜìÆèä%&8;6.5% , %ù&í6 37. Èïêö;ó#5¬ö&, %45#ÜìÆèä%&8;
6.5ù; # 8'#5#4.
%ÜìÆèä$74, add ! mul %ö9ÓÑÕìÑÅ;, 4%&#8;ò6/45.
â%ÜìÆèä%ÓïÏÚìïÆèÚ;¶ 1%új$,ö¬ö%ÓïÏÚìïÆèÚ;¶ 1%-j$9.
foo(1,Tmp,Tmp,S)

fBBhACh

f_g

Cgf_h

CUVUAf_g_hVgaddadd

add_mulRSS¶ 2: Èïêö%¾êÈéÍä

R/&¸, 0÷&Èïê;35:. %ÜìÆèä
$74, Èïê f ! g 9ö 78"58;ò67!, g & h ;ð f $úYM$%n470 f ! g&ö7!& #4. =ÿö¬ö, ÉÀÅ
éÑÅ#%nûÕ;1.5. %45#ÉÀÅéÑÅ#%nûÕ&, 2 %Èïê9úYM$%n7
ç6, ¼7. ö$4, }Èïê85I}Èïê$7%n;1785 37.
 $Èïê f ! h 9ö 78;ò67!, h &f $FY%n47% , ö8 37. f ! h ;ö f h ! g &^,"!}45$ö8 37. ÚÒ f, g, h & 1 %Èïê$ö8 37.

¶ 1: ÓïÏÚìïÆèÚ , U, V, R, S &ÝÑÕ;G,¸!ô$à647¸ 37. 9V 9 R $, U 9 S $%n78¹9n07. 8;Þ [3] %ì;
4tp<vqz!é(, Q` 35:.
öë%ÓïÏÚìïÆèÚ;à7!, _0M#%
nûÕ;G, U 85 S ;G U *, 374& V
85 R ;G V *!45]Y[l_[<vqz9n07. ÉÀÅéÑÅ#%nûÕ937!, :%I&$%n7: 3785, ÓÑÕìÑÅ;, 4
. 1!%ÜìÆèä &, ÉÀÅéÑÅ#%nûÕ&n0#40, ÓÑÕìÑÅ945#4.

GM
Èïê%ö988"58;I7$&, 2 %Èïêú$úYM#%nûÕ9n0#4!;©# 8'#5#4. 8&íù#445, !c$ó#5937. 8!4, n0#4%nûÕ
. n07!.5!, 8#ö18 37!I.5. #:, %nûÕ%ñX%»ö
9, Èïêö%¹$w #.Ñ;67.
6[ &%nûÕ%»ö#ñX$4K+7.
3.3.1 jxc
Fleng &û¸Öæì#"!(#6, ¸9&8I&8ÊîÏÑÅÌ85&> #4. %nûÕ;ñX7$&¸%I&;@5# 8'#5#49, &83.3}U|}~ÓÑÕìÑÅ%ã+&ÉÀÅéÑÅ#%nûÕ 3785, Èïêö;ó#5ÿ$&, ÉÀÅéÑÅ#%nûÕ;15#445$8'44. 9ý6¾êÈéÍä&8%45$#7.
3.2

37 2 %Èïê9ö8 37¯Û&, % 2 %Èïê%ú$úYM#%nûÕ9n0#4!
37.
8&, 2 %Èïêú$úYM#%nûÕ9n07¬ö&, ö7!8#5ÉÀÅéÑÅ#%nûÕ
;16I.50 37.
3

f_c ÝÑÕ&, ü¢$3ö #4)%45$, é(Ij ,¸}1%%nûÕ;16I.
47¬ö937. 8&åïÕ%85#4áÓ¿ïÈïê!c }°Ð 37. 9, åïÕ·+,%nûÕ%ñX$74, ÝÑÕ&áÓ¿ïÈïê!c{7$ 5. %¬ö, ÝÑÕ%åïÕ&ô85à¬ö%åïÕ!35"r$#7.
3.3.3 £<vqz¡b[ n0~7%nûÕ%Í0;99, %A$&36~#4%nûÕ1n07. )6'I&8> #4¸$4&, !cj$V># 8'#5, %nûÕ;ñX7ÿ$¹;H3.5. 37,¸9&8I&8;@7$&,
åïÕ·+;ó#5937.
Þ [4] & well-moded # GHC ÜìÆèä$4ñiÓïÏ1ü0åïÕ·+;ó#479, 6
ßÎ ó#åïÕ·+&, ¸=$%= #åïÕ·+ 37. ., åïÕ·+%ò6&Þ [4] %1%;>47.
¾êÈéÍä&1. 37¸937Èïê%I&#5, %¸;Ï
47o%Èïê && 37.
2. 37¸9 1 ;¥4+%Èïê &#
5, /6% 1 %Èïê &I& 37.
!.
3.3.2 v <vqz{¢áÓ¿ï%A %nûÕ;16~71%$4
#3$K+7.
\xmeZx[ !c$%nûÕ;ÝI7$&, +%&%8¹%37¸85, +%I&%8¹%37¸*%nûÕ937!# 8'#5#4. %Èïê:q &%nûÕ9# 1, %Èïê85
é'87ÉÛÈïê%A %nûÕ937818#485 37.
kdeVY ¸!Êîáê, ¸5#"!%æ×Ú½À%¬ö&%nûÕ&ò6# #4. ¸}1%¬ö&,
7ê4$%nûÕ937!8'44. )6' A = B%¬ö& A & B $, B & A $%n47!8'4
4.
85$r¸!ñiÓïÏ%æ×Ú½À%¬
ö&C&9 37. )6' A = [B|C] !45æ×Ú½À%¬ö, 6<M$&85%¸ A, B, C %ú$&6%%nûÕ1n0#4. 8, 5fM$ A 85
B, C *, B, C 85 A *!45%nûÕ9n07!
#4!, 6n07%nûÕ;ÝI #4!937. )6',

foo:- bar(Y,X), add(X,X,Y).

% bar $74, Y 85 X !45%nûÕ&n0
~#4. ##5' add $4 Y & X $%n47!9:87% , 1 Y 85 X !45%nûÕ9n08', ÓÑÕìÑÅ785 37. 658
ÜìÆèä$ØÆ99 , »­$|171% 37!
5I7!, %45#%nûÕ&n0#4 (¶ 3).
6ßÎ &, Þ [3] $K+5847;>,ö=#%nûÕ$ 7_0M#%nûÕ& ¥7!45µ;!7.  _0M#%nûÕ!&, Èïêö;!c$ó#50, n071%! :#8'#5#49, ö=$n07: &#4%nû
Õ 37. ü¢$3ö #4ÜìÆèä) ,ÝÑÕ;ðn078¹%3%nûÕ9_0M#%nûÕ 37.
_0M#%nûÕ9ö=#%nûÕ! 7¬ö&, _0M#%nûÕ%9, =&n0#4!9© 7: 37.
X
baraddYfoo(B,C,Z):A=[B|C],bar(A,A1),A1=[X|Y],baz(X,Y,Z).
bar([B|C],A1):add(B,B,X),mul(C,C,Y),A1=[X|Y].
baz(X,Y,Z):- sub(X,Y,Z).

¶ 3: 7%nûÕ% ¥}
8. &Èïê %ñX$4K+. 6[&Èïêú %ñX$4K+7.

3.4!45ÜìÆèä%¬ö, foo %A% X & B $, Y & C$%n479, 8& B, C 85 A *, A1 85 X,Y *!45%nûÕ9n07!#4!ÝI
#4.
4®;B Sï$&, é(Ij85é(Ij (Bottom-Up) !é(Ij85é(Ij (TopDown) %A'936, Èïêú B S®$&
I&åïÕ!¸ú%%nûÕ%A'937.
ñX&ÔÑÜÈïê;6, 85é(I87Èïê;"7!$4ó#5. 8&, ³^é(I;"8'44. "Èïê&327 , û193¬ö& ñX;307.
¤¢u¢u (Bottom-Up) 8%45#);ò67.

abs1(true,A,R):- R = A.
abs1(false,A,R):- sub(0,A,R).

%ÜìÆèä;¡7!#3%45$#7.
abs(A,B):- C = 0, greater_abs1(A,C,B).
greater_abs1(#A,#B,C) :compute(>,A,B,D),((D == true)-->C = A;
E = 0, compute(-,E,A,C)).

foo:- bar(U,V,S,R),...
bar(U,V,S,R):- add(U,U,S), mul(V,V,R).

7&*·+ÁîËî PIE64[1] %« ó#.
& Fleng %ôl=ó;M$ZØ8*Ø.
bar ñX®;foo $R67!;ò67. bar%I&åïÕ&^,"K+åïÕ·+;ó#5! 0 37. eÜìÎÑÉ¸& 64 v , ãêÐÇîÒÅ$4@7!9 7. , åïÕ·+$4 ÌÔ¡;ÉâïÔ7. ., gêÚö&:|4
~587~587åïÕ&áÓ¿ïj85àåïÕ -%0;6. =ó7ú%kI?& 3 ò=ó?
%0, P7937. %¬ö, U, V 9&, S, %Ó?;4. ÄïÞËÇëÅÊçî%7ú&ü.
#4.
R 9I& 37.
rªÜìÆèä& ÞîÐãïÅÜìÆèä! N $%nûÕ 379, 8&ÝÑÕ;¥4«
K+%nûÕ%ñX;ó#6'#4. ~587%n queens y;ñ qu(55 ó) ;, =2%ÜìÆèä
ûÕ9 bar %A %%nûÕ 37.  &, U 85 ! Fleng %ãÅì;Oó7ÜìÆèä fme (1175ó) ;a<.
S, V 85 R !45ö=#%nûÕ9~587.
., !UüN4:´&ÜìÆèä%!U;2I.,  C+ &, U 85 R, V 85 S !4745$=h479, øò%7 &!U;
5%nûÕ9n0#4!987Q 37. åïÕ
7w 745ù. 8&, û¸Öæì®%/ &8&85#4.
Id %ÇîÙÀè 12L84745$ [3],7¢u¤¢u (Top-Down) 6ßÎ$  w #!U$1üN#!U46þ84!U$
7 7=h &, é(Ij85é(Ij*%® 8#5#40 37.
%BS&,;Üý4#4. é(I!UüN4ÜìÆèä%¡7ú&, ÜìÆèä;j9¸%¬£85é'87¬ö&, ¸%¬£ ~ ÇîÙÀê, íïÅÌÒïÊçî (Sun Ultra 1) «587®;!c$.!0R6# 8'#5, ., =ó7%1% 37.
ÜìÆèä%ô85é'878¹937¬ö&®
;R67!& #485 37. %45#, qu !UüN4ÜìÆèä;G!$46, ÇîÙÀ&379, @&6<M$é(Ij85é(Ij êØÀÖé%ÉÀÍ& 8925 ØÀÔ85 7918 ØÀÔ$ä§. 8&, Èïêö2ÀîèÀîOó$4*%®%BS!} 37.
69p#ÇïÕ92¥80 37!ò6587. !
UüN4%¡7ú&
5  3.
4 ¦ §H¶ 4$ 9 queens ;=ó¬ö%lUï«;9.
ÇîÙÀè%ÜéÜìÎÑÉ!=h. Fleng 1;&ÜìÎÑÉv¸, G;&!UüN4;ó#:#8
ÜìÆèä;&!, !U;w  Fleng ÜìÆ 7% 1 v%7%lU; 1 !grlU 37. Üìèä;I&7.  6000 ó% Fleng ÜìÆèä 37. ÎÑÉv¸$û:5, c%) 8 #«%lUï«;., !U; 7 w
745$70, Èï 947.
ê þ; 6745, ÇîÙÀè;õD. %., qu #ô%o%ÞîÐãïÅÜìÆèä 1}þ& (Cond --> Then ; Else) %45$35:. . $¸%lUï«;947.
, ÉÌßîÕ#4Èïê& 7 ÀîèÀîOó745$. #3$ù)!, ]r?;Í0 fme =2%ÜìÆèä! fme ;7. fme
7ÜìÆèä;37.
& Fleng %ãÅì;Oó7ÜìÆèä 37. &, &!ãÅìOób% qu(43 ó) ;4. 
abs(A,R):- greater(A,0,IsGt),abs1(IsGt,A,R).
PIE64

5

%ü²%¾êÈéÍä&, separation constraint partitioning[3](#ë SCP) 36, 6ßÎ1w #.Ñ;B47. å&(#796ßÎ%ý6¾êÈéÍä&SCP !6<M$&}1% 37!ò6587.
SCP &&!ÓïÏÚìïÆèÚ;bJ!
47% , Fleng %45#I&9ÜìÆèä%5 8
5I #4æì &, FY&N #4. ., 6
ßÎ J"¾êÈéÍä&, ö;TA 201
»4Ú99~587, !45Q SCP !(#7.

¶ îòââëð³­­VéÒ²­­±­­­í»Íîo-°­­¯­­®­­­­®­¯­°­±­²­³­

Úð¾Æ¸!N¶ 4: 9 queens %lUOÌ6ßÎ &, Committed-Choice Öæì Fleng $7
4, ÜìÆèä%&8;6$%!U;üN47!;M!, ¾êÈéÍä%J", =h, 7;ó#.
6ßÎ &, ÜìÆèä%!U;w 70$Èïêö!45@;4. Èïêö988"58%I;ó#5¾êÈéÍä;J", J"¾êÈéÍä$ý Fleng ÜìÆèä%!U;üN4
7ÜìÆèä;=h, 7;ó#. !UüN4$
46, N-queens y & 8 #«, =2%ÜìÆèä 1 1.2 KU%ôl49zº8.
=2%ÜìÆèä ¹ï« 9H4%&w)
M#ñX9E$ó#:8#80 37!ò65
87. ñX9ù#¬ö 1!U;w 7!9øë%:y!3587.
6

, PIE64 !àÌÔØ.0!%G±7ú;¨ 0, =ÿ%I&&ó#:#8. #:, &&I5[%× ÜìÆèä$70÷/ (!UüN4ÜìÆèä$&G#4), I&&ó#:#445$.
., !UüN4ÜìÆèä&, I5[%w 9w
4!¡9H #7. øò&*I5[$¸9*I(20 è) #«37!¡;ó#:#445$.
!UüN4ÜìÆèä;G!$46, ØÀÖé%ÉÀÍ& 194110 ØÀÔ85 170054 ØÀÔ$ä§.
¡7ú& 12  3. =ólU;¶ 5$9. qu!}, 1;&ÜìÎÑÉv¸, G;&!UüN4;ó
#:#87% 1 v%7%lU; 1 !grlU
37.
üN4$46, 1.2 KU%lUï«9à58. ¦2#ÜìÆèä," &#49, =2%ÜìÆè ¥T¨P
ä 1î9937!998.

[1] Takuya ARAKI, Yasuo HIDAKA, Hidemoto NAKADA,Hanpei KOIKE, and Hidehiko TANAKA. System
integration of the parallel inference engine PIE64.
In Workshop on Parallel Logic Programming at-ãêâ îò«ãé®¯®­VéÒ­í»Íî

tached to International Symposium on Fifth Gen-o-µ³, Dec. 1994.

eration Computer Systems 1994

[2] Martin NILSSON and Hidehiko TANAKA. Flengprolog - the language which turns supercomputers into prolog machines. In LNCS264. SpringerVerlag, 1989.

±¯­
­®­

Úð¾Æ¸!N¯­°­±­²­³­¶ 5: fme %lU[3] K. E. Schauser, D. E. Culler, and S. C. Goldstein.
Separation constraint partitioning { a new algorithm for partitioning non-strict programs intosequential threads. In POPL '95, pp. 259{271.
ACM, 1995.

ËQL
Id %45# Lenient #û¸Öæì! Committed-Choice [4] Kazunori Ueda and Masao Morita. Message-oriented
Öæì%=óåÓê&# 476, 6ßÎ ó#
parallel implementation of moded at GHC. In45#WM!UüN4&, û¸Öæì% 18<$ßÎ847. û¸Öæì$7 7ÌëÑÕ¼º, 1992.
5Proc. of Int. Conf. on Fifth Generation ComputerSystems6