TweetFollow Us on Twitter

FORTRAN Benchmarks
Volume Number:7
Issue Number:1
Column Tag:Jörg's Folder

Absoft's MacFORTRAN II

By Jörg Langowski, MacTutor Editorial Board

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

“Two FORTRANS for MPW”

You have read several columns on the FORTRAN compiler by Language Systems, which for a while was the only one to offer MPW support. Not for long, though; the creators of the first Fortran compiler for the Macintosh, Absoft Co., were not asleep and brought out their MPW FORTRAN, first MacFORTRAN/MPW and recently MacFortran II. A comparison between the two compilers was long overdue, and this month you will find those long-awaited benchmark figures, together with some insights into the code produced by the two compilers.

When I read the Whetstone benchmark figures in the Absoft ad, which were above those of Language Systems’ compiler by more than a factor of two, I was surprised, and curious to find out how they were able to do this. I asked for a sample copy, which they kindly provided, together with a corresponding T-Shirt, so that I can now run advertising for both Language Systems (odd days) and Absoft (even days).

The Absoft MacFORTRAN II package is very easy to set up and use. It comes with a well-written manual and an installation script for MPW 3.1. The manual is very well structured and has an extensive index; the documentations of Absoft and LS Fortran match each other in quality. An extensive set of examples is also provided, showing standard Fortran programming, toolbox calls, performance analysis and Hypercard interfacing.

Code optimization

The installation script sets up a menu that allows you to invoke the Commando interface to the compiler. That interface is almost indispensable; you have a choice between so many different options that it becomes hard to remember or type in everything. Most of these options have to do with code optimization. Absoft lets you switch on or off every available optimization individually. The most important basic optimizations are turned on by the -O compiler switch. They include: subexpression elimination, loop invariant code removal, use unchanged DATA-initialized variables as constants, inline intrinsic functions, and peephole optimization at the machine code level. These optimizations correspond approximately to what the Language System compiler does when you select -opt=3.

However, MacFortran II has more in store. Three more ways of optimizing the code are provided. First, subroutines may be ‘folded’ into the main code, eliminating call overhead (if they are defined in the same file). Second, loops may be expanded into sequences of instructions (‘loop unrolling’). This is approximately equivalent to expanding

do i=1,n
 a(i) = b(i) + c(i)
end do

into

C 1

do i=1,n,2
 a(i) = b(i) + c(i)
 a(i+1) = b(i+1) + c(i+1)
end do

assuming that n is even. This cuts down the number of loop index tests by a factor of two and allows for parallelization on machines that support it (on the Mac’s floating point processor, you can at least distribute the calculation over different FP registers).

The third optimization, called ‘strength reduction’, will try to substitute integer multiplication in loops by integer additions where possible. For instance, the loop:

do i=1,n
 a(i) =i * m
end do

can also be written as

C2

i1 = m
do i=1,n
 a(i) =i1
 i1 = i1 + m
end do

which will run faster if the addition takes less time than the multiplication.

These last three optimizations strategies are often applied already in the source code by Fortran programmers. As an example of loop unrolling, consider the following piece of code from a frequently-employed matrix/vector multiplication routine from the public domain Linpack library:

C 3

      jmin = j+16
      do 60 j = jmin, n2, 16
         do 50 i = 1, n1
            y(i) = ((((((((((((((( (y(i))
     $             + x(j-15)*m(i,j-15)) + x(j-14)*m(i,j-14))
     $             + x(j-13)*m(i,j-13)) + x(j-12)*m(i,j-12))
     $             + x(j-11)*m(i,j-11)) + x(j-10)*m(i,j-10))
     $             + x(j- 9)*m(i,j- 9)) + x(j- 8)*m(i,j- 8))
     $             + x(j- 7)*m(i,j- 7)) + x(j- 6)*m(i,j- 6))
     $             + x(j- 5)*m(i,j- 5)) + x(j- 4)*m(i,j- 4))
     $             + x(j- 3)*m(i,j- 3)) + x(j- 2)*m(i,j- 2))
     $             + x(j- 1)*m(i,j- 1)) + x(j)   *m(i,j)
   50    continue
   60 continue

Here, sixteen of the basic operations are performed in one pass of the loop. Of course, it is necessary to provide code that deals with array dimensions which are not an integer multiple of 16 (or 8, 4, 2). With the loop unrolling option of Absoft’s Fortran, the compiler does this for you.

The increase in execution speed that loop unrolling and subroutine folding provide depends very much on the type of code being operated upon. The Whetstone benchmark, for instance, is strongly affected by subroutine folding. This is not surprising, since the benchmark consists mainly of calls to small subroutines executed over and over again in loops. I have reprinted the Whetstone benchmark in Listing 1, so you can actually see what it is doing.

If you activate loop unrolling and subroutine folding in addition to the basic optimizations, Absoft Fortran runs the Whetstone benchmark at 2466 KWhet/s on a Mac IIx. Language Systems, at its highest optimization level, reaches only 1035 KWhet/s (see Table 1). In real life however, where benchmarks don’t necessarily apply, the speed increase is not quite so dramatic, although still substantial. Absoft Fortran with the basic optimizations still executes the Whetstone program 40% faster than LS Fortran.

The Linpack Benchmark, which mainly tests performance in operations on big matrices, executes about 30% faster under Absoft than under LS Fortran. Note that the loop unrolling actually slows down execution here, because the time-consuming calculations are already unrolled in the source code of the Linpack package. This shows you that you have to test this option carefully before using to see whether it really increases the speed.

Table 1: Language Systems and Absoft Fortran performances on different benchmarks

Compiler Whetstone Linpack Matmult

[KWhet/s] [MFlops] [s]

LSF opt=0 929 0.077 0.1 / 4.80

LSF opt=3 1035 0.103 0.05 / 2.45

ABF no opt. 1265 0.121 0.07 / 3.93

ABF -O 1264 0.134 0.05 / 2.17

ABF -O -h2 1317 0.132 0.07 / 1.93

ABF -O -h4 1345 - 0.05 / 1.91

ABF -O -h8 1346 - 0.07 / 1.95

ABF -O -k 770 (!) 0.126 0.05 / 2.18

ABF -O -Z -G -h2 2466 (!) - 0.05 / 2.16

Why is the code created by the Absoft compiler - even with only the basic optimizations - faster than the LS Fortran code? To understand this, let’s look at the assembler code generated for the matrix multiplication benchmark example from MacTutor Vol. 5, #8. Listing 1 shows the central loop of the multiplication routine for various optimization settings.

You can clearly see that both compilers throw away a lot of redundant code when the optimization is turned on (LSF, opt=3 vs. opt=0; ABF, -O vs. no options). The code generated by both compilers is very tight, but Absoft keeps many more variables in registers. Looking at the complete routine, which is not printed here for space reasons, reveals that Absoft uses all registers except A1, A5, and D1. Language Systems keeps most variables in a local stack frame and must access memory to get them; also, it does not fully exploit the available addressing modes of the 68020, even with the -68020 option turned on. This might be a compromise taken to allow easier generation of 68000 and 68020 code by the same compiler. Since the Absoft Fortran works only on 68020/30 based machines, it could probably be designed to exploit that CPU more efficiently. The floating point registers are used by both compilers to full extent. Note that Absoft does the addition (intermediate calculation in the central loop) in extended precision before converting back to double precision for the final result.

The difference in A and D register use is mainly due to the fact that LS Fortran always generates code that is fully linker-compatible with the other MPW compilers. This means it follows the register-saving conventions which require a subroutine to leave the contents of all registers except A0, A1, D0, D1, and D2 untouched. As long as one just runs a Fortran program, it is not necessary to follow these conventions for each subroutine, but when Fortran routines are to be called from Pascal, it is. Absoft Fortran has an option (-k) that saves and restores A2-A5/D3-D7 at the beginning and the end of each routine, to keep full compatibility with the Macintosh calling conventions. For running plain Fortran code, one does not need this option. Including the register-saving code in Absoft Fortran decreases the Whetstone performance dramatically (as you’ve seen above, the Whetstone figures are very much influenced by the efficiency of subroutine calling). The other benchmarks are not much affected by this option, since subroutine calls make up only a small amount of the total execution time.

Summarizing the benchmark figures, Linpack being the most significant for floating-point calculations, we can grant a fair advantage of about 25-35% in execution speed of Absoft MacFortran II over Language Systems Fortran 2.1. This is in agreement with practical observations; other users of both compilers who I discussed with generally observe speed increases of approx. 30% for pure Fortran code on the Absoft compared to the Language Systems compiler. These figures may be much different for applications which do a lot of cross-language calls.

The loop unrolling options (-h2, -h4, -h8) do not seem to affect the execution speed too much; there is a 10% improvement for the matrix multiplication, and no improvement at all for the Linpack benchmark whose code is already unrolled. The Whetstone benchmark is improved by only about 5%. To show you what the loop unrolling is doing, I have also listed the assembly output for the double (-U) and quadruple (-h4) unrolling.

MacFortran II’s Macintosh interface

Compared to the excellent Macintosh interface that Language Systems Fortran offers, the Absoft MRWE (Macintosh Runtime Window Environment) seems a little rough. It provides you with a resizable terminal window and keyboard input and the possibility to save the output to a file at the end of the program. The elegant menu setup that Language Systems has, where you can assign vectors to Fortran subroutines to user-defined menu items, is missing here.

The good news is that Absoft provides the full source of MRWE, which gives the user the opportunity to read and understand what the code is doing (all Fortran), and possibly modify it. What I also liked about MRWE is that the window setup, dialogs, etc. are kept in resources where they should be. Language Systems takes the easy way out by hard-encoding the window environment into its code. Although LSF’s runtime interface it is very powerful, it would be even better if it were properly resource-based.

Both Fortrans offer optional inclusion of background-processing code under Multifinder. The amount of backgrounding can be controlled by the user in both cases.

Absoft does toolbox calls in a similar way as LS Fortran, by simply calling the routine and adding VAL modifiers to the parameters where call by value is needed. It is not possible to use Pascal calling conventions (as it is in LS Fortran through a PEXTERNAL declaration). The usage of handles and pointers is less convenient than in LS Fortran, where you can use STRUCTURE declarations; that extension is missing in Absoft Fortran and has to be simulated by lots of EQUIVALENCE statements.

