diff --git a/benchmark/Project.toml b/benchmark/Project.toml index 4e82ba12b..75d3128b8 100644 --- a/benchmark/Project.toml +++ b/benchmark/Project.toml @@ -1,6 +1,11 @@ [deps] +ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" +BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +Git = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2" GitHub = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26" IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153" +JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7" KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77" @@ -9,6 +14,8 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" LinearOperators = "5c8ed15e-5a4c-59e4-a42b-c7e8811fb125" MatrixMarket = "4d4711f2-db25-561a-b6b3-d35e7d4047d3" PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" +Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" +SolverBenchmark = "581a75fa-a23a-52d0-a590-d6201de2218a" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" SuiteSparseMatrixCollection = "ac199af8-68bc-55b8-82c4-7abd6f96ed98" diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 186fad0a1..a27f3f38e 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -1,47 +1,32 @@ using BenchmarkTools -using MatrixMarket - -using LinearAlgebra -using SparseArrays - -using Krylov -using LinearOperators -using SuiteSparseMatrixCollection +using LinearAlgebra, SparseArrays, Krylov +using MatrixMarket, SuiteSparseMatrixCollection include("../test/get_div_grad.jl") -# ufl_posdef = filter(p -> p.structure == "symmetric" && p.posDef == "yes" && p.type == "real" && p.rows ≤ 2_000, ssmc) -ufl_posdef = filter(p -> p.structure == "symmetric" && p.posDef == "yes" && p.type == "real" && p.rows ≤ 100, ssmc) - -# fetch_ssmc(ufl_posdef, format="MM") +ssmc = ssmc_db() +ufl_posdef = ssmc[(ssmc.numerical_symmetry .== 1) .& (ssmc.positive_definite .== true) .& (ssmc.real .== true) .& (ssmc.binary .== false) .& (ssmc.nrows .≤ 500), :] +paths = fetch_ssmc(ufl_posdef, format="MM") const SUITE = BenchmarkGroup() -SUITE["CG"] = BenchmarkGroup(["CG", "SPD"]) - +SUITE["DivGrad"] = BenchmarkGroup() for N in [32, 64, 128] - SUITE["CG"]["DivGrad N=$N"] = BenchmarkGroup() A = get_div_grad(N, N, N) - n = size(A, 1) + n, m = size(A) b = ones(n) - op = PreallocatedLinearOperator(A) - M = opEye() - rtol = 1.0e-6 - SUITE["CG"]["DivGrad N=$N"]["Krylov"] = @benchmarkable cg($op, $b, M=$M, atol=0.0, rtol=$rtol, itmax=$n) + rtol = 1.0e-8 + SUITE["DivGrad"]["DivGrad N=$N"] = @benchmarkable cg($A, $b, atol=0.0, rtol=$rtol, itmax=$n) end -SUITE["CG"]["UFL"] = BenchmarkGroup() -for matrix in ufl_posdef - name = matrix.name - A = MatrixMarket.mmread(joinpath(matrix_path(matrix, format="MM"), "$(name).mtx")) - if eltype(A) <: Integer - A = convert(SparseMatrixCSC{Float64,Int}, A) +SUITE["UFL"] = BenchmarkGroup() +for path in paths + name = split(path, '/')[end] + A = MatrixMarket.mmread(path * "/$name.mtx") + n, m = size(A) + if eltype(A) == Float64 + b = ones(n) + rtol = 1.0e-8 + SUITE["UFL"][name] = @benchmarkable cg($A, $b, atol=0.0, rtol=$rtol, itmax=$n) end - n = size(A, 1) - b = ones(eltype(A), n) - op = PreallocatedLinearOperator(A) - M = opEye() - rtol = 1.0e-6 - SUITE["CG"]["UFL"][name] = BenchmarkGroup() - SUITE["CG"]["UFL"][name]["Krylov"] = @benchmarkable cg($op, $b, M=$M, atol=0.0, rtol=$rtol, itmax=$n) end