Skip to content

Fix test error for non-CUDA machines #595

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2025
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