|
1 |
| -@testitem "Solving on GPUs" tags=[:cuda] skip=:(using CUDA; !CUDA.functional()) begin |
| 1 | +@testitem "Solving on GPUs" tags=[:cuda] begin |
2 | 2 | using StaticArrays, CUDA
|
3 | 3 |
|
4 |
| - CUDA.allowscalar(false) |
| 4 | + if CUDA.functional() |
| 5 | + CUDA.allowscalar(false) |
5 | 6 |
|
6 |
| - f(u, p) = u .* u .- 2 |
7 |
| - f!(du, u, p) = du .= u .* u .- 2 |
| 7 | + f(u, p) = u .* u .- 2 |
| 8 | + f!(du, u, p) = du .= u .* u .- 2 |
8 | 9 |
|
9 |
| - @testset "$(nameof(typeof(alg)))" for alg in ( |
10 |
| - SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), |
11 |
| - SimpleTrustRegion(; nlsolve_update_rule = Val(true)), |
12 |
| - SimpleBroyden(), SimpleLimitedMemoryBroyden(), SimpleKlement(), |
13 |
| - SimpleHalley(), SimpleBroyden(; linesearch = Val(true)), |
14 |
| - SimpleLimitedMemoryBroyden(; linesearch = Val(true))) |
15 |
| - # Static Arrays |
16 |
| - u0 = @SVector[1.0f0, 1.0f0] |
17 |
| - probN = NonlinearProblem{false}(f, u0) |
18 |
| - sol = solve(probN, alg; abstol = 1.0f-6) |
19 |
| - @test SciMLBase.successful_retcode(sol) |
20 |
| - @test maximum(abs, sol.resid) ≤ 1.0f-6 |
21 |
| - |
22 |
| - # Regular Arrays |
23 |
| - u0 = [1.0, 1.0] |
24 |
| - probN = NonlinearProblem{false}(f, u0) |
25 |
| - sol = solve(probN, alg; abstol = 1.0f-6) |
26 |
| - @test SciMLBase.successful_retcode(sol) |
27 |
| - @test maximum(abs, sol.resid) ≤ 1.0f-6 |
| 10 | + @testset "$(nameof(typeof(alg)))" for alg in ( |
| 11 | + SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), |
| 12 | + SimpleTrustRegion(; nlsolve_update_rule = Val(true)), |
| 13 | + SimpleBroyden(), SimpleLimitedMemoryBroyden(), SimpleKlement(), |
| 14 | + SimpleHalley(), SimpleBroyden(; linesearch = Val(true)), |
| 15 | + SimpleLimitedMemoryBroyden(; linesearch = Val(true))) |
| 16 | + # Static Arrays |
| 17 | + u0 = @SVector[1.0f0, 1.0f0] |
| 18 | + probN = NonlinearProblem{false}(f, u0) |
| 19 | + sol = solve(probN, alg; abstol = 1.0f-6) |
| 20 | + @test SciMLBase.successful_retcode(sol) |
| 21 | + @test maximum(abs, sol.resid) ≤ 1.0f-6 |
28 | 22 |
|
29 |
| - # Regular Arrays Inplace |
30 |
| - if !(alg isa SimpleHalley) |
| 23 | + # Regular Arrays |
31 | 24 | u0 = [1.0, 1.0]
|
32 |
| - probN = NonlinearProblem{true}(f!, u0) |
| 25 | + probN = NonlinearProblem{false}(f, u0) |
33 | 26 | sol = solve(probN, alg; abstol = 1.0f-6)
|
34 | 27 | @test SciMLBase.successful_retcode(sol)
|
35 | 28 | @test maximum(abs, sol.resid) ≤ 1.0f-6
|
| 29 | + |
| 30 | + # Regular Arrays Inplace |
| 31 | + if !(alg isa SimpleHalley) |
| 32 | + u0 = [1.0, 1.0] |
| 33 | + probN = NonlinearProblem{true}(f!, u0) |
| 34 | + sol = solve(probN, alg; abstol = 1.0f-6) |
| 35 | + @test SciMLBase.successful_retcode(sol) |
| 36 | + @test maximum(abs, sol.resid) ≤ 1.0f-6 |
| 37 | + end |
36 | 38 | end
|
37 | 39 | end
|
38 | 40 | end
|
39 | 41 |
|
40 |
| -@testitem "CUDA Kernel Launch Test" tags=[:cuda] skip=:(using CUDA; !CUDA.functional()) timeout=3600 begin |
| 42 | +@testitem "CUDA Kernel Launch Test" tags=[:cuda] begin |
41 | 43 | using StaticArrays, CUDA
|
42 | 44 |
|
43 |
| - CUDA.allowscalar(false) |
| 45 | + if CUDA.functional() |
| 46 | + CUDA.allowscalar(false) |
44 | 47 |
|
45 |
| - f(u, p) = u .* u .- 2 |
46 |
| - f!(du, u, p) = du .= u .* u .- 2 |
| 48 | + f(u, p) = u .* u .- 2 |
| 49 | + f!(du, u, p) = du .= u .* u .- 2 |
47 | 50 |
|
48 |
| - function kernel_function(prob, alg) |
49 |
| - solve(prob, alg) |
50 |
| - return nothing |
51 |
| - end |
| 51 | + function kernel_function(prob, alg) |
| 52 | + solve(prob, alg) |
| 53 | + return nothing |
| 54 | + end |
52 | 55 |
|
53 |
| - prob = NonlinearProblem{false}(f, @SVector[1.0f0, 1.0f0]) |
54 |
| - prob = convert(SimpleNonlinearSolve.ImmutableNonlinearProblem, prob) |
| 56 | + prob = NonlinearProblem{false}(f, @SVector[1.0f0, 1.0f0]) |
| 57 | + prob = convert(SimpleNonlinearSolve.ImmutableNonlinearProblem, prob) |
55 | 58 |
|
56 |
| - @testset "$(nameof(typeof(alg)))" for alg in ( |
57 |
| - SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), |
58 |
| - SimpleTrustRegion(; nlsolve_update_rule = Val(true)), |
59 |
| - SimpleBroyden(), SimpleLimitedMemoryBroyden(), SimpleKlement(), |
60 |
| - SimpleHalley(), SimpleBroyden(; linesearch = Val(true)), |
61 |
| - SimpleLimitedMemoryBroyden(; linesearch = Val(true))) |
62 |
| - @test begin |
63 |
| - try |
64 |
| - @cuda kernel_function(prob, alg) |
65 |
| - @info "Successfully launched kernel for $(alg)." |
66 |
| - true |
67 |
| - catch err |
68 |
| - @error "Kernel Launch failed for $(alg)." |
69 |
| - false |
70 |
| - end |
71 |
| - end broken=(alg isa SimpleHalley) |
| 59 | + @testset "$(nameof(typeof(alg)))" for alg in ( |
| 60 | + SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), |
| 61 | + SimpleTrustRegion(; nlsolve_update_rule = Val(true)), |
| 62 | + SimpleBroyden(), SimpleLimitedMemoryBroyden(), SimpleKlement(), |
| 63 | + SimpleHalley(), SimpleBroyden(; linesearch = Val(true)), |
| 64 | + SimpleLimitedMemoryBroyden(; linesearch = Val(true))) |
| 65 | + @test begin |
| 66 | + try |
| 67 | + @cuda kernel_function(prob, alg) |
| 68 | + @info "Successfully launched kernel for $(alg)." |
| 69 | + true |
| 70 | + catch err |
| 71 | + @error "Kernel Launch failed for $(alg)." |
| 72 | + false |
| 73 | + end |
| 74 | + end broken=(alg isa SimpleHalley) |
| 75 | + end |
72 | 76 | end
|
73 | 77 | end
|
0 commit comments