Skip to content

Commit 07d2d57

Browse files
Migrate the CUDA Termination Conditions tests from DiffEqBase
1 parent 14499b2 commit 07d2d57

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/cuda_tests.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,28 @@
4343
end
4444
end
4545
end
46+
47+
@testitem "Termination Conditions: Allocations" tags=[:cuda] begin
48+
using CUDA, NonlinearSolveBase, Test, LinearAlgebra
49+
CUDA.allowscalar(false)
50+
51+
du = cu(rand(4))
52+
u = cu(rand(4))
53+
uprev = cu(rand(4))
54+
55+
const TERMINATION_CONDITIONS = [
56+
SteadyStateDiffEqTerminationMode(), SimpleNonlinearSolveTerminationMode(),
57+
NormTerminationMode(), RelTerminationMode(), RelNormTerminationMode(),
58+
AbsTerminationMode(), AbsNormTerminationMode(), RelSafeTerminationMode(),
59+
AbsSafeTerminationMode(), RelSafeBestTerminationMode(), AbsSafeBestTerminationMode()
60+
]
61+
62+
@testset begin
63+
@testset "Mode: $(tcond)" for tcond in TERMINATION_CONDITIONS
64+
for nfn in (Base.Fix1(maximum, abs), Base.Fix2(norm, 2), Base.Fix2(norm, Inf))
65+
tcond = DiffEqBase.set_termination_mode_internalnorm(tcond, nfn)
66+
@test_nowarn DiffEqBase.check_convergence(tcond, du, u, uprev, 1e-3, 1e-3)
67+
end
68+
end
69+
end
70+
end

0 commit comments

Comments
 (0)