Skip to content

Instantly share code, notes, and snippets.

@ArchRobison
Created February 26, 2014 15:47
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/9232051 to your computer and use it in GitHub Desktop.
Save ArchRobison/9232051 to your computer and use it in GitHub Desktop.
This benchmark requires https://github.com/JuliaLang/julia/pull/5355. Try flog(1000,1000000,30)
function inner( x, y )
s = zero(eltype(x))
@simd for i=1:length(x)
@inbounds s += x[i]*y[i]
end
s
end
function flog( n, reps, tolerance )
x = rand(Float32,n)
y = rand(Float32,n)
s = zero(Float64)
time = @elapsed for j in 1:reps
s+=inner(x,y)
end
println("GFlop = ",2.0*n*reps/time*1E-9)
t = dot(x,y)
err = abs(s-t*reps)
if err>tolerance
println(STDERR,"err = $err")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment