Created
February 26, 2014 15:25
-
-
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```.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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