JuliaLang/julia — pull request #917 by certik (2012-06-06 22:53:14+00:00)
Title: Add Fortran version of the benchmarks

I think you should also put Fortran into the benchmarks. The speed in general should be compatible with the C++ version, but the syntax is much nicer, in particular the ``randmatstat`` function:

```
subroutine randmatstat(t, s1, s2)
integer, intent(in) :: t
real(dp), intent(out) :: s1, s2
real(dp), allocatable, dimension(:, :) :: a, b, c, d, P, Q, X
real(dp), allocatable :: v(:), w(:)
integer :: n, i
n = 5
allocate(a(n, n), b(n, n), c(n, n), d(n, n))
allocate(P(4*n, n), Q(2*n, 2*n), X(2*n, 2*n))
allocate(v(t), w(t))
do i = 1, t
call randn(a)
call randn(b)
call randn(c)
call randn(d)
P(:n, :)=a; P(n+1:2*n, :)=b; P(2*n+1:3*n, :)=c; P(3*n+1:, :)=d
Q(:n, :n) = a; Q(n+1:, :n) = b
Q(:n, n+1: ) = c; Q(n+1:, n+1: ) = d
X = matmul(transpose(P), P)
X = matmul(X, X)
X = matmul(X, X)
v(i) = trace(X)
X = matmul(transpose(Q), Q)
X = matmul(X, X)
X = matmul(X, X)
w(i) = trace(X)
end do
s1 = std(v) / mean(v)
s2 = std(w) / mean(w)
end subroutine
```

is pretty much 1:1 equivalent to the Julia version, except that you have to declare variables and except the [a, b, c, d] and ^4 notation for matrices.

If you are willing to accept Fortran into the benchmarks, then I am happy to also include the rest of the benchmarks.

As to compilation, compile it with the same optimization arguments as for ``gcc``. To get optimal performance, one should use Intel compilers and make IFort link with MKL (then the ``matmul`` command will be very fast). But to get a general idea, gfortran works fine too.