Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions test/cuda_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,31 @@ 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
if CUDA.functional()
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 "Mode: $(tcond)" for tcond in NORM_TERMINATION_CONDITIONS
for nfn in (Base.Fix1(maximum, abs), Base.Fix2(norm, 2), Base.Fix2(norm, Inf))
@testset begin
@testset "Mode: $(tcond)" for tcond in TERMINATION_CONDITIONS
@test_nowarn NonlinearSolveBase.check_convergence(
tcond(nfn), du, u, uprev, 1e-3, 1e-3)
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
Expand Down
Loading