Skip to content

Commit

Permalink
splitting testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
epolack committed Feb 8, 2024
1 parent f0e6f7b commit 2d2ea71
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 0 additions & 2 deletions benchmark/humongous/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ function make_suite(; scenarios=all_scenarios(), complexity=:debug)
@assert all(scenarios .∈ Ref(all_scenarios()))

suite = BenchmarkGroup()

for scenario in scenarios
suite[scenario] = BenchmarkGroup()
suite[scenario] = @benchmarkable run_scenario($scenario, $complexity)
end
suite
Expand Down
44 changes: 23 additions & 21 deletions benchmark/regression/testcases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ high_symmetry = let
Atom(:O, [x, y, y]u"bohr", magnetic_moment=0),
]
system = periodic_system(atoms, lattice)
merge(DFTK.parse_system(system), (; temperature=0.03, Ecut=10, kgrid=[4,4,4],
n_electrons=45))
merge(DFTK.parse_system(system), (; temperature=0.03, Ecut=20, kgrid=[4,4,4],
n_electrons=45, description="high_sym"))
end
high_kpoints = merge(magnesium, (; kgrid=[13,13,13], Ecut=10))
high_Ecut = merge(magnesium, (; kgrid=[4,4,4], Ecut=60))
high_kpoints = merge(magnesium, (; kgrid=[13,13,13], Ecut=20, description="high_kpoint"))
high_Ecut = merge(magnesium, (; kgrid=[4,4,4], Ecut=60, description="high_Ecut"))

testcases = (; high_symmetry, high_kpoints, high_Ecut)
end


@testitem "Hamiltonian application" tags=[:regression] setup=[TestCases, Regression] begin
using DFTK
using LinearAlgebra
Expand All @@ -46,10 +48,10 @@ end

(; ham) = energy_hamiltonian(basis, ψ, occupation)

SUITE["ham"] = BenchmarkGroup()
SUITE["ham"] = @benchmarkable for ik = 1:length($(basis.kpoints))
$(ham.blocks)[ik]*$ψ[ik]
end
SUITE["ham"][testcase.description] =
@benchmarkable for ik = 1:length($(basis.kpoints))
$(ham.blocks)[ik]*$ψ[ik]
end
end
end

Expand All @@ -62,8 +64,8 @@ end
model = model_LDA(testcase.lattice, testcase.atoms, testcase.positions;
testcase.temperature)
basis = PlaneWaveBasis(model; testcase.Ecut, testcase.kgrid)
SUITE["scf"] = BenchmarkGroup()
SUITE["scf"] = @benchmarkable self_consistent_field($basis; tol=1e5)
SUITE["scf"][testcase.description] =
@benchmarkable self_consistent_field($basis; tol=1e5)
end
end

Expand All @@ -81,9 +83,10 @@ end
ψ, occupation = DFTK.select_occupied_orbitals(basis, scfres.ψ, scfres.occupation;
threshold=1e-6)

SUITE["density", "ρ", "sym"] = BenchmarkGroup()
SUITE["density", "ρ"] = @benchmarkable compute_density($basis, $ψ, $occupation)
SUITE["density", "sym"] = @benchmarkable DFTK.symmetrize_ρ($basis, $(scfres.ρ))
SUITE["density"]["ρ"][testcase.description] =
@benchmarkable compute_density($basis, $ψ, $occupation)
SUITE["density"]["sym"][testcase.description] =
@benchmarkable DFTK.symmetrize_ρ($basis, $(scfres.ρ))
end
end

Expand All @@ -95,9 +98,9 @@ end
for testcase in Regression.testcases
model = model_LDA(testcase.lattice, testcase.atoms, testcase.positions;
testcase.temperature)
SUITE["basis"] = BenchmarkGroup()
SUITE["basis"] = @benchmarkable PlaneWaveBasis($model; Ecut=$(testcase.Ecut),
kgrid=$(testcase.kgrid))
SUITE["basis"][testcase.description] =
@benchmarkable PlaneWaveBasis($model;
Ecut=$(testcase.Ecut), kgrid=$(testcase.kgrid))
end
end

Expand All @@ -113,8 +116,8 @@ end
scfres = self_consistent_field(basis; tol=10)

rhs = DFTK.compute_projected_gradient(basis, scfres.ψ, scfres.occupation)
SUITE["sternheimer"] = BenchmarkGroup()
SUITE["sternheimer"] = @benchmarkable DFTK.solve_ΩplusK_split($scfres, $rhs)
SUITE["response"]["sternheimer"][testcase.description] =
@benchmarkable DFTK.solve_ΩplusK_split($scfres, $rhs; tol=1e-1)
end
end

Expand Down Expand Up @@ -146,11 +149,10 @@ end
end

# Function to compute the dipole for a given field strength
function compute_dipole(ε; tol=1e-8, kwargs...)
function compute_dipole(ε; tol=1e-2, kwargs...)
scfres = self_consistent_field(make_basis(ε; kwargs...); tol)
dipole(scfres.basis, scfres.ρ)
end

SUITE["response", "ad"] = BenchmarkGroup()
SUITE["response", "ad"] = @benchmarkable ForwardDiff.derivative($compute_dipole, 0.0)
SUITE["response"]["ad"] = @benchmarkable ForwardDiff.derivative($compute_dipole, 0.0)
end
2 changes: 1 addition & 1 deletion test/runtests_runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function TestItemRunner.run_testitem(filepath, use_default_usings, setups, packa
code = string('\n'^line, ' '^column, original_code)

TestItemRunner.withpath(filepath) do
# We replace the test by the current testset
# Replace the test by the current testset.
description = Test.pop_testset().description
@testset "$(description)" begin
Base.invokelatest(include_string, mod, code, filepath)
Expand Down

0 comments on commit 2d2ea71

Please sign in to comment.