Skip to content

Instantly share code, notes, and snippets.

@ArchRobison
Created February 26, 2014 15:25
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/9231536 to your computer and use it in GitHub Desktop.
Save ArchRobison/9231536 to your computer and use it in GitHub Desktop.
Simple benchmark for https://github.com/JuliaLang/julia/pull/5355 . Try ```flog(1000, 1000000, 125000)```. With PR5355, it should also vectorize without ```@simd```.
function saxpy( a, x, y )
@simd for i=1:length(x)
@inbounds y[i] = y[i]+a*x[i]
end
end
function flog( n, reps, tolerance )
x = rand(Float32,n)
y = rand(Float32,n)
z = copy(y)
time = @elapsed for j in 0:reps-1
saxpy(float32(j)/(reps-1),x,y)
end
println("GFlop = ",2.0*n*reps/time*1E-9)
for i in 1:n
err = abs( y[i] - (z[i] + x[i]*reps/2) )
if err>tolerance
println(STDERR,"[$i] has high error = $err")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment