diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 8fa495e..e63c103 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -29,7 +29,8 @@ jobs: fail-fast: false matrix: group: - - "Core" + - "core" + - "adjoint" os: - "ubuntu-latest" - "macos-latest" diff --git a/Project.toml b/Project.toml index 5927f6f..444bfed 100644 --- a/Project.toml +++ b/Project.toml @@ -38,7 +38,6 @@ ADTypes = "1.9" AllocCheck = "0.1.1" Aqua = "0.8" ArrayInterface = "7.9" -CUDA = "5.2" ChainRulesCore = "1.23" ConcreteStructs = "0.2.3" DiffEqBase = "6.149" @@ -48,8 +47,9 @@ ExplicitImports = "1.5.0" FastClosures = "0.3.2" FiniteDiff = "2.23.1" ForwardDiff = "0.10.36" +Hwloc = "3" +InteractiveUtils = "<0.0.1, 1" LinearAlgebra = "1.10" -LinearSolve = "2.30" MaybeInplace = "0.1.3" NonlinearProblemLibrary = "0.1.2" Pkg = "1.10" @@ -60,7 +60,6 @@ ReTestItems = "1.23" Reexport = "1.2" ReverseDiff = "1.15.3" SciMLBase = "2.37.0" -SciMLSensitivity = "7.58" Setfield = "1.1.1" StaticArrays = "1.9" StaticArraysCore = "1.4.2" @@ -72,13 +71,13 @@ julia = "1.10" [extras] AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a" Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" -CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e" ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" +Hwloc = "0e44f5e4-bd66-52a0-8798-143a42290a1d" +InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae" NonlinearProblemLibrary = "b7050fa9-e91f-4b37-bcee-a89a063da141" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" PolyesterForwardDiff = "98d1487c-24ca-40b6-b7ab-df2af84e126b" @@ -86,11 +85,10 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" -SciMLSensitivity = "1ed8b502-d754-442c-8d5d-10ac956f44a1" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [targets] -test = ["AllocCheck", "Aqua", "CUDA", "DiffEqBase", "ExplicitImports", "FiniteDiff", "ForwardDiff", "LinearAlgebra", "LinearSolve", "NonlinearProblemLibrary", "Pkg", "PolyesterForwardDiff", "Random", "ReTestItems", "Reexport", "ReverseDiff", "SciMLSensitivity", "StaticArrays", "Test", "Tracker", "Zygote"] +test = ["AllocCheck", "Aqua", "DiffEqBase", "ExplicitImports", "FiniteDiff", "ForwardDiff", "Hwloc", "InteractiveUtils", "LinearAlgebra", "NonlinearProblemLibrary", "Pkg", "PolyesterForwardDiff", "Random", "ReTestItems", "Reexport", "ReverseDiff", "StaticArrays", "Test", "Tracker", "Zygote"] diff --git a/test/core/23_test_problems_tests.jl b/test/core/23_test_problems_tests.jl index e455609..6d19808 100644 --- a/test/core/23_test_problems_tests.jl +++ b/test/core/23_test_problems_tests.jl @@ -86,7 +86,7 @@ end test_on_library(problems, dicts, alg_ops, broken_tests) end -@testitem "23 Test Problems: SimpleBroyden" retries=5 setup=[RobustnessTesting] tags=[:core] begin +@testitem "23 Test Problems: SimpleBroyden" setup=[RobustnessTesting] tags=[:core] begin alg_ops = (SimpleBroyden(),) broken_tests = Dict(alg => Int[] for alg in alg_ops) diff --git a/test/core/adjoint_tests.jl b/test/core/adjoint_tests.jl index 9b1ae05..c56850e 100644 --- a/test/core/adjoint_tests.jl +++ b/test/core/adjoint_tests.jl @@ -1,4 +1,4 @@ -@testitem "Simple Adjoint Test" tags=[:core] begin +@testitem "Simple Adjoint Test" tags=[:adjoint] begin using ForwardDiff, ReverseDiff, SciMLSensitivity, Tracker, Zygote ff(u, p) = u .^ 2 .- p diff --git a/test/core/rootfind_tests.jl b/test/core/rootfind_tests.jl index eecdeca..272fa3c 100644 --- a/test/core/rootfind_tests.jl +++ b/test/core/rootfind_tests.jl @@ -1,7 +1,6 @@ @testsetup module RootfindingTesting using Reexport -@reexport using AllocCheck, LinearSolve, StaticArrays, Random, LinearAlgebra, ForwardDiff, - DiffEqBase +@reexport using AllocCheck, StaticArrays, Random, LinearAlgebra, ForwardDiff, DiffEqBase import PolyesterForwardDiff quadratic_f(u, p) = u .* u .- p diff --git a/test/gpu/cuda_tests.jl b/test/gpu/cuda_tests.jl index 5050b70..fc99bdd 100644 --- a/test/gpu/cuda_tests.jl +++ b/test/gpu/cuda_tests.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index 2f81c84..c90b994 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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)