Skip to content

Instantly share code, notes, and snippets.

@ArchRobison
Created February 26, 2014 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArchRobison/9231763 to your computer and use it in GitHub Desktop.
Save ArchRobison/9231763 to your computer and use it in GitHub Desktop.
This benchmark requires https://github.com/JuliaLang/julia/pull/5355 and building Julia with LLVM 3.4. Try flog(1000,1000,500).
function sweep( irange, jrange, U, Vx, Vy, A, B )
for j in jrange
@simd for i in irange
@inbounds begin
u = U[i,j]
Vx[i,j] += (A[i,j+1]+A[i,j])*(U[i,j+1]-u)
Vy[i,j] += (A[i+1,j]+A[i,j])*(U[i+1,j]-u)
U [i,j] = u + B[i,j]*((Vx[i,j]-Vx[i,j-1]) + (Vy[i,j]-Vy[i-1,j]))
end
end
end
end
function iterate( t, U, Vx, Vy, A, B )
m,n = size(U)
for k=1:t
sweep(2:m-1,2:n-1,U,Vx,Vy,A,B)
end
end
function flog(m,n,timesteps)
A = fill(0.2f0,m,n)
B = fill(0.25f0,m,n)
U = (rand(Float32,m,n)-0.5f0)*1.0f-6
Vx = zeros(Float32,m,n)
Vy = zeros(Float32,m,n)
time = @elapsed(iterate(timesteps,U, Vx, Vy, A, B))
println("GFlop = ",13.0*(m-2)*(n-2)*timesteps/time*1E-9)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment