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