-
-
Notifications
You must be signed in to change notification settings - Fork 216
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
Minimizing and Testing Memory Usage in Low-Memory RK Methods #640
Comments
Most low-storage methods make some assumption on the possible form of assignments using only two arrays, cf. Ketcheson, David I. "Runge–Kutta methods with minimum storage implementations." Journal of Computational Physics 229.5 (2010): 1763-1773:
As far as I know, the current setup of For the user, it might be relatively easy to write the RHS |
We might want to support alternative AbstractODEProblems for these then. |
If we really want to minimise the memory usage this seems to be the way to go. This can also speed up the solution of the new specialised problems, e.g. if a linear ODE is to be solved using |
We may just want to add these as possibilities to ODEFunction. The whole point is to allow other forms of the function for optimizations there. The documentation will need some work for it though, and then the methods will need to handle the existence/non-existence of such optimized form. |
I'm working on this and will soon push a PR. Another possibility to reduce the memory would be to set |
http://docs.juliadiffeq.org/latest/basics/common_solver_opts.html#Miscellaneous-1 It's set by: https://github.com/JuliaDiffEq/OrdinaryDiffEq.jl/blob/master/src/solve.jl#L27-L29 So note that if you have a |
Yes, I would not save intermediate values for big PDEs (or would control that explicitly). There are some algorithms that use |
We really should do that. It's just waiting to be done, look at the proximity: https://github.com/JuliaDiffEq/OrdinaryDiffEq.jl/blob/master/src/solve.jl#L213-L220 Well actually, why not just universally do |
We could do that. But there are some methods that use |
Yeah thinking about it more, most RK methods need uprev in the |
I would leave that task open for another PR and just submit some first improvements and checks soon. |
Yup that sounds good. |
If we move the initialisation of |
Thinking more about it, I do not really like the idea to more |
Short summary (since I don't have time to work on that part right now): After all the changes linked above, the remaining change is to add new forms of
|
I'd like to work on this issue if its not done yet. |
There is some current discussion on the matrix multiplication API. Hopefully, some decision on the API of inplace multiplication of the form we need for |
I think this needs to be in-method. If a specific method can make good reuse of I don't think the in-place matrix multiplication API is necessary to create the right ODEFunction infrastructure, but for a user to actually define the function without allocations it'll be needed. |
That's what I meant. We might want to use an API similar to the final decision for the matrix multiplication API. If that's |
Yes it would be dependent on both the problem and the algorithm. There may be a function where |
Oh I see where you're going with this. Yeah, this would be a neat solution without requiring additional function interfaces. Great idea! |
@ranocha tasked us at first with fixing memory usage in #178 . We now have all of the pieces in place to do it correctly (see #178 (comment) ). What remains to be done are some
calck
optimizations on the low-memory methods, and testing to make sure it works out.How to do it is already described, so let's talk about testing. Memory tracking makes sense in the asymptotic regime where
u0
is large. Whenu0
is large, say 100,000, then, since the size of the integrator is constant, the size of theuType
andrateType
vectors will completely dominate. In that case, we can measure the integrator's size in order to see how many registers we are actually using. It's quite accurate:and understands aliasing:
So with this, our goal should be to get these methods down to exactly the amount they require. Some things to note are:
solve.jl
, we copyu0
. We should add a new argument to the common interface forcopy_start = true
. True for safety, since if you changeu0
all sorts of wonky things will happen to people's code. But true performance purists may want us to re-use that array, so let's do it.calck
is false, don't need thek
values. They can make the algorithm work out just by aliasing those to another array instead. Note that these are crucial to common use though, sincesaveat
is a widely used thing, so we should try to see if we can do this in a way that eliminates allocations even whencalck=true
(which is thesaveat
case)The text was updated successfully, but these errors were encountered: