Skip to content

Commit c76e08f

Browse files
Migrate the CUDA Termination Conditions tests from DiffEqBase (#549)
* Migrate the CUDA Termination Conditions tests from DiffEqBase * Update cuda_tests.jl * Update test/cuda_tests.jl * Update test/cuda_tests.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/cuda_tests.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/cuda_tests.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update cuda_tests.jl * Update cuda_tests.jl * Update test/cuda_tests.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/cuda_tests.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update cuda_tests.jl * Update test/cuda_tests.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update cuda_tests.jl --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 14499b2 commit c76e08f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/cuda_tests.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,32 @@
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+
du = cu(rand(4))
51+
u = cu(rand(4))
52+
uprev = cu(rand(4))
53+
TERMINATION_CONDITIONS = [
54+
RelTerminationMode, AbsTerminationMode
55+
]
56+
NORM_TERMINATION_CONDITIONS = [
57+
AbsNormTerminationMode, RelNormTerminationMode, RelNormSafeTerminationMode,
58+
AbsNormSafeTerminationMode, RelNormSafeBestTerminationMode, AbsNormSafeBestTerminationMode
59+
]
60+
61+
@testset begin
62+
@testset "Mode: $(tcond)" for tcond in TERMINATION_CONDITIONS
63+
@test_nowarn NonlinearSolveBase.check_convergence(
64+
tcond(), du, u, uprev, 1e-3, 1e-3)
65+
end
66+
67+
@testset "Mode: $(tcond)" for tcond in NORM_TERMINATION_CONDITIONS
68+
for nfn in (Base.Fix1(maximum, abs), Base.Fix2(norm, 2), Base.Fix2(norm, Inf))
69+
@test_nowarn NonlinearSolveBase.check_convergence(
70+
tcond(nfn), du, u, uprev, 1e-3, 1e-3)
71+
end
72+
end
73+
end
74+
end

0 commit comments

Comments
 (0)