For toolbox calling convenience and the Macintosh runtime environment, Language Systems clearly has the advantage.

Summary

Absoft’s MacFortran II is the fastest Fortran for the Macintosh currently available, being about 30% faster than the runner-up, LS Fortran 2.1. For pure number crunching this speed difference might be relevant. If you want easy addition of a Macintosh ‘look and feel’ to your Fortran program, you might prefer LSF with its capability to associate subroutines with menu items. This could in principle be done in Absoft Fortran, but only by modifying the MRWE code, which would be more difficult. If you do a lot of cross-language calling, LSF may have the advantage over Absoft. Another advantage of LSF is the total compatibility with VAX Fortran; for adapting Vax programs to Absoft, one still needs to make some changes now and then, e.g. in I/O statements.

The ideal setup would again be to compile computation-intensive parts in Absoft Fortran with the Pascal-calling option on (taking care not to have too many calls to small subroutines), and run the main program from the Language Systems runtime environment. Well, maybe the two products will move closer to each other in time, Language Systems optimizing its code even more and Absoft adding some convenience to its Mac interface.

Final words

At the end, I want to apologize to Steve Hawley (the author of SteveForth that I reviewed a while ago). I did not see his letter before it was printed in this magazine. I had actually made the error to think that SteveForth was freely available for anyone interested in testing it, because it was on a public accessible FTP host (It was actually removed soon after I had discovered it). Sorry for giving the impression that this is a finished product; SteveForth is not public domain or shareware, but Steve Hawley might make it available later when he gets around to doing some more work on it. I still think that his Forth implementation contains some very interesting ideas, and would be happy to see and review a later version.

At the last minute, I found some very useful information for those of you interested in downloading free-distribution Macintosh software from the Internet network. On the Info-mac mailing list, the following table appeared:

Date: Sun, 11 Nov 90 13:03:56 CST

From: ST5845%SIUCVMB.BITNET@forsythe.stanford.edu

Subject: ftp sites

Here is the list of anonymous FTP sites I promised to share with the net a few weeks ago:

List of Anonymous FTP sites with Macintosh Archives:

------------------------------------------------------------

apple.com 130.43.2.2 /pub/dts/mac

arisia.xerox.com 13.1.100.206 sunfixes, mac, LispUsers, tcp/ip,

ba.excelan.com 130.57.8.6 misc. (looking for suggestions)

bnlux0.bnl.gov 130.199.128.1 looking for suggestions

boombox.micro.umn.edu 128.101.95.95 POP2 email(hypercard->unix host)

brownvm.brown.edu 128.148.128.40 mac

bu.edu 128.197.2.6 RFCs. mail utils, games source, etc.

cc.sfu.ca 128.189.32.250 msdos, mac

citi.umich.edu 35.1.128.16 pathalias, CITI macIP, webster

doc.cso.uiuc.edu 128.174.73.30 msdos (pcsig), mac

elbereth.rutgers.edu 128.6.4.61 sci-fic works, startrek guides,

f.ms.uky.edu 128.163.128.6 mac, msdos, unix-pc

funet.fi 128.214.1.1

genbank.bio.net 134.172.1.160 National Repository for Gene

grape.ecs.clarkson.edu 128.153.13.196 /f/gif

hubcap.clemson.edu 192.5.219.1 /pub/gif

indri.primate.wisc.edu 128.104.230.11 macintosh TransSkel TransDisplay

ix1.cc.utexas.edu 128.83.1.21 /pub/macintosh

merlin.cs.purdue.edu 128.10.2.3 ConcurrenC, Xinu, mac, GIF

net.bio.net 128.92.192.252 /pub/mac

net1.ucsd.edu 128.54.16.10 mac

nyssa.cs.orst.edu 128.193.32.17 GIF, games, misc.

oswego.oswego.edu 129.3.1.1 GNU, mac, kermit

p6xje.ldc.lu.se 130.235.133.7 NCSA telnet 2.2ds, PC networking

pine.circa.ufl.edu 128.227.128.55 this list, RFCs, Internet Worm

polyslo.calpoly.edu 129.65.17.1 Hitchers guide 2 INET:Email list

rascal.ics.utexas.edu 128.83.144.1 /mac

sally.cs.utexas.edu 128.83.1.21 /mac

ssyx.ucsc.edu 128.114.133.1 /pub/mac-misc /pub/startrek

sdres.isd.usgs.gov 130.11.1.2 U.S. Geological Survey public files

sumex-aim.stanford.edu 36.44.0.6 mac archives, Mycin (sun4), imap

sun.cnuce.cnr.it 192.12.192.4 atalk, ka9q, GNU

surya.waterloo.edu 129.97.129.72 /images

tank.uchicago.edu 128.135.4.27 mac

tolsun.oulu.fi 128.214.5.6 amiga, atari, c64, msdos, mac, irc

topaz.rutgers.edu 128.6.4.194 amiga, others, too much to list

trwind.trw.com 129.4.16.70 NNStat,mac, named, sun-utils

tut.fi 128.214.1.2 Images, lots of misc. unix

ucbvax.berkeley.edu 128.32.137.3 /pub/mac

umaxc.weeg.uiowa.edu 128.255.64.80 NCSA telnet, sendmail

