Automatic Translation of Fortran to JVM Bytecode

6 downloads 115610 Views 186KB Size Report
Automatic Translation of Fortran to JVM Bytecode. Keith Seymour ... Java programs. ... motion, for which well-understood optimization tech- ..... The closest.
Automatic Translation of Fortran to JVM Bytecode Keith Seymour Jack Dongarra Department of Computer Science University of Tennessee, Knoxville Knoxville, TN 37996

ABSTRACT         

     "!$#&% # '$( )

 )+*&-,. / 0 1

324 5/1  30  6    4 5 ) 7 68 9 "   :*&-," :& 0   9     :*&-,HRQ68/  . 

/ K 0  +FDREC C

FBC    C D-RE  A 86  +F C [& J " .1 / 8 ,&  

/ CC 4 H,H C DON

I24   /  ? AdX   C  )    1260 eC [& G*&-,c  Cf0 I1 / 8 ,& A 

/ CC  @ ] ? )g  N

C 8   ]8 ) D M 8

 B

    0X& 0X rk^2: cL 8 0  /1 A  / 0 1 c 40 & 8Fc"!$#&% # '$(tH6C   8- 0"0  K /1   B*&-,HRQ24 uwv3xOv]V3 ,& ] & 04 :‹< 2:   5 3 6  4 *&-,. C~8 /18/ lH>:dX ,& 0 G.D0$9 6C1 X 3 / 0 1  Šc "-,&  -3 EM 7wC H3K 8- 6 "2 E2: D -  A*&-,],&   ˆ 9uwv3xOvbV3 ,& ? 30 1   C6D  X8H G uwv3xOvƒŠc B8/

 I /t eK 8- 6  ? 0 0 -24?69    /1 6  b*&-,:8H b .:8 7 D"  3  0   K0 b2:FX C  5

    0EP

 / 6 8 >+  $R 1   36 ) 6 9 X /I $R2 5 -,& @D0$24 8/G860  K  0  -I688 7N60 0 F?9       0  I 4"!$#&% # '$(V5WX4W‡7/1 C D   .K  ]G T860 . K0 CU6 @B*&-, .0  8/[   I I7/1 C D->vb 

 -10 F C0  M :  

  -: 3 / 0 1 G D8 > v ŠS 0    :1  4 ,&  / 0*&-,X  C@K0  "N

C1 - ,  0  K0 IhL  60 1 X i C0 K  *& C t_ `-o1aNj 24 8/260 C [& ˆ K  M    N

 R2 b -,& J   -5 JKDFH 8H J   /1

38D i 7E24 .   ,H 6Q8H    /1

"24 6  D  N   8 RQ 1,H  ? @6  524 A 98/ 8 9  /1   3.  rIMPLEMENTATION k^B8C 0  B  /1 B }N6 A7/  R@ A )

8  K -IK 0 -2   ? 0 0 67 /1 -I GPQ 6  9`>

3.1 +3 wLexical 7/  " "0 Analysis i  w  1 /1and $ JParsing "!$#&% # '$(.6 8

8H @ D[& 5  G . 1   K6 0 X?8C0  vXZ}hrvZH6K -…D6 D:8C 0 1 G7/   K/   0 0 N

C1  K 6J : 

/ Cƒ7 686   CY vXZK6 0 

3.2 Optimizing the Use of Scalar Wrap+"!$#&pers % # '$(U, 0 6 B1  c   -ˆN68 B  

6K 6  KDF  N   8 >  G C0  I 1  "!$#&% # '$(}6K 6  GCH M  B  ? 1 / C )   R  14CH M 8-1  0 9/ [& :? >O 84 I 8- 0 0  I 6  A > @3-2 ,&  -Rw*&-,?6 X  7)gKDFH)g, 0 6 R 24 8/5 C0  O 1Q DFXCH M 8-1 O260 C  B2D$E/ [& ? >O 89 c ?8- 0 0  ->c+]

