Is the ode suite multi threaded?
16 views (last 30 days)
Show older comments
Dear all, my aim is to solve a very large ODE system where the state vector has 2^20 elements.
My first approach was that I compiled the system function to *.mex to make the function evaluation efficient. This works fine. However, one integration step of ode45 is approximately a factor 10 slower then the function evaluation. So my calculation will take 10 days to finish.
This leads immediately to the question: Do the odesolvers of Matlab use multiple cores and are they multithreaded?
If not: Is there a way to parallelize one integation step of the ode suite in Matlab? Are there any functions or toolboxes?
The parallel Computing Toolbox does not seem to help, if one is only interested in solving one large system, but hopefully I am wrong.
How can I speed up the solution of such large systems with Matlab?
Thank you for your assistance, Vergilius
0 Comments
Answers (1)
Jan
on 29 Dec 2014
Edited: Jan
on 29 Dec 2014
No, the ODE suites are not multi-threaded. If you apply linear algebra inside the function to be integrated, mutliple threads are called internally, but this cannot be done automatically for the higher level parts of the integration due to the possible dependencies between the elements of the state vector. Even the set of function evaluations for each full step of the integrator depend on each other, such that a parallelization is not possible even in theory.
2 Comments
John D'Errico
on 29 Dec 2014
Edited: John D'Errico
on 29 Dec 2014
Yes, vector operations MAY BE parallelized by the software, when doing so would be a gain. The linear algebra tools (which includes simple vector additions and dot products) are set so that only large problems are done using multitreading. However, doing something like that is not always free. Unless the operation is large enough, you get no gain, in fact, there may even be a loss of time on small problems. And it takes a fairly large problem to cause multithreading to start up. (I do see it happen often enough, in fact, I have managed to see all of my cores running nearly flat out, on specific problems.)
For your case, a vector add between a pair of vectors with only 1e6 elements, is not really that large of a problem. And you cannot force it to happen. There are no flags you can set that will tell MATLAB that you want certain operations done the way you wish.
Of course, if you own the parallel computing toolbox, AND you are willing to write your own version of a 4th order Runge-Kutta code, then you could try setting up those operations in a parallel form. I'm not sure it would help. There are also GPU tools you can employ to speed things up, but again, you need to invest in those toolboxes and know what you are doing.
Remember that as it is, the FPU on your machine is surely capable of doing pipelined adds, multiplies, etc. (Its been a while since I cared about such things, but I am sure CPUs have continuously evolved.) So it takes some serious effort to get much of a gain here for only a relatively small vector.
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!