-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@btime
errors because tune!
does not execute setup
#264
Comments
I think you just want to specify julia> function f!(x::AbstractVector)
# length(x) == 2 || error("setup not correctly executed")
sleep(length(x)/10) # 100ms per element
push!(x, randn())
end;
julia> @btime f!(y) setup=(y=randn(2);) evals=1;
min 206.132 ms, mean 206.175 ms (6 allocations, 224 bytes)
julia> @btime f!(y) setup=(y=randn(2);) evals=10;
min 655.086 ms, mean 655.086 ms (5 allocations, 185 bytes)
julia> mean(2:11)
6.5 |
I've also run into an issue caused by this behavior. Managed to figure out the My example: using LinearAlgebra
function randposdef(N)
A = randn(100, 100)
return Symmetric(A * A' + I)
end
julia> @btime cholesky!(A) setup=(A = randposdef(100)); # evals=1 needed to make it work
ERROR: PosDefException: matrix is not positive definite; Cholesky factorization failed.
Stacktrace:
[1] checkpositivedefinite
@ ~/lib/julia-1.7.2/share/julia/stdlib/v1.7/LinearAlgebra/src/factorization.jl:18 [inlined]
[2] cholesky!(A::Symmetric{Float64, Matrix{Float64}}, ::Val{false}; check::Bool)
@ LinearAlgebra ~/lib/julia-1.7.2/share/julia/stdlib/v1.7/LinearAlgebra/src/cholesky.jl:266
[3] cholesky! (repeats 2 times)
@ ~/lib/julia-1.7.2/share/julia/stdlib/v1.7/LinearAlgebra/src/cholesky.jl:265 [inlined]
[4] var"##core#423"(A::Symmetric{Float64, Matrix{Float64}})
@ Main ~/.julia/packages/BenchmarkTools/7xSXH/src/execution.jl:489
[5] var"##sample#424"(::Tuple{}, __params::BenchmarkTools.Parameters)
@ Main ~/.julia/packages/BenchmarkTools/7xSXH/src/execution.jl:497
[6] _lineartrial(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters; maxevals::Int64, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ BenchmarkTools ~/.julia/packages/BenchmarkTools/7xSXH/src/execution.jl:161
[7] _lineartrial(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters)
@ BenchmarkTools ~/.julia/packages/BenchmarkTools/7xSXH/src/execution.jl:153
[8] #invokelatest#2
@ ./essentials.jl:716 [inlined]
[9] invokelatest
@ ./essentials.jl:714 [inlined]
[10] #lineartrial#46
@ ~/.julia/packages/BenchmarkTools/7xSXH/src/execution.jl:35 [inlined]
[11] lineartrial
@ ~/.julia/packages/BenchmarkTools/7xSXH/src/execution.jl:35 [inlined]
[12] tune!(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters; progressid::Nothing, nleaves::Float64, ndone::Float64, verbose::Bool, pad::String, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ BenchmarkTools ~/.julia/packages/BenchmarkTools/7xSXH/src/execution.jl:251
[13] tune! (repeats 2 times)
@ ~/.julia/packages/BenchmarkTools/7xSXH/src/execution.jl:250 [inlined]
[14] top-level scope
@ ~/.julia/packages/BenchmarkTools/7xSXH/src/execution.jl:576 |
Actually, if you provided a |
My mental model of what's happening inside
So if we set Could any developer verify that? It might be useful to write in documentation. |
This is the same problem as #24 |
It appears
tune!
does not executesetup
before every run, leading to errors in certain cases. See below for a MWE:Then
@benchmarkable
works:But neither
@btime
nor@benchmark
do:@benchmark
yields a similar stack trace, leading me to believe thattune!
does not callsetup
in subsequent runs.The text was updated successfully, but these errors were encountered: