diff --git a/src/broadcast/BroadcastBenchmarks.jl b/src/broadcast/BroadcastBenchmarks.jl index a527fec4..ad657638 100644 --- a/src/broadcast/BroadcastBenchmarks.jl +++ b/src/broadcast/BroadcastBenchmarks.jl @@ -82,4 +82,22 @@ for t in (t1, t2, t3) g[length(t), "scal_tup_x3"] = @benchmarkable broadcast(+, 1, $t, 1, $t, 1, $t) end +########################################################################### + +xset= 10:15 +yset= 12:14 +f(x,y) = sqrt( x^2 + y^2 ) + +function perf_loop3(xset, yset) + m = Matrix{Float64}(undef, 3, length(xset)*length(yset)) + i = 1 + @inbounds for x in xset, y in yset + m[:,i] .= (Float64(x), Float64(y), f(x,y)) + i += 1 + end + return m +end + +SUITE["26942"] = @benchmarkable perf_loop3($xset, $yset) + end # module diff --git a/src/linalg/LinAlgBenchmarks.jl b/src/linalg/LinAlgBenchmarks.jl index 567d4577..ef9a6c3b 100644 --- a/src/linalg/LinAlgBenchmarks.jl +++ b/src/linalg/LinAlgBenchmarks.jl @@ -262,4 +262,11 @@ for b in values(g) b.params.time_tolerance = 0.40 end +############# +# small exp # +############# + +SUITE["small exp #29116"] = @benchmarkable exp([1. 0; 2 0]) + + end # module diff --git a/src/misc/MiscellaneousBenchmarks.jl b/src/misc/MiscellaneousBenchmarks.jl index 201d5d39..663e6844 100644 --- a/src/misc/MiscellaneousBenchmarks.jl +++ b/src/misc/MiscellaneousBenchmarks.jl @@ -305,4 +305,89 @@ for N in (1,1000), M in 1:4 g["zip($(join(fill("1:$N", M), ", ")))"] = @benchmarkable collect($X) end +#################################################### +# Allocation elision stumped by conditional #28226 # +# Note, not fixed when this benchmark was written # +#################################################### + +function perf_colwise_alloc!(r, a, b) + @inbounds for j = 1:size(a,2) + r[j] = evaluate_cond(view(a, :, j), view(b, :, j)) + end + r +end + +@inline function evaluate_cond(a, b) + length(a) == 0 && return 0.0 # comment out and 0.7 is super fast + @inbounds begin + s = 0.0 + @simd for I in eachindex(a, b) + ai = a[I] + bi = b[I] + s += abs2(ai - bi) + end + return s + end +end + +function perf_colwise_noalloc!(r, a, b) + @inbounds for j = 1:size(a,2) + r[j] = evaluate_nocond(view(a, :, j), view(b, :, j)) + end + r +end + +@inline function evaluate_nocond(a, b) + @inbounds begin + s = 0.0 + @simd for I in eachindex(a, b) + ai = a[I] + bi = b[I] + s += abs2(ai - bi) + end + return s + end +end + +z = zeros(41); A = rand(2, 41); B = rand(2, 41); +g = addgroup!(SUITE, "allocation elision view") +g["conditional"] = @benchmarkable perf_colwise_alloc!($z, $A, $B) +g["no conditional"] = @benchmarkable perf_colwise_noalloc!($z, $A, $B) + + +#################################################### +# Fastmath infererence large number of args #22275 # +#################################################### + +function f2(a,b,c,d,e,f,g,h,j,k,l,m,n,o,p) + aidx = eachindex(a) + @fastmath for i in aidx + @inbounds a[i] = b[i]+c*(d*e[i]+f*g[i]+h*j[i]+k*l[i]+m*n[i]+o*p[i]) + end +end +a = rand(10) +b = rand(10) +c = 0.1 +d = 0.1 +e = rand(10) +f = 0.1 +g = rand(10) +h = 0.1 +j = rand(10) +k = 0.1 +l = rand(10) +m = 0.1 +n = rand(10) +o = 0.1 +p = rand(10) + +SUITE["fastmath many args"] = @benchmarkable f2($a,$b,$c,$d,$e,$f,$g,$h,$j,$k,$l,$m,$n,$o,$p) + +############################################################## +# Performance and typing of 6+ dimensional generators #21058 # +############################################################## +perf_g6() = sum([+(a,b,c,d,e,f) for a in 1:4, b in 1:4, c in 1:4, d in 1:4, e in 1:4, f in 1:4]) + +SUITE["perf highdim generator"] = @benchmarkable perf_g6() + end diff --git a/src/sparse/SparseBenchmarks.jl b/src/sparse/SparseBenchmarks.jl index 4789ddbc..19ec22f6 100644 --- a/src/sparse/SparseBenchmarks.jl +++ b/src/sparse/SparseBenchmarks.jl @@ -258,7 +258,7 @@ for (om, ok, on) in (# order of matmul dimensions m, k, and n g["A_mul_Bt", "dense $(m)x$(k), sparse $(n)x$(k) -> dense $(m)x$(n)"] = @benchmarkable A_mul_Bt($densemat, $tsparsemat) g["At_mul_B", "dense $(k)x$(m), sparse $(k)x$(n) -> dense $(m)x$(n)"] = @benchmarkable At_mul_B($tdensemat, $sparsemat) g["At_mul_Bt", "dense $(k)x$(m), sparse $(n)x$(k) -> dense $(m)x$(n)"] = @benchmarkable At_mul_Bt($tdensemat, $tsparsemat) - end + end # in-place dense-sparse -> dense ops, transpose variants, i.e. A[t]_mul[t]!(dense, dense, sparse) m, k, n, destmat, densemat, sparsemat, tdensemat, tsparsemat = allocmats_ds(om, ok, on, 4, 12, Float64) if VERSION >= v"0.7.0-DEV.3204" @@ -282,7 +282,7 @@ for (om, ok, on) in (# order of matmul dimensions m, k, and n g["A_mul_Bc", "dense $(m)x$(k), sparse $(n)x$(k) -> dense $(m)x$(n)"] = @benchmarkable A_mul_Bc($densemat, $tsparsemat) g["Ac_mul_B", "dense $(k)x$(m), sparse $(k)x$(n) -> dense $(m)x$(n)"] = @benchmarkable Ac_mul_B($tdensemat, $sparsemat) g["Ac_mul_Bc", "dense $(k)x$(m), sparse $(n)x$(k) -> dense $(m)x$(n)"] = @benchmarkable Ac_mul_Bc($tdensemat, $tsparsemat) - end + end # in-place dense-sparse -> dense ops, adjoint variants, i.e. A[c]_mul[c]!(dense, dense, sparse) m, k, n, destmat, densemat, sparsemat, tdensemat, tsparsemat = allocmats_ds(om, ok, on, 2, 8, Complex{Float64}) if VERSION >= v"0.7.0-DEV.3204" @@ -355,4 +355,19 @@ for b in values(g) b.params.time_tolerance = 0.3 end + +################# +# sparse matvec # +################# +g = addgroup!(SUITE, "sparse matvec") +B = randn(100000, 100) +A = sprand(100000, 100000, 0.00001) +if VERSION >= v"0.7.0-DEV.3204" + g["non-adjoint"] = @benchmarkable A * B + g["adjoint"] = @benchmarkable A' * B +else + g["non-adjoint"] = @benchmarkable A * B + g["adjoint"] = @benchmarkable At_mul_B(A, B) +end + end # module diff --git a/src/string/StringBenchmarks.jl b/src/string/StringBenchmarks.jl index a6c6fe3a..b92e3468 100644 --- a/src/string/StringBenchmarks.jl +++ b/src/string/StringBenchmarks.jl @@ -62,4 +62,14 @@ buffer = IOBuffer(("bar" ^ 20000) * "ians") target = ("bar" ^ 300) * "ian" g["barbarian backtrack"] = @benchmarkable readuntil(seekstart($buffer), $target) +################# +# repeat #22462 # +################# + +g = addgroup!(SUITE, "repeat") +g["repeat str len 1"] = @benchmarkable repeat(" ", 500) +g["repeat str len 16"] = @benchmarkable repeat("repeatmerepeatme", 500) +g["repeat char 1"] = @benchmarkable repeat(' ', 500) +g["repeat char 2"] = @benchmarkable repeat('α', 500) + end # module