-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from SciML/ap/up_di
feat: update to new DI.jl
- Loading branch information
Showing
8 changed files
with
97 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,77 @@ | ||
@testitem "Solving on GPUs" tags=[:cuda] skip=:(using CUDA; !CUDA.functional()) begin | ||
@testitem "Solving on GPUs" tags=[:cuda] begin | ||
using StaticArrays, CUDA | ||
|
||
CUDA.allowscalar(false) | ||
if CUDA.functional() | ||
CUDA.allowscalar(false) | ||
|
||
f(u, p) = u .* u .- 2 | ||
f!(du, u, p) = du .= u .* u .- 2 | ||
f(u, p) = u .* u .- 2 | ||
f!(du, u, p) = du .= u .* u .- 2 | ||
|
||
@testset "$(nameof(typeof(alg)))" for alg in ( | ||
SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), | ||
SimpleTrustRegion(; nlsolve_update_rule = Val(true)), | ||
SimpleBroyden(), SimpleLimitedMemoryBroyden(), SimpleKlement(), | ||
SimpleHalley(), SimpleBroyden(; linesearch = Val(true)), | ||
SimpleLimitedMemoryBroyden(; linesearch = Val(true))) | ||
# Static Arrays | ||
u0 = @SVector[1.0f0, 1.0f0] | ||
probN = NonlinearProblem{false}(f, u0) | ||
sol = solve(probN, alg; abstol = 1.0f-6) | ||
@test SciMLBase.successful_retcode(sol) | ||
@test maximum(abs, sol.resid) ≤ 1.0f-6 | ||
|
||
# Regular Arrays | ||
u0 = [1.0, 1.0] | ||
probN = NonlinearProblem{false}(f, u0) | ||
sol = solve(probN, alg; abstol = 1.0f-6) | ||
@test SciMLBase.successful_retcode(sol) | ||
@test maximum(abs, sol.resid) ≤ 1.0f-6 | ||
@testset "$(nameof(typeof(alg)))" for alg in ( | ||
SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), | ||
SimpleTrustRegion(; nlsolve_update_rule = Val(true)), | ||
SimpleBroyden(), SimpleLimitedMemoryBroyden(), SimpleKlement(), | ||
SimpleHalley(), SimpleBroyden(; linesearch = Val(true)), | ||
SimpleLimitedMemoryBroyden(; linesearch = Val(true))) | ||
# Static Arrays | ||
u0 = @SVector[1.0f0, 1.0f0] | ||
probN = NonlinearProblem{false}(f, u0) | ||
sol = solve(probN, alg; abstol = 1.0f-6) | ||
@test SciMLBase.successful_retcode(sol) | ||
@test maximum(abs, sol.resid) ≤ 1.0f-6 | ||
|
||
# Regular Arrays Inplace | ||
if !(alg isa SimpleHalley) | ||
# Regular Arrays | ||
u0 = [1.0, 1.0] | ||
probN = NonlinearProblem{true}(f!, u0) | ||
probN = NonlinearProblem{false}(f, u0) | ||
sol = solve(probN, alg; abstol = 1.0f-6) | ||
@test SciMLBase.successful_retcode(sol) | ||
@test maximum(abs, sol.resid) ≤ 1.0f-6 | ||
|
||
# Regular Arrays Inplace | ||
if !(alg isa SimpleHalley) | ||
u0 = [1.0, 1.0] | ||
probN = NonlinearProblem{true}(f!, u0) | ||
sol = solve(probN, alg; abstol = 1.0f-6) | ||
@test SciMLBase.successful_retcode(sol) | ||
@test maximum(abs, sol.resid) ≤ 1.0f-6 | ||
end | ||
end | ||
end | ||
end | ||
|
||
@testitem "CUDA Kernel Launch Test" tags=[:cuda] skip=:(using CUDA; !CUDA.functional()) timeout=3600 begin | ||
@testitem "CUDA Kernel Launch Test" tags=[:cuda] begin | ||
using StaticArrays, CUDA | ||
|
||
CUDA.allowscalar(false) | ||
if CUDA.functional() | ||
CUDA.allowscalar(false) | ||
|
||
f(u, p) = u .* u .- 2 | ||
f!(du, u, p) = du .= u .* u .- 2 | ||
f(u, p) = u .* u .- 2 | ||
f!(du, u, p) = du .= u .* u .- 2 | ||
|
||
function kernel_function(prob, alg) | ||
solve(prob, alg) | ||
return nothing | ||
end | ||
function kernel_function(prob, alg) | ||
solve(prob, alg) | ||
return nothing | ||
end | ||
|
||
prob = NonlinearProblem{false}(f, @SVector[1.0f0, 1.0f0]) | ||
prob = convert(SimpleNonlinearSolve.ImmutableNonlinearProblem, prob) | ||
prob = NonlinearProblem{false}(f, @SVector[1.0f0, 1.0f0]) | ||
prob = convert(SimpleNonlinearSolve.ImmutableNonlinearProblem, prob) | ||
|
||
@testset "$(nameof(typeof(alg)))" for alg in ( | ||
SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), | ||
SimpleTrustRegion(; nlsolve_update_rule = Val(true)), | ||
SimpleBroyden(), SimpleLimitedMemoryBroyden(), SimpleKlement(), | ||
SimpleHalley(), SimpleBroyden(; linesearch = Val(true)), | ||
SimpleLimitedMemoryBroyden(; linesearch = Val(true))) | ||
@test begin | ||
try | ||
@cuda kernel_function(prob, alg) | ||
@info "Successfully launched kernel for $(alg)." | ||
true | ||
catch err | ||
@error "Kernel Launch failed for $(alg)." | ||
false | ||
end | ||
end broken=(alg isa SimpleHalley) | ||
@testset "$(nameof(typeof(alg)))" for alg in ( | ||
SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), | ||
SimpleTrustRegion(; nlsolve_update_rule = Val(true)), | ||
SimpleBroyden(), SimpleLimitedMemoryBroyden(), SimpleKlement(), | ||
SimpleHalley(), SimpleBroyden(; linesearch = Val(true)), | ||
SimpleLimitedMemoryBroyden(; linesearch = Val(true))) | ||
@test begin | ||
try | ||
@cuda kernel_function(prob, alg) | ||
@info "Successfully launched kernel for $(alg)." | ||
true | ||
catch err | ||
@error "Kernel Launch failed for $(alg)." | ||
false | ||
end | ||
end broken=(alg isa SimpleHalley) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
using ReTestItems, CUDA | ||
using ReTestItems, SimpleNonlinearSolve, Hwloc, InteractiveUtils | ||
using Pkg | ||
|
||
const GROUP = get(ENV, "GROUP", CUDA.functional() ? "All" : "Core") | ||
@info sprint(InteractiveUtils.versioninfo) | ||
|
||
if GROUP == "All" | ||
ReTestItems.runtests(@__DIR__) | ||
else | ||
tags = [Symbol(lowercase(GROUP))] | ||
ReTestItems.runtests(@__DIR__; tags) | ||
const GROUP = lowercase(get(ENV, "GROUP", "All")) | ||
|
||
if GROUP == "adjoint" || GROUP == "all" | ||
Pkg.add(["SciMLSensitivity"]) | ||
end | ||
|
||
if GROUP == "cuda" || GROUP == "all" | ||
Pkg.add(["CUDA"]) | ||
end | ||
|
||
const RETESTITEMS_NWORKERS = parse( | ||
Int, get(ENV, "RETESTITEMS_NWORKERS", string(min(Hwloc.num_physical_cores(), 4)))) | ||
const RETESTITEMS_NWORKER_THREADS = parse(Int, | ||
get(ENV, "RETESTITEMS_NWORKER_THREADS", | ||
string(max(Hwloc.num_virtual_cores() ÷ RETESTITEMS_NWORKERS, 1)))) | ||
|
||
@info "Running tests for group: $(GROUP) with $(RETESTITEMS_NWORKERS) workers" | ||
|
||
ReTestItems.runtests( | ||
SimpleNonlinearSolve; tags = (GROUP == "all" ? nothing : [Symbol(GROUP)]), | ||
nworkers = RETESTITEMS_NWORKERS, nworker_threads = RETESTITEMS_NWORKER_THREADS, | ||
testitem_timeout = 3600, retries = 4) |