Skip to content
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

Smaller benchmarks #157

Merged
merged 3 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 15 additions & 35 deletions benchmark/bench_jogger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,26 @@ Pkg.develop(; path=joinpath(@__DIR__, "SparseConnectivityTracerBenchmarks"))

using BenchmarkTools
using SparseConnectivityTracer
using SparseConnectivityTracer: GradientTracer, HessianTracer
using SparseConnectivityTracer: IndexSetGradientPattern, IndexSetHessianPattern
using SparseConnectivityTracer: DuplicateVector, SortedVector, RecursiveSet
using SparseConnectivityTracer: Shared, NotShared

SET_TYPES = (BitSet, Set{Int}, DuplicateVector{Int}, RecursiveSet{Int}, SortedVector{Int})
using SparseConnectivityTracer: HessianTracer, DictHessianPattern, Shared

include("jacobian.jl")
include("hessian.jl")
include("nlpmodels.jl")

suite = BenchmarkGroup()

suite["OptimizationProblems"] = optbench([:britgas])

for S1 in SET_TYPES
S2 = Set{Tuple{Int,Int}}

# Non-shared tracers
PG = IndexSetGradientPattern{Int,S1}
PH = IndexSetHessianPattern{Int,S1,S2,NotShared}
G = GradientTracer{PG}
H = HessianTracer{PH}

suite["Jacobian"]["Global"][nameof(S1)] = jacbench(TracerSparsityDetector(G, H))
suite["Jacobian"]["Local"][nameof(S1)] = jacbench(TracerLocalSparsityDetector(G, H))
suite["Hessian"]["Global"][(nameof(S1), nameof(S2))] = hessbench(
TracerSparsityDetector(G, H)
)
suite["Hessian"]["Local"][(nameof(S1), nameof(S2))] = hessbench(
TracerLocalSparsityDetector(G, H)
)

# Shared tracers
PG = IndexSetGradientPattern{Int,S1}
PH = IndexSetHessianPattern{Int,S1,S2,Shared}
G = GradientTracer{PG}
H = HessianTracer{PH}

suite["Hessian"]["Global (shared)"][(nameof(S1), nameof(S2))] = hessbench(
TracerSparsityDetector(G, H)
)
end
suite["Jacobian"]["Global"] = jacbench(TracerSparsityDetector())
suite["Jacobian"]["Local"] = jacbench(TracerLocalSparsityDetector())
suite["Hessian"]["Global"] = hessbench(TracerSparsityDetector())
suite["Hessian"]["Local"] = hessbench(TracerLocalSparsityDetector())

# Shared tracers
P = DictHessianPattern{Int,BitSet,Dict{Int,BitSet},Shared}
H = HessianTracer{P}
suite["Hessian"]["Global shared"] = hessbench(
TracerSparsityDetector(; hessian_tracer_type=H)
)
suite["Hessian"]["Local shared"] = hessbench(
TracerLocalSparsityDetector(; hessian_tracer_type=H)
)
6 changes: 2 additions & 4 deletions benchmark/nlpmodels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ function optbench(names::Vector{Symbol})
suite = BenchmarkGroup()
for name in names
nlp = ADNLPProblems.eval(name)()
suite[name]["Jacobian"] = @benchmarkable compute_jac_sparsity_sct($nlp) evals = 1 samples =
1
suite[name]["Hessian"] = @benchmarkable compute_hess_sparsity_sct($nlp) evals = 1 samples =
1
suite[name]["Jacobian"] = @benchmarkable compute_jac_sparsity_sct($nlp)
suite[name]["Hessian"] = @benchmarkable compute_hess_sparsity_sct($nlp)
end
return suite
end
Loading