Benchmark

From: Robert.Bell@mel.dit.csiro.au
Date: Tue Oct 01 1991 - 10:47:02 CDT


 John,
      Because I have nothing netter to do (ha ha), I have fiddled with your
 benchmark further, to try to build defences against aggressive optimization.
      You are welcome to incorporate any of my changes, with acknowledgement.
      Regards,
              Rob. Bell.
/ Robert C. Bell | CSIRO Supercomputing Support Manager \
| Division of Information Technology | 'phone: (03) 282 2620 +61 3 282 2620 |
| 723 Swanston Street | fax: (03) 282 2600 +61 3 282 2600 |
\ Carlton VIC 3053 Australia | email: csrcb@mel.dit.csiro.au /

        program Mc2
C
C This program tests memory transfers.
C Original by
C John D. McCalpin mccalpin@perelandra.cms.udel.edu
C Assistant Professor mccalpin@brahms.udel.edu
C College of Marine Studies, U. Del. DELOCN::MCCALPIN (SPAN)
C
C Modified by
C Robert C. Bell | CSIRO Supercomputing Support Manager \
C Division of Information Technology | 'phone: (03) 282 2620 +61 3 282 2620 |
C 723 Swanston Street | fax: (03) 282 2600 +61 3 282 2600 |
C Carlton VIC 3053 Australia | email: csrcb@mel.dit.csiro.au /
C
C 1991 Oct 01 09:47:24 Tue
C
C Warning - machine dependencies.
C To run correctly, reals must be 64-bit, integers must be able to hold
C numbers up to a million, and a function called second must be available.
C The real function second, which has no arguments, returns the CPU seconds
C used so far in the program.
C This is preferable to using elapsed time for busy machines.
C
        parameter (N= 1 000 000)
        real a(N),b(N),c(N)
        real second, t1, t2, t3, t4, toverh, t
        real check, const
C
C Put the arrays in common, to force the same alignment.
        common // a, b, c
C
        data const / 3.0 /
        data check / 0.0 /

C
C Initialize the arrays with non-trivial values, to stop
C the simple optimization of just doing the calculation for
C one array value.
C Assume that integers as large as one million can be handled.
        do 10 j=1,N
            a(j) = j
            b(j) = N -j
            c(j) = - j
   10 continue
        call sub (N, a, b, c, check)
C
C Insert a few extra calls to second, to by-pass initialization
C which may distort the first few calls.
        t1 = second ( )
        t2 = second ( )
        t3 = second ( )
        t4 = second ( )
        toverh = t4 - t3
        print *, ' The first few times are ', t1, t2, t3, t4
        print *, ' The overhead time is about ', toverh

        t = second( )
        do 20 j=1,N
            c(j) = a(j)
   20 continue
        t = second( )-t - toverh
        call sub (N, a, b, c, check)
        print *,'Timing calibration ; t = ',t*100,' clicks'
        print *,' '
        print *,'Assignment: Rate = ',1.0e-6*real(2*N*8)/t,' MB/s'
     $ ,' MFLOPS = ',1.0e-6* real (0*N)/t

        t = second( )
        do 30 j=1,N
            c(j) = const*a(j)
   30 continue
        t = second( )-t - toverh
        call sub (N, a, b, c, check)
        print *,'Scaling: Rate = ',1.0e-6*real(2*N*8)/t,' MB/s'
     $ ,' MFLOPS = ',1.0e-6 * real (1*N)/t

        t = second( )
        do 40 j=1,N
            c(j) = a(j)+b(j)
   40 continue
        t = second( )-t - toverh
        call sub (N, a, b, c, check)
        print *,'Summing: Rate = ',1.0e-6*real(3*N*8)/t,' MB/s'
     $ ,' MFLOPS = ',1.0e-6 * real (1*N)/t

        t = second( )
        do 50 j=1,N
            c(j) = a(j)+const*b(j)
   50 continue
        t = second( )-t - toverh
        call sub (N, a, b, c, check)
        print *,'SAXPYing: Rate = ',1.0e-6*real(3*N*8)/t,' MB/s'
     $ ,' MFLOPS = ',1.0e-6 * real (2*N)/t
        print *, ' The check sum is ', check,
     1 ', and should be 8999998.'
        end
        subroutine sub (N, a, b, c, check)
C
C This routine forces the storage in the arrays.
C
C It uses the value of pi to pseudo-randomly pick values
C from the array to be used.
C This may defeat most optimization attempts which try to not
C compute all the array values.
C
        Integer N
        real a(n), b(n), c(n)
        real check
C
        real pi, rand
        integer icall, irand
        save pi, rand, icall, irand
C
        data icall / 0 /
C
        if (icall .le. 0) then
           pi = 4.0 * atan (1.0)
        endif
        icall = icall + 1
        rand = mod ( real (icall) * pi, 1.0)
        irand = int (rand * real (N))
        irand = min (N, max (1, irand))
        check = check + a(irand) + b(irand) + c(irand)
C No write (*,*) pi, icall, rand, irand,
C No 1 a(irand), b(irand), c(irand), check
        return
        end
C On Crays, using the provided intrinsic.
C No real function second()
C No real dummy(2)
C No second = etime(dummy)
C No end



This archive was generated by hypermail 2b29 : Tue Apr 18 2000 - 05:23:01 CDT