-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Some automated conversions in saveat #309
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fc7b0f5
Auto stash before checking out "origin/master"
ChrisRackauckas 66c6210
test conversion better
ChrisRackauckas f20a384
Update Project.toml
utkarsh530 fa8bc00
Remove CUDA from testenv
utkarsh530 35f62b9
Fix saveat conversion to correctly map param types
utkarsh530 b350724
Remove param conversion to FP32 StepRangeLen
utkarsh530 e83d47e
fix test
utkarsh530 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
|
||
# saveat is just a bool here: | ||
# true: ts is a vector of timestamps to read from | ||
# false: each ODE has its own timestamps, so ts is a vector to write to | ||
@kernel function ode_solve_kernel(@Const(probs), alg, _us, _ts, dt, callback, | ||
tstops, nsteps, | ||
saveat, ::Val{save_everystep}) where {save_everystep} | ||
i = @index(Global, Linear) | ||
|
||
# get the actual problem for this thread | ||
prob = @inbounds probs[i] | ||
|
||
# get the input/output arrays for this thread | ||
ts = @inbounds view(_ts, :, i) | ||
us = @inbounds view(_us, :, i) | ||
|
||
_saveat = get(prob.kwargs, :saveat, nothing) | ||
|
||
saveat = _saveat === nothing ? saveat : _saveat | ||
|
||
integ = init(alg, prob.f, false, prob.u0, prob.tspan[1], dt, prob.p, tstops, | ||
callback, save_everystep, saveat) | ||
|
||
u0 = prob.u0 | ||
tspan = prob.tspan | ||
|
||
integ.cur_t = 0 | ||
if saveat !== nothing | ||
integ.cur_t = 1 | ||
if prob.tspan[1] == saveat[1] | ||
integ.cur_t += 1 | ||
@inbounds us[1] = u0 | ||
end | ||
else | ||
@inbounds ts[integ.step_idx] = prob.tspan[1] | ||
@inbounds us[integ.step_idx] = prob.u0 | ||
end | ||
|
||
integ.step_idx += 1 | ||
# FSAL | ||
while integ.t < tspan[2] && integ.retcode != DiffEqBase.ReturnCode.Terminated | ||
saved_in_cb = step!(integ, ts, us) | ||
!saved_in_cb && savevalues!(integ, ts, us) | ||
end | ||
if integ.t > tspan[2] && saveat === nothing | ||
## Intepolate to tf | ||
@inbounds us[end] = integ(tspan[2]) | ||
@inbounds ts[end] = tspan[2] | ||
end | ||
|
||
if saveat === nothing && !save_everystep | ||
@inbounds us[2] = integ.u | ||
@inbounds ts[2] = integ.t | ||
end | ||
end | ||
|
||
@kernel function ode_asolve_kernel(@Const(probs), alg, _us, _ts, dt, callback, tstops, | ||
abstol, reltol, | ||
saveat, | ||
::Val{save_everystep}) where {save_everystep} | ||
i = @index(Global, Linear) | ||
|
||
# get the actual problem for this thread | ||
prob = @inbounds probs[i] | ||
# get the input/output arrays for this thread | ||
ts = @inbounds view(_ts, :, i) | ||
us = @inbounds view(_us, :, i) | ||
# TODO: optimize contiguous view to return a CuDeviceArray | ||
|
||
_saveat = get(prob.kwargs, :saveat, nothing) | ||
|
||
saveat = _saveat === nothing ? saveat : _saveat | ||
|
||
u0 = prob.u0 | ||
tspan = prob.tspan | ||
f = prob.f | ||
p = prob.p | ||
|
||
t = tspan[1] | ||
tf = prob.tspan[2] | ||
|
||
integ = init(alg, prob.f, false, prob.u0, prob.tspan[1], prob.tspan[2], dt, | ||
prob.p, | ||
abstol, reltol, DiffEqBase.ODE_DEFAULT_NORM, tstops, callback, | ||
saveat) | ||
|
||
integ.cur_t = 0 | ||
if saveat !== nothing | ||
integ.cur_t = 1 | ||
if tspan[1] == saveat[1] | ||
integ.cur_t += 1 | ||
@inbounds us[1] = u0 | ||
end | ||
else | ||
@inbounds ts[1] = tspan[1] | ||
@inbounds us[1] = u0 | ||
end | ||
|
||
while integ.t < tspan[2] && integ.retcode != DiffEqBase.ReturnCode.Terminated | ||
saved_in_cb = step!(integ, ts, us) | ||
!saved_in_cb && savevalues!(integ, ts, us) | ||
end | ||
|
||
if integ.t > tspan[2] && saveat === nothing | ||
## Intepolate to tf | ||
@inbounds us[end] = integ(tspan[2]) | ||
@inbounds ts[end] = tspan[2] | ||
end | ||
|
||
if saveat === nothing && !save_everystep | ||
@inbounds us[2] = integ.u | ||
@inbounds ts[2] = integ.t | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not allowed?