umn-cs.cs.umn.edu 128.101.224.1 Sendmail, vectrex, mac, unix-pc,

utsun.s.u-tokyo.ac.jp 133.11.7.250 Japanese PD, msdos, mac, unix, etc.

uwasa.fi 128.214.12.3 mac, pc, suntools, unix, vms

uxa.cso.uiuc.edu 128.174.2.1 mac, msdos (pcsig)

uxe.cso.uiuc.edu 128.174.5.54 /mac/pc/gifs/pc/grape

vega.hut.fi 130.233.200.42 msdos, mac, Kermit, fusion docs,

watmath.waterloo.edu 129.97.128.1 lots of stuff

whitechapel.media.mit.edu 18.85.0.125 OBVIUS, macnh

wpi.wpi.edu 130.215.24.1 dspl, anime, fusion, mac, GNU, ash,

wsmr-simtel20.army.mil 26.2.0.74 msdos, unix, cpm, mac (tenex)

wuarchive.wustl.edu 128.252.135.4 GNU,X.11R3,GIF,info-mac, 4.3BSD

zaphod.ncsa.uiuc.edu 128.174.20.50 NCSA Telnet source, Mathematica

- also 128.174.25.50

Those of you with access to Internet will know how to download files from those sites. Those with Bitnet access can send mail to BITFTP@PUCC which is the FTP gateway to Internet from Bitnet. To find out how to use that service, send a HELP message to BITFTP.

Listing 1: Benchmarks
Matrix multiplication

   program matbench
   real*8 a(50,50),b(50,50),c(50,50)

   time = second(0.)
   do i=1,50
   do j=1,50
 a(i,j) = i + j*0.01
 b(i,j) = a(i,j)
 end do
   end do
   time = second(0.) - time
   write (*,*) “Time to set up matrices:”,time,” seconds”

   time = second(0.)
   call mat_mult(c,50,a,50,b,50,50,50,50)
   time = second(0.) - time
   write (*,*) “Time to multiply matrices:”,time,” seconds”
   
   pause
   end
   
      subroutine mat_mult(c,nc,a,na,b,nb,n1,n2,n3)
c      sets c=a.b; c must be different from a or b
c      na,nb,nc are first dimensions
c      n1 n2 n3 are problem dimensions
c      c is n1xn3
c      a    n1 n2
c      b    n2 n3
      real*8 c(nc,n3),a(na,n2),b(nb,n3)

      do k=1,n3
        do i = 1,n1
        c(i,k) = 0d0
        end do
        do j=1,n2
        do i=1,n1
        c(i,k) = c(i,k)+a(i,j)*b(j,k)
        end do
        end do
      end do
      return
      end

      FUNCTION SECOND(X)
      CALL UTILIZ(TIME)
      SECOND=TIME
      RETURN
      END

      SUBROUTINE UTILIZ(TIME)
      TIME = LONG(362)/60.0
      END
Whetstone benchmark

C
      PROGRAM WHETSTONE
      DIMENSION E1(4)
      COMMON /A/ E1,J,K,L
      COMMON /B/ T,T2
C     SYNTHETIC BENCHMARK  BY CURNOW/WICHMANN
C     ***************************************
C     INITIALIZE CONSTANTS
      T=0.499975
      T1=0.50025
      T2=2.0
C     READ VALUE OF I, CONTROLLING TOTAL WEIGHT:
C     IF I=10 THE TOTAL WEIGHT IS ONE MILLION WHETSTONE INSTUCTIONS
C
      I=10
C
      CALL UTILIZ(TT1)
      CPU1=SECOND(Z)
      II=I
      N1=0
      N2=12*I
      N3=14*I
      N4=345*I
      N5=0
      N6=210*I
      N7=32*I
      N8=899*I
      N9=616*I
      N10=0
      N11=93*I
C     MODULE 1: SIMPLE IDENTIFIERS
      JJ=100
99999 CONTINUE
      X1=1.0
      X2=-1.0
      X3=-1.0
      X4=-1.0
      IF (N1) 12,15,12
12    CONTINUE
      DO 10 I=1,N1
      X1=( X1+X2+X3-X4)*T
      X2=( X1+X2-X3+X4)*T
      X3=( X1-X2+X3+X4)*T
      X4=(-X1+X2+X3+X4)*T
10    CONTINUE
X     CALL POUT(N1,N1,N1,X1,X2,X3,X4)
15    CONTINUE
C     MODULE 2: ARRAY ELEMENTS
      E1(1)=1.0
      E1(2)=-1.0
      E1(3)=-1.0
      E1(4)=-1.0
      DO 20 I=1,N2
      E1(1)=( E1(1)+E1(2)+E1(3)-E1(4))*T
      E1(2)=( E1(1)+E1(2)-E1(3)+E1(4))*T
      E1(3)=( E1(1)-E1(2)+E1(3)+E1(4))*T
      E1(4)=(-E1(1)+E1(2)+E1(3)+E1(4))*T
20    CONTINUE
X     CALL POUT(N2,N3,N2,E1(1),E1(2),E1(3),E1(4))
C     MODULE 3: ARRAY AS PARAMETER
      DO 30 I=1,N3
      CALL PA(E1)
30    CONTINUE
X     CALL POUT(N3,N2,N2,E1(1),E1(2),E1(3),E1(4))
C     MODULE 4: CONDITIONAL JUMPS
      J=1
      DO 40 I=1,N4
      IF(J.EQ.1) GOTO 42
41    J=2
      GO TO 43
42    J=3
43    IF(J.GT.2) GOTO 45
44    J=0
      GO TO 46
45    J=1
46    IF(J.LT.1) GOTO 48
47    J=1
      GO TO 40
48    J=0
40    CONTINUE
X     CALL POUT(N4,J,J,X1,X2,X3,X4)
C     MODULE 5: OMITTED
C     MODULE 6: INTEGER ARITHMETIC
      J=1
      K=2
      L=3
      DO 60 I=1,N6
      J=J*(K-J)*(L-K)
      K=L*K-(L-J)*K
      L=(L-K)*(K+J)
      E1(L-1)=J+K+L
      E1(K-1)=J*K*L
60    CONTINUE
X     CALL POUT(N6,J,K,E1(1),E1(2),E1(3),E1(4))
C     MODULE 7: TRIG. FUNCTIONS
      X=0.5
      Y=0.5
      DO 70 I=1,N7
      X=T*ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0))
      Y=T*ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0))
70    CONTINUE
X     CALL POUT(N7,J,K,X,X,Y,Y)
C     MODULE 8: PROCEDURE CALLS
      X=1.0
      Y=1.0
      Z=1.0
      DO 80 I=1,N8
      CALL P3(X,Y,Z)
80    CONTINUE
X     CALL POUT(N8,J,K,X,Y,Z,Z)
C     MODULE 9: ARRAY REFERENCES
      J=1
      K=2
      L=3
      E1(1)=1.0
      E1(2)=2.0
      E1(3)=3.0
      DO 90 I=1,N9
      CALL P0
90    CONTINUE
X     CALL POUT(N9,J,K,E1(1),E1(2),E1(3),E1(4))
C     MODULE 10: INTEGER ARITHMETIC
      J=2
      K=3
      IF (N10) 97,105,97
97    CONTINUE
      DO 100 I=1,N10
      J=J+K
      K=J+K
      J=K-J
      K=K-J-J
100   CONTINUE
X     CALL POUT(N10,J,K,X1,X2,X3,X4)
105   CONTINUE
C     MODULE 11: STANDARD FUNCTIONS
      X=0.75
      DO 110 I=1,N11
      X=SQRT(EXP(ALOG(X)/T1))
110   CONTINUE
      JJ=JJ-1
      IF (JJ.GT.0) GOTO 99999
X     CALL POUT(N11,J,K,X,X,X,X)
      CPU2=SECOND(Z)
      CPU2=1000000.0/FLOAT(II)/(CPU2-CPU1)
      WRITE(*,2) CPU2
2     FORMAT(/// “ TOTAL WEIGHT:” ,F10.3,” (IN THOUSANDS OF WHETSTONE”,
     *       “ INSTRUCTIONS)”)
       CALL UTILIZ(TT2)
       TTT=TT2-TT1
       WRITE(*,7777)TTT
7777   FORMAT(‘ TIME TAKEN  ‘,F12.4)
      END
      SUBROUTINE PA(E)
      DIMENSION E(4)
      COMMON /B/ T,T2
      J=0
100   E(1)=( E(1)+E(2)+E(3)-E(4))*T
      E(2)=( E(1)+E(2)-E(3)+E(4))*T
      E(3)=( E(1)-E(2)+E(3)+E(4))*T
      E(3)=(-E(1)+E(2)+E(3)+E(4))/T2
      J=J+1
      IF (J-6) 100,105,105
105   CONTINUE
      RETURN
      END
      SUBROUTINE P0
      DIMENSION E1(4)
      COMMON /A/ E1,J,K,L
      E1(J)=E1(K)
      E1(K)=E1(L)
      E1(L)=E1(J)
      RETURN
      END
      SUBROUTINE P3(X,Y,Z)
      COMMON /B/ T,T2
   AX=X
      AY=Y
      AX=T*(AX+AY)
      AY=T*(AX+AY)
      Z=(AX+AY)/T2
      RETURN
      END
      SUBROUTINE POUT(N,J,K,X1,X2,X3,X4)
      WRITE(*,4) N
      WRITE(*,4) J
      WRITE(*,4) K
      WRITE(*,3) X1
      WRITE(*,3) X2
      WRITE(*,3) X3
      WRITE(*,3) X3
      WRITE(*,3) X4
3     FORMAT(1X,E25.15)
4     FORMAT(1X,I10)
      RETURN
      END

      FUNCTION SECOND(X)
      CALL UTILIZ(TIME)
      SECOND=TIME
      RETURN
      END

      SUBROUTINE UTILIZ(TIME)
      TIME = LONG(362)/60.0
      END

Listing 2: Assembly listing of inner loops of matrix multiply routine


LS Fortran, no optimization

L10009  EQU *
 ;  File “matmult.f”;  Line         16
 MOVE.L $FFFFFFF8(A6),D1
 SUB.L  $FFFFFFAC(A6),D1
 ASL.L  #3,D1
 MOVE.L $FFFFFFF4(A6),D2
 SUB.L  $FFFFFFB8(A6),D2
 MULS.L $FFFFFFB4(A6),D2
 ADD.L  D1,D2
 MOVE.L D2,$FFFFFF84(A6)
 MOVE.L $FFFFFFF8(A6),D1
 SUB.L  $FFFFFFAC(A6),D1
 ASL.L  #3,D1
 MOVE.L $FFFFFFF4(A6),D2
 SUB.L  $FFFFFFB8(A6),D2
 MULS.L $FFFFFFB4(A6),D2
 ADD.L  D1,D2
 MOVE.L D2,$FFFFFF68(A6)
 MOVE.L $FFFFFFF8(A6),D1
 SUB.L  $FFFFFFC4(A6),D1
 ASL.L  #3,D1
 MOVE.L $FFFFFFFC(A6),D2
 SUB.L  $FFFFFFD0(A6),D2
 MULS.L $FFFFFFCC(A6),D2
 ADD.L  D1,D2
 MOVE.L D2,$FFFFFF6C(A6)
 MOVE.L $FFFFFFFC(A6),D1
 SUB.L  $FFFFFFDC(A6),D1
 ASL.L  #3,D1
 MOVE.L $FFFFFFF4(A6),D2
 SUB.L  $FFFFFFE8(A6),D2
 MULS.L $FFFFFFE4(A6),D2
 ADD.L  D1,D2
 MOVE.L D2,$FFFFFF70(A6)
 MOVEA.L$0020(A6),A0
 ADDA.L $FFFFFF6C(A6),A0
 FMOVE.D(A0),FP7
 MOVEA.L$0018(A6),A1
 ADDA.L $FFFFFF70(A6),A1
 FMUL.D (A1),FP7
 MOVEA.L$0028(A6),A1
 ADDA.L $FFFFFF68(A6),A1
 FADD.D (A1),FP7
 MOVEA.L$0028(A6),A1
 ADDA.L $FFFFFF84(A6),A1
 FMOVE.DFP7,(A1)
 ;  File “matmult.f”;  Line         17
 ADDQ.L #1,$FFFFFFF8(A6)
 SUBQ.L #1,D7
 BGT    L10009

LS Fortran, -opt=3 optimization

L10009  EQU *
 ;  File “matmult.f”;  Line         16
 MOVE.L $FFFFFF5C(A6),$FFFFFF58(A6)
 MOVE.L $FFFFFF64(A6),$FFFFFF40(A6)
 MOVEA.L$0020(A6),A0
 ADDA.L $FFFFFF60(A6),A0
 FMOVE.D(A0),FP7
 MOVEA.L$0018(A6),A1
 ADDA.L $FFFFFF40(A6),A1
 FMUL.D (A1),FP7
 MOVEA.L$0028(A6),A1
 ADDA.L $FFFFFF58(A6),A1
 FADD.D (A1),FP7
 FMOVE.DFP7,(A1)
 ;  File “matmult.f”;  Line         17
 MOVEQ  #$0008,D1
 ADD.L  D1,$FFFFFF5C(A6)
 ADD.L  D1,$FFFFFF60(A6)
 ADDQ.L #1,$FFFFFFF8(A6)
 SUBQ.L #1,D7
 BGT.S  L10009

Absoft Fortran, no optimization

L14:

;                c(i,k) = c(i,k)+a(i,j)*b(j,k)

 move.l d3,d2
 sub.l  #$0001,d2
 move.l (20,a7),d4
 move.l d4,d6
 sub.l  #$0001,d6
 move.l (a7),d0
 muls.l d0,d6
 add.l  d6,d2
 move.l d3,d6
 sub.l  #$0001,d6
 move.l (36,a7),d5
 move.l d5,d7
 sub.l  #$0001,d7
 muls.l (8,a7),d7
 add.l  d7,d6
 sub.l  #$0001,d5
 move.l d4,d7
 sub.l  #$0001,d7
 muls.l (16,a7),d7
 add.l  d7,d5
 move.l (200,a7),a2
 fmove.d(a2,d6.l*8),fp2
 move.l (208,a7),a3
 fmove.d(a3,d5.l*8),fp3
 fmul.x fp3,fp2
 move.l (192,a7),a4
 fmove.d(a4,d2.l*8),fp4
 fadd.x fp2,fp4
 move.l d3,d2
 sub.l  #$0001,d2
 move.l d4,d5
 sub.l  #$0001,d5
 muls.l d0,d5
 add.l  d5,d2
 fmove.dfp4,(a4,d2.l*8)
 add.l  #$0001,d3
 move.l (44,a7),d6
 move.l d6,d7
 sub.l  #$0001,d7

;            end do

 move.l d7,(44,a7)
;  loop bottom branch
 tst.l  d7
 bgt    L14

Absoft Fortran, -O optimization

L14:
 move.l d6,d7
 sub.l  #$0001,d7
 move.l d7,d2
 add.l  (236,a7),d2
 add.l  (240,a7),d7
 fmove.d(a2,d7.l*8),fp2
 fmul.d (248,a7),fp2
 fmove.d(a3,d2.l*8),fp3
 fadd.x fp2,fp3
 fmove.dfp3,(a3,d2.l*8)
 add.l  #$0001,d6
 sub.l  #$0001,d4

;            end do

 tst.l  d4
 bgt    L14

Absoft Fortran, -O -U optimization

L27:
 move.l d4,d2
 sub.l  #$0001,d2
 move.l d2,d7
 add.l  d3,d7
 add.l  d0,d2
 fmove.d(a2,d2.l*8),fp2
 fmul.x fp3,fp2
 fmove.d(a3,d7.l*8),fp4
 fadd.x fp2,fp4
 fmove.dfp4,(a3,d7.l*8)
 move.l d4,d2
 add.l  #$0001,d2
 move.l d2,d4
 sub.l  #$0001,d4
 move.l d4,d7
 add.l  d3,d7
 add.l  d0,d4
 fmove.d(a2,d4.l*8),fp5
 fmul.x fp3,fp5
 fmove.d(a3,d7.l*8),fp6
 fadd.x fp5,fp6
 fmove.dfp6,(a3,d7.l*8)
 move.l d2,d4
 add.l  #$0001,d4
 sub.l  #$0002,d6

;            end do

 tst.l  d6
 bgt    L27
 move.l d4,(28,a7)

Absoft Fortran, -O -h4 optimization

L27:
 move.l d4,d2
 sub.l  #$0001,d2
 move.l d2,d7
 add.l  d3,d7
 add.l  d0,d2
 fmove.d(a2,d2.l*8),fp2
 fmul.x fp3,fp2
 fmove.d(a3,d7.l*8),fp4
 fadd.x fp2,fp4
 fmove.dfp4,(a3,d7.l*8)
 move.l d4,d2
 add.l  #$0001,d2
 move.l d2,d4
 sub.l  #$0001,d4
 move.l d4,d7
 add.l  d3,d7
 add.l  d0,d4
 fmove.d(a2,d4.l*8),fp5
 fmul.x fp3,fp5
 fmove.d(a3,d7.l*8),fp6
 fadd.x fp5,fp6
 fmove.dfp6,(a3,d7.l*8)
 add.l  #$0001,d2
 move.l d2,d4
 sub.l  #$0001,d4
 move.l d4,d7
 add.l  d3,d7
 add.l  d0,d4
 fmove.d(a2,d4.l*8),fp7
 fmul.x fp3,fp7
 fmove.d(a3,d7.l*8),fp0
 fadd.x fp7,fp0
 fmove.dfp0,(a3,d7.l*8)
 add.l  #$0001,d2
 move.l d2,d4
 sub.l  #$0001,d4
 move.l d4,d7
 add.l  d3,d7
 add.l  d0,d4
 fmove.d(a2,d4.l*8),fp2
 fmul.x fp3,fp2
 fmove.d(a3,d7.l*8),fp1
 fadd.x fp2,fp1
 fmove.dfp1,(a3,d7.l*8)
 move.l d2,d4
 add.l  #$0001,d4
 sub.l  #$0004,d6

;            end do

 tst.l  d6
 bgt    L27

 
AAPL
$102.50
Apple Inc.
+0.25
MSFT
$45.43
Microsoft Corpora
+0.55
GOOG
$571.60
Google Inc.
+2.40

MacTech Search:
Community Search:

Software Updates via MacUpdate

VueScan 9.4.41 - Scanner software with a...
VueScan is a scanning program that works with most high-quality flatbed and film scanners to produce scans that have excellent color fidelity and color balance. VueScan is easy to use, and has... Read more
Cloud 3.0.0 - File sharing from your men...
Cloud is simple file sharing for the Mac. Drag a file from your Mac to the CloudApp icon in the menubar and we take care of the rest. A link to the file will automatically be copied to your clipboard... Read more
LibreOffice 4.3.1.2 - Free Open Source o...
LibreOffice is an office suite (word processor, spreadsheet, presentations, drawing tool) compatible with other major office suites. The Document Foundation is coordinating development and... Read more
SlingPlayer Plugin 3.3.20.505 - Browser...
SlingPlayer is the screen interface software that works hand-in-hand with the hardware inside the Slingbox to make your TV viewing experience just like that at home. It features an array of... Read more
Get Lyrical 3.8 - Auto-magically adds ly...
Get Lyrical auto-magically add lyrics to songs in iTunes. You can choose either a selection of tracks, or the current track. Or turn on "Active Tagging" to get lyrics for songs as you play them.... Read more
Viber 4.2.2 - Send messages and make cal...
Viber lets you send free messages and make free calls to other Viber users, on any device and network, in any country! Viber syncs your contacts, messages and call history with your mobile device,... Read more
Cocktail 7.6 - General maintenance and o...
Cocktail is a general purpose utility for OS X that lets you clean, repair and optimize your Mac. It is a powerful digital toolset that helps hundreds of thousands of Mac users around the world get... Read more
LaunchBar 6.1 - Powerful file/URL/email...
LaunchBar is an award-winning productivity utility that offers an amazingly intuitive and efficient way to search and access any kind of information stored on your computer or on the Web. It provides... Read more
Maya 2015 - Professional 3D modeling and...
Maya is an award-winning software and powerful, integrated 3D modeling, animation, visual effects, and rendering solution. Because Maya is based on an open architecture, all your work can be scripted... Read more
BBEdit 10.5.12 - Powerful text and HTML...
BBEdit is the leading professional HTML and text editor for the Mac. Specifically crafted in response to the needs of Web authors and software developers, this award-winning product provides a... Read more

Latest Forum Discussions

See All

Qube Kingdom – Tips, Tricks, Strategies,...
Qube Kingdom is a tower defense game from DeNA. You rally your troops – magicians, archers, knights, barbarians, and others – and fight against an evil menace looking to dominate your kingdom of tiny squares. Planning a war isn’t easy, so here are a... | Read more »
Qube Kingdom Review
Qube Kingdom Review By Nadia Oxford on August 29th, 2014 Our Rating: :: KIND OF A SQUARE KINGDOMUniversal App - Designed for iPhone and iPad Qube Kingdom has cute visuals, but it’s a pretty basic tower defense game at heart.   | Read more »
Fire in the Hole Review
Fire in the Hole Review By Rob Thomas on August 29th, 2014 Our Rating: :: WALK THE PLANKUniversal App - Designed for iPhone and iPad Seafoam’s Fire in the Hole looks like a bright, 8-bit throwback, but there’s not enough booty to... | Read more »
Alien Creeps TD is Now Available Worldwi...
Alien Creeps TD is Now Available Worldwide Posted by Ellis Spice on August 29th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Dodo Master Review
Dodo Master Review By Jordan Minor on August 29th, 2014 Our Rating: :: NEST EGGiPad Only App - Designed for the iPad Dodo Master is tough but fair, and that’s what makes it a joy to play.   | Read more »
Motorsport Manager Review
Motorsport Manager Review By Lee Hamlet on August 29th, 2014 Our Rating: :: MARVELOUS MANAGEMENTUniversal App - Designed for iPhone and iPad Despite its depth and sense of tactical freedom, Motorsport Manager is one of the most... | Read more »
Motorsport Manager – Beginner Tips, Tric...
The world of Motorsport management can be an unforgiving and merciless one, so to help with some of the stress that comes with running a successful race team, here are a few hints and tips to leave your opponents in the dust. | Read more »
CalPal Update Brings the App to 2.0, Add...
CalPal Update Brings the App to 2.0, Adds Lots of New Stuff Posted by Ellis Spice on August 29th, 2014 [ permalink ] | Read more »
Baseball Battle Review
Baseball Battle Review By Jennifer Allen on August 29th, 2014 Our Rating: :: SIMPLE HITTINGUniversal App - Designed for iPhone and iPad Simple and cute, Baseball Battle is a fairly fun baseball game for those looking for something... | Read more »
Checkmark 2.1 Update Released, and it’s...
Checkmark 2.1 Update Released, and it’s on Sale for a Limited Time Posted by Jessica Fisher on August 29th, 2014 [ permalink ] | Read more »

Price Scanner via MacPrices.net

Labor Day Weekend MacBook Pro sale; 15-inch m...
B&H Photo has the new 2014 15″ Retina MacBook Pros on sale for up to $125 off MSRP. Shipping is free, and B&H charges NY sales tax only. They’ll also include free copies of Parallels Desktop... Read more
Labor Day Weekend iPad mini sale; $50 to $100...
Best Buy has the iPad mini with Retina Display (WiFi models) on sale for $50 off MSRP on their online store for Labor Day Weekend. Choose free shipping or free local store pick up. Price is for... Read more
13-inch 1.4GHz MacBook Air on sale for $899,...
Adorama has the new 2014 13″ 1.4GHz/128GB MacBook Air on sale for $899.99 including free shipping plus NY & NJ tax only. Their price is $100 off MSRP. Read more
It’s Official: Apple Issues Invitations To Se...
Apple has issued one of its characteristically cryptic press invitations for a special event to be held at the Flint Center for the Performing Arts in hometown Cupertino on Sept. 9, 2014 at 10:00 am... Read more
Tablet Shipments To See First On-year Decline...
TrendForce analyst Caroline Chen notes that when the iPad launched in 2010, it was an instant hit and spurred a tablet PC revolution, with tablets so popular that that notebook PC sales stagnated and... Read more
SOBERLINK Releases Apple iOS Compatible Handh...
Cypress, California based SOBERLINK, Inc., creator of the first handheld Breathalyzer designed to improve recovery outcomes, continues to show prominence in the mobile alcohol monitoring space with... Read more
New 21″ 1.4GHz iMac on sale again for $999, s...
Best Buy has the new 21″ 1.4GHz iMac on sale for $999.99 on their online store. Their price is $100 off MSRP. Choose free shipping or free local store pick up. Price is for online orders only, in-... Read more
Smartphone Outlook Remains Strong for 2014, U...
According to a new mobile phone forecast from the International Data Corporation (IDC) Worldwide Quarterly Mobile Phone Tracker, more than 1.25 billion smartphones will be shipped worldwide in 2014,... Read more
Save up to $60 with Apple refurbished iPod to...
The Apple Store has Apple Certified Refurbished 5th generation iPod touches available starting at $149. Apple’s one-year warranty is included with each model, and shipping is free. Many, but not all... Read more
12-Inch MacBook Air Coming in 4Q14 or 2015 –...
Digitimes’ Aaron Lee and Joseph Tsai report that according to Taiwan-based upstream supply chain insiders, Apple plans to launch a thinner MacBook model either at year end 2014 or in 2015, and that... Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.