Skip to content

Migrate the CUDA Termination Conditions tests from DiffEqBase #549

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 13 commits into from
Mar 22, 2025
29 changes: 29 additions & 0 deletions test/cuda_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,32 @@
end
end
end

@testitem "Termination Conditions: Allocations" tags=[:cuda] begin
using CUDA, NonlinearSolveBase, Test, LinearAlgebra
CUDA.allowscalar(false)
du = cu(rand(4))
u = cu(rand(4))
uprev = cu(rand(4))
TERMINATION_CONDITIONS = [
RelTerminationMode, AbsTerminationMode
]
NORM_TERMINATION_CONDITIONS = [
AbsNormTerminationMode, RelNormTerminationMode, RelNormSafeTerminationMode,
AbsNormSafeTerminationMode, RelNormSafeBestTerminationMode, AbsNormSafeBestTerminationMode
]

@testset begin
@testset "Mode: $(tcond)" for tcond in TERMINATION_CONDITIONS
@test_nowarn NonlinearSolveBase.check_convergence(
tcond(), du, u, uprev, 1e-3, 1e-3)
end

@testset "Mode: $(tcond)" for tcond in NORM_TERMINATION_CONDITIONS
for nfn in (Base.Fix1(maximum, abs), Base.Fix2(norm, 2), Base.Fix2(norm, Inf))
@test_nowarn NonlinearSolveBase.check_convergence(
tcond(nfn), du, u, uprev, 1e-3, 1e-3)
end
end
end
end
Loading