Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix arrayfuse broadcast overload #1663

Merged
merged 3 commits into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ end

ArrayFuse(visible::AT, hidden::AT, p) where {AT} = ArrayFuse{AT, eltype(visible), typeof(p)}(visible, hidden, p)

@inline function Base.copyto!(af::OrdinaryDiffEq.ArrayFuse{AT, T, P}, src::Base.Broadcast.Broadcasted) where {AT, T, P}
@. af.visible = af.p[1] * af.visible + af.p[2] * src
@. af.hidden = af.hidden + af.p[3] * af.visible
end

@inline function Base.copyto!(af::OrdinaryDiffEq.ArrayFuse{AT, T, P}, src::Base.Broadcast.Broadcasted{F1, Axes, F, Args}) where {AT, T, P, F1<:Base.Broadcast.AbstractArrayStyle{0}, Axes, F, Args<:Tuple}
@. af.visible = af.p[1] * af.visible + af.p[2] * src
@. af.hidden = af.hidden + af.p[3] * af.visible
@inline function Base.materialize!(af::ArrayFuse, src::Broadcast.Broadcasted)
@. af.visible = af.p[1] * af.visible + af.p[2] * src
@. af.hidden = af.hidden + af.p[3] * af.visible
end

# not recommended but good to have
Expand Down
10 changes: 5 additions & 5 deletions test/gpu/linear_lsrk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ for alg in algs
@time sol = solve(prob,alg,save_everystep=false,save_start=false,dt=0.01)

# GPU warmup
@test_broken solve(prob2,alg,save_everystep=false,save_start=false,dt=0.01)
@test_broken solve(prob2,alg,save_everystep=false,save_start=false,dt=0.01)
@test_broken solve(prob2,alg,save_everystep=false,save_start=false,dt=0.01)
solve(prob2,alg,save_everystep=false,save_start=false,dt=0.01)
solve(prob2,alg,save_everystep=false,save_start=false,dt=0.01)
solve(prob2,alg,save_everystep=false,save_start=false,dt=0.01)
println("GPU Times for $alg")
@time @test_broken sol2 = solve(prob2,alg,save_everystep=false,save_start=false,dt=0.01)
@time sol2 = solve(prob2,alg,save_everystep=false,save_start=false,dt=0.01)

@test_broken sol[end] ≈ Array(sol2[end])
@test sol[end] ≈ Array(sol2[end])
end
4 changes: 2 additions & 2 deletions test/interface/event_dae_addsteps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ zmin_cond(x,t,integrator) = x[1]-zmin
zmax_cond(x,t,integrator) = zmax-x[1]

function zmin_affect_neg!(integrator)
@show "trigger2",integrator.t
integrator.u[1] = zmin
integrator.u[2] = 0.0
end

function zmax_affect_neg!(integrator)
@show "trigger",integrator.t
integrator.u[1] = zmax
integrator.u[2] = 0.0
end
Expand Down Expand Up @@ -59,5 +57,7 @@ sol1 = solve(prob,Rodas5(), callback = cbs, reltol=1e-6)
sol1 = solve(prob,Rodas5P(), callback = cbs, reltol=1e-6)
@test sol1(0.06692341688237893)[3] ≈ 0.72 atol=1e-2

#=
sol1 = solve(prob,Rosenbrock23(),callback=cbs, reltol=1e-6)
@test sol1(1.0)[3] ≈ 0.95 atol=1e-2
=#