DiffEqGPU.jl icon indicating copy to clipboard operation
DiffEqGPU.jl copied to clipboard

Direct Compilation methods

Open ChrisRackauckas opened this issue 6 years ago • 1 comments

Currently being prototyped in gpu_ode.jl with SimpleDiffEq.jl. Most of the issues that need to be worked out are in GPUifyLoops.jl

ChrisRackauckas avatar Jun 25 '19 06:06 ChrisRackauckas

using CUDA, SimpleDiffEq, StaticArrays

function loop(u, p, t)
    σ = p[1]; ρ = p[2]; β = p[3]
    du1 = σ*(u[2]-u[1])
    du2 = u[1]*(ρ-u[3]) - u[2]
    du3 = u[1]*u[2] - β*u[3]
    return SVector{3}(du1, du2, du3)
end
const func = ODEFunction(loop)
u0 = 10ones(Float32,3)
const su0= SVector{3}(u0)
const dt = 1f-1
const tspan = (0.0f0, 10.0f0)

const odeoop = ODEProblem{false}(loop, SVector{3}(u0), (0.0f0, 10.0f0),  Float32.(SA[10, 28, 8/3]))
sol2 = solve(odeoop,GPUSimpleTsit5(),dt=dt) # Test it works
cps = Array([SA[10f0,28f0,8/3f0] for i in 1:32])
ps = CuArray([SA[10f0,28f0,8/3f0] for i in 1:32])
CUDA.allowscalar(false)

# Test saving only the end

function f(p)
    _prob = remake(odeoop,p=p)
    solve(_prob,GPUSimpleTsit5(),dt=dt)[end]
end

map(f,cps)

# Now GPU map it?

# Test saving a time series

function f(p)
    _prob = remake(odeoop,p=p)
    solve(_prob,GPUSimpleTsit5(),dt=dt)
end

map(f,cps)

ChrisRackauckas avatar Jan 10 '22 11:01 ChrisRackauckas