Skip to content

Commit

Permalink
Add kernel launch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Jan 13, 2024
1 parent 043336b commit 91a995d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/SimpleNonlinearSolve/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SimpleNonlinearSolve"
uuid = "727e6d20-b764-4bd8-a329-72de5adea6c7"
authors = ["SciML"]
version = "1.2.0"
version = "1.2.1"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
1 change: 1 addition & 0 deletions lib/SimpleNonlinearSolve/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

[![codecov](https://codecov.io/gh/SciML/SimpleNonlinearSolve.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/SciML/SimpleNonlinearSolve.jl)
[![Build Status](https://github.com/SciML/SimpleNonlinearSolve.jl/workflows/CI/badge.svg)](https://github.com/SciML/SimpleNonlinearSolve.jl/actions?query=workflow%3ACI)
[![Build status](https://badge.buildkite.com/c5f7db4f1b5e8a592514378b6fc807d934546cc7d5aa79d645.svg?branch=main)](https://buildkite.com/julialang/simplenonlinearsolve-dot-jl)

[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)
Expand Down
3 changes: 2 additions & 1 deletion lib/SimpleNonlinearSolve/src/nlsolve/dfsane.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ end
function SimpleDFSane(; σ_min::Real = 1e-10, σ_max::Real = 1e10, σ_1::Real = 1.0,
M::Union{Int, Val} = Val(10), γ::Real = 1e-4, τ_min::Real = 0.1, τ_max::Real = 0.5,
nexp::Int = 2, η_strategy::F = (f_1, k, x, F) -> f_1 ./ k^2) where {F}
return SimpleDFSane{SciMLBase._unwrap_val(M)}(σ_min, σ_max, σ_1, γ, τ_min, τ_max, nexp, η_strategy)
return SimpleDFSane{SciMLBase._unwrap_val(M)}(σ_min, σ_max, σ_1, γ, τ_min, τ_max, nexp,
η_strategy)
end

function SciMLBase.__solve(prob::NonlinearProblem, alg::SimpleDFSane{M}, args...;
Expand Down
4 changes: 0 additions & 4 deletions lib/SimpleNonlinearSolve/src/nlsolve/lbroyden.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,9 @@ function __init_low_rank_jacobian(u::StaticArray{S1, T1}, fu::StaticArray{S2, T2
U = MArray{Tuple{prod(fuSize), threshold}, T}(undef)
return U, Vᵀ
end

@generated function __init_low_rank_jacobian(u::SVector{Lu, T1}, fu::SVector{Lfu, T2},
::Val{threshold}) where {Lu, Lfu, T1, T2, threshold}
T = promote_type(T1, T2)
# Lfu, Lu = __prod_size(S2), __prod_size(S1)
# Lfu, Lu = __prod(Size(fu)), __prod(Size(u))
inner_inits_Vᵀ = [:(zeros(SVector{$Lu, $T})) for i in 1:threshold]
inner_inits_U = [:(zeros(SVector{$Lfu, $T})) for i in 1:threshold]
return quote
Expand All @@ -273,7 +270,6 @@ end
return U, Vᵀ
end
end

function __init_low_rank_jacobian(u, fu, ::Val{threshold}) where {threshold}
Vᵀ = similar(u, threshold, length(u))
U = similar(u, length(fu), threshold)
Expand Down
23 changes: 23 additions & 0 deletions lib/SimpleNonlinearSolve/test/cuda.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,26 @@ f!(du, u, p) = du .= u .* u .- 2
@test maximum(abs, sol.resid) 1.0f-6
end
end

function kernel_function(prob, alg)
solve(prob, alg; abstol = 1.0f-6, reltol = 1.0f-6)
return nothing
end

@testset "CUDA Kernel Launch Test" begin
prob = NonlinearProblem{false}(f, @SVector[1.0f0, 1.0f0])

for alg in (SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), SimpleBroyden(),
SimpleLimitedMemoryBroyden(), SimpleKlement(), SimpleHalley())
@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
2 changes: 1 addition & 1 deletion lib/SimpleNonlinearSolve/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using SafeTestsets, Test
using Pkg, SafeTestsets, Test

const GROUP = get(ENV, "GROUP", "All")

Expand Down

0 comments on commit 91a995d

Please sign in to comment.