-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
Reducing memory requirements of 2N methods for special functions #691
Conversation
|
||
Base.setindex!(a::WilliamsonWrapper{kType, dtType}, b::bType, c::cType) where {kType, dtType, bType, cType} = (a.kref[c] += a.dt * b) |
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.
How does this interact with linear algebra?
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.
All the linear algebra in RHS is untouched. Just replaces du = ....
statements to du += ...
. So the RHS is all the same.
Yeah, I think a flag in each of the low memory algorithms about this optimization would be good to have. I would even have it set to true by default. |
Okay I will add more possibilities to the interface now. Been traveling, so would do it by evening (IST). This would need nice documentation too. |
Codecov Report
@@ Coverage Diff @@
## master #691 +/- ##
=========================================
Coverage ? 72.86%
=========================================
Files ? 93
Lines ? 29111
Branches ? 0
=========================================
Hits ? 21211
Misses ? 7900
Partials ? 0
Continue to review full report at Codecov.
|
Current status: |
Actual work is almost done. The only problem is that while using Benchmarks:
Master:
With flag turned to true:
Flag = false:
|
Hopefully (just waiting for the tests to complete) this completes the PR. Maybe some variable name changes and moving code here and there (because wrappers like this could help us further improve memory usage in other algorithms and it should be nice to have a seperate file for these) and it should be good. By default this optimization is set to true. We finally get to the theoretical limit of memory. |
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.
I love this solution. It's great haha. Nicely done.
@. u = u + B2end[i]*tmp | ||
end | ||
|
||
f(k, u, p, t+dt) | ||
@. tmp = dt*k | ||
integrator.destats.nf += 1 |
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.
These will never Hermite interpolate, so the default interpolation should just be set to linear interpolation for these.
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.
For these methods, the interpolation is already set to 1st order Linear.
The tests need to be updated to make sure it's only 2 registers. |
Added some more of the tests to test both with and without the flag. Have started documentation for this. |
lgtm. Still WIP? |
No, can be merged now :) |
This is a very experimental PR. Just to demonstrate the trick to remove
k
from the 2N Low Memory Methods for some specific problem.Trick is to make a wrapper of a register for which just overloads
du[i] = ...
todu[i] += ...
. Using this the dependency of k is removed.Limitation:
This won't work with the functions where du is on the right hand side. For example:
which should not be a problem as ,in theory, we write
du/dt = f(u, p, t)
sodu
can be written purely in terms of u, p and t. Still we can make a flag which will make sure from the user that this can be done.I tried this code with my code and gave same output before and after the commit:
If this idea is good to go,I would remove the unused registers and add the flag.