/  @B C@60 1   7)gKDFH)

 N   8  *&-,HRb2 IC@67.2: / t ?8- 0 1 ?   KH^7 8-> A 7 -A :   ? @ D   , 0 6 R

F77 Source

f2j Lexical/Syntactic Analysis

Abstract Syntax Tree

Intermediate Stages

Annotated AST

Java Source

Code Generation

JVM Bytecode

javac

Bytecode

GOTO Translation

Transformed Bytecode

Java Virtual Machine

  

         2 J260   w bKH^7 8Q2: /   E24 b8- 0 1 "M 0  CFK 5CH M -? ? X6K 6  > dX6   v},1   K0 5C@674K 32: /  -I +‰ `>4 @,1   K0 @ 5  1 6C D3 3N68    S G Gˆ A0  B    }  C D 7/1 C D4 ? 4 

/ C 6  kD>4 @,1   K0 @ 5  1 6C D3 3N68    ? 

  A  7 68 A0 &]I0 D8- 0b,1   K0 RQH6  8  -  3 1,&  / 0 0  N

C 8       /1 - 8H >

vQ  2: X

    0 0 F  5N

5 C0  8 +FG 13 8H    /1

4860  C : 0 0O,1   K0 41 3 C 4 C   S S A C BC   -> @3-2 ,&  -R368/S8H,& )  8 66  0 0 F8C 1?   8 G  t  8-  R  4  8 : b  N

C 8 >QŠc M  . 1" 4*;5=  ) 7 68 50 &X7/1 8e @2

[H@2 0 0:6   @ ?86   D 7) 6C 9 1 0 0 ,1   K0 1  X 0 0 C  - b7/1 8 80  

4.1.5 ZHC "!$Intrinsic #&% # '$(S DFunctions    8IN68 CFtK ? / 7)

0 1 -  80 F}8

     SC Hˆ } *&-,B8

 Gv3x"/>JP

 i C0 RJC DF]C1 C1 8- 0 N68 68/e #  7.F < R gC@60  0 B 80 1 /1 I  G C G8C9) CK0 D8/[9 i 7  3"!$#&% # '$(I6 8 RHrk^bC     @,1   K0 @  C  Q K0  @3-2 ,&  -Rbrk^8- e   0 GA0  C9)   -AN

CŒ "3+;Ev3u"5y" 0 B  ,1  )  K0 5K  ? -…D6 , 0 8 -B? 5 >O  5 B+F @   1  X 4$ >O : C - 8/I   ->J :  7  8 I C9) 0  3 15 DFI+2I1  /FXK   -…D6 , 0 8 -GC@67  8  Fˆ   8 I ?`> @3-2 ,&  -R3  G 0 0 -2: K0  -…D6 , 0 8 I1  /F9 X >O   D C  IhL > >  )+ C    0 D   1  /F93+2 )+ C    0  D   I1  /F j/R4 ? 0 031  /F?1  0   -1  \ -e   C  A   @ 88 5 XK   8- 0 0 FB . C .  ) &1 /0 J  b ) 0 :,1   K0  E0 & -@ .0  8 :   DF   b,1   K0   1:2     ,H 60 F? -…D6 , 0 8 -O>

4.1.8 ŠS 0 "I/O W] wStatements  $ "C7w8   8- 0D  8Q H / 0 1)

 ?H6C   8- 0E0  K /1  68/A uwv3xOv~‹#"Jv v

4.1.10 Limitations v 69 b J b 1 J   B *&-,50 1N

C‡0  8 b.1  M 8  0  7  8   ) 86  $ROK636 

3N

X  86  ,& .N68 3 X7 0 0  J8C0  0 F. C0 C D - 9rk^>J :K7/ 80 4 N60 0 F@ C0 C D <  86   J 1b 0 0 -24 5  86 )  . D  N   Q24  b8- 0 1 E2: /   " C \-1     ?hL  9ZH 8 AlH> kj:24 G   86  B 3   )

 8  ] ?  ZHC E H  E  7  8 E1  "C

 "   6$      > P

? i C0 R:8H  1  0  ? --,H 0 Fe "3+;Ev3u"5y"ˆ24 0 0: @0  [& 0 Fc / 0 1 2 0 0K ) 8- 6 X68/I0  6   587 684D : :C 2 0 0  *&-,0  6   >  ?uwv3xOvJ+ 8-  R1 "3+;Ev3u"5y"?7/1 C Dw1  " N

C  15rk^8- c   0 98

  80 FDR" . 8  K -  ]ZH 8)  Im> `> pD>  86   D  0 -  B *&uwv3xOv V5WX4W 7/1 C D@24 8/e  -1  i0  8 0 Ft t "!$#&% # '$(B6 8 X  -…D6  50  D0 F >O   D4   0    8 5 XK / 8/I/1  "H6R&6  c   A 9 iH5   R$2 8-  -  0 FAM 0 0" A @K / 8/ /1  H  "N

 DFV5WX4WS7/1 C D"KDF@0 D[H  6I 4K / 8/I0  K 0L>

4.2.2 Calculating Stack Depth and Branch vJ J Targets  D-R& "J 8/c,1   K0 C@675K 7

 -B G "! u #AEs%$ u 3 J .86   DX80  R K65 i0  8     0  \-1 t8H 9 50 FA   ) 1 -3N

E1  /F5  3  N   8 b1/+F >$ŠS     /1 5KDFH 8H R&2 4C@67"8  -1 @3-2 ,&  -R24 S*&-, 6 8 R 4 4   0 -IKDF :$; D> 



"F G8- 7I1  BC@68/C

 G C 

/ D24     /1 KDFH 8H B  ˆ*&-,t6 8  8 - 8/? 7 68 I b+F )g 8 M 8>JH6R  C DF3 7/ 8 $ 1w2 J860  + "2:F :24     /1 9 ? i   ? I*&-,24 64 DF i0  8 38- 7R 2 .C@674   /1 +F 58H,&  )   7 68 4 KDFH 8H >

ŠS   8H    /1

9  -50 ?K ) +2  5CH  U68/ $:6  5*&-,:6 8 J8H    /1 t  AK  c   /1 8H  cKDFH 8H 0 F  2 G C0 F  G    1 G0 K  0    9 5?  -GN

. DFBCH M 8-1 B? @8H    /1  6  >  9   /1  86D5  M  -B '&)(+*Qh-,/.10hh-& &  4 &65-j87 &651j:9‚&j/R24   3&   "     0, 0 6 R%3 & 2  J :  C   0, 0 6 R  ;&654 J 4 8  C D/1  

, 0 6 9_ k l1ar>



 U      4.4 Resolving Calls to External Func w tions 8 @ 8  K E 8/ …D6 EN

Q  0 ,H 

    !!"#%$'&  & (') 6 )7$  !!"#%$'&  & (') 8:9 ;!< $="' 8:9 ;!< $="'@? ACB;%& D%%&FE I (D%(@J$K'& '*+* >

> d : $; > d :$; > d :$; > d :$;

6 :$;

6 :$;

 0%V!  T  V!  T   !$ . /0  _   5    W 

0%12 3 4+2 5/5 4!12 4 52 14 452 > 52 0=4 G/H 2 > 52 3 H 452 0 52 0/5 G 32 > 52 L/5

R  M     .U   Z   Dncp R  'N ` Z     C  85 i    4 8  C D 5   i?KDFB`X 8C 1 @N

 @L 8 1.*&-,?  .‚1)gK   -A )  i @24   - 4ŠS 0 5 4260 2

[?2 0 0LRO 8 rk^: b2:   I ye  ?D : : -,& X 88 . 8 *&-,4N -16  Q0  [& J ? < 8 $R Q260 5  -…D6  40  "  iH /8H  1   80  3M 0 >3+7 -OR 2 .6 BC

 I0  D+2  D D8 -6  I ]rk^>ev98C 0 )  C R&rk^b8  -1  #

   X4E)D ! u Q24 8/ X iHJM 0 8D/   I0  75 J ,&  FC H   /1 -O> "J 8/ 0    E  8  



=I H  C Qs3 "  C J  JC HX  0 +> 



=I H@ 8  

Qs3 EC H7 E 8  

-R 24 8/I  G 3_ L/`%1 0=4`_ G 5/` 3=4>_ G >=4

 #"!,

   tS  

5. ŠS ?EXPERIMENTAL , 0 6 1 . <  60 : RESULTS Q6 48H X   /1

-R

 "+23  8Q2 1  bC7Q88   -X24 @1  b8

)

 8 :yb

)

 8 C - . 19 I   /1 -8H I H68   @ C 9H6C   8- 0Q  60  X @ 1 ,& )g8C 0 - "!$#&% # '$(8H R&24  38  /   

  :  0  / 8     D? ˆ  N

C  < &1  )g  DI8- 0 860 1   >O   D:7F7 C>EŠc X 0 C - 6  3 T8 8F?    CJ $ 4

    0$"!$#&% # '$(I8H RH6 5 c ? /c D Fc    )  D X  N

C 8 5 Q 5*;5= KDFH 8H 3   ) 1 -]KDF rk^>t N6 t D Fc @  C I @  /S i8 I 1 ,!@$ ;  <  2:  8 M - 24  6 c BK 8/C1 [ >€ A0  7I+2t )   $     Dw J*&-,6 8 b8H J   /1 -5KDFQP

w i C0 R- w260 XK "7 /  D) N

2:1 /.CH  F6 8H 3   /1

:68/ 1 ) 7 -5 6 47/  1 /*&-,GW€  iHb7/  3  3 ,& 0 C Db $ 4KDFH 8H :+ 1  860 1 -R 2 5260 0  [& 59 ) ,& 7 &1  . C  83 b,1  638C 0  X C \-1)  4I 5  N

C 8 5 E 5*&uwv3xOvX  . 8/ …D6   

Šc I 0  0  tG  C -HF]C ? 3rk^? 0  C /1)  8C0 iS1  C  8A6 

-R3K   W

 

"! &('()+*-,.,0/



4 #

4 4

4 

#

#

4 #$#

4

4

4

4 4

#$#$#%#$#

4

4 #

4 4

#$#

4

4

4

4

4

4

#

4

4 4

#%#$#$#%#$#%#$#$#

  





 





   

    TS VUa`    k21 N    p43&]    0  RE  AC 97FD/ 8 8@  7  8     D   6 5 1   -> @ ,& D6  0E& 0J XI -,& 9D0 24 @

o

o

m

 Dn65TR1Z  N    pYq     

_ p-a@y‹ yb 1  L^7  R   I‹>b 72: > @3 )+x"  N

C 8 *&-,ybH :N

ybC6/1   0wPQ0 6 Id3F  C 8>H+ E  D  8 # B?C  D  EG9 H+IJLKM M NO;sOv k ‚‚H`> 7._ `a.ZHREFERENCES 6G=I 8 7F7 C4+8>87:9 +;s= s$B?@s2?

_ q1a5Š >;b    @3 F $R ":> dX  HFDR   A BB<  D$BBC 0B1EL>OZH6G=I 8 7F7 CRO=I6D/   .>xE  0 )7yb0 0  >wy1 /b0  8-  v ;3 25ROyvR$`-||&nD> x"6  )+*&-,HR ybC  D)gK   -IZDF7 C ZH C@60 1 D0$N

5yb60 - 3)g0   -1 _ k-a*D A@3 8/[H0  $R yb0 ,& .=I0  -R xQ   4Šc KK$R " x DF 84 37 686  -V<  >+ ‹ b ,&  -R J 68 .=I 0 0  -R ‹Ov =1  ixJ 8/[  R *6 9`-|||H> v Šc

0 H)rŠS  3Šc K1 D$‰  1C1$>  7-> 1, ^-, H6C   8 ^ CH> _ |1ad@>dXD0  $R *> dX&1  /HR   Iz9> ZH FC6 -> *&uwv3xOv  J*&-,.N

36C   8- 0wybC6 >D   0B1E  ! _ ``a.*>dX&1  /HR *>dX6GyJ \ROZ @X CC1 0  R   E DF? sC0C  B? ROpHhgkj/‰ |&ps ``-|HRE`-|||H> ‹> @X $> vu$  *&HR vOv    ,H  $> 8C 1 H68 1   iO> DC0L> `mh7`1j/‰ `/sHl&kDRE`-|qqH> _ o1a5dX‹3v ZDF7 C>W3‹4)7W3KH^7 8RdX 8 C@K  X`-|||H> _ `1k-a.*>dX&1  /HR *>dX6GyJ \R />dX6 >ER   v @X CC1 0  >v ZH 4 "u$ ,& 0wl9  8.u$  -1 D$‰  17   -1 8/$> 8C W3‹4) v H+IJW7 s$B  s? E  D$B C  D$B W3KH^7 8 1   iO> DC0L> Jas$EG9 X C#s$E   s.uD2D 0 EZY,s  /Rw`-oh7`1j/‰ `/s `1pDRE`-||‚H>

_ `-l1a ":> v  LROy b 8/ +ROZ > b0  8/[DN

/OR *>dX CC 0LR*> dX&1  /HR *>dX6GyJ \R v> V<   HK  6CR Z 1> @X CC1 0  R v> =I8z5  FDR  Id@> ZH

  $>[=H EH+I  

  P @ / #   7:9 8 #(A # E  D$B> ZH7vX=AR x" 0  0  HR xOvRO`-|||H> _ `m a.v>;.> v ZH LR  *>d@> 30 0 C $> I DC X  u

 E  B   X_u

  7 X 9B  @

  s$B1# 72D D.u > v3 )rŠc 0 FIx"6K0   ybC  DFDR ‹< - R =vR$`-|qqH> _ `1n-a.xQ> v4  & R =A>OV36/HR Z > =I [H >ER    *> =I

  /H2> @3 x"  N

C 8 @ybC6 @  *&-,H‰buw 6     GybC 0  + E  D  8 # B?C  D  EG9 0

N KEG9 D   9DXD$B = s$B?@s2? T

s$B1#4I DC X  u

. D E s s.uvu  u I DC X@E

R v$`-|||H> _ `-o1a.*> =I FD  3  I3> dX-24 :> ;s  W ‹<  0 0  F  v _ `1p-a.*> =I FD  ->d3)+*&-,HRdX 8 C@K  X`-||oH>Ov 8-1-> DF6$> -6 1C FD  ^7,HC  1^-,H> _ `-q1a.xQ   iH-> _ `-|1a.xQ>Šc6$R Z > =I [H >ER *>O=I

  /HR   G=A> V36/H> "ET8 DXZH6 

N

5ybC0 i 36C@K    *&-,H>+4  E  D  8 # B?C  D  EG9 H+IJ NO;s$`-|||H> _ k ‚1a.v>v ybC0 iIv4  C  8 v  0 C  >  C$> 8> 6[ 1DC0 ybC0 i ybC0 i N

*&-,H> DC0L> _ kD`a.*> J DFD>dX   byb0  XybC0 iOR k ‚‚H`> v ,HL> 8C 18

  1&1 /  1

/   18C0 iO> DC> _ kk-a.3> u$  0 C~  IPb> b 0 0  $> 7:9 +

;s v3 )rŠc 0 FDR b  [& 0 FDR yvRO`-||&pD> _ k l1a.v v AXlH> |1)`-|&p qHR v5ZH/R 3 2 b

[ R 3 2 b

[ R `-|&p qH> _ k1m a.*>dX&1  /H> u$   8/[?b 8/C1 [ >$_ W30   a v  0  K$> 

 1K 8/C1 [ 10    8/[OR W38K  `-||&kD> _ kn-a.*> =I

  /HR$Z > =I [H >ER   G=A> V36/H> v ybC 1   J   v+ E  D  8 # B?C  D  EG9 H+IJLKM M NO;s k ‚‚H`>

Suggest Documents